Not showing virtual control on computer

This commit is contained in:
Squishy (C6H12O6+NaCl+H2O)
2024-04-20 22:33:30 +07:00
parent aa57db8675
commit 1773a6aa67
2 changed files with 15 additions and 4 deletions

View File

@@ -98,8 +98,9 @@ function control_type.button:getDistance(x,y)
end
local touches={}
local global_toggle=false
VCTRL={}
VCTRL.focus=nil -- Focusing buttons
-- VCTRL.focus=nil -- Focusing buttons
---@param ... table
---@class data
@@ -120,6 +121,7 @@ function VCTRL.new(...)
end
function VCTRL.press(x,y,id)
if not global_toggle then return end
local obj,closestDist=false,1e99
for i=1,#VCTRL do
local w=VCTRL[i]
@@ -133,12 +135,13 @@ function VCTRL.press(x,y,id)
if obj then
touches[id]=obj
obj:press(x,y,id)
VCTRL.focus=obj
-- VCTRL.focus=obj
return true
end
end
function VCTRL.release(id)
if not global_toggle then return end
if touches[id] then
touches[id]:release()
return true
@@ -147,15 +150,23 @@ function VCTRL.release(id)
end
function VCTRL.drag(dx,dy,id)
if not global_toggle then return end
if touches[id] then
touches[id]:drag(dx,dy)
end
end
function VCTRL.draw(forceLight)
if not global_toggle then return end
for i=1,#VCTRL do
if VCTRL[i].show then
VCTRL[i]:draw(forceLight)
end
end
end
---@param toggle boolean|false
---Enabling virtual control or not
function VCTRL.toggle(toggle)
global_toggle=toggle
end