88 lines
2.7 KiB
Lua
88 lines
2.7 KiB
Lua
require("common.globals")
|
|
local Common = require("common.util")
|
|
local Dim = require("common.dimensions")
|
|
local Wallpaper = require("components.wallpaper")
|
|
|
|
local PageView = require("api.page.pageview")
|
|
|
|
local BootPage = require("titlescreen.pages.boot.bootpage")
|
|
local ModeSelectPage = require("titlescreen.pages.modeselect.modeselectpage")
|
|
local ServiceMenuPage = require("titlescreen.pages.service.mainmenupage")
|
|
|
|
local BootScreen = require('titlescreen.boot')
|
|
local SplashScreen = require('titlescreen.splash')
|
|
local TitleScreen = require('titlescreen.title')
|
|
local ModeSelectScreen = require('titlescreen.modeselect')
|
|
local ServiceScreen = require('titlescreen.service')
|
|
|
|
|
|
local screens = {
|
|
[tostring(BootScreen)] = BootScreen.new(),
|
|
--splash = splashScreen,
|
|
--title = titleScreen,
|
|
--[tostring(ModeSelectPage)] = ModeSelectPage.new(),
|
|
--[tostring(ServiceMenuPage)] = ServiceMenuPage.new()
|
|
}
|
|
|
|
--local currentScreen = game.GetSkinSetting("animations_skipIntro") and screens.title or screens.boot -- show boot screen if skipIntro is not set
|
|
local currentScreen = screens[tostring(BootScreen)]
|
|
|
|
---@param obj ScreenCallbackObject
|
|
local function onDeactivationCallback(obj)
|
|
currentScreen = screens[obj.hint]
|
|
end
|
|
|
|
for _, value in pairs(screens) do
|
|
value.onDeactivation = onDeactivationCallback
|
|
end
|
|
|
|
local function deltaKnob(delta)
|
|
-- what the hell does this do?
|
|
if math.abs(delta) > 1.5 * math.pi then
|
|
return delta + 2 * math.pi * Common.sign(delta) * -1
|
|
end
|
|
return delta
|
|
end
|
|
|
|
local lastKnobs = nil
|
|
local knobThreshold = (2 * math.pi) / 360
|
|
local function handleKnobs()
|
|
if lastKnobs == nil then
|
|
lastKnobs = {game.GetKnob(game.KNOB_LEFT), game.GetKnob(game.KNOB_RIGHT)}
|
|
else
|
|
local newKnobs = {game.GetKnob(game.KNOB_LEFT), game.GetKnob(game.KNOB_RIGHT)}
|
|
local knobProgress = {deltaKnob(lastKnobs[1] - newKnobs[1]), deltaKnob(lastKnobs[2] - newKnobs[2])}
|
|
lastKnobs = newKnobs
|
|
|
|
if math.abs(knobProgress[1]) > knobThreshold then
|
|
currentScreen:handleKnobInput(game.KNOB_LEFT, knobProgress[1])
|
|
end
|
|
|
|
if math.abs(knobProgress[2]) > knobThreshold then
|
|
currentScreen:handleKnobInput(game.KNOB_RIGHT, knobProgress[2])
|
|
end
|
|
end
|
|
end
|
|
|
|
function render(deltaTime)
|
|
handleKnobs()
|
|
|
|
Dim.updateResolution()
|
|
|
|
Wallpaper.render()
|
|
|
|
Dim.transformToScreenSpace()
|
|
|
|
currentScreen:render(deltaTime)
|
|
end
|
|
|
|
function mouse_pressed(button)
|
|
local mouseX, mouseY = game.GetMousePos()
|
|
currentScreen:handleMouseInput(mouseX, mouseY, button)
|
|
return 0 --THIS '0' IS VERY IMPORTANT, IT WILL CRASH VERY HARD WITHOUT THIS
|
|
end
|
|
|
|
function button_pressed(button)
|
|
currentScreen:handleButtonInput(button)
|
|
end
|