Revert "Separate in-game bindings from menu bindings"

This reverts commit 0fce4b632f.
This commit caused issue #41. Will resolve ASAP.
pull/43/head
Ishaan Bhardwaj 2021-10-21 20:52:42 -04:00
parent 0fce4b632f
commit 7495c4ad04
12 changed files with 44 additions and 140 deletions

View File

@ -1 +1 @@
version = "v0.3.1" version = "v0.3"

View File

@ -13,7 +13,6 @@ GameScene = require "scene.game"
ModeSelectScene = require "scene.mode_select" ModeSelectScene = require "scene.mode_select"
KeyConfigScene = require "scene.key_config" KeyConfigScene = require "scene.key_config"
StickConfigScene = require "scene.stick_config" StickConfigScene = require "scene.stick_config"
MenuConfigScene = require "scene.menu_config"
InputConfigScene = require "scene.input_config" InputConfigScene = require "scene.input_config"
GameConfigScene = require "scene.game_config" GameConfigScene = require "scene.game_config"
TuningScene = require "scene.tuning" TuningScene = require "scene.tuning"

View File

@ -80,7 +80,8 @@ function CreditsScene:render()
end end
function CreditsScene:onInputPress(e) function CreditsScene:onInputPress(e)
if e.input == "menu_decide" or e.input == "menu_back" then if e.input == "menu_decide" or e.scancode == "return" or
e.input == "menu_back" or e.scancode == "delete" or e.scancode == "backspace" then
scene = TitleScene() scene = TitleScene()
switchBGM(nil) switchBGM(nil)
end end

View File

@ -84,17 +84,17 @@ function ConfigScene:render()
end end
function ConfigScene:onInputPress(e) function ConfigScene:onInputPress(e)
if e.input == "menu_decide" then if e.input == "menu_decide" or e.scancode == "return" then
playSE("mode_decide") playSE("mode_decide")
saveConfig() saveConfig()
scene = SettingsScene() scene = SettingsScene()
elseif e.input == "menu_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 == "menu_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 == "menu_left" then elseif e.input == "left" or e.scancode == "left" then
if not self.options[self.highlight][3] then if not self.options[self.highlight][3] then
playSE("cursor_lr") playSE("cursor_lr")
local option = ConfigScene.options[self.highlight] local option = ConfigScene.options[self.highlight]
@ -105,7 +105,7 @@ function ConfigScene:onInputPress(e)
sld:update() sld:update()
playSE("cursor") playSE("cursor")
end end
elseif e.input == "menu_right" then elseif e.input == "right" or e.scancode == "right" then
if not self.options[self.highlight][3] then if not self.options[self.highlight][3] then
playSE("cursor_lr") playSE("cursor_lr")
local option = ConfigScene.options[self.highlight] local option = ConfigScene.options[self.highlight]
@ -116,7 +116,7 @@ function ConfigScene:onInputPress(e)
sld:update() sld:update()
playSE("cursor") playSE("cursor")
end end
elseif e.input == "menu_back" then elseif e.input == "menu_back" or e.scancode == "delete" or e.scancode == "backspace" then
loadSave() loadSave()
scene = SettingsScene() scene = SettingsScene()
end end

View File

@ -1,6 +1,6 @@
local ConfigScene = Scene:extend() local ConfigScene = Scene:extend()
ConfigScene.title = "Game Controls" ConfigScene.title = "Input Config"
local menu_screens = { local menu_screens = {
KeyConfigScene, KeyConfigScene,
@ -27,7 +27,7 @@ function ConfigScene:render()
) )
love.graphics.setFont(font_3x5_4) love.graphics.setFont(font_3x5_4)
love.graphics.print("IN-GAME CONTROLS", 80, 40) love.graphics.print("INPUT CONFIG", 80, 40)
love.graphics.setFont(font_3x5_2) love.graphics.setFont(font_3x5_2)
love.graphics.print("Which controls do you want to configure?", 80, 90) love.graphics.print("Which controls do you want to configure?", 80, 90)
@ -48,17 +48,18 @@ function ConfigScene:changeOption(rel)
end end
function ConfigScene:onInputPress(e) function ConfigScene:onInputPress(e)
local had_config = config.input ~= nil if e.input == "menu_decide" or e.scancode == "return" then
if e.input == "menu_decide" or (not had_config and e.scancode == "return") then
playSE("main_decide") playSE("main_decide")
scene = menu_screens[self.menu_state]() scene = menu_screens[self.menu_state]()
elseif e.input == "menu_up" or (not had_config and e.scancode == "up") then elseif e.input == "up" or e.scancode == "up" then
self:changeOption(-1) self:changeOption(-1)
playSE("cursor") playSE("cursor")
elseif e.input == "menu_down" or (not had_config and e.scancode == "down") then elseif e.input == "down" or e.scancode == "down" then
self:changeOption(1) self:changeOption(1)
playSE("cursor") playSE("cursor")
elseif had_config and e.input == "menu_back" then elseif config.input and (
e.input == "menu_back" or e.scancode == "backspace" or e.scancode == "delete"
) then
scene = SettingsScene() scene = SettingsScene()
end end
end end

