5 protected int m_ActiveIndex = 0;
15 protected int m_FocusedColumn = 0;
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;
50 if (m_ActiveIndex < m_OpenedContainers.Count())
51 return Container.Cast(m_OpenedContainers[m_ActiveIndex]);
57 if (
index < m_Body.Count())
65 m_FocusedContainer =
cont;
72 return c.GetFocusedSlotsIcon();
83 m_ActiveIndex =
index;
111 if (m_OpenedContainers.Count() > 0)
112 m_ActiveIndex = m_OpenedContainers.Count() - 1;
130 UpdateSelectionIcons();
132 Inventory.GetInstance().UpdateConsoleToolbar();
142 sw.GetScreenPos(
x,
y);
154 sw.VScrollToPos(amount);
158 amount =
sw.GetVScrollPos() +
f_y -
y - 2;
159 sw.VScrollToPos(amount);
171 if (!
sw.IsScrollbarVisible())
172 sw.VScrollToPos01(0.0);
173 else if (
sw.GetVScrollPos01() > 1.0)
174 sw.VScrollToPos01(1.0);
181 UpdateSelectionIcons();
187 UpdateSelectionIcons();
203 icon.GetRadialIconClosed().Show(!
open);
223 if (GetFocusedContainer())
225 else if (GetRootWidget())
226 GetRootWidget().GetScreenSize(
x,
y);
230 if (m_ActiveIndex == 0)
244 if (GetFocusedContainer())
246 else if (GetRootWidget())
247 GetRootWidget().GetPos(
x,
y);
255 if (GetFocusedContainer())
257 else if (GetRootWidget())
258 GetRootWidget().GetScreenPos(
x,
y);
263 if (m_ActiveIndex == 0)
276 return m_Body.Count();
281 if (GetFocusedContainer())
282 return GetFocusedContainer().SelectItem();
288 if (GetFocusedContainer())
289 return GetFocusedContainer().Select();
295 if (GetFocusedContainer())
296 return GetFocusedContainer().OnSelectButton();
302 if (GetFocusedContainer())
303 return GetFocusedContainer().Combine();
309 if (GetFocusedContainer())
310 return GetFocusedContainer().TransferItemToVicinity();
316 if (GetFocusedContainer())
317 return GetFocusedContainer().TransferItem();
323 if (GetFocusedContainer())
324 return GetFocusedContainer().InspectItem();
330 if (GetFocusedContainer())
331 return GetFocusedContainer().SplitItem();
337 if (GetFocusedContainer())
338 return GetFocusedContainer().EquipItem();
350 if (GetFocusedContainer())
351 return GetFocusedContainer().CanOpenCloseContainerEx(
focusedEntity);
369 if (GetFocusedContainer())
393 if (GetFocusedContainer())
423 if (GetFocusedContainer())
424 return GetFocusedContainer().CanSwapOrTakeToHandsEx(
focusedEntity);
461 if (GetFocusedContainer())
505 if (GetFocusedContainer())
506 return GetFocusedContainer().CanTakeToInventoryEx(
focusedEntity);
532 if (GetFocusedContainer())
557 if (GetFocusedContainer())
558 return GetFocusedContainer().CanCombineAmmo();
600 return m_OpenedContainers.Count() == 0;
605 if (GetFocusedContainer())
606 return GetFocusedContainer().IsItemActive();
612 if (GetFocusedContainer())
613 return GetFocusedContainer().IsItemWithQuantityActive();
620 if (GetFocusedContainer())
621 item = GetFocusedContainer().GetFocusedItem();
629 if (GetFocusedContainer())
630 item = GetFocusedContainer().GetFocusedContainerEntity();
636 return m_ColumnCount;
641 m_ColumnCount =
count;
646 return m_FocusedColumn;
656 for (
int i = 0;
i < m_Body.Count();
i++)
659 m_Body.Get(
i).UpdateInterval();
670 if (m_OpenedContainers.Count())
673 if (!m_OpenedContainers[m_ActiveIndex].
IsActive())
675 for (
int i = 0;
i < m_OpenedContainers.Count() - 1;
i++)
678 m_OpenedContainers[
i].SetActive(
false);
680 m_OpenedContainers[m_ActiveIndex].SetLastActive();
683 m_OpenedContainers[m_ActiveIndex].SetLastActive();
692 if (m_OpenedContainers.Count())
707 if (m_OpenedContainers.Count())
710 if (!m_OpenedContainers[m_ActiveIndex].
IsActive())
712 for (
int i = 1;
i < m_OpenedContainers.Count();
i++)
715 m_OpenedContainers[
i].SetActive(
false);
717 m_OpenedContainers[m_ActiveIndex].SetActive(
true);
720 m_OpenedContainers[m_ActiveIndex].SetFirstActive();
737 if (m_MainWidget.FindAnyWidget(
"SelectedContainer"))
738 m_MainWidget.FindAnyWidget(
"SelectedContainer").Show(
active);
745 if (m_OpenedContainers.Count())
747 c =
Container.Cast(m_OpenedContainers.Get(m_ActiveIndex));
754 c = GetFocusedContainer();
756 GetFocusedContainer().SetActive(
false);
770 if (
Get(
i) &&
Get(
i).GetMainWidget())
771 Get(
i).GetMainWidget().GetUserData(
icon);
774 icon.GetCursorWidget().Show(
false);
781 if (GetFocusedContainer())
784 GetFocusedContainer().UnfocusAll();
790 return m_ActiveIndex == (m_OpenedContainers.Count() - 1);
795 return m_ActiveIndex == 0;
800 return m_ActiveIndex == 0;
805 return m_ActiveIndex >= (m_OpenedContainers.Count() - 1);
810 if (GetFocusedContainer())
811 GetFocusedContainer().ResetFocusedContainer();
821 if (m_OpenedContainers.Count())
829 if (!IsLastContainerFocused())
834 next.SetActive(
true);
850 if (m_OpenedContainers.Count())
854 active.SetPreviousActive();
859 if (!IsFirstContainerFocused())
864 prev.SetLastActive();
879 if (m_OpenedContainers.Count())
883 active.SetNextRightActive();
889 if (m_OpenedContainers.Count())
893 active.SetNextLeftActive();
903 if (m_ActiveIndex > m_OpenedContainers.Count() - 1)
917 if (m_ActiveIndex < 0)
918 m_ActiveIndex = m_OpenedContainers.Count() - 1;
926 m_OpenedContainers.Clear();
930 for (
i = 0;
i < m_Body.Count();
i++)
935 c.RecomputeOpenedContainers();
936 if (
c.IsDisplayable() &&
c.IsVisible())
937 m_OpenedContainers.Insert(
c);
938 else if (
c.IsActive())
950 if (!
need_reset_focus && (m_ActiveIndex >= m_OpenedContainers.Count() || !m_OpenedContainers[m_ActiveIndex].IsActive()))
953 for (
i = 0;
i < m_OpenedContainers.Count();
i++)
975 if (pos > -1 && pos < m_Body.Count())
977 if (pos <= m_ActiveIndex)
998 if (
index <= m_ActiveIndex)
1005 m_OpenedContainers.RemoveItem(
container);
1016 return m_Body.Get(
x);
1021 for (
int i = 0;
i < m_Body.Count();
i++)
1024 m_Body.Get(
i).Refresh();
1030 for (
int i = 0;
i < m_Body.Count();
i++)
1044 for (
int i = 0;
i < m_Body.Count();
i++)
1047 m_Body.Get(
i).OnHide();
1054 m_ForcedHide =
false;
1058 for (
int i = 0;
i < m_Body.Count();
i++)
1061 m_Body.Get(
i).OnShow();
1068 m_ForcedShow =
value;
void Inventory(LayoutHolder parent)
FindInventoryLocationType
flags for searching locations in inventory
array< ref PlayerStatBase > Get()
ref Widget m_RootWidget[MAX_SIMULTANIOUS_PLAYERS]
override void CheckHeaderDragability()
override void SetLastFocus()
override void SetNextActive()
override EntityAI GetFocusedItem()
override float GetFocusedContainerHeight(bool contents=false)
override void SetPreviousActive(bool force=false)
override Header GetHeader()
override float GetFocusedContainerYScreenPos(bool contents=false)
override void SetDefaultFocus(bool while_micromanagment_mode=false)
override void SetNextLeftActive()
override void SetLastActive()
override void SetNextRightActive()
script counterpart to engine's class Inventory
static bool CanSwapEntitiesEx(notnull EntityAI item1, notnull EntityAI item2)
static bool CanForceSwapEntitiesEx(notnull EntityAI item1, InventoryLocation item1_dst, notnull EntityAI item2, out InventoryLocation item2_dst)
static int GetCombinationFlags(EntityAI entity1, EntityAI entity2)
static ItemManager GetInstance()
void Container(LayoutHolder parent)
bool CanCombineEx(EntityAI focusedEntity)
bool CanSwapOrTakeToHandsEx(EntityAI focusedEntity)
void SetSlotIcon(SlotsIcon icon)
void ExpandCollapseContainer()
override void UpdateInterval()
ref array< ref LayoutHolder > m_Body
override void SetFirstActive()
EntityAI GetFocusedContainerEntity()
ref array< LayoutHolder > m_OpenedContainers
Container GetContainer(int index)
float GetFocusedContainerYPos(bool contents=false)
EntityAI GetFocusedItem()
override void SetLayoutName()
override void SetLastActive()
void SetFocusedColumn(int column)
bool CanAddToQuickbarEx(EntityAI focusedEntity)
bool CanSwapOrTakeToHands()
ScrollWidget GetScrollWidget()
void ResetFocusedContainer()
bool CanTakeToInventory()
void SetFocusedContainer(Container cont)
void SetSameLevelNextActive()
void DraggingOver(Widget w, int x, int y, Widget receiver)
void SetPreviousActive(bool force=false)
bool TransferItemToVicinity()
bool CanOpenCloseContainer()
Container GetFocusedContainer()
void MoveGridCursor(int direction)
void ScrollToActiveContainer()
void CheckScrollbarVisibility()
void DraggingOverHeader(Widget w, int x, int y, Widget receiver)
bool IsItemWithQuantityActive()
void SetOpenForSlotIcon(bool open, SlotsIcon icon=null)
override void UpdateSelectionIcons()
bool IsLastContainerFocused()
void SetForceShow(bool value)
void HideContent(bool force_hide=false)
bool CanEquipEx(EntityAI focusedEntity)
void SetDefaultFocus(bool while_micromanagment_mode=false)
void Remove(LayoutHolder container)
void Insert(LayoutHolder container, int pos=-1, bool immedUpdate=true)
bool AddItemToQuickbarRadial(EntityAI itemToAssign)
void ShowContent(bool force_show=false)
void RecomputeOpenedContainers()
void SetNextRightActive()
override void SetActive(bool active)
Container m_FocusedContainer
void SetHeader(Header header)
bool CanOpenCloseContainerEx(EntityAI focusedEntity)
bool CanDropEx(EntityAI focusedEntity)
void SetActiveIndex(int index)
bool CanTakeToInventoryEx(EntityAI focusedEntity)
void CheckHeaderDragability()
bool CanSplitEx(EntityAI focusedEntity)
void OnDropReceivedFromHeader(Widget w, int x, int y, Widget receiver)
bool IsFirstContainerFocused()
void SetColumnCount(int count)
void SetSameLevelPreviousActive()
float GetFocusedContainerYScreenPos(bool contents=false)
SlotsIcon GetFocusedSlotsIcon()
float GetFocusedContainerHeight(bool contents=false)
Widget GetRadialIconPanel()
proto native CGame GetGame()