--Name: Settings of FarmingTablet
--Author: kevink98
--Date: 15.06.2016
--Version: 1.0
--Description: SettingsApp für FarmingTablet

--Versionen: 
--				1.0: Release
--						- ...
	
--Keine Änderung ohne meine Erlaubnis!
--No modification without my permission!

Settings = {};
Settings_directory = g_currentModDirectory;

print("Settings of FarmingTablet v 1.0 loaded! Support on Marhu.net");

function Settings:loadSettings ()

	
	St = {};
	
	self.tab1Vis = true;
	self.tab2Vis = false;
	self.tab3Vis = false;
	
end;

function Settings:loadXml(xml)
	g_currentMission.FarmingTablet.Settings = {};
	g_currentMission.FarmingTablet.Settings.activeOverlay = getXMLInt(xml, "FarmingTablet.Settings.activeOverlay");
	g_currentMission.FarmingTablet.Settings.akkuFuel = getXMLInt(xml, "FarmingTablet.Settings.akkuFuel");
	g_currentMission.FarmingTablet.Settings.appstoreOn = getXMLBool(xml, "FarmingTablet.Settings.appstoreOn");
	if g_currentMission.FarmingTablet.Settings.appstoreOn == false then
		g_currentMission.FarmingTablet.Appstore.apps[1] = true;
		g_currentMission.FarmingTablet.Appstore.apps[2] = true;
		g_currentMission.FarmingTablet.Appstore.apps[3] = true;
		g_currentMission.FarmingTablet.Appstore.apps[4] = true;
	end;
end;

function Settings:loadXmlFirst()
	g_currentMission.FarmingTablet.Settings = {};
	g_currentMission.FarmingTablet.Settings.activeOverlay = 6;
	g_currentMission.FarmingTablet.Settings.akkuFuel = 648000;
	g_currentMission.FarmingTablet.Settings.appstoreOn = true;
end;


function Settings:saveXml(xml)
	setXMLInt(xml, "FarmingTablet.Settings.activeOverlay", g_currentMission.FarmingTablet.Settings.activeOverlay);
	setXMLInt(xml, "FarmingTablet.Settings.akkuFuel", g_currentMission.FarmingTablet.Settings.akkuFuel);
	setXMLBool(xml, "FarmingTablet.Settings.appstoreOn", g_currentMission.FarmingTablet.Settings.appstoreOn);
end;

function Settings:StartscreenApp (posX, posY, isDown, button)
	if posX > 0.08 and posX < 0.28 and posY < 0.86 and posY > 0.82 and isDown and button == 1 then
		self.tab1Vis = true;
		self.tab2Vis = false;
		self.tab3Vis = false;
	elseif posX > 0.29 and posX < 0.485 and posY < 0.86 and posY > 0.82 and isDown and button == 1 then
		self.tab1Vis = false;
		self.tab2Vis = true;
		self.tab3Vis = false;
	elseif posX < 0.69 and posX > 0.49 and posY < 0.86 and posY > 0.82 and isDown and button == 1 then
		self.tab1Vis = false;
		self.tab2Vis = false;
		self.tab3Vis = true;
	end;
	
	if posX > 0.2 and posX < 0.237 and posY > 0.7 and posY < 0.75 and isDown and button == 1 then
		g_currentMission.FarmingTablet.Settings.activeOverlay = 1;
	elseif posX > 0.2 and posX < 0.237 and posY > 0.6 and posY < 0.65 and isDown and button == 1 then
		g_currentMission.FarmingTablet.Settings.activeOverlay = 2;
	elseif posX > 0.2 and posX < 0.237 and posY > 0.5 and posY < 0.55 and isDown and button == 1 then
		g_currentMission.FarmingTablet.Settings.activeOverlay = 3;
	elseif posX > 0.2 and posX < 0.237 and posY > 0.4 and posY < 0.45 and isDown and button == 1 then
		g_currentMission.FarmingTablet.Settings.activeOverlay = 4;
	elseif posX > 0.2 and posX < 0.237 and posY > 0.3 and posY < 0.35 and isDown and button == 1 then
		g_currentMission.FarmingTablet.Settings.activeOverlay = 5;
	elseif posX > 0.2 and posX < 0.237 and posY > 0.2 and posY < 0.25 and isDown and button == 1 then
		g_currentMission.FarmingTablet.Settings.activeOverlay = 6;
	end;
