mirror of
https://gitea.com/SweetSea-ButImNotSweet/tromi_mobile.git
synced 2025-01-08 17:33:09 +08:00
Moving VCTRL related calls and adding buttons for name entry screen
This commit is contained in:
@@ -65,6 +65,7 @@ local button = {
|
||||
|
||||
_hovering = false,
|
||||
_pressed = false,
|
||||
_touchID = false,
|
||||
}; button.__index = button
|
||||
function button:draw()
|
||||
love.graphics.setLineWidth(self.borderWidth)
|
||||
@@ -112,17 +113,30 @@ function button:isHovering(x,y)
|
||||
end
|
||||
end
|
||||
---Trigger press action, only when ``self._hovering`` is true
|
||||
function button:press(x, y)
|
||||
if self:isHovering(x, y) and not self._pressed then
|
||||
self._pressed = true
|
||||
function button:press(x, y, touchID)
|
||||
if (touchID and self:isHovering(x, y) or self._hovering) and not self._pressed then
|
||||
self.codeWhenPressed()
|
||||
|
||||
self._touchID = touchID
|
||||
self._pressed = true
|
||||
end
|
||||
end
|
||||
---Trigger release action, don't need ``self._hovering`` to ``true``
|
||||
function button:release(x, y)
|
||||
if self:isHovering(x, y) and self._pressed then
|
||||
self._pressed = false
|
||||
function button:release(x, y, touchID)
|
||||
local valid = true
|
||||
if touchID then valid = touchID == self._touchID end
|
||||
|
||||
if valid then
|
||||
self.codeWhenReleased()
|
||||
|
||||
self._pressed = false
|
||||
self._touchID = false
|
||||
|
||||
if touchID then
|
||||
self._hovering = false
|
||||
else
|
||||
self._hovering = self:isHovering(x, y)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -235,16 +249,14 @@ end
|
||||
---@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
|
||||
function BUTTON.press(list, x, y, touchID)
|
||||
for _, v in pairs(list) do v:press(x, y, touchID) end
|
||||
end
|
||||
|
||||
---Trigger the release action
|
||||
---@param list table<BUTTON.button>
|
||||
---@param x number # Mouse position
|
||||
---@param y number # Mouse position
|
||||
function BUTTON.release(list, x, y)
|
||||
for _, v in pairs(list) do v:release(x, y) end
|
||||
function BUTTON.release(list, x, y, touchID)
|
||||
for _, v in pairs(list) do v:release(x, y, touchID) end
|
||||
end
|
||||
|
||||
return BUTTON
|
||||
Reference in New Issue
Block a user