Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
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 //------------------------------------------------------------------------------------------------
12 {
13 return SCR_EAnalyticalItemSlotType.VICINITY;
14 }
15
16 //------------------------------------------------------------------------------------------------
17 // ! creates the slot
18 protected override SCR_InventorySlotUI CreateSlotUI( InventoryItemComponent pComponent, SCR_ItemAttributeCollection pAttributes = null )
19 {
20 const SCR_ItemAttributeCollection attributes = SCR_ItemAttributeCollection.Cast(pComponent.GetAttributes());
21 if (!attributes || !attributes.IsVisible(pComponent))
22 return null; // following slots dont add themselves as handlers if the item is not visible, thus skip creation of those as without a strong ref they will self destruct, and simply waste time
23
24 BaseInventoryStorageComponent inventoryStorageComponent = GetCurrentNavigationStorage();
25 if (inventoryStorageComponent)
26 {
27 IEntity storageOwner = inventoryStorageComponent.GetOwner();
28
29 if (!storageOwner || !storageOwner.FindComponent(SCR_ArsenalInventoryStorageManagerComponent))
30 return new SCR_InventorySlotUI(pComponent, this, true, pAttributes: attributes);
31
32 SCR_ArsenalInventorySlotUI slotUI = new SCR_ArsenalInventorySlotUI(pComponent, this, false, -1, attributes);
33
34 if (inventoryStorageComponent)
35 {
36 slotUI.SetArsenalResourceComponent(SCR_ResourceComponent.FindResourceComponent(inventoryStorageComponent.GetOwner()));
37 SCR_InventoryStorageBaseUI.ARSENAL_SLOT_STORAGES.Insert(slotUI, inventoryStorageComponent.GetOwner());
38 }
39 return slotUI;
40 }
41
42 if (WeaponAttachmentsStorageComponent.Cast(pComponent))
43 return new SCR_InventorySlotWeaponUI(pComponent, this, true, pAttributes: attributes);
44
45 if (SCR_ResourceComponent.FindResourceComponent(pComponent.GetOwner()))
46 return new SCR_SupplyInventorySlotUI(pComponent, this, true, pAttributes: attributes);
47
48 if (BaseInventoryStorageComponent.Cast(pComponent))
49 return new SCR_InventorySlotStorageEmbeddedUI(pComponent, this, true, pAttributes: attributes);
50
51 if (SCR_SalineBagStorageSlot.Cast(pComponent.GetParentSlot()))
52 return null; // dont create slots for saline bags which are applied to the character
53
54 return new SCR_InventorySlotUI(pComponent, this, true, pAttributes: attributes);
55 }
56
57 //------------------------------------------------------------------------ USER METHODS ------------------------------------------------------------------------
58
59 //------------------------------------------------------------------------------------------------
60 override void Init()
61 {
62 if (!m_Character)
63 return;
64 //get the workspace
65 if ( m_workspaceWidget == null )
66 m_workspaceWidget = GetGame().GetWorkspace();
67
68 //Get inventory manager and the actual character's topmost storage
69 m_InventoryManager = SCR_InventoryStorageManagerComponent.Cast( m_Character.FindComponent( SCR_InventoryStorageManagerComponent ) );
71 m_Vicinity = CharacterVicinityComponent.Cast( m_Character.FindComponent(CharacterVicinityComponent) );
72 m_wWidthOverride = SizeLayoutWidget.Cast(m_widget.FindWidget("TitleWidthOverride"));
73
76
78 {
79 m_wGrid = GridLayoutWidget.Cast( m_widget.FindAnyWidget( m_sGridPath ) );
80 m_wStorageName = TextWidget.Cast( m_widget.FindAnyWidget( "StorageName" ) );
81 //Set the proper ratio according to the number of columns and rows
82 SizeLayoutWidget wSizeContainer = SizeLayoutWidget.Cast( m_widget.FindAnyWidget( "SizeLayout0" ) );
83 if ( wSizeContainer )
84 wSizeContainer.SetAspectRatio( m_iMaxColumns / m_iMaxRows );
85 }
87 m_wStorageName.SetText("#AR-Inventory_Vicinity");
88
89 Widget storageSpace = m_widget.FindAnyWidget("StorageSpaceIndicator");
90 if (storageSpace)
91 storageSpace.SetVisible(false);
92
93 Widget item = m_widget.FindAnyWidget("itemStorage");
94 if (item)
95 item.SetVisible(false);
96 }
97
98 //------------------------------------------------------------------------------------------------
99 override void Traverse(BaseInventoryStorageComponent storage)
100 {
101 super.Traverse(storage);
102
103 BaseInventoryStorageComponent currentStorage = GetCurrentNavigationStorage();
104 if (currentStorage && currentStorage.GetOwner())
105 m_ResourceComponent = SCR_ResourceComponent.FindResourceComponent(currentStorage.GetOwner(), true);
106
108 return;
109
110 m_ResourceConsumer = m_ResourceComponent.GetConsumer(EResourceGeneratorID.VEHICLE_UNLOAD, EResourceType.SUPPLIES);
111
113 m_ResourceConsumer = m_ResourceComponent.GetConsumer(EResourceGeneratorID.DEFAULT_STORAGE, EResourceType.SUPPLIES);
114
117
119 return;
120
122
123 if (!resourceInventoryPlayerComponent)
124 return;
125
126 m_ResourceComponent.TEMP_GetOnInteractorReplicated().Insert(RefreshResources);
127
128 RplId resourceInventoryPlayerComponentRplId = Replication.FindItemId(resourceInventoryPlayerComponent);
129
130 if (!resourceInventoryPlayerComponentRplId.IsValid())
131 return;
132
133 m_ResourceSubscriptionHandleConsumer = GetGame().GetResourceSystemSubscriptionManager().RequestSubscriptionListenerHandle(m_ResourceConsumer, resourceInventoryPlayerComponentRplId);
134 }
135
136 //------------------------------------------------------------------------------------------------
137 override void Back(int traverseStorageIndex)
138 {
139 super.Back(traverseStorageIndex);
140
142 m_ResourceComponent.TEMP_GetOnInteractorReplicated().Remove(RefreshResources);
143
145 }
146
147 //------------------------------------------------------------------------------------------------
148 override void RefreshResources()
149 {
151 {
152 FindConsumer();
153 m_wResourceStoredDisplay = m_widget.FindAnyWidget("ResourceDisplayStored");
155 m_wResourceStoredText = TextWidget.Cast(m_wResourceStoredDisplay.FindAnyWidget("ResourceText"));
156
157 m_wResourceAvailableDisplay = m_widget.FindAnyWidget("ResourceDisplayAvailable");
159 m_wResourceAvailableText = TextWidget.Cast(m_wResourceAvailableDisplay.FindAnyWidget("ResourceText"));
160
162 return;
163 }
164
165 super.RefreshResources();
166 }
167
168 //------------------------------------------------------------------------ COMMON METHODS ----------------------------------------------------------------------
169
170 //------------------------------------------------------------------------------------------------
171 override void HandlerAttached( Widget w )
172 {
173 super.HandlerAttached( w );
174 InitPaging();
177 CreateSlots();
178 SortSlots();
179 ShowPage(0);
180 }
181
182 //------------------------------------------------------------------------------------------------
183 protected override void GetAllItems( out notnull array<IEntity> pItemsInStorage, BaseInventoryStorageComponent pStorage = null )
184 {
185 if( !m_Vicinity )
186 return;
187
188 if (pStorage)
189 super.GetAllItems(pItemsInStorage, pStorage);
190 else
191 m_Vicinity.GetAvailableItems(pItemsInStorage);
192 }
193
194 //------------------------------------------------------------------------------------------------
196 BaseInventoryStorageComponent storage,
197 LoadoutAreaType slotID = null,
198 SCR_InventoryMenuUI menuManager = null,
199 int iPage = 0,
200 array<BaseInventoryStorageComponent> aTraverseStorage = null,
201 GenericEntity character = null,
202 int rows = 8,
203 int cols = 6)
204 {
205 m_iMaxRows = rows;
206 m_iMaxColumns = cols;
208 SetSlotAreaType( slotID );
209 m_Character = character;
210 m_bEnabled = true;
211 }
212
213 //------------------------------------------------------------------------------------------------
215 {
216 }
217};
ArmaReforgerScripted GetGame()
Definition game.c:1398
SCR_EAnalyticalItemSlotType
EResourceGeneratorID
proto external Managed FindComponent(typename typeName)
Main replication API.
Definition Replication.c:14
Replication item identifier.
Definition RplId.c:14
void SetArsenalResourceComponent(SCR_ResourceComponent component)
void ShowPage(int iPage, out int slotToFocus=-1)
ref SCR_ResourceSystemSubscriptionHandleBase m_ResourceSubscriptionHandleConsumer
SCR_CharacterInventoryStorageComponent m_InventoryStorage
void CreateEmptyLayout(bool recreate=false)
SCR_ResourceComponent m_ResourceComponent
void SCR_InventoryStorageBaseUI(BaseInventoryStorageComponent storage, LoadoutAreaType slotID=null, SCR_InventoryMenuUI menuManager=null, int iPage=0, array< BaseInventoryStorageComponent > aTraverseStorage=null)
SCR_InventoryStorageManagerComponent m_InventoryManager
SCR_EAnalyticalItemSlotType GetAnalyticalItemSlotType()
void SetSlotAreaType(LoadoutAreaType eSlotType)
void SCR_InventoryStorageLootUI(BaseInventoryStorageComponent storage, LoadoutAreaType slotID=null, SCR_InventoryMenuUI menuManager=null, int iPage=0, array< BaseInventoryStorageComponent > aTraverseStorage=null, GenericEntity character=null, int rows=8, int cols=6)
override void Traverse(BaseInventoryStorageComponent storage)
override SCR_InventorySlotUI CreateSlotUI(InventoryItemComponent pComponent, SCR_ItemAttributeCollection pAttributes=null)
override void Back(int traverseStorageIndex)
override void GetAllItems(out notnull array< IEntity > pItemsInStorage, BaseInventoryStorageComponent pStorage=null)
override void HandlerAttached(Widget w)
proto external PlayerController GetPlayerController()