mirror of
https://gitea.com/SweetSea-ButImNotSweet/tromi_mobile.git
synced 2025-01-08 17:33:09 +08:00
TEST
This commit is contained in:
@@ -87,7 +87,7 @@ end
|
||||
|
||||
---Round a number with specified unit
|
||||
---@param n number
|
||||
---@param u number # Default: 10
|
||||
---@param u? number # Default: 10
|
||||
---@return number
|
||||
function math.roundUnit(n,u)
|
||||
local u = u or 10
|
||||
|
||||
1
main.lua
1
main.lua
@@ -161,6 +161,7 @@ function love.keypressed(key, scancode)
|
||||
love.window.setFullscreen(SETTINGS["fullscreen"])
|
||||
elseif scancode == "f2" and SCENE.title ~= "Input Config" and SCENE.title ~= "Game" then
|
||||
SCENE = InputConfigScene()
|
||||
elseif scancode == "f12" then REQUEST_BREAK()
|
||||
-- function keys are reserved
|
||||
elseif string.match(scancode, "^f[1-9]$") or string.match(scancode, "^f1[0-2]+$") then
|
||||
return
|
||||
|
||||
@@ -1,6 +1,28 @@
|
||||
local TouchConfigScene = SCENE:extend()
|
||||
TouchConfigScene.title = "Touchscreen config\n(you can tap anywhere on touch screen to select this)"
|
||||
|
||||
local widgetList = {
|
||||
BUTTON.new{
|
||||
text = "Select widget\nLoading...",
|
||||
x = 10, y = 10, w = 120, h = 50
|
||||
}
|
||||
}
|
||||
local function widgetList_update()
|
||||
for _, v in pairs(widgetList) do v:update() end
|
||||
end
|
||||
local function widgetList_draw()
|
||||
for _, v in pairs(widgetList) do v:draw() end
|
||||
end
|
||||
local function widgetList_isHovering(x, y)
|
||||
for _, v in pairs(widgetList) do v:isHovering(x, y) end
|
||||
end
|
||||
local function widgetList_press()
|
||||
for _, v in pairs(widgetList) do v:press() end
|
||||
end
|
||||
local function widgetList_release()
|
||||
for _, v in pairs(widgetList) do v:release() end
|
||||
end
|
||||
|
||||
function TouchConfigScene:new()
|
||||
-- TODO
|
||||
end
|
||||
@@ -8,38 +30,24 @@ function TouchConfigScene:update()
|
||||
-- TODO
|
||||
end
|
||||
|
||||
local test_button = BUTTON.new{
|
||||
name = 'PHÍM THỬ - Chọn widget',
|
||||
x = 50, y = 50, w = 200, h = 30, textColor = {1,1,1,1},
|
||||
codeWhenPressed = function() PlaySE("promote") end,
|
||||
codeWhenReleased = function() PlaySE("lock") end,
|
||||
}
|
||||
|
||||
local function drawButtons()
|
||||
-- drawText('Select button', 10, 10, 100, 'center')
|
||||
-- love.graphics.setColor(1,1,1)
|
||||
-- love.graphics.setLineWidth(3)
|
||||
-- love.graphics.rectangle('line',0,0,120,40)
|
||||
test_button:draw()
|
||||
end
|
||||
|
||||
function TouchConfigScene:render()
|
||||
MainBackground()
|
||||
drawButtons()
|
||||
widgetList_draw()
|
||||
end
|
||||
|
||||
---@param e SCENE_onInput
|
||||
function TouchConfigScene:onInputMove(e)
|
||||
if e.type == "mouse" then
|
||||
test_button:isHovering(e.x, e.y)
|
||||
widgetList_isHovering(e.x, e.y)
|
||||
end
|
||||
end
|
||||
---@param e SCENE_onInput
|
||||
function TouchConfigScene:onInputPress(e)
|
||||
if e.input == 'menu_back' then SCENE = InputConfigScene() end
|
||||
if e.type == 'mouse' then test_button:press() end
|
||||
if e.type == 'touch' then test_button:press(true) end
|
||||
if e.type =="mouse" then widgetList_press() end
|
||||
end
|
||||
function TouchConfigScene:onInputRelease(e)
|
||||
if e.type == 'mouse' then test_button:press() end
|
||||
if e.type =="mouse" then widgetList_release() end
|
||||
end
|
||||
|
||||
return TouchConfigScene
|
||||
Reference in New Issue
Block a user