Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_InventoryStorageLootUI.c
Go to the documentation of this file.
1 //------------------------------------------------------------------------------------------------
5 {
6  private GenericEntity m_Character;
7  private CharacterVicinityComponent m_Vicinity;
8 // protected string sGridPath = "centerFrame.gridFrame.size.grid";
9 
10  //------------------------------------------------------------------------------------------------
11  // ! creates the slot
12  protected override SCR_InventorySlotUI CreateSlotUI( InventoryItemComponent pComponent, SCR_ItemAttributeCollection pAttributes = null )
13  {
14  BaseInventoryStorageComponent inventoryStorageComponent = GetCurrentNavigationStorage();
15 
16  if (inventoryStorageComponent)
17  {
18  IEntity storageOwner = inventoryStorageComponent.GetOwner();
19 
20  if (!storageOwner || !storageOwner.FindComponent(SCR_ArsenalInventoryStorageManagerComponent))
21  return new SCR_InventorySlotUI(pComponent, this, true);
22 
23  SCR_ArsenalInventorySlotUI slotUI = SCR_ArsenalInventorySlotUI(pComponent, this, false, -1, null);
24 
25  if (inventoryStorageComponent)
26  {
27  slotUI.SetArsenalResourceComponent(SCR_ResourceComponent.FindResourceComponent(inventoryStorageComponent.GetOwner()));
28  SCR_InventoryStorageBaseUI.ARSENAL_SLOT_STORAGES.Insert(slotUI, inventoryStorageComponent.GetOwner());
29  }
30  return slotUI;
31  }
32  else if (WeaponAttachmentsStorageComponent.Cast(pComponent))
33  {
34  return SCR_InventorySlotWeaponUI(pComponent, this, true);
35  }
36  else if (SCR_ResourceComponent.FindResourceComponent(pComponent.GetOwner()))
37  {
38  return SCR_SupplyInventorySlotUI(pComponent, this, true);
39  }
40  else if (BaseInventoryStorageComponent.Cast( pComponent))
41  {
42  return SCR_InventorySlotStorageEmbeddedUI(pComponent, this, true);
43  }
44  else
45  {
46  return new SCR_InventorySlotUI(pComponent, this, true);
47  }
48  }
49 
50  //------------------------------------------------------------------------ USER METHODS ------------------------------------------------------------------------
51 
52  //------------------------------------------------------------------------------------------------
53  override void Init()
54  {
55  if (!m_Character)
56  return;
57  //get the workspace
58  if ( m_workspaceWidget == null )
59  m_workspaceWidget = GetGame().GetWorkspace();
60 
61  //Get inventory manager and the actual character's topmost storage
62  m_InventoryManager = SCR_InventoryStorageManagerComponent.Cast( m_Character.FindComponent( SCR_InventoryStorageManagerComponent ) );
63  m_InventoryStorage = SCR_CharacterInventoryStorageComponent.Cast( m_Character.FindComponent( SCR_CharacterInventoryStorageComponent ) );
64  m_Vicinity = CharacterVicinityComponent.Cast( m_Character.FindComponent(CharacterVicinityComponent) );
65  m_wWidthOverride = SizeLayoutWidget.Cast(m_widget.FindWidget("TitleWidthOverride"));
66 
67  if (m_wWidthOverride)
68  m_wWidthOverride.SetWidthOverride(m_iMaxColumns * SLOT_LAYOUT_WIDTH);
69 
70  if( m_InventoryStorage )
71  {
72  m_wGrid = GridLayoutWidget.Cast( m_widget.FindAnyWidget( m_sGridPath ) );
73  m_wStorageName = TextWidget.Cast( m_widget.FindAnyWidget( "TextC" ) );
74  //Set the proper ratio according to the number of columns and rows
75  SizeLayoutWidget wSizeContainer = SizeLayoutWidget.Cast( m_widget.FindAnyWidget( "SizeLayout0" ) );
76  if ( wSizeContainer )
77  wSizeContainer.SetAspectRatio( m_iMaxColumns / m_iMaxRows );
78  }
79  if( !m_wStorageName )
80  return;
81  m_wStorageName.SetText( "#AR-Inventory_Vicinity" );
82  }
83 
84  //------------------------------------------------------------------------ COMMON METHODS ----------------------------------------------------------------------
85 
86  //------------------------------------------------------------------------------------------------
87  override void HandlerAttached( Widget w )
88  {
89  super.HandlerAttached( w );
90  InitPaging();
91  SetRowsAndColumns();
92  CreateEmptyLayout();
93  CreateSlots();
94  SortSlots();
95  ShowPage(0);
96  }
97 
98  //------------------------------------------------------------------------------------------------
99  protected override void GetAllItems( out notnull array<IEntity> pItemsInStorage, BaseInventoryStorageComponent pStorage = null )
100  {
101  if( !m_Vicinity )
102  return;
103 
104  if (pStorage)
105  super.GetAllItems(pItemsInStorage, pStorage);
106  else
107  m_Vicinity.GetAvailableItems(pItemsInStorage);
108  }
109 
110  //------------------------------------------------------------------------------------------------
112  BaseInventoryStorageComponent storage,
113  LoadoutAreaType slotID = null,
114  SCR_InventoryMenuUI menuManager = null,
115  int iPage = 0,
116  array<BaseInventoryStorageComponent> aTraverseStorage = null,
117  GenericEntity character = null,
118  int rows = 6,
119  int cols = 6)
120  {
121  m_iMaxRows = rows;
122  m_iMaxColumns = cols;
123  m_iMatrix = new SCR_Matrix( m_iMaxColumns, m_iMaxRows );
124  SetSlotAreaType( slotID );
125  m_Character = character;
126  m_bEnabled = true;
127  }
128 
129  //------------------------------------------------------------------------------------------------
131  {
132  }
133 };
SCR_SupplyInventorySlotUI
Definition: SCR_SupplyInventorySlotUI.c:2
SCR_InventoryStorageLootUI
Definition: SCR_InventoryStorageLootUI.c:4
CreateSlots
protected override int CreateSlots()
Definition: SCR_InventoryAttachmentStorageUI.c:39
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
SCR_ArsenalInventorySlotUI
Definition: SCR_ArsenalInventorySlotUI.c:2
SCR_InventorySlotWeaponUI
Definition: SCR_InventorySlotWeaponUI.c:6
m_InventoryManager
SCR_InventoryStorageManagerComponent m_InventoryManager
Definition: SCR_AttachementAction.c:15
GenericEntity
SCR_GenericBoxEntityClass GenericEntity
SCR_InventoryStorageBaseUI
Definition: SCR_InventoryStorageBaseUI.c:6
SCR_InventorySlotStorageEmbeddedUI
Definition: SCR_InventorySlotStorageEmbeddedUI.c:5
SCR_InventoryMenuUI
Definition: SCR_InventoryMenuUI.c:247
InventoryItemComponent
Definition: InventoryItemComponent.c:12
SCR_ItemAttributeCollection
Definition: SCR_ItemAttributeCollection.c:2
SCR_Matrix
Definition: SCR_Matrix.c:2
m_bEnabled
private bool m_bEnabled
Definition: SCR_BaseManualCameraComponent.c:3
LoadoutAreaType
Definition: LoadoutAreaType.c:12
SCR_InventorySlotUI
Definition: SCR_InventorySlotUI.c:27