Fix bugs related to the first time launching game

This commit is contained in:
Squishy (C6H12O6+NaCl+H2O)
2024-05-25 16:15:41 +07:00
parent dfeece9ddc
commit 9e1c8d4680
4 changed files with 31 additions and 10 deletions

View File

@@ -4,7 +4,7 @@ ConfigScene.title = "Input Config"
local menu_screens = {
KeyConfigScene,
StickConfigScene,
TouchConfigScene
TouchConfigScene,
}
local buttonList
@@ -45,6 +45,23 @@ function ConfigScene:new(first_time)
end
}
}
if not SETTINGS.firstTime then
menu_screens[4] = TitleScene
buttonList[4] = BUTTON.new{
text = "", font = FONT_big,
x = 75, y = 280, w = 40, h = 40,
codeWhenReleased = function()
if self.menu_state ~= 4 then
self.menu_state = 4
else
SCENE = TitleScene()
end
end
}
else
menu_screens[4] = nil
buttonList[4] = nil
end
self.menu_state = 1
if first_time then

View File

@@ -65,7 +65,7 @@ function KeyConfigScene:onInputPress(e)
if e.type == "key" then
-- function keys, escape, and tab are reserved and can't be remapped
if e.scancode == "escape" then
SCENE = InputConfigScene()
SCENE = InputConfigScene(SETTINGS.firstTime)
elseif self.input_state > #configurable_inputs then
if e.scancode == "return" then
SETTINGS.input.keys = self.new_input

View File

@@ -14,10 +14,15 @@ local snapUnit = 1
local hasChanged
---@type function
local exitSceneFunc = function()
local function exitSceneFunc(saved)
VCTRL.release()
BUTTON.release(buttonList)
SCENE = TitleScene()
if SETTINGS.firstTime and not saved then
SCENE = InputConfigScene(true)
else
SCENE = TitleScene()
SETTINGS.firstTime = false
end
end
buttonList = {
@@ -51,7 +56,7 @@ buttonList = {
text = "MENU",
x = 570, y = 5, w = 60, h = 25,
codeWhenReleased = function()
if hasChanged then
if hasChanged or SETTINGS.firstTime then
local selection = love.window.showMessageBox(
"Save config?", "Do you want to save your changes before exiting?",
{"Save", "Discard", "Keep editing", escapebutton = 2, enterbutton = 1},
@@ -59,10 +64,9 @@ buttonList = {
)
if selection == 1 then
SETTINGS.input.virtual = VCTRL.exportAll()
SETTINGS.firstTime = false
-- love.window.showMessageBox("Saved!", "Your changes was saved!")
exitSceneFunc()
exitSceneFunc(true)
elseif selection == 2 then
VCTRL.clearAll()
VCTRL.new(SETTINGS.input.virtual)
@@ -141,12 +145,12 @@ local function sliderList_update()
end
end
function TouchConfigScene:new()
function TouchConfigScene:new(fromPreviewScene)
VCTRL.toggle(true)
VCTRL.focus = nil
focusingButton = nil
hasChanged = false
hasChanged = fromPreviewScene
Grid:new(10, 20)
-- TODO
end