mirror of
https://github.com/SashLilac/cambridge.git
synced 2024-11-22 17:59:01 -06:00
Refactored input handling, so that arrow keys will always work on menus.
This commit is contained in:
parent
fd739dcfdf
commit
a470b40def
@ -71,11 +71,11 @@ function GameScene:render()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function GameScene:onInputPress(e)
|
function GameScene:onInputPress(e)
|
||||||
if self.game.completed and (e.input == "menu_decide" or e.input == "menu_back") then
|
if self.game.completed and (e.input == "menu_decide" or e.input == "menu_back" or e.input == "retry") then
|
||||||
highscore_entry = self.game:getHighscoreData()
|
highscore_entry = self.game:getHighscoreData()
|
||||||
highscore_hash = self.game.hash .. "-" .. self.ruleset.hash
|
highscore_hash = self.game.hash .. "-" .. self.ruleset.hash
|
||||||
submitHighscore(highscore_hash, highscore_entry)
|
submitHighscore(highscore_hash, highscore_entry)
|
||||||
scene = ModeSelectScene()
|
scene = e.input == "retry" and GameScene(self.retry_mode, self.retry_ruleset) or ModeSelectScene()
|
||||||
elseif e.input == "retry" then
|
elseif e.input == "retry" then
|
||||||
scene = GameScene(self.retry_mode, self.retry_ruleset)
|
scene = GameScene(self.retry_mode, self.retry_ruleset)
|
||||||
elseif e.input == "menu_back" then
|
elseif e.input == "menu_back" then
|
||||||
|
@ -56,17 +56,17 @@ function ConfigScene:onInputPress(e)
|
|||||||
playSE("mode_decide")
|
playSE("mode_decide")
|
||||||
saveConfig()
|
saveConfig()
|
||||||
scene = TitleScene()
|
scene = TitleScene()
|
||||||
elseif e.input == "up" then
|
elseif e.input == "up" or e.scancode == "up" then
|
||||||
playSE("cursor")
|
playSE("cursor")
|
||||||
self.highlight = Mod1(self.highlight-1, optioncount)
|
self.highlight = Mod1(self.highlight-1, optioncount)
|
||||||
elseif e.input == "down" then
|
elseif e.input == "down" or e.scancode == "down" then
|
||||||
playSE("cursor")
|
playSE("cursor")
|
||||||
self.highlight = Mod1(self.highlight+1, optioncount)
|
self.highlight = Mod1(self.highlight+1, optioncount)
|
||||||
elseif e.input == "left" then
|
elseif e.input == "left" or e.scancode == "left" then
|
||||||
playSE("cursor_lr")
|
playSE("cursor_lr")
|
||||||
local option = ConfigScene.options[self.highlight]
|
local option = ConfigScene.options[self.highlight]
|
||||||
config.gamesettings[option[1]] = Mod1(config.gamesettings[option[1]]-1, #option[3])
|
config.gamesettings[option[1]] = Mod1(config.gamesettings[option[1]]-1, #option[3])
|
||||||
elseif e.input == "right" then
|
elseif e.input == "right" or e.scancode == "right" then
|
||||||
playSE("cursor_lr")
|
playSE("cursor_lr")
|
||||||
local option = ConfigScene.options[self.highlight]
|
local option = ConfigScene.options[self.highlight]
|
||||||
config.gamesettings[option[1]] = Mod1(config.gamesettings[option[1]]+1, #option[3])
|
config.gamesettings[option[1]] = Mod1(config.gamesettings[option[1]]+1, #option[3])
|
||||||
|
@ -67,13 +67,13 @@ function ModeSelectScene:onInputPress(e)
|
|||||||
playSE("mode_decide")
|
playSE("mode_decide")
|
||||||
saveConfig()
|
saveConfig()
|
||||||
scene = GameScene(game_modes[self.menu_state.mode], rulesets[self.menu_state.ruleset])
|
scene = GameScene(game_modes[self.menu_state.mode], rulesets[self.menu_state.ruleset])
|
||||||
elseif e.input == "up" then
|
elseif e.input == "up" or e.scancode == "up" then
|
||||||
self:changeOption(-1)
|
self:changeOption(-1)
|
||||||
playSE("cursor")
|
playSE("cursor")
|
||||||
elseif e.input == "down" then
|
elseif e.input == "down" or e.scancode == "down" then
|
||||||
self:changeOption(1)
|
self:changeOption(1)
|
||||||
playSE("cursor")
|
playSE("cursor")
|
||||||
elseif e.input == "left" or e.input == "right" then
|
elseif e.input == "left" or e.input == "right" or e.scancode == "left" or e.scancode == "right" then
|
||||||
self:switchSelect()
|
self:switchSelect()
|
||||||
playSE("cursor_lr")
|
playSE("cursor_lr")
|
||||||
elseif e.input == "menu_back" then
|
elseif e.input == "menu_back" then
|
||||||
|
@ -61,10 +61,10 @@ function TitleScene:onInputPress(e)
|
|||||||
if e.input == "menu_decide" then
|
if e.input == "menu_decide" then
|
||||||
playSE("main_decide")
|
playSE("main_decide")
|
||||||
scene = main_menu_screens[self.main_menu_state]()
|
scene = main_menu_screens[self.main_menu_state]()
|
||||||
elseif e.input == "up" then
|
elseif e.input == "up" or e.scancode == "up" then
|
||||||
self:changeOption(-1)
|
self:changeOption(-1)
|
||||||
playSE("cursor")
|
playSE("cursor")
|
||||||
elseif e.input == "down" then
|
elseif e.input == "down" or e.scancode == "down" then
|
||||||
self:changeOption(1)
|
self:changeOption(1)
|
||||||
playSE("cursor")
|
playSE("cursor")
|
||||||
elseif e.input == "menu_back" then
|
elseif e.input == "menu_back" then
|
||||||
|
Loading…
Reference in New Issue
Block a user