Skip to content

Commit

Permalink
perf(gridmenu): Refreshing needlessly on pregame (beyond-all-reason#3253
Browse files Browse the repository at this point in the history
)
  • Loading branch information
badosu authored Jun 26, 2024
1 parent 0352587 commit 15da5b0
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions luaui/Widgets/gui_gridmenu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -895,8 +895,6 @@ local function reloadBindings()
key = getActionHotkey("gridmenu_cycle_builder")

nextBuilderRect.opts.keyText = keyConfig.sanitizeKey(key, currentLayout) or nil

refreshCommands()
end

local function setLabBuildMode(value)
Expand Down Expand Up @@ -1216,7 +1214,9 @@ function widget:Initialize()

widget:ViewResize()

if not isPregame then
if isPregame then
refreshCommands()
else
widget:SelectionChanged(Spring.GetSelectedUnits())
end

Expand Down Expand Up @@ -1290,7 +1290,10 @@ function widget:Initialize()
WG["buildmenu"].getSize = function()
return backgroundRect.y, backgroundRect.yEnd
end
WG["buildmenu"].reloadBindings = reloadBindings
WG["buildmenu"].reloadBindings = function()
reloadBindings()
refreshCommands()
end
WG["buildmenu"].getIsShowing = function()
return buildmenuShows
end
Expand Down Expand Up @@ -1570,9 +1573,11 @@ function widget:Update(dt)

-- PERF: Maybe make this slow-ish-update?
if isPregame then
local previousStartDefID = startDefID
startDefID = Spring.GetTeamRulesParam(myTeamID, "startUnit")

doUpdate = true
-- Don't update unless defid has changed
doUpdate = previousStartDefID ~= startDefID
else
activeCmd = select(2, spGetActiveCommand())

Expand Down

0 comments on commit 15da5b0

Please sign in to comment.