9 protected static int s_iLastSelectedSlotIndex;
10 protected static int s_iInitSelectedSlotIndex;
11 protected static bool s_bQuickBarClosed;
13 protected ResourceName m_sGamepadIcons =
"{F7FD1672FECA05E8}UI/Textures/Icons/icons_gamepad_64.imageset";
19 override void InitPaging() {
return; }
23 protected void HighlightSlot(
int iSlotIndex,
bool bHighlight )
25 if (
m_aSlots.IsEmpty() || iSlotIndex == -1 )
28 if (m_pLastSelectedSlot)
29 m_pLastSelectedSlot.SetSelected(
false);
31 m_pLastSelectedSlot = m_pSelectedSlot;
32 if ( iSlotIndex >
m_aSlots.Count() - 1 )
34 m_pSelectedSlot =
m_aSlots.Get( iSlotIndex );
35 if ( !m_pSelectedSlot )
38 m_pSelectedSlot.SetSelectedQuickSlot( bHighlight );
39 CheckIfQuickSlotActionsAvailable(
m_Player);
44 void SelectSlot(
float fWheelValue )
46 if ( fWheelValue == 0 )
52 if ( fWheelValue == 1 )
55 if ( s_iLastSelectedSlotIndex < 0 )
58 s_iLastSelectedSlotIndex =
m_aSlots.Count() - 1;
60 s_iLastSelectedSlotIndex = 0;
65 if (m_pInputManager.IsUsingMouseAndKeyboard() && s_iLastSelectedSlotIndex < 0)
66 s_iLastSelectedSlotIndex =
m_aSlots.Count()-1;
68 HighlightSlot( s_iLastSelectedSlotIndex,
false );
71 if (m_pInputManager.IsUsingMouseAndKeyboard())
72 s_iLastSelectedSlotIndex = Math.Max( ( s_iLastSelectedSlotIndex - 1 ), 0 );
74 s_iLastSelectedSlotIndex = ( s_iLastSelectedSlotIndex - 1 ) % (
m_aSlots.Count() );
78 if (m_pInputManager.IsUsingMouseAndKeyboard())
79 s_iLastSelectedSlotIndex = Math.Min( ( s_iLastSelectedSlotIndex + 1 ),
m_aSlots.Count()-1 );
81 s_iLastSelectedSlotIndex = ( s_iLastSelectedSlotIndex + 1 ) % (
m_aSlots.Count() );
90 HighlightSlot( s_iLastSelectedSlotIndex,
true );
96 void SelectSlot(
int iSlotIndex )
98 HighlightSlot( iSlotIndex,
true );
99 s_iLastSelectedSlotIndex = iSlotIndex;
104 void FilterOutSlots()
108 if ( pSlot && pSlot != m_pSelectedSlot )
109 pSlot.SetSlotVisible(
false );
115 override protected void UpdateOwnedSlots(notnull array<IEntity> pItemsInStorage)
117 int count = pItemsInStorage.Count();
119 count = Math.Min(count, 4);
123 for (
int i =
m_aSlots.Count() - count; i > 0; i--)
133 for (
int i = 0; i < count; i++)
137 m_aSlots[i].UpdateReferencedComponent(pComponent);
139 m_aSlots[i] = CreateSlotUI(pComponent, i);
141 CheckIfQuickSlotActionsAvailable(
m_Player);
146 override protected void GetAllItems( out notnull array<IEntity> pItemsInStorage, BaseInventoryStorageComponent pStorage =
null )
151 if ( m_InventoryStorage && m_InventoryStorage.GetQuickSlotItems() )
152 pItemsInStorage.Copy( m_InventoryStorage.GetQuickSlotItems() );
157 override protected int CreateSlots()
159 array<IEntity> itemsInStorage = {};
160 GetAllItems(itemsInStorage);
161 UpdateOwnedSlots(itemsInStorage);
162 CheckIfQuickSlotActionsAvailable(
m_Player);
168 override protected void SortSlots()
170 array<int> aCoordinates;
171 int iWidgetColumnSize, iWidgetRowSize;
172 int iPageCounter = 0;
173 int iRelativeOffset = 0;
182 Widget w = pSlot.GetWidget();
186 iWidgetColumnSize = pSlot.GetColumnSize();
187 iWidgetRowSize = pSlot.GetRowSize();
189 int iCol = pSlot.GetSlotIndex() + iRelativeOffset;
190 m_iMatrix.ReservePlace( iWidgetColumnSize, iWidgetRowSize, iCol, 0 );
191 GridSlot.SetColumn( w, iCol );
192 iRelativeOffset += ( iWidgetColumnSize - 1 );
193 GridSlot.SetRow( w, 0 );
194 pSlot.SetPage( iPageCounter );
196 GridSlot.SetColumnSpan( w, iWidgetColumnSize );
197 GridSlot.SetRowSpan( w, iWidgetRowSize );
199 m_iNrOfPages = iPageCounter + 1;
200 FillWithEmptySlots();
201 CheckIfQuickSlotActionsAvailable(
m_Player);
205 protected void CheckIfQuickSlotActionsAvailable(IEntity player)
212 Widget w = pSlot.GetWidget();
216 if (!pSlot.GetInventoryItemComponent())
227 override void FillWithEmptySlots()
229 array<int> aCoordinates;
230 int iWidgetColumnSize, iWidgetRowSize;
231 int iPageCounter = 0;
232 int iRelativeOffset = 0;
246 pAttrib.SetSlotType(
ESlotID.SLOT_ANY );
247 pAttrib.SetSlotSize( eSlotSize );
251 Widget w = pSlot.GetWidget();
255 iWidgetColumnSize = pSlot.GetColumnSize();
256 iWidgetRowSize = pSlot.GetRowSize();
258 int iCol = i + iRelativeOffset;
259 m_iMatrix.ReservePlace( iWidgetColumnSize, iWidgetRowSize, iCol, 0 );
260 GridSlot.SetColumn( w, iCol );
261 GridSlot.SetRow( w, 0 );
265 pSlot.SetSlotVisible(
false);
270 iRelativeOffset += iWidgetColumnSize - 1;
274 GridSlot.SetColumnSpan( w, iWidgetColumnSize );
275 GridSlot.SetRowSpan( w, iWidgetRowSize );
282 m_aSlots.InsertAt( CreateSlotUI( pInventoryComponent ), iSlotIndex );
293 override void SetRowsAndColumns()
301 if (!m_pSelectedSlot)
306 if (s_bQuickBarClosed)
308 useItem = (s_iInitSelectedSlotIndex != s_iLastSelectedSlotIndex);
309 s_bQuickBarClosed =
false;
326 void SetInitialQuickSlot()
328 IEntity currentItem = m_InventoryStorage.GetSelectedItem();
330 s_iInitSelectedSlotIndex = -1;
332 array<IEntity> items = m_InventoryStorage.GetQuickSlotItems();
333 foreach (
int i, IEntity item : items)
335 if (item != currentItem)
338 s_iInitSelectedSlotIndex = i;
339 SelectSlot(s_iInitSelectedSlotIndex);
345 void SetQuickBarClosed()
347 s_bQuickBarClosed =
true;
365 void RefreshQuickSlots()
373 override void RefreshSlot(
int index)
378 IEntity item = m_InventoryStorage.GetItemFromQuickSlot(
index);
387 m_aSlots[
index].UpdateReferencedComponent(itemComp, attributes);
392 int GetActualSlotsUsedCount()
397 for (
int id = 0;
id < slotCount; ++id)
405 result += slot.GetColumnSize();
429 m_iMaxColumns = GetActualSlotsUsedCount();
430 m_iMatrix =
new SCR_Matrix(m_iMaxColumns, m_iMaxRows);
431 m_iPageSize = m_iMaxRows * m_iMaxColumns;
433 for (
int y = 0; y < m_iMaxRows; ++y)
435 m_wGrid.SetRowFillWeight(y, 1);
436 for (
int x = 0; x < m_iMaxColumns; ++x)
438 m_wGrid.SetColumnFillWeight(x, 1);
442 SizeLayoutWidget wSizeContainer = SizeLayoutWidget.Cast(m_widget.FindAnyWidget(
"SizeLayout0"));
444 wSizeContainer.SetAspectRatio(m_iMaxColumns / m_iMaxRows);
448 ResourceName GetGamepadIcons()
450 return m_sGamepadIcons;
456 if (!slot.GetInventoryItemComponent())
459 return slot.GetInventoryItemComponent();
463 void HighlightLastSelectedSlot()
465 SelectSlot(s_iLastSelectedSlotIndex);
471 override void HandlerAttached( Widget w )
473 super.HandlerAttached( w );
482 m_eSlotAreaType =
null;
485 m_iLastShownPage = iPage;