diff --git a/scene/input_config.lua b/scene/input_config.lua index 3f3acb2..8d65e3a 100644 --- a/scene/input_config.lua +++ b/scene/input_config.lua @@ -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 diff --git a/scene/key_config.lua b/scene/key_config.lua index 678a1f7..a983586 100644 --- a/scene/key_config.lua +++ b/scene/key_config.lua @@ -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 diff --git a/scene/touch_config.lua b/scene/touch_config.lua index 022c87f..6ceb65b 100644 --- a/scene/touch_config.lua +++ b/scene/touch_config.lua @@ -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 diff --git a/settings.lua b/settings.lua index d4cc7bb..ea49d31 100644 --- a/settings.lua +++ b/settings.lua @@ -32,7 +32,7 @@ local _defaultSettings = { } SETTINGS = setmetatable( - {__force_saving__ = function() bitser.dumpLoveFile(CONFIG_FILE,_settings) end}, + {}, { __index = function(_, k) if _settings[k] == nil then