View File

@ -5,6 +5,8 @@ KeyConfigScene.title = "Key Config"
require 'load.save' require 'load.save'
local configurable_inputs = { local configurable_inputs = {
"menu_decide",
"menu_back",
"left", "left",
"right", "right",
"up", "up",
@ -73,15 +75,10 @@ function KeyConfigScene:onInputPress(e)
if e.scancode == "return" then if e.scancode == "return" then
-- save new input, then load next scene -- save new input, then load next scene
local had_config = config.input ~= nil local had_config = config.input ~= nil
if not had_config then if not config.input then config.input = {} end
config.input = {} config.input.keys = self.new_input
config.input.keys = {}
end
for k, v in pairs(self.new_input) do
config.input.keys[k] = v
end
saveConfig() saveConfig()
scene = had_config and InputConfigScene() or MenuConfigScene() scene = had_config and InputConfigScene() or TitleScene()
elseif e.scancode == "delete" or e.scancode == "backspace" then elseif e.scancode == "delete" or e.scancode == "backspace" then
-- retry -- retry
self.input_state = 1 self.input_state = 1

View File

@ -1,93 +0,0 @@
local MenuConfigScene = Scene:extend()
MenuConfigScene.title = "Menu Controls"
require 'load.save'
local configurable_inputs = {
"menu_left",
"menu_right",
"menu_up",
"menu_down",
"menu_decide",
"menu_back",
}
local function newSetInputs()
local set_inputs = {}
for i, input in ipairs(configurable_inputs) do
set_inputs[input] = false
end
return set_inputs
end
function MenuConfigScene:new()
self.input_state = 1
self.set_inputs = newSetInputs()
self.new_input = {}
DiscordRPC:update({
details = "In settings",
state = "Changing key config",
})
end
function MenuConfigScene:update()
end
function MenuConfigScene:render()
love.graphics.setColor(1, 1, 1, 1)
love.graphics.draw(
backgrounds["input_config"],
0, 0, 0,
0.5, 0.5
)
love.graphics.setFont(font_3x5_2)
for i, input in ipairs(configurable_inputs) do
love.graphics.printf(input, 40, 50 + i * 20, 200, "left")
if self.set_inputs[input] then
love.graphics.printf(self.set_inputs[input], 240, 50 + i * 20, 300, "left")
end
end
if self.input_state > table.getn(configurable_inputs) then
love.graphics.print("press enter to confirm, delete/backspace to retry" .. (config.input and ", escape to cancel" or ""))
else
love.graphics.print("press key input for " .. configurable_inputs[self.input_state] .. ", tab to skip, escape to cancel", 0, 0)
love.graphics.print("function keys (F1, F2, etc.), escape, and tab can't be changed", 0, 20)
end
end
function MenuConfigScene: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 = SettingsScene()
elseif self.input_state > table.getn(configurable_inputs) then
if e.scancode == "return" then
-- save new input, then load next scene
local had_config = config.input.menu_left ~= nil
for k, v in pairs(self.new_input) do
config.input.keys[k] = v
end
saveConfig()
scene = had_config and SettingsScene() or TitleScene()
elseif e.scancode == "delete" or e.scancode == "backspace" then
-- retry
self.input_state = 1
self.set_inputs = newSetInputs()
self.new_input = {}
end
elseif e.scancode == "tab" then
self.set_inputs[configurable_inputs[self.input_state]] = "skipped"
self.input_state = self.input_state + 1
elseif e.scancode ~= "escape" and not self.new_input[e.scancode] then
-- all other keys can be configured
self.set_inputs[configurable_inputs[self.input_state]] = "key " .. love.keyboard.getKeyFromScancode(e.scancode) .. " (" .. e.scancode .. ")"
self.new_input[e.scancode] = configurable_inputs[self.input_state]
self.input_state = self.input_state + 1
end
end
end
return MenuConfigScene

View File

@ -120,7 +120,7 @@ function ModeSelectScene:onInputPress(e)
if e.y ~= 0 then if e.y ~= 0 then
self:changeOption(-e.y) self:changeOption(-e.y)
end end
elseif e.input == "menu_decide" then elseif e.input == "menu_decide" or e.scancode == "return" then
current_mode = self.menu_state.mode current_mode = self.menu_state.mode
current_ruleset = self.menu_state.ruleset current_ruleset = self.menu_state.ruleset
config.current_mode = current_mode config.current_mode = current_mode
@ -132,17 +132,17 @@ function ModeSelectScene:onInputPress(e)
rulesets[self.menu_state.ruleset], rulesets[self.menu_state.ruleset],
self.secret_inputs self.secret_inputs
) )
elseif e.input == "menu_up" then elseif e.input == "up" or e.scancode == "up" then
self:changeOption(-1) self:changeOption(-1)
self.das_up = true self.das_up = true
self.das_down = nil self.das_down = nil
elseif e.input == "menu_down" then elseif e.input == "down" or e.scancode == "down" then
self:changeOption(1) self:changeOption(1)
self.das_down = true self.das_down = true
self.das_up = nil self.das_up = nil
elseif e.input == "menu_left" or e.input == "menu_right" then elseif e.input == "left" or e.input == "right" or e.scancode == "left" or e.scancode == "right" then
self:switchSelect() self:switchSelect()
elseif e.input == "menu_back" then elseif e.input == "menu_back" or e.scancode == "delete" or e.scancode == "backspace" then
scene = TitleScene() scene = TitleScene()
elseif e.input then elseif e.input then
self.secret_inputs[e.input] = true self.secret_inputs[e.input] = true
@ -150,9 +150,9 @@ function ModeSelectScene:onInputPress(e)
end end
function ModeSelectScene:onInputRelease(e) function ModeSelectScene:onInputRelease(e)
if e.input == "menu_up" then if e.input == "up" or e.scancode == "up" then
self.das_up = nil self.das_up = nil
elseif e.input == "menu_down" then elseif e.input == "down" or e.scancode == "down" then
self.das_down = nil self.das_down = nil
elseif e.input then elseif e.input then
self.secret_inputs[e.input] = false self.secret_inputs[e.input] = false

