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_PlayerSupplyAllocationUI.c
Go to the documentation of this file.
1
//PlayerSupplyAllocation Widget Handler
2
3
class
SCR_PlayerSupplyAllocationUI
:
ScriptedWidgetComponent
4
{
5
//Supplies text widget for showing up maximum amount of supplies Allocation and current supplies amount
6
[
Attribute
(
"MSARSuppliesText"
,
desc
:
"Text for displaying supplies related info to player"
)]
7
protected
ResourceName
m_sSuppliesText
;
8
9
//Number of currently available allocated supplies
10
[
Attribute
(
"0"
,
desc
:
"Available supplies Count"
)]
11
protected
int
m_iAvailableSuppliesAmount
;
12
13
//Current allocated supplies limit
14
[
Attribute
(
"0"
,
desc
:
"Allocated supplies limit"
)]
15
protected
int
m_iMaxAvailableSuppliesAmount
;
16
17
//Switch for allowing visible top limit of supplies, if set to true - there will be also top limit visible in inventory at all times no matter this setting
18
[
Attribute
(
"0"
,
desc
:
"Bool for switching between supplies amount display modes"
)]
19
protected
bool
m_bVisibleTopLimit
;
20
21
protected
int
m_iPlayerSupplyAllocationOffset
;
22
23
protected
RichTextWidget
m_wSuppliesText
;
24
25
protected
string
m_sSuppliesAmount
;
26
27
[
Attribute
(
"#AR-supplies_MSAR_Availability"
)]
28
protected
string
m_sAvailableText
;
29
30
[
Attribute
(
"#AR-supplies_MSAR_Availability_Long"
)]
31
protected
string
m_sAvailableTextLong
;
32
33
protected
PlayerController
m_PlayerController
=
GetGame
().GetPlayerController();
34
35
protected
SCR_PlayerSupplyAllocationComponent
m_PlayerSupplyAllocationComponent
;
36
37
//------------------------------------------------------------------------------------------------
40
override
void
HandlerAttached
(
Widget
w)
41
{
42
super.HandlerAttached(w);
43
44
if
(
SCR_Global
.
IsEditMode
() || !
m_PlayerController
)
45
{
46
w.SetVisible(
false
);
47
return
;
48
}
49
50
m_PlayerSupplyAllocationComponent
= SCR_PlayerSupplyAllocationComponent.Cast(
m_PlayerController
.FindComponent(SCR_PlayerSupplyAllocationComponent));
51
if
(!
m_PlayerSupplyAllocationComponent
|| !SCR_ArsenalManagerComponent.IsMilitarySupplyAllocationEnabled())
52
{
53
w.SetVisible(
false
);
54
return
;
55
}
56
57
w.SetVisible(
true
);
58
m_wSuppliesText
=
RichTextWidget
.Cast(w.GetParent().FindAnyWidget(
m_sSuppliesText
));
59
60
m_PlayerSupplyAllocationComponent
.GetOnAvailableAllocatedSuppliesChanged().Insert(
OnAvailableAllocatedSuppliesChanged
);
61
m_PlayerSupplyAllocationComponent
.GetOnMilitarySupplyAllocationChanged().Insert(
OnMilitarySupplyAllocationChanged
);
62
63
SCR_InventoryMenuUI
.
GetOnItemHover
().Insert(
OnItemHover
);
64
SCR_InventoryMenuUI
.
GetOnItemHoverEnd
().Insert(
OnItemHoverEnd
);
65
66
SetPlayerCurrentAndLimitAllocation
(w);
67
}
68
69
//------------------------------------------------------------------------------------------------
72
override
void
HandlerDeattached
(
Widget
w)
73
{
74
super.HandlerDeattached(w);
75
76
if
(
m_PlayerSupplyAllocationComponent
)
77
{
78
w.SetVisible(
false
);
79
m_PlayerSupplyAllocationComponent
.GetOnAvailableAllocatedSuppliesChanged().Remove(
OnAvailableAllocatedSuppliesChanged
);
80
m_PlayerSupplyAllocationComponent
.GetOnMilitarySupplyAllocationChanged().Remove(
OnMilitarySupplyAllocationChanged
);
81
}
82
83
SCR_InventoryMenuUI
.
GetOnItemHover
().Remove(
OnItemHover
);
84
SCR_InventoryMenuUI
.
GetOnItemHoverEnd
().Remove(
OnItemHoverEnd
);
85
}
86
87
//------------------------------------------------------------------------------------------------
88
protected
void
SetPlayerCurrentAndLimitAllocation
(
Widget
w)
89
{
90
if
(!
m_PlayerSupplyAllocationComponent
)
91
return
;
92
93
m_iAvailableSuppliesAmount
=
m_PlayerSupplyAllocationComponent
.GetPlayerAvailableAllocatedSupplies();
94
m_iMaxAvailableSuppliesAmount
=
m_PlayerSupplyAllocationComponent
.GetPlayerMilitarySupplyAllocation();
95
96
UpdateSupplyAmountText
();
97
}
98
99
//------------------------------------------------------------------------------------------------
101
protected
void
UpdateSupplyAmountText
()
102
{
103
if
(!
m_wSuppliesText
)
104
return
;
105
106
string
maxSuppliesString =
m_iMaxAvailableSuppliesAmount
.ToString();
107
if
(
m_iPlayerSupplyAllocationOffset
< 0)
108
maxSuppliesString = maxSuppliesString.Format(
"%1 (<color name='red'>%2</color>)"
, maxSuppliesString,
m_iPlayerSupplyAllocationOffset
.ToString());
109
else
if
(
m_iPlayerSupplyAllocationOffset
> 0)
110
maxSuppliesString = maxSuppliesString.Format(
"%1 (<color name='green'>+%2</color>)"
, maxSuppliesString,
m_iPlayerSupplyAllocationOffset
.ToString());
111
112
if
(
m_bVisibleTopLimit
)
113
//Formating String to display to player Available supplies/Max Available Supplies, 100/500 Available
114
m_wSuppliesText
.SetTextFormat(
m_sAvailableTextLong
,
m_iAvailableSuppliesAmount
, maxSuppliesString);
115
else
116
//Formating String to display to player Available supplies only 100 Available
117
m_wSuppliesText
.SetTextFormat(
m_sAvailableText
,
m_iAvailableSuppliesAmount
);
118
}
119
120
//------------------------------------------------------------------------------------------------
121
protected
void
OnItemHover
(
SCR_InventorySlotUI
slot)
122
{
123
if
(!slot || !SCR_ArsenalManagerComponent.IsMilitarySupplyAllocationEnabled())
124
return
;
125
126
SCR_ArsenalInventorySlotUI
arsenalSlot =
SCR_ArsenalInventorySlotUI
.Cast(slot);
127
if
(arsenalSlot)
128
{
129
// Item to be purchased, show the effect of the purchase on MSAR
130
m_iPlayerSupplyAllocationOffset
= -arsenalSlot.
GetPersonalResourceCost
();
131
UpdateSupplyAmountText
();
132
}
133
else
134
{
135
// Item to be refunded, show the effect of the refund on MSAR
136
m_iPlayerSupplyAllocationOffset
=
GetItemPlayerSupplyAllocationRefundValue
(slot);
137
UpdateSupplyAmountText
();
138
}
139
}
140
141
//------------------------------------------------------------------------------------------------
142
protected
void
OnItemHoverEnd
()
143
{
144
m_iPlayerSupplyAllocationOffset
= 0;
145
UpdateSupplyAmountText
();
146
}
147
148
//------------------------------------------------------------------------------------------------
151
void
OnLoadoutSelected
(
SCR_BasePlayerLoadout
loadout
)
152
{
153
if
(!
m_PlayerController
)
154
return
;
155
156
SCR_ArsenalManagerComponent arsenalManager;
157
SCR_ArsenalManagerComponent.GetArsenalManager(arsenalManager);
158
if
(!arsenalManager)
159
return
;
160
161
m_iPlayerSupplyAllocationOffset
= -arsenalManager.GetLoadoutMilitarySupplyAllocationCost(
loadout
,
m_PlayerController
.GetPlayerId());
162
UpdateSupplyAmountText
();
163
}
164
165
//------------------------------------------------------------------------------------------------
166
protected
int
GetItemPlayerSupplyAllocationRefundValue
(
SCR_InventorySlotUI
slot)
167
{
168
SCR_InventoryMenuUI
inventoryMenu =
SCR_InventoryMenuUI
.
GetInventoryMenu
();
169
if
(!inventoryMenu)
170
return
0;
171
172
SCR_InventoryStorageBaseUI
storageUI = inventoryMenu.
GetLootStorage
();
173
if
(!storageUI)
174
return
0;
175
176
BaseInventoryStorageComponent storage = storageUI.GetCurrentNavigationStorage();
177
if
(!storage)
178
return
0;
179
180
IEntity
storageOwner = storage.GetOwner();
181
if
(!storageOwner)
182
return
0;
183
184
SCR_ArsenalComponent
arsenalComp =
SCR_ArsenalComponent
.Cast(storageOwner.
FindComponent
(
SCR_ArsenalComponent
));
185
if
(!arsenalComp)
186
return
0;
187
188
SCR_ChimeraCharacter character = SCR_ChimeraCharacter.Cast(
SCR_PlayerController
.
GetLocalControlledEntity
());
189
if
(!character)
190
return
0;
191
192
if
(arsenalComp.
GetAssignedFaction
() != character.GetFaction())
193
return
0;
194
195
InventoryItemComponent
item = slot.
GetInventoryItemComponent
();
196
if
(!item)
197
return
0;
198
199
IEntity
itemEntity = item.GetOwner();
200
if
(!itemEntity)
201
return
0;
202
203
SCR_ArsenalManagerComponent arsenalManager;
204
if
(!SCR_ArsenalManagerComponent.GetArsenalManager(arsenalManager))
205
return
0;
206
207
return
arsenalManager.GetItemMilitarySupplyAllocationRefundAmount(itemEntity, arsenalComp);
208
}
209
210
//------------------------------------------------------------------------------------------------
213
protected
void
OnAvailableAllocatedSuppliesChanged
(
int
amount)
214
{
215
if
(
m_iAvailableSuppliesAmount
== amount)
216
return
;
217
218
m_iAvailableSuppliesAmount
= amount;
219
UpdateSupplyAmountText
();
220
}
221
222
//------------------------------------------------------------------------------------------------
225
protected
void
OnMilitarySupplyAllocationChanged
(
int
amount)
226
{
227
if
(
m_iMaxAvailableSuppliesAmount
== amount)
228
return
;
229
230
m_iMaxAvailableSuppliesAmount
= amount;
231
UpdateSupplyAmountText
();
232
}
233
}
GetGame
ArmaReforgerScripted GetGame()
Definition
game.c:1398
loadout
string loadout
Definition
SCR_ArsenalManagerComponent.c:0
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition
SCR_RespawnBriefingComponent.c:17
IEntity
Definition
IEntity.c:13
IEntity::FindComponent
proto external Managed FindComponent(typename typeName)
InventoryItemComponent
Definition
InventoryItemComponent.c:13
ResourceName
Definition
ResourceName.c:13
RichTextWidget
Definition
RichTextWidget.c:13
SCR_ArsenalComponent
Definition
SCR_ArsenalComponent.c:10
SCR_ArsenalComponent::GetAssignedFaction
SCR_Faction GetAssignedFaction()
Definition
SCR_ArsenalComponent.c:313
SCR_ArsenalInventorySlotUI
Definition
SCR_ArsenalInventorySlotUI.c:3
SCR_ArsenalInventorySlotUI::GetPersonalResourceCost
int GetPersonalResourceCost()
Definition
SCR_ArsenalInventorySlotUI.c:207
SCR_BasePlayerLoadout
Definition
SCR_BasePlayerLoadout.c:3
SCR_Global
Definition
Functions.c:7
SCR_Global::IsEditMode
static bool IsEditMode()
Definition
Functions.c:1566
SCR_InventoryMenuUI
Definition
SCR_InventoryMenuUI.c:286
SCR_InventoryMenuUI::GetOnItemHoverEnd
static ScriptInvoker GetOnItemHoverEnd()
Definition
SCR_InventoryMenuUI.c:466
SCR_InventoryMenuUI::GetLootStorage
SCR_InventoryStorageBaseUI GetLootStorage()
Definition
SCR_InventoryMenuUI.c:726
SCR_InventoryMenuUI::GetOnItemHover
static ScriptInvokerInventorySlotHover GetOnItemHover()
Definition
SCR_InventoryMenuUI.c:457
SCR_InventoryMenuUI::GetInventoryMenu
static SCR_InventoryMenuUI GetInventoryMenu()
Definition
SCR_InventoryMenuUI.c:5673
SCR_InventorySlotUI
Definition
SCR_InventorySlotUI.c:26
SCR_InventorySlotUI::GetInventoryItemComponent
InventoryItemComponent GetInventoryItemComponent()
Definition
SCR_InventorySlotUI.c:621
SCR_InventoryStorageBaseUI
Definition
SCR_InventoryStorageBaseUI.c:7
SCR_PlayerController
Definition
SCR_PlayerController.c:31
SCR_PlayerController::GetLocalControlledEntity
static IEntity GetLocalControlledEntity()
Definition
SCR_PlayerController.c:495
SCR_PlayerSupplyAllocationUI
Definition
SCR_PlayerSupplyAllocationUI.c:4
SCR_PlayerSupplyAllocationUI::m_sAvailableText
string m_sAvailableText
Definition
SCR_PlayerSupplyAllocationUI.c:28
SCR_PlayerSupplyAllocationUI::m_wSuppliesText
RichTextWidget m_wSuppliesText
Definition
SCR_PlayerSupplyAllocationUI.c:23
SCR_PlayerSupplyAllocationUI::m_iMaxAvailableSuppliesAmount
int m_iMaxAvailableSuppliesAmount
Definition
SCR_PlayerSupplyAllocationUI.c:15
SCR_PlayerSupplyAllocationUI::m_sSuppliesText
ResourceName m_sSuppliesText
Definition
SCR_PlayerSupplyAllocationUI.c:7
SCR_PlayerSupplyAllocationUI::OnItemHoverEnd
void OnItemHoverEnd()
Definition
SCR_PlayerSupplyAllocationUI.c:142
SCR_PlayerSupplyAllocationUI::m_sAvailableTextLong
string m_sAvailableTextLong
Definition
SCR_PlayerSupplyAllocationUI.c:31
SCR_PlayerSupplyAllocationUI::m_PlayerSupplyAllocationComponent
SCR_PlayerSupplyAllocationComponent m_PlayerSupplyAllocationComponent
Definition
SCR_PlayerSupplyAllocationUI.c:35
SCR_PlayerSupplyAllocationUI::m_PlayerController
PlayerController m_PlayerController
Definition
SCR_PlayerSupplyAllocationUI.c:33
SCR_PlayerSupplyAllocationUI::GetItemPlayerSupplyAllocationRefundValue
int GetItemPlayerSupplyAllocationRefundValue(SCR_InventorySlotUI slot)
Definition
SCR_PlayerSupplyAllocationUI.c:166
SCR_PlayerSupplyAllocationUI::m_bVisibleTopLimit
bool m_bVisibleTopLimit
Definition
SCR_PlayerSupplyAllocationUI.c:19
SCR_PlayerSupplyAllocationUI::m_sSuppliesAmount
string m_sSuppliesAmount
Definition
SCR_PlayerSupplyAllocationUI.c:25
SCR_PlayerSupplyAllocationUI::m_iAvailableSuppliesAmount
int m_iAvailableSuppliesAmount
Definition
SCR_PlayerSupplyAllocationUI.c:11
SCR_PlayerSupplyAllocationUI::m_iPlayerSupplyAllocationOffset
int m_iPlayerSupplyAllocationOffset
Definition
SCR_PlayerSupplyAllocationUI.c:21
SCR_PlayerSupplyAllocationUI::OnLoadoutSelected
void OnLoadoutSelected(SCR_BasePlayerLoadout loadout)
Definition
SCR_PlayerSupplyAllocationUI.c:151
SCR_PlayerSupplyAllocationUI::UpdateSupplyAmountText
void UpdateSupplyAmountText()
Sets the Supplies text to current amount of available and allocated supplies.
Definition
SCR_PlayerSupplyAllocationUI.c:101
SCR_PlayerSupplyAllocationUI::HandlerDeattached
override void HandlerDeattached(Widget w)
Definition
SCR_PlayerSupplyAllocationUI.c:72
SCR_PlayerSupplyAllocationUI::OnItemHover
void OnItemHover(SCR_InventorySlotUI slot)
Definition
SCR_PlayerSupplyAllocationUI.c:121
SCR_PlayerSupplyAllocationUI::HandlerAttached
override void HandlerAttached(Widget w)
Definition
SCR_PlayerSupplyAllocationUI.c:40
SCR_PlayerSupplyAllocationUI::SetPlayerCurrentAndLimitAllocation
void SetPlayerCurrentAndLimitAllocation(Widget w)
Definition
SCR_PlayerSupplyAllocationUI.c:88
SCR_PlayerSupplyAllocationUI::OnMilitarySupplyAllocationChanged
void OnMilitarySupplyAllocationChanged(int amount)
Definition
SCR_PlayerSupplyAllocationUI.c:225
SCR_PlayerSupplyAllocationUI::OnAvailableAllocatedSuppliesChanged
void OnAvailableAllocatedSuppliesChanged(int amount)
Definition
SCR_PlayerSupplyAllocationUI.c:213
ScriptedWidgetComponent
Definition
ScriptedWidgetComponent.c:13
Widget
Definition
Widget.c:13
Attribute
SCR_FieldOfViewSettings Attribute
Definition
SendGoalMessage.c:170
scripts
Game
UI
Menu
DeployMenu
SCR_PlayerSupplyAllocationUI.c
Generated by
1.17.0