end;

function Settings:updateSettings (dt) 

end;

function Settings:drawSettings ()
	
	setTextColor(0, 0, 0, 1);
	renderText(0.1, 0.83, 0.03, tostring("Allgemeines"));
	renderText(0.3, 0.83, 0.03, tostring("Design"));
	renderText(0.5, 0.83, 0.03, tostring("Sonstiges"));
	
	if self.tab1Vis then
		renderOverlay(FarmingTablet.overlay.tab1, 0.01, 0.01, 1, 1.5);
		renderOverlay(FarmingTablet.overlay.hackOff, 0.1, 0.7, 0.04, 0.05);
		renderOverlay(FarmingTablet.overlay.hackOff, 0.18, 0.6, 0.04, 0.05);
		--renderOverlay(FarmingTablet.overlay.hackOff, 0.1, 0.5, 0.04, 0.05);
		renderText(0.151, 0.705, 0.035, tostring("Kalenderoverlay außerhalb des Tablets anzeigen"));
		renderText(0.233, 0.605, 0.035, tostring("Overlay durchsichtig"));
		renderOverlay(FarmingTablet.overlay.ls17, 0.01, 0.01, 1, 1.5);
	
	elseif self.tab2Vis then
		renderOverlay(FarmingTablet.overlay.tab2, 0.01, 0.01, 1, 1.5);
		renderText(0.2, 0.76, 0.035, tostring("Hintergrundfarbe auf dem Startbildschirm"));
		
		renderOverlay(FarmingTablet.overlay.window_blue, 0.2, 0.7, 0.04, 0.05);
		renderOverlay(FarmingTablet.overlay.window_green, 0.2, 0.6, 0.04, 0.05);
		renderOverlay(FarmingTablet.overlay.window_red, 0.2, 0.5, 0.04, 0.05);
		renderOverlay(FarmingTablet.overlay.window_greylight, 0.2, 0.4, 0.04, 0.05);
		renderOverlay(FarmingTablet.overlay.window_grey, 0.2, 0.3, 0.04, 0.05);
		renderOverlay(FarmingTablet.overlay.window_greydark, 0.2, 0.2, 0.04, 0.05);
		
		if g_currentMission.FarmingTablet.Settings.activeOverlay == 1 then
			renderOverlay(FarmingTablet.overlay.window_black, 0.2, 0.7, 0.04, 0.05);
		elseif g_currentMission.FarmingTablet.Settings.activeOverlay == 2 then
			renderOverlay(FarmingTablet.overlay.window_black, 0.2, 0.6, 0.04, 0.05);
		elseif g_currentMission.FarmingTablet.Settings.activeOverlay == 3 then
			renderOverlay(FarmingTablet.overlay.window_black, 0.2, 0.5, 0.04, 0.05);
		elseif g_currentMission.FarmingTablet.Settings.activeOverlay == 4 then
			renderOverlay(FarmingTablet.overlay.window_black, 0.2, 0.4, 0.04, 0.05);
		elseif g_currentMission.FarmingTablet.Settings.activeOverlay == 5 then
			renderOverlay(FarmingTablet.overlay.window_black, 0.2, 0.3, 0.04, 0.05);
		elseif g_currentMission.FarmingTablet.Settings.activeOverlay == 6 then
			renderOverlay(FarmingTablet.overlay.window_black, 0.2, 0.2, 0.04, 0.05);
		end;
		
		renderText(0.26, 0.7, 0.035, tostring("Blau"));
		renderText(0.26, 0.6, 0.035, tostring("Grün"));
		renderText(0.26, 0.5, 0.035, tostring("Rot"));
		renderText(0.26, 0.4, 0.035, tostring("Hellgrau"));
		renderText(0.26, 0.3, 0.035, tostring("Grau"));
		renderText(0.26, 0.2, 0.035, tostring("Dunkelgrau"));
		
	
	elseif self.tab3Vis then
		renderOverlay(FarmingTablet.overlay.tab3, 0.01, 0.01, 1, 1.5);
		renderOverlay(FarmingTablet.overlay.ls17, 0.01, 0.01, 1, 1.5);
		
	
	end;
	
end;


function Settings:deleteSettings() end;
 
 
 
 
 
 
 