I am trying to open UnitPromotionPopup using LuaEvents.UnitPanel_PromoteUnit(). Very simple event that ends up calling OnPromoteUnitPopup() in UPP.lua that prepares data and eventually calls UIManager:QueuePopup(ContextPtr, PopupPriority.Current) to open a window.
You can fire the event in FireTuner and it always goes into OnPromoteUnitPopup(). If the unit has an available promotion, it properly queues the popup. I've checked that using UIManager:IsInPopupQueue(ContextPtr).
Now the problem. The window only opens if the unit is already selected on the map. And I want to do the following:
xxx is ofc a unit id, but a different one. The selection works - another unit is selected (checked with UI.GetHeadSelectedUnit()), event is called, OnPromoteUnitPopup() properly detects selcted unitt (yes! it knows that a new unit is selcted), popup is queued (again, checked that) but the window doesn't open. What gives? What am I missing in this sequence?
You can fire the event in FireTuner and it always goes into OnPromoteUnitPopup(). If the unit has an available promotion, it properly queues the popup. I've checked that using UIManager:IsInPopupQueue(ContextPtr).
Now the problem. The window only opens if the unit is already selected on the map. And I want to do the following:
Code:
UI.SelectUnit(Players[0]:GetUnits():FindID(xxx))
LuaEvents.UnitPanel_PromoteUnit()