2022-04-04 01:58:10 +02:00
|
|
|
require("common.class")
|
2022-04-05 17:31:02 +02:00
|
|
|
local Dim = require("common.dimensions")
|
|
|
|
local ServiceField = require("titlescreen.fields.service.servicefield")
|
2022-04-04 01:58:10 +02:00
|
|
|
|
|
|
|
---@class UpdateField: ServiceField
|
|
|
|
---@field _timer number
|
|
|
|
local UpdateField = {
|
2022-04-11 18:47:26 +02:00
|
|
|
__tostring = function() return "UpdateField" end,
|
2022-04-04 01:58:10 +02:00
|
|
|
UPDATE_FLICKER_TIME = 0.5,
|
|
|
|
UPDATE_FLICKER_COLORS = {
|
|
|
|
{255, 0, 0, 255},
|
|
|
|
{255, 255, 0, 255}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function UpdateField:new(o)
|
2022-04-11 18:47:26 +02:00
|
|
|
o = o or {}
|
2022-04-04 01:58:10 +02:00
|
|
|
|
|
|
|
o._timer = 0
|
|
|
|
|
2022-04-11 18:47:26 +02:00
|
|
|
return Inherit(self, o, ServiceField)
|
2022-04-04 01:58:10 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
function UpdateField:handleButtonInput(button)
|
|
|
|
local url, _ = game.UpdateAvailable()
|
|
|
|
|
|
|
|
if button == game.BUTTON_STA and url then
|
|
|
|
Menu.Update()
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
|
|
|
|
function UpdateField:drawValue(deltaTime)
|
|
|
|
self._timer = self._timer + deltaTime
|
|
|
|
local url, version = game.UpdateAvailable()
|
|
|
|
|
|
|
|
gfx.BeginPath()
|
2022-04-11 18:47:26 +02:00
|
|
|
gfx.FontSize(self.FONT_SIZE)
|
|
|
|
gfx.LoadSkinFont(self.FONT_FACE)
|
2022-04-04 01:58:10 +02:00
|
|
|
gfx.TextAlign(gfx.TEXT_ALIGN_LEFT | gfx.TEXT_ALIGN_TOP)
|
|
|
|
if url then
|
|
|
|
if (self._timer % self.UPDATE_FLICKER_TIME) < self.UPDATE_FLICKER_TIME / 2 then
|
|
|
|
gfx.FillColor(table.unpack(self.UPDATE_FLICKER_COLORS[1]))
|
|
|
|
else
|
|
|
|
gfx.FillColor(table.unpack(self.UPDATE_FLICKER_COLORS[2]))
|
|
|
|
end
|
2022-04-05 17:31:02 +02:00
|
|
|
gfx.Text("*UPDATE AVAILABLE (" .. version .. ")*", Dim.design.width / 2, 0)
|
2022-04-04 01:58:10 +02:00
|
|
|
else
|
2022-04-11 18:47:26 +02:00
|
|
|
gfx.FillColor(table.unpack(self.FONT_COLOR))
|
2022-04-05 17:31:02 +02:00
|
|
|
gfx.Text(self.value or "<VERSION STRING NOT AVAILABLE>", Dim.design.width / 2, 0)
|
2022-04-04 01:58:10 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
2022-04-05 23:53:19 +02:00
|
|
|
return UpdateField
|