filled_in_Kg = {}


function filled_in_Kg.prerequisitesPresent(specializations)
    return SpecializationUtil.hasSpecialization(Fillable, specializations);
end;


function filled_in_Kg:load(xmlFile)
 self.hudHawepath = Utils.getFilename("scripts/haweControl.dds", self.baseDirectory);
	self.hudHawePoxX = 0.501;
    self.hudHawePoxY = 1-0.204;
    self.hudHaweWidth = 0.256;
    self.hudHaweHeight = 0.256;
	self.hudBasePoxX = 0.531;
    self.hudBasePoxY = 0.9069; --1-0.094; 0.907 0.001
    self.hudHaweOverlay = Overlay:new("hudHaweControl", self.hudHawepath, self.hudHawePoxX, self.hudHawePoxY, self.hudHaweWidth, self.hudHaweHeight);

	


	self.bcActive = false;
	

	
end;

function filled_in_Kg:delete()
	if self.hudHaweOverlay ~= nil then
		self.hudHaweOverlay:delete();
	end;
end;

function filled_in_Kg:update(dt)
end;

function filled_in_Kg:draw()
if self.attacherVehicle ~= nil then
	    if self.bcActive then	
			g_currentMission:addExtraPrintText("Touche 0: Controlpanel  on");
		else
			g_currentMission:addExtraPrintText("Touche 0: Controlpanel  off");
		end;
		
		
			if self.bcActive and self.hudHaweOverlay ~= nil  then
						
			self.hudHaweOverlay:render();
			setTextBold(true);
			setTextColor(0.8, 0.2, 0.2, 1.0);
			local text = "";
		
		local massPerLiter =1.0; --1000 litres  (density)
		
		if self.currentFillType == Fillable.FILLTYPE_WHEAT then				
		massPerLiter = 0.780;
		elseif self.currentFillType == Fillable.FILLTYPE_BARLEY then			
		massPerLiter = 0.700;
		elseif self.currentFillType == Fillable.FILLTYPE_MAIZE then				
		massPerLiter = 0.740;
		elseif self.currentFillType == Fillable.FILLTYPE_RAPE then				
		massPerLiter = 0.640;
		elseif self.currentFillType == Fillable.FILLTYPE_CHAFF or self.currentFillType == Fillable.FILLTYPE_FORAGE then			
		massPerLiter = 0.795;
		elseif self.currentFillType == Fillable.FILLTYPE_SUGARBEET then			
		massPerLiter = 0.740;
		elseif self.currentFillType == Fillable.FILLTYPE_POTATO then			
		massPerLiter = 0.760;
		elseif self.currentFillType == Fillable.FILLTYPE_MANURE then			
		massPerLiter = 0.930;
		elseif self.currentFillType == Fillable.FILLTYPE_SILAGE then			
		massPerLiter = 0.860;
		elseif self.currentFillType == Fillable.FILLTYPE_WHEAT_WINDROW then		
		massPerLiter = 0.70;
		elseif self.currentFillType == Fillable.FILLTYPE_BARLEY_WINDROW then	
		massPerLiter = 0.70;
		elseif self.currentFillType == Fillable.FILLTYPE_DRYGRASS_WINDROW or self.currentFillType == Fillable.FILLTYPE_DRYGRASS then			
		massPerLiter = 0.70;
		elseif self.currentFillType == Fillable.FILLTYPE_GRASS_WINDROW or self.currentFillType == Fillable.FILLTYPE_GRASS then	
		massPerLiter = 0.80;
		end;
		
			local mass = self.fillLevel*massPerLiter;
			local fillLevelString = "asd";
			if mass >= 0 and mass < 10 then
				fillLevelString = "0000" .. string.format("%d", mass);
			elseif mass >= 10 and mass < 100 then
				fillLevelString = "000" .. string.format("%d", mass);
			elseif mass >= 100 and mass < 1000 then
				fillLevelString = "00" .. string.format("%d", mass);
			elseif mass >= 1000 and mass < 10000 then
				fillLevelString = "0" .. string.format("%d", mass);
			elseif mass >= 10000 and mass < 50000 then
				fillLevelString = string.format("%d", mass);
			else
				fillLevelString = "ERROR";
			end;
			renderText(self.hudBasePoxX, self.hudBasePoxY, 0.070, fillLevelString);
			renderText(self.hudBasePoxX+0.145, self.hudBasePoxY+0.007, 0.06, "kg");      
		  
    
		end;
			
		   
		 
           
		end;
end;

function filled_in_Kg:mouseEvent(posX, posY, isDown, isUp, button)
end;

function filled_in_Kg:keyEvent(unicode, sym, modifier, isDown)
	
	if self.attacherVehicle ~= nil then
	
		if isDown and sym == Input.KEY_KP_0 then -- Key: 0
			self.bcActive = not self.bcActive;
		end;
	end;
end;

function filled_in_Kg:onDetach()
end;