Workaround for DZEXP-266 (Vicinity attachment panels in the wrong order)
Here's a workaround until this gets fixed.
Why it happens:
Vanilla reads the GUIInventoryAttachmentsProps classes in config order, but it stores them in a map (TAttachmentGroupMap). A map does not keep the order you add things in. AttachmentCategoriesContainer.InitGhostSlots() then builds the icon row and the panels with groupMap.GetKey(i) so they come out in map order instead of config order. The slots inside each panel come from an array, which is why those stay in order.
The fix:
I override InitGhostSlots(). It walks the config classes in the order they are written and only uses the map to look up each one by name. Apart from the loop, it's the vanilla 1.30 code. If an item has no categories, it falls back to vanilla. Put it in any 5_Mission script folder:
modded class AttachmentCategoriesContainer
{
override void InitGhostSlots()
{
TypeAttachmentGroupsDataHolder holder = m_Entity.GetTypeAttachmentGroupInfoHolder()
if (!holder || !holder.GetAttachmentGroupMap())
{
super.InitGhostSlots()
return
}
TAttachmentGroupMap groupMap = holder.GetAttachmentGroupMap()
string propsPath = holder.GetPropsCfgPath()
int categoriesCount = holder.GetValidAttachmnetGroupCount()
int childrenCount = m_Body.Count()
int cfgCount = g_Game.ConfigGetChildrenCount(propsPath)
SlotsContainer items_cont
SlotsIcon icon
string attCategoryClass
TypeAttachmentGroupData groupData
int i = 0
for (int c = 0
{
g_Game.ConfigGetChildName(propsPath, c, attCategoryClass)
groupData = groupMap.Get(attCategoryClass)
if (!groupData)
continue
items_cont = GetSlotsContainer(i / ITEMS_IN_ROW)
if (items_cont)
{
int slot_number = i % ITEMS_IN_ROW
m_CategorySlotIndex.Insert(attCategoryClass, i)
icon = items_cont.GetSlotIcon(slot_number)
icon.GetGhostSlot().SetFlags(WidgetFlags.IGNOREPOINTER)
LoadAttachmentCategoriesIcon(items_cont, groupData.m_IconPath, slot_number)
icon.SetSlotDisplayName(groupData.m_Name)
AttachmentCategoriesRow ar = new AttachmentCategoriesRow(this, -1)
ar.Init(categoriesCount, i, attCategoryClass, propsPath, m_Entity, childrenCount)
ar.SetSlotIcon(icon)
icon.GetRadialIconPanel().Show(true)
ar.Open()
icon.SetContainer(ar)
Insert(ar)
}
i++
}
if (m_Entity.GetInventory().GetCargo())
{
items_cont = GetSlotsContainer(m_SlotsCount - 1)
if (items_cont)
{
icon = items_cont.GetSlotIcon(categoriesCount)
icon.GetGhostSlot().Show(true)
icon.GetGhostSlot().LoadImageFile(0, StaticGUIUtils.VerifyIconImageString(StaticGUIUtils.IMAGESETGROUP_INVENTORY, m_Entity.ConfigGetString("GUIInventoryCargoIcon")))
icon.SetSlotDisplayName(m_Entity.ConfigGetString("GUIInventoryCargoName"))
icon.GetGhostSlot().SetFlags(WidgetFlags.IGNOREPOINTER)
icon.GetRadialIconPanel().Show(true)
icon.GetMainWidget().Show(true)
ContainerWithCargo iwc = new ContainerWithCargo(this, -1)
iwc.Get(0).GetRootWidget().ClearFlags(WidgetFlags.DRAGGABLE)
iwc.SetEntity(m_Entity, 0, false)
iwc.SetSlotIcon(icon)
iwc.Open()
icon.SetContainer(iwc)
m_CargoSlotsIcon = icon
}
}
RecomputeOpenedContainers()
}
}
