Skip to content

Commit dd43a39

Browse files
committed
Add proper visual progress bar support via helper widget
Create helper widget that searches for missile command buttons and updates their progress bars using SetProgressBar() method, matching factory unit behavior. Missile widget exports progress data via WG.missileProgress for the helper to consume. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GiaPfKSj8kGFjaUPyxYYHd
1 parent 5606e56 commit dd43a39

2 files changed

Lines changed: 74 additions & 6 deletions

File tree

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
function widget:GetInfo()
2+
return {
3+
name = "Missile Command Progress",
4+
desc = "Displays visual progress bars for missile building",
5+
author = "Amnykon",
6+
date = "2026",
7+
license = "GNU GPL, v2 or later",
8+
layer = 5,
9+
enabled = true,
10+
handler = true,
11+
}
12+
end
13+
14+
local missileCommands = {
15+
[39610] = true,
16+
[39611] = true,
17+
[39612] = true,
18+
[39613] = true,
19+
[39614] = true,
20+
[39615] = true,
21+
[39616] = true,
22+
}
23+
24+
local UPDATE_FREQUENCY = 0.25
25+
local timer = UPDATE_FREQUENCY + 1
26+
local buttonCache = {}
27+
28+
local function findButtonsByCommand()
29+
local screen = WG.Chili.Screen0
30+
if not screen then return end
31+
32+
local function searchChildren(control)
33+
if not control then return end
34+
35+
if control.cmdID and missileCommands[control.cmdID] then
36+
buttonCache[control.cmdID] = control
37+
end
38+
39+
if control.children then
40+
for _, child in ipairs(control.children) do
41+
searchChildren(child)
42+
end
43+
end
44+
end
45+
46+
if screen.children then
47+
for _, child in ipairs(screen.children) do
48+
searchChildren(child)
49+
end
50+
end
51+
end
52+
53+
function widget:Update(dt)
54+
timer = timer + dt
55+
if timer < UPDATE_FREQUENCY then
56+
return
57+
end
58+
timer = 0
59+
60+
findButtonsByCommand()
61+
62+
for cmdID in pairs(missileCommands) do
63+
local progress = WG.missileProgress and WG.missileProgress[cmdID] or 0
64+
local button = buttonCache[cmdID]
65+
66+
if button and button.SetProgressBar then
67+
button:SetProgressBar(progress)
68+
end
69+
end
70+
end

LuaUI/Widgets/missle_command_center.lua

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -537,13 +537,16 @@ function widget:Update(dt)
537537
end
538538
timer = 0
539539

540-
local integralMenu = widgetHandler:FindWidget("Chili Integral Menu")
540+
WG.missileProgress = WG.missileProgress or {}
541541

542542
for _, command in pairs(commands) do
543543
local count = command:getCount()
544544
local buildProgress = command:getMaxBuildProgress()
545545
local customCommands = widgetHandler.customCommands
546546

547+
-- Export progress for other widgets
548+
WG.missileProgress[command.cmd] = buildProgress
549+
547550
for i = 1, #customCommands do
548551
if customCommands[i].id == command.cmd then
549552
local displayName = ""
@@ -559,11 +562,6 @@ function widget:Update(dt)
559562
end
560563
end
561564
customCommands[i].name = displayName
562-
563-
-- Update visual progress bar on integral menu button if available
564-
if integralMenu and integralMenu.SetCmdButtonProgress and buildProgress > 0 then
565-
integralMenu:SetCmdButtonProgress(command.cmd, buildProgress)
566-
end
567565
break
568566
end
569567
end

0 commit comments

Comments
 (0)