Skip to content

Commit 608fac6

Browse files
committed
Merge progress bar logic into missile widget
Consolidate all missile command functionality into missle_command_center.lua. The widget now handles: command registration, count display, progress display (text and visual progress bars), and button updates. Removes unnecessary separation. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GiaPfKSj8kGFjaUPyxYYHd
1 parent dd43a39 commit 608fac6

2 files changed

Lines changed: 43 additions & 74 deletions

File tree

LuaUI/Widgets/gui_missile_progress.lua

Lines changed: 0 additions & 70 deletions
This file was deleted.

LuaUI/Widgets/missle_command_center.lua

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,42 @@ local commands = {
520520

521521
local UPDATE_FREQUENCY = 0.25
522522
local timer = UPDATE_FREQUENCY + 1
523+
local buttonCache = {}
524+
525+
local missileCommandIDs = {
526+
[39610] = true,
527+
[39611] = true,
528+
[39612] = true,
529+
[39613] = true,
530+
[39614] = true,
531+
[39615] = true,
532+
[39616] = true,
533+
}
534+
535+
local function findButtonsByCommand()
536+
local screen = WG.Chili.Screen0
537+
if not screen then return end
538+
539+
local function searchChildren(control)
540+
if not control then return end
541+
542+
if control.cmdID and missileCommandIDs[control.cmdID] then
543+
buttonCache[control.cmdID] = control
544+
end
545+
546+
if control.children then
547+
for _, child in ipairs(control.children) do
548+
searchChildren(child)
549+
end
550+
end
551+
end
552+
553+
if screen.children then
554+
for _, child in ipairs(screen.children) do
555+
searchChildren(child)
556+
end
557+
end
558+
end
523559

524560
--------------------------------------------------------------------------------
525561
--------------------------------------------------------------------------------
@@ -537,16 +573,13 @@ function widget:Update(dt)
537573
end
538574
timer = 0
539575

540-
WG.missileProgress = WG.missileProgress or {}
576+
findButtonsByCommand()
541577

542578
for _, command in pairs(commands) do
543579
local count = command:getCount()
544580
local buildProgress = command:getMaxBuildProgress()
545581
local customCommands = widgetHandler.customCommands
546582

547-
-- Export progress for other widgets
548-
WG.missileProgress[command.cmd] = buildProgress
549-
550583
for i = 1, #customCommands do
551584
if customCommands[i].id == command.cmd then
552585
local displayName = ""
@@ -562,6 +595,12 @@ function widget:Update(dt)
562595
end
563596
end
564597
customCommands[i].name = displayName
598+
599+
-- Update visual progress bar on button
600+
local button = buttonCache[command.cmd]
601+
if button and button.SetProgressBar then
602+
button:SetProgressBar(buildProgress)
603+
end
565604
break
566605
end
567606
end

0 commit comments

Comments
 (0)