Arma Reforger Explorer
1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Toggle main menu visibility
Loading...
Searching...
No Matches
SCR_InventoryWeaponSlotsUI.c
Go to the documentation of this file.
1
[
EntityEditorProps
(
category
:
"GameScripted/UI/Inventory"
, description:
"Inventory 2.0 Weapon Slots UI class"
)]
2
3
//------------------------------------------------------------------------------------------------
6
class
SCR_InventoryWeaponSlotsUI
:
SCR_InventoryStorageBaseUI
7
{
8
protected
ref array<WeaponSlotComponent>
m_aWeaponSlots
=
new
array<WeaponSlotComponent>(); ;
9
protected
EquipedWeaponStorageComponent
m_weaponStorage
;
10
11
//------------------------------------------------------------------------------------------------
12
override
SCR_EAnalyticalItemSlotType
GetAnalyticalItemSlotType
()
13
{
14
return
SCR_EAnalyticalItemSlotType
.HORIZONTAL;
15
}
16
17
//------------------------------------------------------------------------------------------------
18
override
void
HandlerAttached
(
Widget
w)
19
{
20
m_weaponStorage
=
EquipedWeaponStorageComponent
.Cast(
m_Storage
);
21
22
super.HandlerAttached(w);
23
CreateEmptyLayout
();
24
CreateSlots
();
25
SortSlots
();
26
InitMatrix
();
27
}
28
29
//------------------------------------------------------------------------------------------------
30
override
void
InitPaging
()
31
{}
32
33
//------------------------------------------------------------------------------------------------
34
override
bool
IsTraversalAllowed
()
35
{
36
return
false
;
37
}
38
39
//------------------------------------------------------------------------------------------------
40
// !
41
override
protected
int
CreateSlots
()
42
{
43
array<IEntity> pItemsInStorage = {};
44
array<Managed> weaponSlots = {};
45
46
m_Player
.FindComponents(
WeaponSlotComponent
, weaponSlots);
47
48
m_iMaxColumns
=
Math
.Min(weaponSlots.Count(),
SCR_InventoryMenuUI
.
WEAPON_SLOTS_COUNT
);
49
50
pItemsInStorage.Resize(
m_iMaxColumns
);
51
m_aWeaponSlots
.Resize(
m_iMaxColumns
);
52
53
WeaponSlotComponent
weaponSlot;
54
int
weaponSlotIndex;
55
foreach
(Managed managed : weaponSlots)
56
{
57
weaponSlot =
WeaponSlotComponent
.Cast(managed);
58
if
(!weaponSlot)
59
continue
;
60
61
weaponSlotIndex = weaponSlot.GetWeaponSlotIndex();
62
if
(weaponSlotIndex <
m_iMaxColumns
)
63
{
64
pItemsInStorage.Set(weaponSlotIndex, weaponSlot.GetWeaponEntity());
65
m_aWeaponSlots
.Set(weaponSlotIndex, weaponSlot);
66
}
67
}
68
69
UpdateOwnedSlots
(pItemsInStorage);
70
FillWithEmptySlots
();
71
return
0;
72
}
73
74
//------------------------------------------------------------------------------------------------
75
// !
76
override
protected
void
UpdateOwnedSlots
(notnull array<IEntity> pItemsInStorage)
77
{
78
int
count = pItemsInStorage.Count();
79
if
(count <
m_aSlots
.Count())
80
{
81
for
(
int
i =
m_aSlots
.Count() - count; i > 0; i--)
82
{
83
SCR_InventorySlotUI
slotUI =
m_aSlots
[
m_aSlots
.Count() - 1];
84
if
(slotUI)
85
slotUI.
Destroy
();
86
}
87
}
88
m_aSlots
.Resize(count);
89
for
(
int
i = 0; i < count; i++)
90
{
91
InventoryItemComponent
pComponent =
GetItemComponentFromEntity
( pItemsInStorage[i] );
92
93
if
(
m_aSlots
[i])
94
m_aSlots
[i].UpdateReferencedComponent(pComponent);
95
else
96
m_aSlots
[i] =
CreateSlotUI
(pComponent, i, null, i,
m_aWeaponSlots
[i].GetWeaponSlotType());
97
}
98
}
99
100
//------------------------------------------------------------------------------------------------
101
override
void
FillWithEmptySlots
()
102
{
103
array<int> aCoordinates;
104
int
iWidgetColumnSize, iWidgetRowSize;
105
int
iRelativeOffset = 0;
//if there's an item taking more than one slot, offset the following items to the right
106
107
foreach
(
int
iIndex,
SCR_InventorySlotUI
pSlot:
m_aSlots
)
108
{
109
if
( !pSlot )
//if pSlot doesn't exist it means no assigned item in this slot and we create the "empty" slot
110
{
111
ESlotSize
eSlotSize;
112
if
( iIndex > 1 )
113
eSlotSize =
ESlotSize
.SLOT_1x1;
114
else
115
eSlotSize =
ESlotSize
.SLOT_2x1;
//first 2 slots are dedicated to weapons ( thus 2x1 layout)
116
117
SCR_ItemAttributeCollection
pAttrib =
new
SCR_ItemAttributeCollection
();
118
pAttrib.SetSlotType(
ESlotID
.SLOT_ANY );
119
pAttrib.SetSlotSize( eSlotSize );
120
pSlot =
CreateSlotUI
( null, iIndex, pAttrib, iIndex,
m_aWeaponSlots
[iIndex].GetWeaponSlotType() );
121
m_aSlots
.Set( iIndex, pSlot );
122
}
123
Widget
w = pSlot.GetWidget();
124
if
( !w )
125
continue
;
126
127
iWidgetColumnSize = pSlot.GetColumnSize();
128
iWidgetRowSize = pSlot.GetRowSize();
129
130
int
iCol = pSlot.GetSlotIndex() + iRelativeOffset;
131
m_iMatrix
.ReservePlace( iWidgetColumnSize, iWidgetRowSize, iCol, 0 );
132
GridSlot
.SetColumn( w, iCol );
133
iRelativeOffset += ( iWidgetColumnSize - 1 );
134
GridSlot
.SetRow( w, 0 );
135
136
GridSlot
.SetColumnSpan( w, iWidgetColumnSize );
137
GridSlot
.SetRowSpan( w, iWidgetRowSize );
138
}
139
140
SetRowsAndColumns
();
141
}
142
143
//------------------------------------------------------------------------------------------------
144
// ! creates the slot
145
protected
SCR_InventorySlotWeaponSlotsUI
CreateSlotUI
(
InventoryItemComponent
pComponent,
int
iSlotIndex,
SCR_ItemAttributeCollection
pAttributes = null,
int
iWeaponSlotIndex = -1,
string
sWeaponSlotType =
""
)
146
{
147
return
SCR_InventorySlotWeaponSlotsUI
( pComponent,
this
,
true
, iSlotIndex, pAttributes, iWeaponSlotIndex, sWeaponSlotType );
//creates the slot
148
}
149
150
//------------------------------------------------------------------------------------------------
151
override
void
SetRowsAndColumns
()
152
{
153
// leave this empty because we need to initialize rows and columns in different place
154
}
155
156
//------------------------------------------------------------------------------------------------
157
int
GetActualSlotsUsedCount
()
158
{
159
int
result = 0;
160
int
slotCount =
m_aSlots
.Count();
161
SCR_InventorySlotUI
slot;
162
for
(
int
id
= 0;
id
< slotCount; ++
id
)
163
{
164
slot =
m_aSlots
[
id
];
165
if
(slot)
166
result += slot.
GetColumnSize
();
167
}
168
169
return
result;
170
}
171
172
//------------------------------------------------------------------------------------------------
173
// ! creates the the grid from array of UI items
174
override
protected
void
SortSlots
()
175
{
176
int
iWidgetColumnSize, iWidgetRowSize;
177
const
int
iPageCounter = 0;
// TODO: check for good const usage
178
int
iRelativeOffset = 0;
// if there's an item taking more than one slot, offset the following items to the right
179
180
//reset all elements to 0 - free it
181
m_iMatrix
.Reset();
182
183
foreach
(
SCR_InventorySlotUI
pSlot:
m_aSlots
)
184
{
185
if
( !pSlot )
186
continue
;
187
188
Widget
w = pSlot.GetWidget();
189
if
( !w )
190
continue
;
191
192
iWidgetColumnSize = pSlot.GetColumnSize();
193
iWidgetRowSize = pSlot.GetRowSize();
194
195
int
iCol = pSlot.GetSlotIndex() + iRelativeOffset;
196
m_iMatrix
.ReservePlace( iWidgetColumnSize, iWidgetRowSize, iCol, 0 );
197
GridSlot
.SetColumn( w, iCol );
198
iRelativeOffset += ( iWidgetColumnSize - 1 );
199
GridSlot
.SetRow( w, 0 );
200
pSlot.SetPage( iPageCounter );
201
202
GridSlot
.SetColumnSpan( w, iWidgetColumnSize );
203
GridSlot
.SetRowSpan( w, iWidgetRowSize );
204
}
205
206
m_iNrOfPages
= iPageCounter + 1;
207
FillWithEmptySlots
();
208
}
209
210
//------------------------------------------------------------------------------------------------
211
void
InitMatrix
()
212
{
213
if
(!
m_wGrid
)
214
return
;
215
216
m_iMaxColumns
=
GetActualSlotsUsedCount
();
217
m_iMatrix
=
new
SCR_Matrix
(
m_iMaxColumns
,
m_iMaxRows
);
218
m_iPageSize
=
m_iMaxRows
*
m_iMaxColumns
;
219
220
for
(
int
y = 0; y <
m_iMaxRows
; ++y)
221
{
222
m_wGrid
.SetRowFillWeight(y, 1);
223
for
(
int
x = 0; x <
m_iMaxColumns
; ++x)
224
{
225
m_wGrid
.SetColumnFillWeight(x, 1);
226
}
227
}
228
229
SizeLayoutWidget
wSizeContainer =
SizeLayoutWidget
.Cast(
m_widget
.FindAnyWidget(
"SizeLayout0"
));
230
if
(wSizeContainer)
231
wSizeContainer.SetAspectRatio(
m_iMaxColumns
/
m_iMaxRows
);
232
}
233
234
//------------------------------------------------------------------------------------------------
235
void
SCR_InventoryWeaponSlotsUI
(BaseInventoryStorageComponent storage,
LoadoutAreaType
slotID = null,
SCR_InventoryMenuUI
menuManager = null,
int
iPage = 0, array<BaseInventoryStorageComponent> aTraverseStorage = null )
236
{
237
m_MenuHandler
= menuManager;
238
m_iMaxRows
= 1;
239
m_iMaxColumns
= 0;
240
m_iMatrix
=
new
SCR_Matrix
(
m_iMaxColumns
,
m_iMaxRows
);
241
m_sGridPath
=
"WeaponsGrid"
;
242
m_Storage
= storage;
243
}
244
}
id
AddonBuildInfoTool id
ESlotID
ESlotID
Definition
InventoryConstants.c:15
ESlotSize
ESlotSize
Definition
InventoryConstants.c:2
SCR_EAnalyticalItemSlotType
SCR_EAnalyticalItemSlotType
Definition
SCR_AnalyticsApplication.c:3
EntityEditorProps
enum SCR_ECompassType EntityEditorProps(category:"GameScripted/Gadgets", description:"Compass", color:"0 0 255 255")
Prefab data class for compass component.
Definition
SCR_CompassComponent.c:10
category
params category
Definition
SCR_VehicleDamageManagerComponent.c:302
EquipedWeaponStorageComponent
Definition
EquipedWeaponStorageComponent.c:6
GridSlot
Definition
GridSlot.c:13
InventoryItemComponent
Definition
InventoryItemComponent.c:13
LoadoutAreaType
Definition
LoadoutAreaType.c:13
Math
Definition
Math.c:13
SCR_InventoryMenuUI
Definition
SCR_InventoryMenuUI.c:286
SCR_InventoryMenuUI::WEAPON_SLOTS_COUNT
const int WEAPON_SLOTS_COUNT
Definition
SCR_InventoryMenuUI.c:393
SCR_InventorySlotUI
Definition
SCR_InventorySlotUI.c:26
SCR_InventorySlotUI::Destroy
void Destroy()
Removes just the UI slot.
Definition
SCR_InventorySlotUI.c:972
SCR_InventorySlotUI::GetColumnSize
int GetColumnSize()
Definition
SCR_InventorySlotUI.c:1071
SCR_InventorySlotWeaponSlotsUI
Definition
SCR_InventorySlotWeaponSlotsUI.c:5
SCR_InventoryStorageBaseUI::m_iNrOfPages
int m_iNrOfPages
Definition
SCR_InventoryStorageBaseUI.c:48
SCR_InventoryStorageBaseUI::m_wGrid
GridLayoutWidget m_wGrid
Definition
SCR_InventoryStorageBaseUI.c:34
SCR_InventoryStorageBaseUI::m_iMatrix
ref SCR_Matrix m_iMatrix
Definition
SCR_InventoryStorageBaseUI.c:45
SCR_InventoryStorageBaseUI::m_aSlots
ref array< SCR_InventorySlotUI > m_aSlots
Definition
SCR_InventoryStorageBaseUI.c:25
SCR_InventoryStorageBaseUI::CreateEmptyLayout
void CreateEmptyLayout(bool recreate=false)
Definition
SCR_InventoryStorageBaseUI.c:1782
SCR_InventoryStorageBaseUI::m_Player
ChimeraCharacter m_Player
Definition
SCR_InventoryStorageBaseUI.c:17
SCR_InventoryStorageBaseUI::m_iPageSize
int m_iPageSize
Definition
SCR_InventoryStorageBaseUI.c:46
SCR_InventoryStorageBaseUI::m_MenuHandler
SCR_InventoryMenuUI m_MenuHandler
Definition
SCR_InventoryStorageBaseUI.c:24
SCR_InventoryStorageBaseUI::SCR_InventoryStorageBaseUI
void SCR_InventoryStorageBaseUI(BaseInventoryStorageComponent storage, LoadoutAreaType slotID=null, SCR_InventoryMenuUI menuManager=null, int iPage=0, array< BaseInventoryStorageComponent > aTraverseStorage=null)
Definition
SCR_InventoryStorageBaseUI.c:2058
SCR_InventoryStorageBaseUI::m_iMaxRows
int m_iMaxRows
Definition
SCR_InventoryStorageBaseUI.c:46
SCR_InventoryStorageBaseUI::m_sGridPath
string m_sGridPath
Definition
SCR_InventoryStorageBaseUI.c:35
SCR_InventoryStorageBaseUI::GetItemComponentFromEntity
InventoryItemComponent GetItemComponentFromEntity(IEntity pEntity)
Definition
SCR_InventoryStorageBaseUI.c:1820
SCR_InventoryStorageBaseUI::m_Storage
BaseInventoryStorageComponent m_Storage
Definition
SCR_InventoryStorageBaseUI.c:21
SCR_InventoryStorageBaseUI::m_iMaxColumns
int m_iMaxColumns
Definition
SCR_InventoryStorageBaseUI.c:46
SCR_InventoryStorageBaseUI::m_widget
Widget m_widget
Definition
SCR_InventoryStorageBaseUI.c:33
SCR_InventoryWeaponSlotsUI::InitPaging
override void InitPaging()
Definition
SCR_InventoryWeaponSlotsUI.c:30
SCR_InventoryWeaponSlotsUI::GetAnalyticalItemSlotType
override SCR_EAnalyticalItemSlotType GetAnalyticalItemSlotType()
Definition
SCR_InventoryWeaponSlotsUI.c:12
SCR_InventoryWeaponSlotsUI::HandlerAttached
override void HandlerAttached(Widget w)
Definition
SCR_InventoryWeaponSlotsUI.c:18
SCR_InventoryWeaponSlotsUI::SetRowsAndColumns
override void SetRowsAndColumns()
Definition
SCR_InventoryWeaponSlotsUI.c:151
SCR_InventoryWeaponSlotsUI::CreateSlotUI
SCR_InventorySlotWeaponSlotsUI CreateSlotUI(InventoryItemComponent pComponent, int iSlotIndex, SCR_ItemAttributeCollection pAttributes=null, int iWeaponSlotIndex=-1, string sWeaponSlotType="")
Definition
SCR_InventoryWeaponSlotsUI.c:145
SCR_InventoryWeaponSlotsUI::m_aWeaponSlots
ref array< WeaponSlotComponent > m_aWeaponSlots
Definition
SCR_InventoryWeaponSlotsUI.c:8
SCR_InventoryWeaponSlotsUI::FillWithEmptySlots
override void FillWithEmptySlots()
Definition
SCR_InventoryWeaponSlotsUI.c:101
SCR_InventoryWeaponSlotsUI::GetActualSlotsUsedCount
int GetActualSlotsUsedCount()
Definition
SCR_InventoryWeaponSlotsUI.c:157
SCR_InventoryWeaponSlotsUI::IsTraversalAllowed
override bool IsTraversalAllowed()
Definition
SCR_InventoryWeaponSlotsUI.c:34
SCR_InventoryWeaponSlotsUI::SortSlots
void SortSlots()
Definition
SCR_InventoryWeaponSlotsUI.c:174
SCR_InventoryWeaponSlotsUI::UpdateOwnedSlots
void UpdateOwnedSlots(notnull array< IEntity > pItemsInStorage)
Definition
SCR_InventoryWeaponSlotsUI.c:76
SCR_InventoryWeaponSlotsUI::SCR_InventoryWeaponSlotsUI
void SCR_InventoryWeaponSlotsUI(BaseInventoryStorageComponent storage, LoadoutAreaType slotID=null, SCR_InventoryMenuUI menuManager=null, int iPage=0, array< BaseInventoryStorageComponent > aTraverseStorage=null)
Definition
SCR_InventoryWeaponSlotsUI.c:235
SCR_InventoryWeaponSlotsUI::CreateSlots
int CreateSlots()
Definition
SCR_InventoryWeaponSlotsUI.c:41
SCR_InventoryWeaponSlotsUI::InitMatrix
void InitMatrix()
Definition
SCR_InventoryWeaponSlotsUI.c:211
SCR_InventoryWeaponSlotsUI::m_weaponStorage
EquipedWeaponStorageComponent m_weaponStorage
Definition
SCR_InventoryWeaponSlotsUI.c:9
SCR_ItemAttributeCollection
Definition
SCR_ItemAttributeCollection.c:3
SCR_Matrix
Definition
SCR_Matrix.c:3
SizeLayoutWidget
Definition
SizeLayoutWidget.c:16
WeaponSlotComponent
Definition
WeaponSlotComponent.c:13
Widget
Definition
Widget.c:13
scripts
Game
UI
Inventory
SCR_InventoryWeaponSlotsUI.c
Generated by
1.17.0