From 0eb274436ee228cccf59ddc6fa4be7d95bb61fc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Qu=E1=BB=91c=20H=C6=B0ng?= <106439598+SweetSea-ButImNotSweet@users.noreply.github.com> Date: Sat, 10 Aug 2024 14:34:08 +0700 Subject: [PATCH] Attempt to fix broken button --- scene/stick_config.lua | 49 ++++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 26 deletions(-) diff --git a/scene/stick_config.lua b/scene/stick_config.lua index 91b2065..80a4509 100644 --- a/scene/stick_config.lua +++ b/scene/stick_config.lua @@ -41,8 +41,8 @@ function StickConfigScene:new() self.new_input = {} self.axis_timer = 0 - BUTTON.reset(buttonList) - buttonList = { -- Configuring + BUTTON.reset(buttonList1, buttonList2) + buttonList1 = { -- Configuring BUTTON.new{ text = CHAR.icon.fastForward.." SKIP", x = 40, y = 300, w = 100, h = 30, @@ -54,34 +54,31 @@ function StickConfigScene:new() 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 + }, + 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 function StickConfigScene: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 StickConfigScene:render() MainBackground() - BUTTON.draw(buttonList) + BUTTON.draw(self.input_state > #configurable_inputs and buttonList2 or buttonList1) for i, input in ipairs(configurable_inputs) do drawText(input_names[input], 40, 60 + i * 20, 200, "left") @@ -107,7 +104,7 @@ end ---@param e SCENE_onInput function StickConfigScene:onInputPress(e) if e.type == "mouse" or e.type == "touch" then - BUTTON.press(buttonList, e.x, e.y, e.id) + BUTTON.press(self.input_state > #configurable_inputs and buttonList2 or buttonList1, e.x, e.y, e.id) elseif e.type == "key" then -- 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 @@ -185,13 +182,13 @@ end function StickConfigScene:onInputRelease(e) if e.type == "mouse" or e.type == "touch" then - BUTTON.release(buttonList, e.x, e.y, e.id) + BUTTON.release(self.input_state > #configurable_inputs and buttonList2 or buttonList1, e.x, e.y, e.id) end end function StickConfigScene:onInputMove(e) if e.type == "mouse" then - BUTTON.checkHovering(buttonList, e.x, e.y) + BUTTON.checkHovering(self.input_state > #configurable_inputs and buttonList2 or buttonList1, e.x, e.y) end end