--
-- Fruit name under fruit icon
--
-- @author  Decker
-- @date    2011-02-25
--
-- Use as you please, I really dont care.
--


--
--
--
function DrawFruitName(fruitType)
    setTextAlignment(RenderText.ALIGN_RIGHT);
    setTextColor(1.0, 1.0, 1.0, 1.0);

    local genericFruitName = FruitUtil.fruitIndexToDesc[ fruitType ].name;
    renderText(0.99, 0.27, 0.02, genericFruitName);

    if (g_i18n:hasText(genericFruitName)) then
        local localizedFruitName = g_i18n:getText(genericFruitName);
        renderText(0.99, 0.24, 0.03, localizedFruitName);
    end;

    setTextAlignment(RenderText.ALIGN_LEFT);
end;


--
-- SowingMachine:draw()
--
local origSowingMachineDraw = SowingMachine.draw;
SowingMachine.draw = function(self)
	if origSowingMachineDraw ~= nil then
		origSowingMachineDraw(self);
	end;
	
	if self.isClient then
        DrawFruitName( self.seeds[self.currentSeed] );
	end;
end;

--
-- Trailer:draw()
--
local origTrailerDraw = Trailer.draw;
Trailer.draw = function(self)
	if origTrailerDraw ~= nil then
		origTrailerDraw(self);
	end;

	if self.isClient then
        if self.currentFillType ~= Fillable.FILLTYPE_UNKNOWN then
            local fruitType = FruitUtil.fillTypeToFruitType[self.currentFillType];
            if fruitType ~= nil then
                DrawFruitName( fruitType );
            end;
        end;
	end;
end;

--
-- Combine:draw()
--
local origCombineDraw = Combine.draw;
Combine.draw = function(self)
    if origCombineDraw ~= nil then
        origCombineDraw(self)
    end;

	if self.isClient then
        if (self.grainTankCapacity > 0) and (self.currentGrainTankFruitType ~= FruitUtil.FRUITTYPE_UNKNOWN) then
            DrawFruitName( self.currentGrainTankFruitType );
        end;
	end;
end;