View File

@ -4,7 +4,6 @@ SettingsScene.title = "Settings"
local menu_screens = { local menu_screens = {
InputConfigScene, InputConfigScene,
MenuConfigScene,
GameConfigScene, GameConfigScene,
TuningScene TuningScene
} }
@ -58,16 +57,16 @@ function SettingsScene:changeOption(rel)
end end
function SettingsScene:onInputPress(e) function SettingsScene:onInputPress(e)
if e.input == "menu_decide" then if e.input == "menu_decide" or e.scancode == "return" then
playSE("main_decide") playSE("main_decide")
scene = menu_screens[self.menu_state]() scene = menu_screens[self.menu_state]()
elseif e.input == "menu_up" then elseif e.input == "up" or e.scancode == "up" then
self:changeOption(-1) self:changeOption(-1)
playSE("cursor") playSE("cursor")
elseif e.input == "menu_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" or e.scancode == "backspace" or e.scancode == "delete" then
scene = TitleScene() scene = TitleScene()
end end
end end

View File

@ -86,7 +86,7 @@ function StickConfigScene:onInputPress(e)
if not config.input then config.input = {} end if not config.input then config.input = {} end
config.input.joysticks = self.new_input config.input.joysticks = self.new_input
saveConfig() saveConfig()
scene = had_config and InputConfigScene() or MenuConfigScene() scene = had_config and InputConfigScene() or TitleScene()
elseif e.scancode == "delete" or e.scancode == "backspace" then elseif e.scancode == "delete" or e.scancode == "backspace" then
-- retry -- retry
self.input_state = 1 self.input_state = 1

View File

@ -114,16 +114,16 @@ function TitleScene:changeOption(rel)
end end
function TitleScene:onInputPress(e) function TitleScene:onInputPress(e)
if e.input == "menu_decide" then if e.input == "menu_decide" or e.scancode == "return" 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 == "menu_up" then elseif e.input == "up" or e.scancode == "up" then
self:changeOption(-1) self:changeOption(-1)
playSE("cursor") playSE("cursor")
elseif e.input == "menu_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" or e.scancode == "backspace" or e.scancode == "delete" then
love.event.quit() love.event.quit()
-- no winter easter egg for now -- no winter easter egg for now
--[[ --[[

View File

@ -63,25 +63,25 @@ function TuningScene:render()
end end
function TuningScene:onInputPress(e) function TuningScene:onInputPress(e)
if e.input == "menu_decide" then if e.input == "menu_decide" or e.scancode == "return" then
playSE("mode_decide") playSE("mode_decide")
saveConfig() saveConfig()
scene = SettingsScene() scene = SettingsScene()
elseif e.input == "menu_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 == "menu_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 == "menu_left" then elseif e.input == "left" or e.scancode == "left" then
playSE("cursor") playSE("cursor")
sld = self[self.options[self.highlight][3]] sld = self[self.options[self.highlight][3]]
sld.value = math.max(sld.min, math.min(sld.max, (sld:getValue() - 1) / (sld.max - sld.min))) sld.value = math.max(sld.min, math.min(sld.max, (sld:getValue() - 1) / (sld.max - sld.min)))
elseif e.input == "menu_right" then elseif e.input == "right" or e.scancode == "right" then
playSE("cursor") playSE("cursor")
sld = self[self.options[self.highlight][3]] sld = self[self.options[self.highlight][3]]
sld.value = math.max(sld.min, math.min(sld.max, (sld:getValue() + 1) / (sld.max - sld.min))) sld.value = math.max(sld.min, math.min(sld.max, (sld:getValue() + 1) / (sld.max - sld.min)))
elseif e.input == "menu_back" then elseif e.input == "menu_back" or e.scancode == "delete" or e.scancode == "backspace" then
loadSave() loadSave()
scene = SettingsScene() scene = SettingsScene()
end end