Update both key and stick configuration scenes

This commit is contained in:
Nguyễn Quốc Hưng
2024-08-10 17:13:43 +07:00
parent e6388c79bc
commit 78501f368c
2 changed files with 25 additions and 36 deletions

View File

@@ -27,7 +27,6 @@ local input_names = {
rotate_right2='Rotate Clockwise (2)'
}
local function newSetInputs()
local set_inputs = {}
for i, input in ipairs(configurable_inputs) do
@@ -40,43 +39,34 @@ function KeyConfigScene:new()
self.input_state = 1
self.set_inputs = newSetInputs()
self.new_input = {}
self.axis_timer = 0
BUTTON.reset(buttonList)
buttonList = { -- Configuring
BUTTON.new{
text = CHAR.icon.fastForward.." SKIP",
x = 40, y = 300, w = 100, h = 30,
text = CHAR.key.tab.."\nTab",
x = 40, y = 300, w = 100, h = 50,
codeWhenReleased = function() self:onInputPress{type = "key", scancode = "tab"} end
},
BUTTON.new{
text = CHAR.icon.cross_thick.." Cancel",
x = 150, y = 300, w = 100, h = 30,
text = CHAR.key.enter_or_return.."\nEnter/Return",
x = 150, y = 300, w = 100, h = 50,
codeWhenReleased = function() self:onInputPress{type = "key", scancode = "return"} end
},
BUTTON.new{
text = CHAR.key.del.."\nDelete",
x = 260, y = 300, w = 100, h = 50,
codeWhenReleased = function() self:onInputPress{type = "key", scancode = "delete"} end
},
BUTTON.new{
text = CHAR.key.esc.."\nEscape",
x = 370, y = 300, w = 100, h = 50,
codeWhenReleased = function() self:onInputPress{type = "key", scancode = "escape"} end
},
}
end
function KeyConfigScene:update()
if self.input_state > #configurable_inputs then
BUTTON.reset(buttonList)
buttonList = { -- Confirming
BUTTON.new{
text = CHAR.icon.checkMark.." CONFIRM",
x = 40, y = 300, w = 100, h = 30,
codeWhenReleased = function() self:onInputPress{type = "key", scancode = "return"} end
},
BUTTON.new{
text = CHAR.icon.retry_spin.." Restart",
x = 150, y = 300, w = 100, h = 30,
codeWhenReleased = function() self:onInputPress{type = "key", scancode = "delete"} end
},
BUTTON.new{
text = CHAR.icon.cross_thick.." Cancel",
x = 260, y = 300, w = 100, h = 30,
codeWhenReleased = function() self:onInputPress{type = "key", scancode = "escape"} end
}
}
end
end
function KeyConfigScene:render()
@@ -90,10 +80,10 @@ function KeyConfigScene:render()
end
end
if self.input_state > #configurable_inputs then
drawText("Press Enter/Confirm Selection to confirm, delete/backspace to retry" .. (SETTINGS.input.keys and ", esc/Go Back to cancel" or ""),0,0,1000)
drawText("Press Enter/Confirm Selection to confirm, Delete/Backspace to retry" .. (SETTINGS.input.keys and ", Esc/Go Back to cancel" or ""), 0, 0, 1000)
else
drawText("Press key input for " .. input_names[configurable_inputs[self.input_state]] .. ", escape to cancel\nPress tab on keyboard, or any key from other inputs, to skip",0,0,1000)
drawText("Function keys (F1, F2, etc.), escape, and tab can't be changed", 0, 35,1000)
drawText("Function keys (F1, F2, etc.), Escape, and Tab can't be changed", 0, 35,1000)
end
end