singe/assets/Service.singe

117 lines
2.4 KiB
Text

--[[
*
* Singe 2
* Copyright (C) 2006-2024 Scott Duensing <scott@kangaroopunch.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*
*
--]]
local socket = require("socket")
local copas = require("copas")
local https = require("copas.http").request
dofile("Singe/Framework.singe")
function get(url)
local download = {}
download.url = url
download.finished = false
copas.addthread(function(d)
d.result, d.error = https(d.url)
d.finished = true
end,
download)
return download
end
function onInputPressed(what)
if what == SWITCH_LEFT then
discStepBackward()
end
if what == SWITCH_RIGHT then
discStepForward()
end
end
function onOverlayUpdate()
copas.step()
colorBackground(0, 0, 0, 127) -- this dims the background 50%
overlayClear()
overlayPrint(1, 1, dldGameList.url.." "..(dldGameList.finished and 'true' or 'false'))
if dldGameList.finished then
overlayPrint(1, 2, dldGameList.error)
overlayPrint(1, 3, dldGameList.result)
end
colorForeground(255, 0, 0)
overlayBox(0, 0, overlayGetWidth() - 1, overlayGetHeight() - 1)
spriteDraw((overlayGetWidth() - spriteGetWidth(sprServiceMenu)) / 2, 25, sprServiceMenu)
return(OVERLAY_UPDATED)
end
function onShutdown()
spriteUnload(sprServiceMenu)
fontUnload(fntSans18)
fontUnload(fntSans32)
end
copas.running = true
dldGameList = get("https://kangaroopunch.com/api/singeSoftware")
overlaySetResolution(vldpGetWidth(), vldpGetHeight())
DISC_SINGE_LOGO = 140
discSkipToFrame(DISC_SINGE_LOGO)
discPause()
fontQuality(FONT_QUALITY_BLENDED)
fntSans18 = fontLoad("Singe/FreeSansBold.ttf", 18)
fntSans32 = fontLoad("Singe/FreeSansBold.ttf", 32)
fontSelect(fntSans32)
sprServiceMenu = fontToSprite("Singe Service Menu")
--[[
Game Management
--]]