--PSPMoney by A. Brummer alias uPSP_08

background=pge.texture.load("/img/background.png")

--1. MainLoop
while pge.running() do
pge.controls.update()
pge.gfx.startdrawing()
pge.gfx.clearscreen()
background:activate()
background:draweasy(0,0)
dreieck:activate()
dreieck:draweasy(20,96)
select:activate()
select:draweasy(10,121)
mittel:activate()
mittel:print(10,10,blau,"Updating the exchange rates")
klein:activate()
klein:print(10,45,schwarz,"You can update the exchange rates here.")
klein:print(10,65,schwarz,"The current exchange rates on your system are from "..datummonat.."/"..datumtag.."/"..datumjahr..".")
klein:print(55,100,schwarz,"Start downloading.")
klein:print(55,125,schwarz,"Back.")

if pge.controls.pressed(PGE_CTRL_TRIANGLE) then
break
end

pge.gfx.enddrawing()
pge.utils.netupdate()
pge.gfx.swapbuffers()

if pge.controls.pressed(PGE_CTRL_SELECT) then
dofile("./ENG/SYSTEM2.lua")
end

end



pge.net.init()
pge.utils.netinit()
state = -1

--2. MainLoop mit Verbindungsaufbau
while pge.running() do
pge.gfx.startdrawing()
pge.gfx.clearscreen()
pge.gfx.enddrawing()
state = pge.utils.netupdate()
if state == 0 then
break
elseif state == 1 then
pge.net.shutdown()
break
elseif state ~= PGE_UTILS_DIALOG_RUNNING then
pge.net.shutdown()
break
end
pge.gfx.swapbuffers()
end

--3.MainLoop mit Download
while pge.running() do
pge.gfx.startdrawing()
pge.gfx.clearscreen()
background:activate()
background:draweasy(0,0)
mittel:activate()
if pge.net.isconnected() then
mittel:printcenter(130,schwarz,"Downloading...")
else
mittel:printcenter(130,schwarz,"Not connected - Unable to download.")
end
pge.gfx.enddrawing()
pge.gfx.swapbuffers()
if pge.net.isconnected() then
pge.net.getfile("http://www.alexwebsite.kilu.de/pspmoney/wechselkurse.txt","wechselkurse.lua")
pge.net.shutdown()
if pge.file.exists(pge.dir.getcwd().."/wechselkurse.lua") then
dofile(pge.dir.getcwd().."/wechselkurse.lua")
end
pge.gfx.startdrawing()
pge.gfx.clearscreen()
background:activate()
background:draweasy(0,0)
mittel:activate()
mittel:printcenter(115,schwarz,"Update successful.")
klein:activate()
klein:printcenter(140,schwarz,"The new exchange rates are from "..datummonat.."/"..datumtag.."/"..datumjahr..".")
pge.gfx.enddrawing()
pge.gfx.swapbuffers()
pge.delay(4000000)

end
dofile("./ENG/SYSTEM2.lua")
end