Zero-K
Zero-K copied to clipboard
Extract cycling comm selector into a WG API
This is hardcoded to use commanders: https://github.com/ZeroK-RTS/Zero-K/blob/f6a2f0d33568f780a6953aa362a802cda25769ea/LuaUI/Widgets/gui_chili_core_selector.lua#L370
- add some sort of WG API that lets widgets receive a closure which works like the existing comm selector but for an arbitrary unitID list passed to the API (that the widget would then have to populate). So you'd do
local loaded_nukes = {}
function widget:GameFrame()
-- populate `loaded_nukes`
-- for unitID in ... if Spring.GetUnitStockpile(unitID) ...
end
function widget:Initialize()
local SelectLoadedNuke = WG.GetSelectorForUnitSet(loaded_nukes)
widgetHandler:AddAction("select_loaded_nuke", SelectLoadedNuke, nil, 'p')
-- and then, say, `/bind Ctrl+☢️ select_loaded_nuke` or bind action to a chili button etc
end
- add a wrapper for the bullet point above where you pass a list of unitDefIDs and the API returns a closure that automagically handles it from there.
function widget:Initialize()
local SelectStrider = WG.GetSelectorForUnitDefs({UnitDefNames.dante.id, UnitDefNames.det.id, ...})
widgetHandler:AddAction("select_strider", SelectStrider, nil, 'p')
-- `/bind ctrl+ф select_strider`
end