2019-05-22 22:57:34 -05:00
|
|
|
local ConfigScene = Scene:extend()
|
|
|
|
|
|
|
|
ConfigScene.title = "Input Config"
|
|
|
|
|
|
|
|
require 'load.save'
|
|
|
|
|
|
|
|
local configurable_inputs = {
|
|
|
|
"left",
|
|
|
|
"right",
|
|
|
|
"up",
|
|
|
|
"down",
|
|
|
|
"rotate_left",
|
|
|
|
"rotate_left2",
|
|
|
|
"rotate_right",
|
|
|
|
"rotate_right2",
|
|
|
|
"rotate_180",
|
|
|
|
"hold",
|
2020-10-07 22:56:46 -05:00
|
|
|
"retry",
|
2019-05-22 22:57:34 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
function ConfigScene:new()
|
|
|
|
-- load current config
|
|
|
|
self.config = config.input
|
|
|
|
self.input_state = 1
|
2020-10-09 17:43:22 -05:00
|
|
|
|
2020-10-10 20:17:48 -05:00
|
|
|
DiscordRPC:update({
|
|
|
|
details = "In menus",
|
|
|
|
state = "Changing input config",
|
|
|
|
})
|
2019-05-22 22:57:34 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
function ConfigScene:update()
|
|
|
|
end
|
|
|
|
|
|
|
|
function ConfigScene:render()
|
2020-10-09 12:44:48 -05:00
|
|
|
love.graphics.setColor(1, 1, 1, 1)
|
|
|
|
love.graphics.draw(
|
|
|
|
backgrounds["input_config"],
|
|
|
|
0, 0, 0,
|
|
|
|
0.5, 0.5
|
|
|
|
)
|
2020-10-09 17:43:22 -05:00
|
|
|
|
2019-05-22 22:57:34 -05:00
|
|
|
love.graphics.setFont(font_3x5_2)
|
|
|
|
for i, input in pairs(configurable_inputs) do
|
2020-10-10 18:42:56 -05:00
|
|
|
love.graphics.printf(input, 40, 50 + i * 20, 200, "left")
|
2019-05-22 22:57:34 -05:00
|
|
|
if config.input[input] then
|
|
|
|
love.graphics.printf(
|
|
|
|
love.keyboard.getKeyFromScancode(config.input[input]) .. " (" .. config.input[input] .. ")",
|
|
|
|
240, 50 + i * 20, 200, "left"
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if self.input_state > table.getn(configurable_inputs) then
|
|
|
|
love.graphics.print("press enter to confirm, delete to retry")
|
|
|
|
else
|
|
|
|
love.graphics.print("press key for " .. configurable_inputs[self.input_state])
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function ConfigScene:onKeyPress(e)
|
|
|
|
if self.input_state > table.getn(configurable_inputs) then
|
|
|
|
if e.scancode == "return" then
|
|
|
|
-- save, then load next scene
|
|
|
|
saveConfig()
|
|
|
|
scene = TitleScene()
|
|
|
|
elseif e.scancode == "delete" or e.scancode == "backspace" then
|
|
|
|
self.input_state = 1
|
|
|
|
end
|
|
|
|
else
|
2020-10-10 18:42:56 -05:00
|
|
|
if e.scancode == "escape" then
|
|
|
|
loadSave()
|
|
|
|
scene = TitleScene()
|
|
|
|
else
|
|
|
|
config.input[configurable_inputs[self.input_state]] = e.scancode
|
|
|
|
self.input_state = self.input_state + 1
|
|
|
|
end
|
2019-05-22 22:57:34 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
return ConfigScene
|