5 protected int m_ActiveIndex = 0;
6 protected bool m_LastIndex;
7 protected bool m_Closed;
9 protected float m_PrevAlpha;
13 protected int m_ColumnCount;
15 protected int m_FocusedColumn = 0;
16 protected bool m_ForcedHide;
17 protected bool m_ForcedShow;
22 const int SORT_ATTACHMENTS_OWN = 1;
23 const int SORT_CARGO_OWN = 2;
24 const int SORT_ATTACHMENTS_NEXT_OFFSET = 2;
25 const int SORT_CARGO_NEXT_OFFSET = 3;
27 void OnDropReceivedFromHeader(
Widget w,
int x,
int y,
Widget receiver );
29 void DraggingOverHeader(
Widget w,
int x,
int y,
Widget receiver );
32 void SetHeader(
Header header);
33 void CheckHeaderDragability();
50 if (m_ActiveIndex < m_OpenedContainers.Count())
52 return Container.Cast(m_OpenedContainers[m_ActiveIndex]);
59 if (index < m_Body.Count())
67 void SetFocusedContainer(
Container cont )
69 m_FocusedContainer = cont;
77 return c.GetFocusedSlotsIcon();
87 void SetActiveIndex(
int index )
89 m_ActiveIndex = index;
92 ScrollWidget GetScrollWidget()
97 void UpdateRadialIcon()
101 m_SlotIcon.GetRadialIconPanel().Show(
false );
110 void SetDefaultFocus(
bool while_micromanagment_mode =
false)
119 if ( m_OpenedContainers.Count() > 0 )
121 m_ActiveIndex = m_OpenedContainers.Count() - 1;
129 void MoveGridCursor(
int direction)
141 SetNextRightActive();
148 UpdateSelectionIcons();
150 Inventory.GetInstance().UpdateConsoleToolbar();
153 void ScrollToActiveContainer()
155 ScrollWidget sw = GetScrollWidget();
160 sw.GetScreenPos(
x,
y );
161 sw.GetScreenSize(
x, y_s );
164 f_y = GetFocusedContainerYScreenPos(
true );
165 f_h = GetFocusedContainerHeight(
true );
167 float next_pos = f_y + f_h;
169 if (next_pos > (
y + y_s ))
171 amount = sw.GetVScrollPos() + next_pos - (
y + y_s ) + 2;
172 sw.VScrollToPos( amount );
176 amount = sw.GetVScrollPos() + f_y -
y - 2;
177 sw.VScrollToPos(amount);
184 void CheckScrollbarVisibility()
186 ScrollWidget sw = GetScrollWidget();
189 if (!sw.IsScrollbarVisible())
191 sw.VScrollToPos01(0.0);
193 else if (sw.GetVScrollPos01() > 1.0)
195 sw.VScrollToPos01(1.0);
203 UpdateSelectionIcons();
209 UpdateSelectionIcons();
217 void SetOpenForSlotIcon(
bool open,
SlotsIcon icon =
null)
226 icon.GetRadialIcon().Show(open);
227 icon.GetRadialIconClosed().Show(!open);
248 float GetFocusedContainerHeight(
bool contents =
false )
251 if( GetFocusedContainer() )
252 y = GetFocusedContainer().GetFocusedContainerHeight( contents );
253 else if( GetRootWidget() )
254 GetRootWidget().GetScreenSize(
x,
y );
258 if ( m_ActiveIndex == 0 )
269 float GetFocusedContainerYPos(
bool contents =
false )
272 if( GetFocusedContainer() )
273 y = GetFocusedContainer().GetFocusedContainerYPos( contents );
274 else if( GetRootWidget() )
275 GetRootWidget().GetPos(
x,
y );
280 float GetFocusedContainerYScreenPos(
bool contents =
false )
283 if( GetFocusedContainer() )
284 y = GetFocusedContainer().GetFocusedContainerYScreenPos( contents );
285 else if( GetRootWidget() )
286 GetRootWidget().GetScreenPos(
x,
y );
291 if ( m_ActiveIndex == 0 )
304 return m_Body.Count();
309 if( GetFocusedContainer() )
310 return GetFocusedContainer().SelectItem();
316 if( GetFocusedContainer() )
317 return GetFocusedContainer().Select();
321 bool OnSelectButton()
323 if(GetFocusedContainer())
325 return GetFocusedContainer().OnSelectButton();
332 if( GetFocusedContainer() )
333 return GetFocusedContainer().Combine();
337 bool TransferItemToVicinity()
339 if( GetFocusedContainer() )
340 return GetFocusedContainer().TransferItemToVicinity();
346 if( GetFocusedContainer() )
347 return GetFocusedContainer().TransferItem();
353 if( GetFocusedContainer() )
354 return GetFocusedContainer().InspectItem();
360 if( GetFocusedContainer() )
361 return GetFocusedContainer().SplitItem();
367 if( GetFocusedContainer() )
368 return GetFocusedContainer().EquipItem();
372 bool CanOpenCloseContainer()
374 if (
ItemManager.GetInstance().IsMicromanagmentMode() )
377 EntityAI focusedEntity = GetFocusedItem();
380 if (GetFocusedContainer())
381 return GetFocusedContainer().CanOpenCloseContainerEx(focusedEntity);
383 return CanOpenCloseContainerEx(focusedEntity);
389 bool CanOpenCloseContainerEx(
EntityAI focusedEntity)
396 EntityAI focusedEntity = GetFocusedItem();
399 if (GetFocusedContainer())
400 return GetFocusedContainer().CanSplitEx(focusedEntity);
402 return CanSplitEx(focusedEntity);
408 bool CanSplitEx(
EntityAI focusedEntity)
410 if (
ItemManager.GetInstance().IsMicromanagmentMode() )
415 return focusedEntity.CanBeSplit();
422 EntityAI focusedEntity = GetFocusedItem();
425 if (GetFocusedContainer())
426 return GetFocusedContainer().CanDropEx(focusedEntity);
428 return CanDropEx(focusedEntity);
435 bool CanDropEx(
EntityAI focusedEntity)
437 if (
ItemManager.GetInstance().IsMicromanagmentMode() )
446 return player.CanDropEntity(focusedEntity);
452 bool CanSwapOrTakeToHands()
454 EntityAI focusedEntity = GetFocusedItem();
457 if (GetFocusedContainer())
458 return GetFocusedContainer().CanSwapOrTakeToHandsEx(focusedEntity);
460 return CanSwapOrTakeToHandsEx(focusedEntity);
466 bool CanSwapOrTakeToHandsEx(
EntityAI focusedEntity)
468 if (
ItemManager.GetInstance().IsMicromanagmentMode() )
474 EntityAI entityInHands = player.GetItemInHands();
479 if (!
GameInventory.CanSwapEntitiesEx(focusedEntity, entityInHands))
481 return GameInventory.CanForceSwapEntitiesEx( focusedEntity,
null, entityInHands, il );
490 return player.GetInventory().CanAddEntityIntoHands(focusedEntity);
498 EntityAI focusedEntity = GetFocusedItem();
501 if (GetFocusedContainer())
502 return GetFocusedContainer().CanEquipEx(focusedEntity);
504 return CanEquipEx(focusedEntity);
510 bool CanEquipEx(
EntityAI focusedEntity)
512 if (
ItemManager.GetInstance().IsMicromanagmentMode() )
524 for (
int i = 0; i < focusedEntity.GetInventory().GetSlotIdCount(); i++)
526 int slot_id = focusedEntity.GetInventory().GetSlotId(i);
527 EntityAI slot_item = player.GetInventory().FindAttachment( slot_id );
528 if (slot_item && player.GetInventory().CanSwapEntitiesEx( focusedEntity, slot_item ))
540 bool CanTakeToInventory()
542 EntityAI focusedEntity = GetFocusedItem();
545 if (GetFocusedContainer())
546 return GetFocusedContainer().CanTakeToInventoryEx(focusedEntity);
548 return CanTakeToInventoryEx(focusedEntity);
554 bool CanTakeToInventoryEx(
EntityAI focusedEntity)
556 if (
ItemManager.GetInstance().IsMicromanagmentMode() )
569 EntityAI focusedEntity = GetFocusedItem();
572 if (GetFocusedContainer())
573 return GetFocusedContainer().CanCombineEx(focusedEntity);
575 return CanCombineEx(focusedEntity);
581 bool CanCombineEx(
EntityAI focusedEntity)
583 if (
ItemManager.GetInstance().IsMicromanagmentMode())
589 if (focusedEntity != entityInHands)
591 return (
ItemManager.GetCombinationFlags(entityInHands, focusedEntity) != 0);
597 bool CanCombineAmmo()
599 if( GetFocusedContainer() )
600 return GetFocusedContainer().CanCombineAmmo();
604 bool CanAddToQuickbarEx(
EntityAI focusedEntity)
606 if (
ItemManager.GetInstance().IsMicromanagmentMode() )
612 if (focusedEntity.GetHierarchyRootPlayer() == player)
621 bool AddItemToQuickbarRadial(
EntityAI itemToAssign)
623 if ( CanAddToQuickbarEx(itemToAssign) )
627 dpi = player.GetDayZPlayerInventory();
629 if (itemToAssign && dpi && !dpi.IsProcessing())
631 RadialQuickbarMenu.SetItemToAssign(itemToAssign);
646 return m_OpenedContainers.Count() == 0;
651 if( GetFocusedContainer() )
652 return GetFocusedContainer().IsItemActive();
656 bool IsItemWithQuantityActive()
658 if( GetFocusedContainer() )
659 return GetFocusedContainer().IsItemWithQuantityActive();
666 if( GetFocusedContainer() )
667 item = GetFocusedContainer().GetFocusedItem();
672 EntityAI GetFocusedContainerEntity()
675 if( GetFocusedContainer() )
676 item = GetFocusedContainer().GetFocusedContainerEntity();
682 return m_ColumnCount;
685 void SetColumnCount(
int count )
687 m_ColumnCount = count;
690 int GetFocusedColumn()
692 return m_FocusedColumn;
695 void SetFocusedColumn(
int column )
697 m_FocusedColumn = column;
700 override void UpdateInterval()
702 for (
int i = 0; i < m_Body.Count(); i++ )
704 if ( m_Body.Get( i ) )
705 m_Body.Get( i ).UpdateInterval();
708 CheckHeaderDragability();
711 override void SetLastActive()
716 if (m_OpenedContainers.Count())
719 if (!m_OpenedContainers[m_ActiveIndex].
IsActive())
721 for (
int i = 0; i < m_OpenedContainers.Count() - 1; i++)
723 if (m_OpenedContainers[i].
IsActive())
725 m_OpenedContainers[i].SetActive(
false);
728 m_OpenedContainers[m_ActiveIndex].SetLastActive();
732 m_OpenedContainers[m_ActiveIndex].SetLastActive();
744 if (m_OpenedContainers.Count())
755 override void SetFirstActive()
763 if (m_OpenedContainers.Count())
766 if (!m_OpenedContainers[m_ActiveIndex].
IsActive())
768 for (
int i = 1; i < m_OpenedContainers.Count(); i++)
770 if (m_OpenedContainers[i].
IsActive())
772 m_OpenedContainers[i].SetActive(
false);
775 m_OpenedContainers[m_ActiveIndex].SetActive(
true);
779 m_OpenedContainers[m_ActiveIndex].SetFirstActive();
785 override void SetActive(
bool active)
795 super.SetActive( active );
801 if (m_MainWidget.FindAnyWidget(
"SelectedContainer"))
803 m_MainWidget.FindAnyWidget(
"SelectedContainer").Show(active);
811 if( m_OpenedContainers.Count() )
813 c =
Container.Cast(m_OpenedContainers.Get( m_ActiveIndex ));
822 c = GetFocusedContainer();
825 GetFocusedContainer().SetActive(
false);
835 for (
int i = 0; i <
Count(); i++ )
840 if (Get(i) && Get(i).GetMainWidget())
841 Get( i ).GetMainWidget().GetUserData(icon);
844 icon.GetCursorWidget().Show(
false );
851 if( GetFocusedContainer() )
854 GetFocusedContainer().UnfocusAll();
860 return m_ActiveIndex == ( m_OpenedContainers.Count() - 1 );
865 return m_ActiveIndex == 0;
868 bool IsFirstContainerFocused()
870 return m_ActiveIndex == 0;
873 bool IsLastContainerFocused()
875 return m_ActiveIndex >= ( m_OpenedContainers.Count() - 1 );
878 void ResetFocusedContainer()
880 if ( GetFocusedContainer() )
882 GetFocusedContainer().ResetFocusedContainer();
893 if (m_OpenedContainers.Count())
895 active =
Container.Cast(m_OpenedContainers[m_ActiveIndex]);
898 if (active && active.IsActive())
900 active.SetNextActive();
902 if (!active || !active.IsActive())
905 if (!IsLastContainerFocused())
909 next =
Container.Cast(m_OpenedContainers[m_ActiveIndex]);
910 next.SetActive(
true);
924 void SetPreviousActive(
bool force =
false)
928 if (m_OpenedContainers.Count())
930 active =
Container.Cast(m_OpenedContainers[m_ActiveIndex]);
933 if (active && active.IsActive())
935 active.SetPreviousActive();
938 if (!active || !active.IsActive())
941 if (!IsFirstContainerFocused())
945 prev =
Container.Cast(m_OpenedContainers[m_ActiveIndex]);
946 prev.SetLastActive();
960 void SetNextRightActive()
963 if (m_OpenedContainers.Count())
965 active =
Container.Cast(m_OpenedContainers[m_ActiveIndex]);
970 active.SetNextRightActive();
974 void SetNextLeftActive()
977 if (m_OpenedContainers.Count())
979 active =
Container.Cast(m_OpenedContainers[m_ActiveIndex]);
984 active.SetNextLeftActive();
988 void SetSameLevelNextActive()
991 active =
Container.Cast(m_OpenedContainers[m_ActiveIndex]);
992 active.SetActive(
false);
995 if (m_ActiveIndex > m_OpenedContainers.Count() - 1)
1000 active =
Container.Cast(m_OpenedContainers[m_ActiveIndex]);
1001 active.SetActive(
true);
1004 void SetSameLevelPreviousActive()
1007 active =
Container.Cast(m_OpenedContainers[m_ActiveIndex]);
1008 active.SetActive(
false);
1011 if (m_ActiveIndex < 0)
1013 m_ActiveIndex = m_OpenedContainers.Count() - 1;
1016 active =
Container.Cast(m_OpenedContainers[m_ActiveIndex]);
1017 active.SetActive(
true);
1020 void RecomputeOpenedContainers()
1022 m_OpenedContainers.Clear();
1024 bool need_reset_focus =
false;
1026 for (i = 0; i < m_Body.Count(); i++)
1031 c.RecomputeOpenedContainers();
1032 if (c.IsDisplayable() && c.IsVisible())
1034 m_OpenedContainers.Insert(c);
1036 else if (c.IsActive())
1039 need_reset_focus =
true;
1048 if (!need_reset_focus && ( m_ActiveIndex >= m_OpenedContainers.Count() || !m_OpenedContainers[m_ActiveIndex].IsActive() ))
1050 need_reset_focus =
true;
1051 for (i = 0; i < m_OpenedContainers.Count(); i++)
1053 if (m_OpenedContainers[i].
IsActive())
1055 need_reset_focus =
false;
1061 if (need_reset_focus)
1068 override void SetLayoutName()
1073 void Insert(
LayoutHolder container,
int pos = -1,
bool immedUpdate =
true )
1075 if ( pos > -1 && pos < m_Body.Count() )
1077 if ( pos <= m_ActiveIndex )
1079 m_Body.InsertAt( container, pos );
1082 m_Body.Insert( container );
1092 int index = m_Body.Find( container );
1095 index = m_OpenedContainers.Find( container );
1098 if (index <= m_ActiveIndex)
1100 if (GetFocusedContainer() == container)
1102 SetPreviousActive(
true );
1109 m_OpenedContainers.RemoveItem( container );
1111 m_Body.RemoveItem( container );
1120 return m_Body.Get(
x );
1123 override void Refresh()
1125 for (
int i = 0; i < m_Body.Count(); i++ )
1127 if( m_Body.Get( i ) )
1128 m_Body.Get( i ).Refresh();
1132 void UpdateBodySpacers()
1134 for (
int i = 0; i < m_Body.Count(); i++ )
1146 void HideContent(
bool force_hide =
false )
1150 m_ForcedHide = force_hide;
1152 for(
int i = 0; i < m_Body.Count(); i++)
1154 if( m_Body.Get( i ) )
1155 m_Body.Get( i ).OnHide();
1159 void ShowContent(
bool force_show =
false )
1162 m_ForcedHide =
false;
1166 for(
int i = 0; i < m_Body.Count(); i++)
1168 if( m_Body.Get( i ) )
1169 m_Body.Get( i ).OnShow();
1174 void SetForceShow(
bool value)
1176 m_ForcedShow = value;
1179 override void UpdateSelectionIcons()
1184 void ExpandCollapseContainer(){}