love-loader/skins/nx.lua

72 lines
1.6 KiB
Lua

return function(ll)
-- Nintendo NX (AKA Switch) UI
local r
os.setlocale('', 'time')
function resize()
r = math.min(W, H) / 30
f = love.graphics.setNewFont(math.min(W, H) / 30)
bf = love.graphics.newFont(math.min(W, H) / 20)
--ll.kbInit('h', H / 2 - ch, H / 2 + ch + cg, 0, cx + cw * 2)
end
local function update(dt)
end
local function roundRect(m, x, y, w, h, r)
if w < 1 or h < 1 then return end
love.graphics.rectangle(m, x, y, w, h, r)
if m == 'fill'
then roundRect('line', x, y, w, h, r)
end
end
local function draw()
love.graphics.setColor(0 / COLDIV, 50 / COLDIV, 75 / COLDIV)
love.graphics.rectangle('fill', 0, 0, W, H)
love.graphics.setColor(255, 255, 255)
-- Indicators
love.graphics.push()
love.graphics.translate(W - W / 16, H / 16)
love.graphics.setLineWidth(r / 8)
local pst, pper = love.system.getPowerInfo()
if pst ~= 'nobattery' then
pper = pper or 0
if pst == 'charging'
then pper = os.time() % 5 / 4 * 100
end
roundRect('line', -r * 2.2, 0, r * 2, r * 1.2, r / 4)
roundRect('fill', -r / 6, r * 0.3, r / 4, r / 2, r / 16)
roundRect('fill', -r * 1.95, r * 0.3, r * 1.5 * pper / 100, r * 0.6, r / 16)
love.graphics.translate(-r * 2.8, 0)
end
local time = os.date('%X'):gsub('^(%d+.+%d+).+%d+', '%1')
local w = f:getWidth(time)
love.graphics.print(time, -w, -2)
love.graphics.pop()
end
local function addGame(file, cont, x, y)
local msg, id = ll.addGame(file, cont)
love.graphics.print(msg, x, y)
if id then
sel = id
end
end
return {
update = update,
draw = draw,
addGame = addGame,
}
end