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_LoadoutStatistics.c
Go to the documentation of this file.
1
2
3
//------------------------------------------------------------------------------------------------
4
class
SCR_LoadoutStatisticsComponent
:
ScriptedWidgetComponent
5
{
6
[
Attribute
()]
7
protected
ref array<ref LoadoutStatSet>
m_aLoadouts
;
8
9
// Resources
10
protected
const
ResourceName
ENTRY_LAYOUT
=
"{C87F7F6734B61688}UI/layouts/Menus/Career/CareerEntry.layout"
;
11
12
// Strings
13
protected
const
string
WIDGET_LOADOUT_SPIN
=
"SpinLoadout"
;
14
protected
const
string
WIDGET_STAT_LIST
=
"vStatList"
;
15
16
// Widgets
17
protected
Widget
m_wRoot
;
18
protected
Widget
m_wStatList
;
19
protected
Widget
m_wLoadoutSpin
;
20
21
// Objects and references
22
protected
CareerMenuUI
m_CareerUI
;
23
protected
SCR_SpinBoxComponent
m_LoadoutSpin
;
24
25
protected
ref array<ref Widget>
m_aStatWidgets
=
new
array<ref Widget>();
26
27
// Values
28
protected
int
m_iEntryCount
= 0;
29
protected
int
m_iSelected
= 0;
30
31
ref
ScriptInvoker
m_OnLoadoutChange
=
new
ScriptInvoker
();
32
33
//------------------------------------------------------------------------------------------------
34
override
void
HandlerAttached
(
Widget
w)
35
{
36
m_wRoot
= w;
37
m_wStatList
= w.FindAnyWidget(
WIDGET_STAT_LIST
);
38
39
// Loadout spin
40
m_wLoadoutSpin
= w.FindAnyWidget(
WIDGET_LOADOUT_SPIN
);
41
if
(
m_wLoadoutSpin
)
42
m_LoadoutSpin
=
SCR_SpinBoxComponent
.Cast(
m_wLoadoutSpin
.FindHandler(
SCR_SpinBoxComponent
));
43
44
if
(
m_LoadoutSpin
)
45
m_LoadoutSpin
.m_OnChanged.Insert(
OnLoadoutChanged
);
46
47
// Setup
48
SetupLoadoutSpin
();
49
CreateStatEntries
(
m_iEntryCount
);
50
51
OnLoadoutChanged
(null,
m_LoadoutSpin
.GetCurrentIndex());
52
}
53
54
//------------------------------------------------------------------------------------------------
56
protected
void
SetupLoadoutSpin
()
57
{
58
if
(!
m_LoadoutSpin
)
59
return
;
60
61
// Get info from loadout stats
62
int
total =
m_aLoadouts
.Count();
63
foreach
(
int
i,
LoadoutStatSet
statSet :
m_aLoadouts
)
64
{
65
if
(!statSet)
66
continue
;
67
68
m_LoadoutSpin
.AddItem(statSet.GetLoadout().GetLoadoutName(), i == total - 1);
69
70
// Get max entry count
71
int
c = 0;
72
if
(statSet)
73
{
74
if
(statSet.GetStats())
75
c = statSet.GetStats().Count();
76
}
77
78
if
(c >
m_iEntryCount
)
79
m_iEntryCount
= c;
80
}
81
}
82
83
//------------------------------------------------------------------------------------------------
84
protected
void
CreateStatEntries
(
int
count)
85
{
86
for
(
int
i = 0; i < count; i++)
87
{
88
Widget
entry =
GetGame
().GetWorkspace().CreateWidgets(
ENTRY_LAYOUT
,
m_wStatList
);
89
m_aStatWidgets
.Insert(entry);
90
entry.SetVisible(
false
);
91
}
92
}
93
94
//------------------------------------------------------------------------------------------------
95
protected
void
OnLoadoutChanged
(
SCR_SpinBoxComponent
spin,
int
id
)
96
{
97
UpdateStats
(
id
);
98
m_OnLoadoutChange
.Invoke(
id
);
99
}
100
101
//------------------------------------------------------------------------------------------------
102
void
UpdateStats
(
int
id
)
103
{
104
m_iSelected
=
id
;
105
int
count = 0;
106
if
(
m_aLoadouts
[
id
])
107
{
108
if
(
m_aLoadouts
[
id
].GetStats())
109
count =
m_aLoadouts
[
id
].GetStats().Count();
110
}
111
112
for
(
int
i = 0; i <
m_aStatWidgets
.Count(); i++)
113
{
114
Widget
entry =
m_aStatWidgets
[i];
115
116
bool
display = i < count;
117
// Hiding entries
118
entry.SetVisible(display);
119
if
(!display)
120
continue
;
121
122
string
name =
m_aLoadouts
[
id
].GetStats()[i].m_sName;
123
int
valueId =
m_aLoadouts
[
id
].GetStats()[i].m_iValueId;
124
string
value =
""
;
125
if
(
m_CareerUI
)
126
value =
m_CareerUI
.GetBackendValues()[valueId];
127
SetStatEntry
(
""
, name, value, entry);
128
}
129
}
130
131
//------------------------------------------------------------------------------------------------
132
protected
void
SetStatEntry
(
string
sName,
string
sLabel,
string
sValue,
Widget
wEntry = null)
133
{
134
if
(!wEntry)
135
return
;
136
137
SetStatLabel
(sName, sLabel, wEntry);
138
SetStatValue
(sName, sValue, wEntry);
139
}
140
141
//------------------------------------------------------------------------------------------------
142
protected
void
SetStatLabel
(
string
sName,
string
sLabel,
Widget
wEntry = null)
143
{
144
if
(!wEntry)
145
return
;
146
147
const
string
sLabelName =
"txtLabel"
;
148
TextWidget
wLabel =
TextWidget
.Cast(wEntry.FindAnyWidget(sLabelName));
149
if
(wLabel)
150
wLabel.SetText(sLabel);
151
}
152
153
//------------------------------------------------------------------------------------------------
154
protected
void
SetStatValue
(
string
sName,
string
sValue,
Widget
wEntry = null)
155
{
156
if
(!wEntry)
157
return
;
158
159
const
string
sValueName =
"txtValue"
;
160
TextWidget
wValue =
TextWidget
.Cast(wEntry.FindAnyWidget(sValueName));
161
if
(wValue)
162
wValue.SetText(sValue);
163
}
164
165
//------------------------------------------------------------------------------------------------
166
array<ref LoadoutStatSet>
GetLodoutStatSets
() {
return
m_aLoadouts
; }
167
int
GetCurrentLoadoutId
() {
return
m_iSelected
; }
168
169
//------------------------------------------------------------------------------------------------
170
void
SetCareerUI
(
CareerMenuUI
careerUI) {
m_CareerUI
= careerUI; }
171
};
172
173
//------------------------------------------------------------------------------------------------
175
[
BaseContainerProps
()]
176
class
LoadoutStatSet
177
{
178
[
Attribute
(
""
,
UIWidgets
.Object,
""
)]
179
protected
ref
SCR_BasePlayerLoadout
m_Loadout
;
180
[
Attribute
()]
181
protected
ref array<ref LoadoutStat>
m_aStats
;
182
183
SCR_BasePlayerLoadout
GetLoadout
() {
return
m_Loadout
; }
184
array<ref LoadoutStat>
GetStats
() {
return
m_aStats
; }
185
};
186
187
//------------------------------------------------------------------------------------------------
188
[
BaseContainerProps
()]
189
class
LoadoutStat
190
{
191
[
Attribute
()]
192
string
m_sName;
193
/*[Attribute()]
194
string m_sValue; */
195
[
Attribute
(
"0"
, uiwidget:
UIWidgets
.ComboBox,
""
,
""
, ParamEnumArray.FromEnum(
ECareerStatId
))]
196
ECareerStatId
m_iValueId;
197
};
id
AddonBuildInfoTool id
ECareerStatId
ECareerStatId
Ids to receive all.
Definition
CareerMenuUI.c:232
GetGame
ArmaReforgerScripted GetGame()
Definition
game.c:1398
BaseContainerProps
SCR_AIAnimation_Loitering BaseContainerProps
Commanding menu commanding element class.
Definition
SCR_AIAnimationWaypoint.c:14
UpdateStats
void UpdateStats()
Definition
SCR_NetworkedStatsComponent.c:85
CareerMenuUI
Definition
CareerMenuUI.c:3
LoadoutStat
Definition
SCR_LoadoutStatistics.c:190
LoadoutStatSet
Definition
SCR_LoadoutStatistics.c:177
LoadoutStatSet::m_aStats
ref array< ref LoadoutStat > m_aStats
Definition
SCR_LoadoutStatistics.c:181
LoadoutStatSet::GetLoadout
SCR_BasePlayerLoadout GetLoadout()
Definition
SCR_LoadoutStatistics.c:183
LoadoutStatSet::GetStats
array< ref LoadoutStat > GetStats()
Definition
SCR_LoadoutStatistics.c:184
LoadoutStatSet::m_Loadout
ref SCR_BasePlayerLoadout m_Loadout
Definition
SCR_LoadoutStatistics.c:179
ResourceName
Definition
ResourceName.c:13
SCR_BasePlayerLoadout
Definition
SCR_BasePlayerLoadout.c:3
SCR_LoadoutStatisticsComponent
Class for switching and displaying stats for different loadouts.
Definition
SCR_LoadoutStatistics.c:5
SCR_LoadoutStatisticsComponent::m_wRoot
Widget m_wRoot
Definition
SCR_LoadoutStatistics.c:17
SCR_LoadoutStatisticsComponent::SetCareerUI
void SetCareerUI(CareerMenuUI careerUI)
Definition
SCR_LoadoutStatistics.c:170
SCR_LoadoutStatisticsComponent::GetLodoutStatSets
array< ref LoadoutStatSet > GetLodoutStatSets()
Definition
SCR_LoadoutStatistics.c:166
SCR_LoadoutStatisticsComponent::m_wLoadoutSpin
Widget m_wLoadoutSpin
Definition
SCR_LoadoutStatistics.c:19
SCR_LoadoutStatisticsComponent::SetStatValue
void SetStatValue(string sName, string sValue, Widget wEntry=null)
Definition
SCR_LoadoutStatistics.c:154
SCR_LoadoutStatisticsComponent::WIDGET_STAT_LIST
const string WIDGET_STAT_LIST
Definition
SCR_LoadoutStatistics.c:14
SCR_LoadoutStatisticsComponent::UpdateStats
void UpdateStats(int id)
Definition
SCR_LoadoutStatistics.c:102
SCR_LoadoutStatisticsComponent::m_iSelected
int m_iSelected
Definition
SCR_LoadoutStatistics.c:29
SCR_LoadoutStatisticsComponent::CreateStatEntries
void CreateStatEntries(int count)
Definition
SCR_LoadoutStatistics.c:84
SCR_LoadoutStatisticsComponent::SetStatLabel
void SetStatLabel(string sName, string sLabel, Widget wEntry=null)
Definition
SCR_LoadoutStatistics.c:142
SCR_LoadoutStatisticsComponent::m_LoadoutSpin
SCR_SpinBoxComponent m_LoadoutSpin
Definition
SCR_LoadoutStatistics.c:23
SCR_LoadoutStatisticsComponent::ENTRY_LAYOUT
const ResourceName ENTRY_LAYOUT
Definition
SCR_LoadoutStatistics.c:10
SCR_LoadoutStatisticsComponent::SetStatEntry
void SetStatEntry(string sName, string sLabel, string sValue, Widget wEntry=null)
Definition
SCR_LoadoutStatistics.c:132
SCR_LoadoutStatisticsComponent::GetCurrentLoadoutId
int GetCurrentLoadoutId()
Definition
SCR_LoadoutStatistics.c:167
SCR_LoadoutStatisticsComponent::m_OnLoadoutChange
ref ScriptInvoker m_OnLoadoutChange
Definition
SCR_LoadoutStatistics.c:31
SCR_LoadoutStatisticsComponent::m_wStatList
Widget m_wStatList
Definition
SCR_LoadoutStatistics.c:18
SCR_LoadoutStatisticsComponent::HandlerAttached
override void HandlerAttached(Widget w)
Definition
SCR_LoadoutStatistics.c:34
SCR_LoadoutStatisticsComponent::WIDGET_LOADOUT_SPIN
const string WIDGET_LOADOUT_SPIN
Definition
SCR_LoadoutStatistics.c:13
SCR_LoadoutStatisticsComponent::SetupLoadoutSpin
void SetupLoadoutSpin()
Fill spin.
Definition
SCR_LoadoutStatistics.c:56
SCR_LoadoutStatisticsComponent::m_iEntryCount
int m_iEntryCount
Definition
SCR_LoadoutStatistics.c:28
SCR_LoadoutStatisticsComponent::m_CareerUI
CareerMenuUI m_CareerUI
Definition
SCR_LoadoutStatistics.c:22
SCR_LoadoutStatisticsComponent::m_aLoadouts
ref array< ref LoadoutStatSet > m_aLoadouts
Definition
SCR_LoadoutStatistics.c:7
SCR_LoadoutStatisticsComponent::m_aStatWidgets
ref array< ref Widget > m_aStatWidgets
Definition
SCR_LoadoutStatistics.c:25
SCR_LoadoutStatisticsComponent::OnLoadoutChanged
void OnLoadoutChanged(SCR_SpinBoxComponent spin, int id)
Definition
SCR_LoadoutStatistics.c:95
SCR_SpinBoxComponent
Definition
SCR_SpinBoxComponent.c:2
ScriptedWidgetComponent
Definition
ScriptedWidgetComponent.c:13
TextWidget
Definition
TextWidget.c:16
UIWidgets
Definition
attributes.c:40
Widget
Definition
Widget.c:13
Attribute
SCR_FieldOfViewSettings Attribute
Definition
SendGoalMessage.c:170
ScriptInvoker
ScriptInvokerBase< func > ScriptInvoker
Definition
tools.c:134
scripts
Game
UI
Menu
Career
SCR_LoadoutStatistics.c
Generated by
1.17.0