--
-- FirstStart
--
-- (c) by Wagenheber
-- > 03.07.2011 < --
--

-- print("  FirstStart loaded");

FirstStart = {};
FirstStart.XML = getUserProfileAppPath() .. "/radio.xml"	-- Pfad
FirstStart.DIR = getUserProfileAppPath() .. "mods/";		-- Pfad
FirstStart.modDirectory = g_currentModDirectory;			-- Pfad
FirstStart.channel = 1;										-- Wiederholte loadMap Funktionen


function FirstStart:loadMap(name)
	
	if FirstStart.channel == 1 then
		if io.open (FirstStart.XML, "r") ~= nil then
			self.FirstTimeRun = false;
		else
			self.FirstTimeRun = true;
			-- createFolder(FirstStart.DIR);
			io.open (FirstStart.XML, "w");
		end;
		
		self.info = createImageOverlay(FirstStart.modDirectory .. "image/info.png");
		
	end;

	FirstStart.channel = FirstStart.channel + 1
	self.renderInfo = true;
	self.alphaChannel = 1;
	
end;

function FirstStart:deleteMap()
end;

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

function FirstStart:keyEvent(unicode, sym, modifier, isDown)

	-- Meldung schließen
	if InputBinding.isPressed(InputBinding.CLOSE_INFO) then
		self.renderInfo = false;
	end;

end;

function FirstStart:update(dt)
	
	if self.renderInfo == false then
		self.alphaChannel = self.alphaChannel - dt / 500
		if self.alphaChannel < 0 then
			self.alphaChannel = 0;
		end;
	end;
	
end;

function FirstStart:draw()

	if self.FirstTimeRun == true and self.alphaChannel > 0 then
		setOverlayColor(self.info, 1, 1, 1, self.alphaChannel)
		renderOverlay(self.info, 0.15, 0.15, 0.7, 0.7);
	end;	
	
end;

addModEventListener(FirstStart);