Skip to content

Commit 08f30dd

Browse files
authored
Better reactivity
On the demand of Godde
1 parent bba8934 commit 08f30dd

1 file changed

Lines changed: 16 additions & 6 deletions

File tree

LuaUI/Widgets/gui_chili_gesture_menu.lua

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ function widget:GetInfo()
1515
handler = true,
1616
}
1717
end
18-
18+
Spring.Echo('test')
1919
include("keysym.lua")
2020
VFS.Include("LuaRules/Configs/customcmds.h.lua")
2121
-------------------------------------------------
@@ -226,9 +226,8 @@ local function CanInitialQueue()
226226
end
227227

228228

229-
function widget:Update(t)
229+
function widget:MouseMove(mx, my)
230230
if not menu or KEYBOARD_ONLY or mouselessOpen then return end
231-
local mx, my = Spring.GetMouseState()
232231
ProcessMove(mx,my)
233232
if hold_pos then
234233
local dx = mx - hold_pos[1]
@@ -240,6 +239,17 @@ function widget:Update(t)
240239
end
241240
end
242241

242+
243+
function widget:Update(t)
244+
if not menu or KEYBOARD_ONLY or mouselessOpen then return end
245+
if hold_pos then
246+
if osclock() - menu_start > IDLE_THRESHOLD then
247+
menu_invisible = false
248+
hold_pos = nil
249+
end
250+
end
251+
end
252+
243253
local lx = 0
244254
local ly = 0
245255

@@ -391,10 +401,10 @@ function EndMenu(ok)
391401
level = level + 1 -- save level
392402
levels[level] = {menu_selected, menu_selected.angle+180}
393403
end
394-
if osclock() - menu_start > level * 0.25 then -- if speed was slower than 250ms per level, flash the gesture
404+
if osclock() - menu_start > level * 0.25 then -- if speed was slower than 250ms per level, flash the gesture
395405
menu_flash = {origin[1], origin[2], osclock()}
396406
end
397-
Spring.SetActiveCommand(cmdid, 1, left, right, alt, ctrl, meta, shift) -- FIXME set only when you close menu
407+
Spring.SetActiveCommand(cmdid, 1, left, right, alt, ctrl, meta, shift) -- FIXME set only when you close menu
398408
end
399409
end
400410
origin = nil
@@ -619,7 +629,7 @@ local function DrawMenuItem(item, x,y, size, alpha, displayLabel, angle, cmdDesc
619629
if displayLabel == nil then displayLabel = true end
620630
if item then
621631
local ud = UnitDefNames[item.unit]
622-
if (ud) then
632+
if (ud) then
623633
if (displayLabel and item.label) then
624634
glColor(1,1,1,alpha)
625635
local wid = glGetTextWidth(item.label)*12

0 commit comments

Comments
 (0)