Skip to content

Commit 6d7a261

Browse files
committed
Add missile count display to command buttons
Update widget:Update to periodically refresh the missile count for each command and display it on the button via the command name. Counts update every 0.25 seconds. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GiaPfKSj8kGFjaUPyxYYHd
1 parent dd3fe28 commit 6d7a261

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

LuaUI/Widgets/missle_command_center.lua

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,9 @@ local commands = {
500500
trinityMissile = trinity_missile_controller_class(),
501501
}
502502

503+
local UPDATE_FREQUENCY = 0.25
504+
local timer = UPDATE_FREQUENCY + 1
505+
503506
--------------------------------------------------------------------------------
504507
--------------------------------------------------------------------------------
505508

@@ -509,6 +512,30 @@ function widget:CommandsChanged()
509512
end
510513
end
511514

515+
function widget:Update(dt)
516+
timer = timer + dt
517+
if timer < UPDATE_FREQUENCY then
518+
return
519+
end
520+
timer = 0
521+
522+
for _, command in pairs(commands) do
523+
local count = command:getCount()
524+
local customCommands = widgetHandler.customCommands
525+
526+
for i = 1, #customCommands do
527+
if customCommands[i].id == command.cmd then
528+
if count > 0 then
529+
customCommands[i].name = "x" .. count
530+
else
531+
customCommands[i].name = ""
532+
end
533+
break
534+
end
535+
end
536+
end
537+
end
538+
512539
function widget:CommandNotify(cmdID, cmdParams, cmdOptions)
513540
for _, command in pairs(commands) do
514541
if command:commandNotify(cmdID, cmdParams, cmdOptions) then return true end

0 commit comments

Comments
 (0)