8 protected ref array<WeaponSlotComponent> m_aWeaponSlots =
new array<WeaponSlotComponent>(); ;
9 protected EquipedWeaponStorageComponent m_weaponStorage;
13 override void HandlerAttached(Widget w)
15 m_weaponStorage = EquipedWeaponStorageComponent.Cast(
m_Storage);
17 super.HandlerAttached(w);
25 override void InitPaging()
29 override bool IsTraversalAllowed()
36 override protected int CreateSlots()
38 array<IEntity> pItemsInStorage = {};
39 array<Managed> weaponSlots = {};
45 pItemsInStorage.Resize(m_iMaxColumns);
46 m_aWeaponSlots.Resize(m_iMaxColumns);
50 foreach (Managed managed : weaponSlots)
56 weaponSlotIndex = weaponSlot.GetWeaponSlotIndex();
57 if (weaponSlotIndex < m_iMaxColumns)
59 pItemsInStorage.Set(weaponSlotIndex, weaponSlot.GetWeaponEntity());
60 m_aWeaponSlots.Set(weaponSlotIndex, weaponSlot);
64 UpdateOwnedSlots(pItemsInStorage);
71 override protected void UpdateOwnedSlots(notnull array<IEntity> pItemsInStorage)
73 int count = pItemsInStorage.Count();
76 for (
int i =
m_aSlots.Count() - count; i > 0; i--)
84 for (
int i = 0; i < count; i++)
89 m_aSlots[i].UpdateReferencedComponent(pComponent);
91 m_aSlots[i] = CreateSlotUI(pComponent, i,
null, i, m_aWeaponSlots[i].GetWeaponSlotType());
96 override void FillWithEmptySlots()
98 array<int> aCoordinates;
99 int iWidgetColumnSize, iWidgetRowSize;
100 int iPageCounter = 0;
101 int iRelativeOffset = 0;
114 pAttrib.SetSlotType(
ESlotID.SLOT_ANY );
115 pAttrib.SetSlotSize( eSlotSize );
119 Widget w = pSlot.GetWidget();
123 iWidgetColumnSize = pSlot.GetColumnSize();
124 iWidgetRowSize = pSlot.GetRowSize();
126 int iCol = pSlot.GetSlotIndex() + iRelativeOffset;
127 m_iMatrix.ReservePlace( iWidgetColumnSize, iWidgetRowSize, iCol, 0 );
128 GridSlot.SetColumn( w, iCol );
129 iRelativeOffset += ( iWidgetColumnSize - 1 );
130 GridSlot.SetRow( w, 0 );
132 GridSlot.SetColumnSpan( w, iWidgetColumnSize );
133 GridSlot.SetRowSpan( w, iWidgetRowSize );
147 override void SetRowsAndColumns()
153 int GetActualSlotsUsedCount()
158 for (
int id = 0;
id < slotCount; ++id)
162 result += slot.GetColumnSize();
170 override protected void SortSlots()
172 int iWidgetColumnSize, iWidgetRowSize;
173 int iPageCounter = 0;
174 int iRelativeOffset = 0;
184 Widget w = pSlot.GetWidget();
188 iWidgetColumnSize = pSlot.GetColumnSize();
189 iWidgetRowSize = pSlot.GetRowSize();
191 int iCol = pSlot.GetSlotIndex() + iRelativeOffset;
192 m_iMatrix.ReservePlace( iWidgetColumnSize, iWidgetRowSize, iCol, 0 );
193 GridSlot.SetColumn( w, iCol );
194 iRelativeOffset += ( iWidgetColumnSize - 1 );
195 GridSlot.SetRow( w, 0 );
196 pSlot.SetPage( iPageCounter );
198 GridSlot.SetColumnSpan( w, iWidgetColumnSize );
199 GridSlot.SetRowSpan( w, iWidgetRowSize );
202 m_iNrOfPages = iPageCounter + 1;
203 FillWithEmptySlots();
212 m_iMaxColumns = GetActualSlotsUsedCount();
213 m_iMatrix =
new SCR_Matrix(m_iMaxColumns, m_iMaxRows);
214 m_iPageSize = m_iMaxRows * m_iMaxColumns;
216 for (
int y = 0; y < m_iMaxRows; ++y)
218 m_wGrid.SetRowFillWeight(y, 1);
219 for (
int x = 0; x < m_iMaxColumns; ++x)
221 m_wGrid.SetColumnFillWeight(x, 1);
225 SizeLayoutWidget wSizeContainer = SizeLayoutWidget.Cast(m_widget.FindAnyWidget(
"SizeLayout0"));
227 wSizeContainer.SetAspectRatio(m_iMaxColumns / m_iMaxRows);
236 m_iMatrix =
new SCR_Matrix( m_iMaxColumns, m_iMaxRows );
237 m_sGridPath =
"WeaponsGrid";