Skip to content

Commit

Permalink
Fix: Mex building deselection in default buildmenu (#2654)
Browse files Browse the repository at this point in the history
  • Loading branch information
thehobojoe authored Feb 24, 2024
1 parent 85c3f99 commit 567d42c
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions luaui/Widgets/cmd_extractor_snap.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ function widget:GetInfo()
}
end

include("keysym.h.lua")

local spGetActiveCommand = Spring.GetActiveCommand
local spGetMouseState = Spring.GetMouseState
Expand Down Expand Up @@ -252,9 +253,15 @@ end


-- Since mex snap bypasses normal building behavior, we have to hand hold gridmenu a little bit
local endShift = false
local function handleBuildMenu(shift)
local grid = WG["gridmenu"]
if not grid or not grid.clearCategory or not grid.getAlwaysReturn or not grid.setCurrentCategory then
if not shift then
Spring.SetActiveCommand(0)
else
endShift = true
end
return
end

Expand Down Expand Up @@ -287,6 +294,14 @@ function widget:MousePress(x, y, button)
end


-- I really hate that I have to do this, but something is hardcoding shift behavior with mouse clicks, and I need to override it
function widget:KeyRelease(code)
if endShift and (code == KEYSYMS.LSHIFT or code == KEYSYMS.RSHIFT) then
Spring.SetActiveCommand(0)
end
end


function widget:DrawWorld()
if not WG.DrawUnitShapeGL4
or not targetPos
Expand Down

0 comments on commit 567d42c

Please sign in to comment.