-- displayControl
--
-- Author RivalBomb
-- edit by STv-Modding in displayControl

displayControl = {};
function displayControl.prerequisitesPresent(specializations)
    return true;
end;

function displayControl:load(savegame)
	self.displayControl = {};
	
	local node = "vehicle.displayControl.";
	-- self.displayControl.warning = Utils.indexToObject(self.components, getXMLString(self.xmlFile, node.."warnLight#index"));
	self.displayControl.forward = Utils.indexToObject(self.components, getXMLString(self.xmlFile, node.."forward#index"));
	self.displayControl.reverse = Utils.indexToObject(self.components, getXMLString(self.xmlFile, node.."reverse#index"));
	self.displayControl.neutral = Utils.indexToObject(self.components, getXMLString(self.xmlFile, node.."neutral#index"));
	-- self.displayControl.preHeating = Utils.indexToObject(self.components, getXMLString(self.xmlFile, node.."preHeating#index"));
	-- self.displayControl.battery = Utils.indexToObject(self.components, getXMLString(self.xmlFile, node.."battery#index"));
	-- self.displayControl.blinker1 = Utils.indexToObject(self.components, getXMLString(self.xmlFile, node.."blinker1#index"));
	-- self.displayControl.blinker2 = Utils.indexToObject(self.components, getXMLString(self.xmlFile, node.."blinker2#index"));
	
	-- self.displayControl.timer = 0; -- timer for warning light
	-- self.displayControl.warnBlinkSpeed = 500;	-- 0.5 sec
	-- self.displayControl.warningLightActive = true;
	-- self.hasAttachedTrailers = 0;
	
	-- interior turn lights
	-- self.interiorTS = {};
	-- self.interiorTS.t2 = 0;
	-- self.interiorTS.leftIndex = Utils.indexToObject(self.components, getXMLString(self.xmlFile, "vehicle.turnSignals.interiorTurnSignals#left"));
	-- self.interiorTS.rightIndex = Utils.indexToObject(self.components, getXMLString(self.xmlFile, "vehicle.turnSignals.interiorTurnSignals#right"));
	-- self.interiorTS.warnIndex = Utils.indexToObject(self.components, getXMLString(self.xmlFile, "vehicle.turnSignals.interiorTurnSignals#hazard"));
	-- self.displayControl.t = 0;
end;

function displayControl:delete()
end;

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

function displayControl:keyEvent(unicode, sym, modifier, isDown)
end;

function displayControl:update(dt)
	-- self.interiorTS.t2=self.interiorTS.t2+dt;
	-- if self.interiorTS.t2 > self.displayControl.warnBlinkSpeed then
		-- self.displayControl.warningLightActive = not self.displayControl.warningLightActive;
		-- self.interiorTS.t2=0;
	-- end;
	
	-- local mFlickering=Utils.clamp(math.cos( 7.0 * (g_currentMission.time/1000) ) + 0.2, 0, 1);
	-- if self:getIsActive() then
		-- if (self.turnSignalState == 1 or self.turnSignalState == 3) and mFlickering == 0  then 	-- Blinker links
			-- if self.interiorTS.leftIndex ~= nil then
				-- setVisibility(self.interiorTS.leftIndex, true);
			-- end;
		-- else
			-- if self.interiorTS.leftIndex ~= nil then
				-- setVisibility(self.interiorTS.leftIndex, false);
			-- end;
		-- end;
		-- if (self.turnSignalState == 2 or self.turnSignalState == 3) and mFlickering == 0 then	-- Blinker rechts
			-- if self.interiorTS.rightIndex ~= nil then
				-- setVisibility(self.interiorTS.rightIndex, true);
			-- end;
		-- else
			-- if self.interiorTS.rightIndex ~= nil then
				-- setVisibility(self.interiorTS.rightIndex, false);
			-- end;
		-- end;
		-- if self.turnSignalState == 3 and mFlickering == 0 then	-- Warnblinker
			-- if self.interiorTS.warnIndex ~= nil then
				-- setVisibility(self.interiorTS.warnIndex, true);
			-- end;
		-- else
			-- if self.interiorTS.warnIndex ~= nil then
				-- setVisibility(self.interiorTS.warnIndex, false);
			-- end;
		-- end;
		
		
			-- Forward / Reverse --
		if self:getLastSpeed() * self.speedDisplayScale > 1 and self.movingDirection > 0 then
			if self.displayControl.forward ~= nil then
				setVisibility(self.displayControl.forward, true);
				setVisibility(self.displayControl.neutral, false);
			end;
		elseif self:getLastSpeed() * self.speedDisplayScale > 1 and self.movingDirection < 0 then
			if self.displayControl.reverse ~= nil then
				setVisibility(self.displayControl.reverse, true);
				setVisibility(self.displayControl.neutral, false);
			end;
		else
			if self.displayControl.forward ~= nil then
				setVisibility(self.displayControl.forward, false);
				setVisibility(self.displayControl.neutral, true);
			end;
			if self.displayControl.reverse ~= nil then
				setVisibility(self.displayControl.reverse, false);
				setVisibility(self.displayControl.neutral, true);
			end;
		end;
		end;
		-- preHeating --
		-- if (self.ignitionMode ~= nil and self.ignitionMode == ManualIgnition.STAGE_PRE_HEAT) or (self.driveControl ~=nil and self.driveControl.manMotorStart.isMotorStarted ~= nil and self.driveControl.manMotorStart.isMotorStarted == false and self.driveControl.manMotorStart.startCnt ~= nil and self.driveControl.manMotorStart.startCnt < 800 and self.driveControl.manMotorStart.startCnt > 0) then 
			-- self.displayControl.t=self.displayControl.t+dt;
			-- if self.displayControl.preHeating ~= nil then
				-- if self.displayControl.t <= 2000 then
					-- setVisibility(self.displayControl.preHeating, true);
				-- else
					-- setVisibility(self.displayControl.preHeating, false);
				-- end;
			-- end;
			-- if self.displayControl.battery ~= nil then
				-- setVisibility(self.displayControl.battery, true);
			-- end;
			-- self.displayControl.timer = self.interiorTS.t2;
			-- if self.displayControl.timer >= self.displayControl.warnBlinkSpeed then
				-- self.displayControl.warningLightActive = not self.displayControl.warningLightActive;
				-- self.displayControl.timer=0;
			-- end;
			-- if self.displayControl.warning ~= nil then
				-- setVisibility(self.displayControl.warning, self.displayControl.warningLightActive);
				-- --setVisibility(self.displayControl.warning, true);
			-- end;
		-- else
			-- if self.displayControl.preHeating ~= nil then
				-- setVisibility(self.displayControl.preHeating, false);
				-- self.displayControl.t=0;
			-- end;
			-- if self.displayControl.battery ~= nil then
				-- setVisibility(self.displayControl.battery, false);
			-- end;
			-- if self.displayControl.warning ~= nil then
				-- self.displayControl.warningLightActive = false;
				-- setVisibility(self.displayControl.warning, self.displayControl.warningLightActive);
				-- --setVisibility(self.displayControl.warning, false);
			-- end;
		-- end;	
	-- end;
-- end;

function displayControl:updateTick(dt)

end;

function displayControl:draw()
end;