4 protected const int ROWS_NUMBER_XBOX = 5;
7 protected int m_CargoIndex = -1;
9 protected int m_FocusedItemPosition = -1;
24#ifndef PLATFORM_CONSOLE
38 m_CargoContainer =
m_RootWidget.FindAnyWidget(
"grid_background");
39 m_ItemsContainer =
m_RootWidget.FindAnyWidget(
"grid_overlay");
40 m_CargoHeader =
m_RootWidget.FindAnyWidget(
"grid_container_header_spacer");
41#ifndef PLATFORM_CONSOLE
44 m_RootWidget.FindAnyWidget(
"grid_container").GetScript(m_Resizer2);
46 m_FalseHeaderTextWidget =
TextWidget.Cast(m_CargoHeader.FindAnyWidget(
"TextWidget0"));
49 m_FocusedItemPosition = -1;
56 m_Entity.GetOnItemAddedIntoCargo().Remove(AddedToCargo);
57 m_Entity.GetOnItemRemovedFromCargo().Remove(RemovedFromCargo);
58 m_Entity.GetOnItemMovedInCargo().Remove(MovedInCargo);
60 m_Entity.GetOnReleaseLock().Remove(ReleaseLock);
69 item.GetInventory().GetCurrentInventoryLocation(
il);
73 if (m_ShowedItemPositions.Contains(
item))
91#ifdef PLATFORM_CONSOLE
98 data.param1.SetCargoPos(
i);
103 m_FocusedItemPosition =
Math.
Min(m_ShowedItemPositions.Count() - 1, m_FocusedItemPosition);
120 m_Icons.RemoveItem(
data.param1);
121 m_ShowedItemPositions.Remove(
item);
126#ifdef PLATFORM_CONSOLE
133 data.param1.SetCargoPos(
i);
134 data.param1.SetPos();
138 m_FocusedItemPosition =
Math.
Min(m_ShowedItemPositions.Count() - 1, m_FocusedItemPosition);
147 item.GetInventory().GetCurrentInventoryLocation(
il);
150#ifdef PLATFORM_CONSOLE
151 int y =
il.GetRow() - 1;
155 if (m_ShowedItemPositions.Contains(
item))
164#ifdef PLATFORM_CONSOLE
165 data.param1.SetCargoPos(
data.param3);
167#ifdef PLATFORM_WINDOWS
172 data.param1.UpdateInterval();
180#ifndef PLATFORM_CONSOLE
184 int index =
GetGame().GetPlayer().GetHumanInventory().FindUserReservedLocationIndex(
item);
187 GetGame().GetPlayer().GetHumanInventory().GetUserReservedLocation(
index,
il);
190 m_Icons.Insert(
icon);
193 item.GetOnReleaseLock().Insert(ReleaseLock);
201#ifndef PLATFORM_CONSOLE
202 if (m_ShowedLockPositions.Contains(
item))
204 Icon ic = m_ShowedLockPositions.Get(
item).param1;
205 m_Icons.RemoveItem(
ic);
206 m_ShowedLockPositions.Remove(
item);
207 item.GetOnReleaseLock().Remove(ReleaseLock);
214#ifdef PLATFORM_CONSOLE
247 m_Entity.GetOnItemAddedIntoCargo().Insert(AddedToCargo);
248 m_Entity.GetOnItemRemovedFromCargo().Insert(RemovedFromCargo);
249 m_Entity.GetOnItemMovedInCargo().Insert(MovedInCargo);
251 m_Entity.GetOnReleaseLock().Insert(ReleaseLock);
262 int prev_count = m_ShowedItemPositions.Count();
272#ifdef PLATFORM_CONSOLE
291 if (
m_Entity.CanDisplayCargo() &&
m_Entity.GetInventory().GetCargoFromIndex(m_CargoIndex))
294 if (m_IsAttachment && m_CargoHeader)
296 m_FalseHeaderTextWidget.SetText(
name);
298 m_FalseHeaderTextWidget.Update();
299 m_FalseHeaderTextWidget.GetScreenSize(
x,
y);
300 m_CargoHeader.FindAnyWidget(
"grid_container_header").SetSize(1,
y +
InventoryMenu.GetHeightMultiplied(10));
301 m_CargoHeader.Update();
303 if (m_AlternateFalseHeaderTextWidget)
304 m_AlternateFalseHeaderTextWidget.SetText(
name);
316 m_ShowedItemPositions.Clear();
320#ifdef PLATFORM_CONSOLE
333#ifdef PLATFORM_WINDOWS
334#ifndef PLATFORM_CONSOLE
335 row.SetWidth(
m_Entity.GetInventory().GetCargoFromIndex(m_CargoIndex).GetWidth(),
false);
339 row.GetRootWidget().SetSort(
j,
false);
344 row.GetRootWidget().FindAnyWidget(
"Icon0").GetScreenSize(
y, m_IconSize);
345#ifdef PLATFORM_WINDOWS
346#ifndef PLATFORM_CONSOLE
347 row.GetRootWidget().FindAnyWidget(
"Spacer0").GetScreenSize(m_SpaceSize,
y);
351 m_Resizer2.ResizeParentToChild();
352#ifndef PLATFORM_CONSOLE
353 m_Resizer1.ResizeParentToChild();
359#ifndef PLATFORM_CONSOLE
360 m_Resizer1.ResizeParentToChild();
362 m_Resizer2.ResizeParentToChild();
378#ifdef PLATFORM_CONSOLE
379#ifndef PLATFORM_WINDOWS
395#ifdef PLATFORM_CONSOLE
396#ifndef PLATFORM_WINDOWS
397 return CargoList.Cast(m_Cargo).GetMaxWeight();
405 if (
item && m_ShowedItemPositions.Contains(
item))
425 return GetIcon(m_FocusedItemPosition);
434 GetRootWidget().GetScreenSize(
x,
y);
444 GetRootWidget().GetPos(
x,
y);
454 GetRootWidget().GetScreenPos(
x,
y);
462 if (m_FocusedItemPosition >= m_Icons.Count())
463 m_FocusedItemPosition = m_Icons.Count() - 1;
467 icon.SetActive(
true);
468 Inventory.GetInstance().UpdateConsoleToolbar();
481 for (
i = m_Rows.Count() - 1;
i >=
rows;
i--)
487 for (
i = m_Rows.Count();
i <
rows;
i++)
493 row.GetRootWidget().SetSort(
i);
499 m_Resizer2.ResizeParentToChild();
500#ifndef PLATFORM_CONSOLE
501 m_Resizer1.ResizeParentToChild();
507#ifdef PLATFORM_CONSOLE
509 m_ResizeTimer =
new Timer();
510 if (m_ResizeTimer.IsRunning())
511 m_ResizeTimer.Stop();
512 m_ResizeTimer.Run(0.05,
this,
"RefreshImpl");
527 data.param1.UpdateInterval();
533#ifdef PLATFORM_CONSOLE
535#ifdef PLATFORM_WINDOWS
545 if (
item.GetInventory().GetFlipCargo())
565 return m_ShowedItemPositions.Contains(
item);
578 if (
item.GetTargetQuantityMax() <
item.GetQuantity())
579 item.SplitIntoStackMaxClient(
null, -1);
594 m_FocusedItemPosition = 0;
607 icon.SetActive(
false);
615 icon.SetActive(
false);
617 m_FocusedItemPosition = 0;
624 int max_row = (m_Icons.Count() - 1) / ROWS_NUMBER_XBOX;
629 if (m_FocusedItemPosition >= m_Icons.Count())
630 m_FocusedItemPosition = m_Icons.Count() - 1;
654 if (m_Icons.Count() > 0)
661 if (
row_max >= m_Icons.Count())
664 m_FocusedItemPosition++;
665 if (m_FocusedItemPosition >
row_max)
666 m_FocusedItemPosition =
row_min;
674 if (m_Icons.Count() > 0)
681 if (
row_max >= m_Icons.Count())
684 m_FocusedItemPosition--;
685 if (m_FocusedItemPosition <
row_min)
686 m_FocusedItemPosition =
row_max;
703 super.SetLastActive();
706 m_FocusedItemPosition = ((m_Rows.Count() - 1) * ROWS_NUMBER_XBOX);
738 return m_Icons.Count() == 0;
763 if (CanTakeToInventory())
856 m_FocusedItemPosition = 0;
915 m_CargoHeader.Show(show);
921 m_AlternateFalseHeaderTextWidget =
w;
void Inventory(LayoutHolder parent)
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
FindInventoryLocationType
flags for searching locations in inventory
PluginBase GetPlugin(typename plugin_type)
ref Widget m_RootWidget[MAX_SIMULTANIOUS_PLAYERS]
represents base for cargo storage for entities
proto native int GetWidth()
proto native int GetHeight()
proto bool GetItemSize(int index, out int w, out int h)
proto native int GetItemCount()
proto native EntityAI GetItem(int index)
override void SetLastFocus()
ref SizeToChild m_Resizer2
override void SetActive(bool active)
void MovedInCargo(EntityAI item)
TextWidget m_FalseHeaderTextWidget
override void SetNextActive()
override void SetLayoutName()
void SetLock(EntityAI item)
override EntityAI GetFocusedItem()
void ShowFalseCargoHeader(bool show)
ref array< ref Icon > m_Icons
override float GetFocusedContainerYPos(bool contents=false)
int GetMaxCargoCapacity()
ref SizeToChild m_Resizer1
override void UnfocusAll()
override bool EquipItem()
override float GetFocusedContainerHeight(bool contents=false)
override bool IsItemActive()
const int ROWS_NUMBER_XBOX
void SetEntity(EntityAI item, int cargo_index=0, bool immedUpdate=true)
void AddedToCargoEx(EntityAI item, bool refresh=true)
override bool SelectItem()
override bool TransferItemToVicinity()
override bool TransferItem()
Icon InitIcon(Icon icon, EntityAI item, int pos_x, int pos_y)
bool HasItem(EntityAI item)
override void SetPreviousActive(bool force=false)
override Header GetHeader()
override bool SplitItem()
override float GetFocusedContainerYScreenPos(bool contents=false)
void RemovedFromCargo(EntityAI item)
void AddedToCargo(EntityAI item)
override void SetDefaultFocus(bool while_micromanagment_mode=false)
void UpdateRowVisibility(int count)
override bool IsItemWithQuantityActive()
void SetAlternateFalseTextHeaderWidget(TextWidget w)
override void SetNextLeftActive()
ref map< EntityAI, ref Param3< ref Icon, int, int > > m_ShowedItemPositions
ref map< EntityAI, ref Param3< ref Icon, int, int > > m_ShowedLockPositions
override bool CanCombineAmmo()
override void SetLastActive()
Icon GetIcon(EntityAI item)
void ReleaseLock(EntityAI item)
TextWidget m_AlternateFalseHeaderTextWidget
override void SetNextRightActive()
void CargoContainer(LayoutHolder parent, bool is_attachment=false)
int GetRecipeCount(bool recipe_anywhere, ItemBase entity1, ItemBase entity2, PlayerBase player)
Icon InitIconEx(Icon icon, EntityAI item, int pos_x, int pos_y, bool refresh=true)
ref array< ref CargoContainerRow > m_Rows
override void UpdateInterval()
script counterpart to engine's class Inventory
static bool CanSwapEntitiesEx(notnull EntityAI item1, notnull EntityAI item2)
override void SetActive(bool active)
static ItemManager GetInstance()
static int HasItemQuantity(notnull EntityAI item)
proto native CGame GetGame()
static proto float Max(float x, float y)
Returns bigger of two given values.
static proto float Min(float x, float y)
Returns smaller of two given values.
static proto float Ceil(float f)
Returns ceil of value.