This commit is contained in:
Squishy (C6H12O6+NaCl+H2O)
2024-05-21 22:45:49 +07:00
parent 7cf9d0cadc
commit fb7ccc2527
3 changed files with 10 additions and 13 deletions

View File

@@ -235,15 +235,16 @@ end
---@param x number # Mouse position ---@param x number # Mouse position
---@param y number # Mouse position ---@param y number # Mouse position
function BUTTON.checkHovering(list, x, y) function BUTTON.checkHovering(list, x, y)
for _, v in pairs(list) do v:isHovering(x, y) end for _, v in pairs(list) do v._hovering = v:isHovering(x, y) end
end end
--- Trigger the press action, only if ``button._hovering == true`` --- Trigger the press action, only if ``button._hovering == true``
---@param list table<BUTTON.button> ---@param list table<BUTTON.button>
---@param x number # Mouse position ---@param x number # Mouse position
---@param y number # Mouse position ---@param y number # Mouse position
function BUTTON.press(list, x, y) ---@param isMouse? boolean # Is mouse just released a button?
for _, v in pairs(list) do v:press(x, y) end function BUTTON.press(list, x, y, isMouse)
for _, v in pairs(list) do v:press(x, y, isMouse) end
end end
---Trigger the release action ---Trigger the release action

View File

@@ -129,7 +129,7 @@ end
function NameEntryScene:onInputPress(e) function NameEntryScene:onInputPress(e)
if e.type == "mouse" or e.type == "touch" then if e.type == "mouse" or e.type == "touch" then
BUTTON.press(buttonList, e.x, e.y) BUTTON.press(buttonList, e.x, e.y, e.type == "touch")
elseif e.input == "menu_decide" or e.input == "rotate_left" or e.scancode == "return" then elseif e.input == "menu_decide" or e.input == "rotate_left" or e.scancode == "return" then
self.delete_confirm = false self.delete_confirm = false
self.delete_input_count = 0 self.delete_input_count = 0
@@ -198,10 +198,8 @@ function NameEntryScene:onInputPress(e)
end end
function NameEntryScene:onInputRelease(e) function NameEntryScene:onInputRelease(e)
if e.type == "mouse" then if e.type == "mouse" or e.type == "touch" then
BUTTON.release(buttonList, e.x, e.y) BUTTON.release(buttonList, e.x, e.y, e.type == "touch")
elseif e.type == "touch" then
BUTTON.release(buttonList, e.x, e.y, true)
elseif e.input == "left" or e.scancode == "left" or e.input == "right" or e.scancode == "right" then elseif e.input == "left" or e.scancode == "left" or e.input == "right" or e.scancode == "right" then
self.direction = nil self.direction = nil
self.repeat_counter = self.repeat_limit-1 self.repeat_counter = self.repeat_limit-1

View File

@@ -77,15 +77,13 @@ end
function TouchConfigScene:onInputPress(e) function TouchConfigScene:onInputPress(e)
if e.input == 'menu_back' then SCENE = InputConfigScene() end if e.input == 'menu_back' then SCENE = InputConfigScene() end
if e.type == "mouse" or e.type == "touch" then if e.type == "mouse" or e.type == "touch" then
BUTTON.press(buttonList, e.x, e.y) BUTTON.press(buttonList, e.x, e.y, e.type == "touch")
end end
end end
---@param e SCENE_onInput ---@param e SCENE_onInput
function TouchConfigScene:onInputRelease(e) function TouchConfigScene:onInputRelease(e)
if e.type == "mouse" then if e.type == "mouse" or e.type == "touch" then
BUTTON.release(buttonList, e.x, e.y, true) BUTTON.release(buttonList, e.x, e.y, e.type == "touch")
elseif e.type == "touch" then
BUTTON.release(buttonList, e.x, e.y)
end end
end end