Skip to content

Commit

Permalink
Make actions on build and orders menu take place upon mousedown inste…
Browse files Browse the repository at this point in the history
…ad of mouseup
  • Loading branch information
ForbodingAngel committed Nov 28, 2020
1 parent c124974 commit d8e8618
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 3 deletions.
35 changes: 35 additions & 0 deletions LuaUI/Widgets_Evo/api_chili.lua
Expand Up @@ -73,6 +73,41 @@ end
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------

local pressed = {}

function widget:MousePress(mx, my, mButton)
if pressed[mButton] then --engine bug?(mouserelease is not called when another mouse button is pressed before releasing)
--this is also fixed in Update()
widget:MouseRelease(mx, my, mButton)
end

pressed[mButton] = true

return true
end

function widget:MouseRelease(mx, my, mButton)
if not pressed[mButton] then return false end

pressed[mButton] = false
return true
end

function widget:Update()
local mx, my, lmb, mmb, rmb = Spring.GetMouseState()--engine BUG FIX --should work fine even after engine/wh bug is fixed
if pressed[1] and not lmb then
widget:MouseRelease(mx, my, 1)
end
if pressed[2] and not mmb then
widget:MouseRelease(mx, my, 2)
end
if pressed[3] and not rmb then
widget:MouseRelease(mx, my, 3)
end
end



function widget:RecvLuaMsg(msg, playerID)
if msg:sub(1,18) == 'LobbyOverlayActive' then
chobbyInterface = (msg:sub(1,19) == 'LobbyOverlayActive1')
Expand Down
9 changes: 6 additions & 3 deletions LuaUI/Widgets_Evo/gui_chili_buildordermenu.lua
Expand Up @@ -470,7 +470,8 @@ local function addOrderCommand(cmd)
textPadding = 9, --8, (MaDDoX)
padding = {0, 0, 0, 0},
margin = {2, 2, 2, 2},
OnMouseUp = {ActionCommand},
OnClick = {function() end},
OnMouseDown = {ActionCommand}
}
if cmd.name == "Repair" then button:SetCaption("Build")
else button:SetCaption(cmd.name) end
Expand All @@ -489,7 +490,8 @@ local function addStateCommand(cmd)
textPadding = 12, --8,
padding = {0, 0, 0, 0},
margin = {2, 2, 2, 2},
OnMouseUp = {ActionCommand},
OnClick = {function() end},
OnMouseDown = {ActionCommand}
}
button:SetCaption(cmd.params[cmd.params[1] + 2])
chiliCache['button' .. cmd.id] = button
Expand All @@ -508,7 +510,8 @@ local function addBuildCommand(cmd)
file = '#' .. cmd.id * -1,
padding = {0, 0, 0, 0},
margin = {2, 2, 2, 2},
OnClick = {ActionCommand},
OnClick = {function() end},
OnMouseDown = {ActionCommand}
}
chiliCache['button' .. cmd.id] = image

Expand Down

0 comments on commit d8e8618

Please sign in to comment.