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

View File

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

View File

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