Attempt to fix, one again

This commit is contained in:
Nguyễn Quốc Hưng
2024-08-10 16:53:49 +07:00
parent e4e43ec61e
commit e6388c79bc

View File

@@ -1,6 +1,6 @@
local StickConfigScene = SCENE:extend() local StickConfigScene = SCENE:extend()
StickConfigScene.title = "Controller Config" StickConfigScene.title = "Controller Config"
local buttonList1, buttonList2 = {}, {} local buttonList1 = {}
local configurable_inputs = { local configurable_inputs = {
"menu_decide", "menu_decide",
@@ -41,35 +41,28 @@ function StickConfigScene:new()
self.new_input = {} self.new_input = {}
self.axis_timer = 0 self.axis_timer = 0
BUTTON.reset(buttonList1, buttonList2) BUTTON.reset(buttonList1)
buttonList1 = { -- Configuring buttonList1 = { -- Configuring
BUTTON.new{ BUTTON.new{
text = CHAR.icon.fastForward.." SKIP", text = CHAR.key.tab.."\nTab",
x = 40, y = 300, w = 100, h = 30, x = 40, y = 300, w = 100, h = 50,
codeWhenReleased = function() self:onInputPress{type = "key", scancode = "tab"} end codeWhenReleased = function() self:onInputPress{type = "key", scancode = "tab"} end
}, },
BUTTON.new{ BUTTON.new{
text = CHAR.icon.cross_thick.." Cancel", text = CHAR.key.enter_or_return.."\nEnter/Return",
x = 150, y = 300, w = 100, h = 30, x = 150, y = 300, w = 100, h = 50,
codeWhenReleased = function() self:onInputPress{type = "key", scancode = "escape"} end
},
}
buttonList2 = { -- 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 codeWhenReleased = function() self:onInputPress{type = "key", scancode = "return"} end
}, },
BUTTON.new{ BUTTON.new{
text = CHAR.icon.retry_spin.." Restart", text = CHAR.key.del.."\nDelete",
x = 150, y = 300, w = 100, h = 30, x = 260, y = 300, w = 100, h = 50,
codeWhenReleased = function() self:onInputPress{type = "key", scancode = "delete"} end codeWhenReleased = function() self:onInputPress{type = "key", scancode = "delete"} end
}, },
BUTTON.new{ BUTTON.new{
text = CHAR.icon.cross_thick.." Cancel", text = CHAR.key.esc.."\nEscape",
x = 260, y = 300, w = 100, h = 30, x = 370, y = 300, w = 100, h = 50,
codeWhenReleased = function() self:onInputPress{type = "key", scancode = "escape"} end codeWhenReleased = function() self:onInputPress{type = "key", scancode = "escape"} end
} },
} }
end end
@@ -78,7 +71,7 @@ end
function StickConfigScene:render() function StickConfigScene:render()
MainBackground() MainBackground()
BUTTON.draw(self.input_state > #configurable_inputs and buttonList2 or buttonList1) BUTTON.draw(buttonList1)
for i, input in ipairs(configurable_inputs) do for i, input in ipairs(configurable_inputs) do
drawText(input_names[input], 40, 60 + i * 20, 200, "left") drawText(input_names[input], 40, 60 + i * 20, 200, "left")
@@ -104,7 +97,7 @@ end
---@param e SCENE_onInput ---@param e SCENE_onInput
function StickConfigScene:onInputPress(e) function StickConfigScene:onInputPress(e)
if e.type == "mouse" or e.type == "touch" then if e.type == "mouse" or e.type == "touch" then
BUTTON.press(self.input_state > #configurable_inputs and buttonList2 or buttonList1, e.x, e.y, e.id) BUTTON.press(buttonList1, e.x, e.y, e.id)
elseif e.type == "key" then elseif e.type == "key" then
-- function keys, escape, and tab are reserved and can't be remapped -- function keys, escape, and tab are reserved and can't be remapped
if e.scancode == "escape" or (self.input_state > #configurable_inputs and e.input == "menu_back") then if e.scancode == "escape" or (self.input_state > #configurable_inputs and e.input == "menu_back") then
@@ -182,13 +175,13 @@ end
function StickConfigScene:onInputRelease(e) function StickConfigScene:onInputRelease(e)
if e.type == "mouse" or e.type == "touch" then if e.type == "mouse" or e.type == "touch" then
BUTTON.release(self.input_state > #configurable_inputs and buttonList2 or buttonList1, e.x, e.y, e.id) BUTTON.release(buttonList1, e.x, e.y, e.id)
end end
end end
function StickConfigScene:onInputMove(e) function StickConfigScene:onInputMove(e)
if e.type == "mouse" then if e.type == "mouse" then
BUTTON.checkHovering(self.input_state > #configurable_inputs and buttonList2 or buttonList1, e.x, e.y) BUTTON.checkHovering(buttonList1, e.x, e.y)
end end
end end