Arma Reforger Explorer
1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Toggle main menu visibility
Loading...
Searching...
No Matches
CareerMenuUI.c
Go to the documentation of this file.
1
//------------------------------------------------------------------------------------------------
2
class
CareerMenuUI
:
ChimeraMenuBase
3
{
4
// Widget names
5
protected
const
string
WIDGET_NAME_EDIT
=
"editPlayerName"
;
6
protected
const
string
WIDGET_LOADOUT_STATS
=
"hLoadoutPanel"
;
7
protected
const
string
WIDGET_CHARACTER_PREVIEW
=
"CharacterPreview"
;
8
9
protected
const
string
STRING_UNKNOWN_STAT
=
"Unknown"
;
10
11
// Resources
12
const
ResourceName
ENTRY_LAYOUT
=
"{C87F7F6734B61688}UI/layouts/Menus/Career/CareerEntry.layout"
;
13
14
// Components
15
protected
ref
SCR_EditBoxComponent
m_EditPlayerName
;
16
protected
ref
SCR_LoadoutPreviewComponent
m_LoadoutPreview
;
17
protected
SCR_LoadoutManager
m_LoadoutManager
;
18
protected
ref
SCR_LoadoutStatisticsComponent
m_LoadoutStatistics
;
19
20
// Widgets
21
protected
Widget
m_wEditPlayerName
;
22
23
//private EditBoxWidget m_ProfileEditbox;
24
//private Widget m_ProfileData;
25
protected
ref array<string>
m_aBackendValues
=
new
array<string>();
26
27
// Values
28
static
CareerMenuUI
m_sInstance
;
29
ref
CareerBackendData
m_BackendData
;
30
protected
ref
BackendCallback
m_Callback
=
new
BackendCallback
();
31
32
[
MenuBindAttribute
()]
33
ButtonWidget
Back
;
34
35
//------------------------------------------------------------------------------------------------
36
[
MenuBindAttribute
()]
37
void
Back
()
38
{
39
if
(
IsFocused
())
40
Close
();
41
}
42
43
//------------------------------------------------------------------------------------------------
44
protected
void
CreateStatEntry
(
Widget
wParent,
string
sName,
string
sLabel,
string
sValue)
45
{
46
Widget
entry =
GetGame
().GetWorkspace().CreateWidgets(
ENTRY_LAYOUT
, wParent);
47
entry.SetName(sName);
48
49
// Setup label
50
const
string
sLabelName =
"txtLabel"
;
51
TextWidget
wLabel =
TextWidget
.Cast(entry.FindAnyWidget(sLabelName));
52
if
(wLabel)
53
wLabel.SetText(sLabel);
54
55
ItemPreviewWidget
preview;
56
57
// set value
58
//SetStatValue(sName, sValue);
59
}
60
61
//------------------------------------------------------------------------------------------------
62
override
bool
OnChange
(
Widget
w,
bool
finished)
63
{
64
if
(!finished || !
m_EditPlayerName
|| w !=
m_EditPlayerName
.GetRootWidget())
65
return
false
;
66
67
// TODO: Future feature of custom name
68
69
return
false
;
70
}
71
72
//------------------------------------------------------------------------------------------------\
73
protected void OnPlayerNameConfirm(string value)
74
{
75
if
(value.IsEmpty())
76
return
;
77
78
string
nameOld
=
SCR_Global
.GetProfileName();
79
//string nameNew = m_ProfileEditbox.GetText();
80
string
nameNew
=
m_EditPlayerName
.GetValue();
81
nameNew
=
nameNew
.Trim();
82
// TODO: Future feature of custom name
83
m_EditPlayerName
.SetValue(
nameOld
);
84
}
85
86
//------------------------------------------------------------------------------------------------
87
void
UpdateCareerData
()
88
{
89
if
(!
m_BackendData
)
90
return
;
91
Widget
wClassList =
GetGame
().GetWorkspace().FindAnyWidget(
"vStatList"
);
92
93
if
(
m_aBackendValues
.Count() == 0)
94
{
95
// Prepare stats array
96
typename
stats =
ECareerStatId
;
97
int
count = stats.GetVariableCount();
98
for
(
int
i = 0; i < count; i++)
99
{
100
m_aBackendValues
.Insert(
""
);
101
}
102
}
103
104
// General
105
m_aBackendValues
[
ECareerStatId
.KILLS] =
m_BackendData
.GetKills().ToString();
106
m_aBackendValues
[
ECareerStatId
.DEATHS] =
m_BackendData
.GetDeaths().ToString();
107
m_aBackendValues
[
ECareerStatId
.FRIENDLY_KILLS] =
m_BackendData
.GetFriendlyKills().ToString();
108
109
// Playtime
110
m_aBackendValues
[
ECareerStatId
.PLAYTIME_RIFFLEMAN] =
STRING_UNKNOWN_STAT
;
111
m_aBackendValues
[
ECareerStatId
.PLAYIME_SHARPSHOOTER] =
STRING_UNKNOWN_STAT
;
112
113
// Weapons
114
m_aBackendValues
[
ECareerStatId
.HEADSHOTS] =
STRING_UNKNOWN_STAT
;
115
116
if
(
m_LoadoutStatistics
)
117
m_LoadoutStatistics
.UpdateStats(
m_LoadoutStatistics
.GetCurrentLoadoutId());
118
}
119
120
//------------------------------------------------------------------------------------------------
121
array<string>
GetBackendValues
() {
return
m_aBackendValues
; }
122
123
//------------------------------------------------------------------------------------------------
124
protected
void
TestingShow
()
125
{
126
Widget
wEntry =
GetRootWidget
().FindAnyWidget(
"StatEntry"
);
127
128
}
129
130
//------------------------------------------------------------------------------------------------
131
override
void
OnMenuUpdate
(
float
tDelta)
132
{
133
if
(!
m_BackendData
&&
BackendAuthenticatorApi
.IsAuthenticated())
134
{
135
m_BackendData
=
new
CareerBackendData
;
136
BackendApi
backendApi =
GetGame
().GetBackendApi();
137
if
(backendApi)
138
{
139
m_Callback
.SetOnSuccess(
UpdateCareerData
);
140
/*
141
PlayerId was forced to 0 = invalid player. Have no idea what the original autor had
142
in mind, but I'm trying to leave it in the same state as it was before.
143
//TODO@Buracisko - check this after IdentityManager integration
144
*/
145
backendApi.PlayerCharacterGet(
m_Callback
,
m_BackendData
, 0);
146
}
147
}
148
149
super.OnMenuUpdate(tDelta);
150
}
151
152
//------------------------------------------------------------------------------------------------
153
override
void
OnMenuShow
()
154
{
155
// Disallow changing profile name on consoles
156
#ifndef PLATFORM_WINDOWS
157
if
(
m_wEditPlayerName
)
158
m_wEditPlayerName
.SetEnabled(
false
);
159
#endif
160
161
// Player name edit
162
m_wEditPlayerName
=
GetRootWidget
().FindAnyWidget(
WIDGET_NAME_EDIT
);
163
if
(
m_wEditPlayerName
)
164
m_EditPlayerName
=
SCR_EditBoxComponent
.Cast(
m_wEditPlayerName
.FindHandler(
SCR_EditBoxComponent
));
165
166
if
(
m_EditPlayerName
)
167
{
168
// Listeners
169
m_EditPlayerName
.m_OnConfirm.Insert(OnPlayerNameConfirm);
170
// Setup text
171
string
profileName =
SCR_Global
.GetProfileName();
172
m_EditPlayerName
.SetValue(profileName);
173
}
174
175
super.OnMenuShow();
176
}
177
178
//------------------------------------------------------------------------------------------------
179
override
void
OnMenuOpen
()
180
{
181
Widget
w =
GetRootWidget
();
182
m_sInstance
=
this
;
183
InputManager
inputManager =
GetGame
().GetInputManager();
184
inputManager.AddActionListener(
UIConstants
.MENU_ACTION_BACK,
EActionTrigger
.PRESSED,
Back
);
185
186
// Preview character
187
Widget
wCharacterPreview =
GetRootWidget
().FindAnyWidget(
WIDGET_CHARACTER_PREVIEW
);
188
if
(wCharacterPreview)
189
m_LoadoutPreview
=
SCR_LoadoutPreviewComponent
.Cast(wCharacterPreview.FindHandler(
SCR_LoadoutPreviewComponent
));
190
191
//m_LoadoutManager = SCR_LoadoutManager.GetInstance();
192
193
// Loadout stats
194
Widget
wLoadoutStats =
GetRootWidget
().FindAnyWidget(
WIDGET_LOADOUT_STATS
);
195
if
(wLoadoutStats)
196
m_LoadoutStatistics
=
SCR_LoadoutStatisticsComponent
.Cast(wLoadoutStats.FindHandler(
SCR_LoadoutStatisticsComponent
));
197
198
if
(
m_LoadoutStatistics
)
199
{
200
m_LoadoutStatistics
.SetCareerUI(
this
);
201
m_LoadoutStatistics
.m_OnLoadoutChange.Insert(
OnLoadoutChange
);
202
OnLoadoutChange
(
m_LoadoutStatistics
.GetCurrentLoadoutId());
203
}
204
205
super.OnMenuOpen();
206
}
207
208
//------------------------------------------------------------------------------------------------
209
override
void
OnMenuClose
()
210
{
211
m_sInstance
= null;
212
213
super.OnMenuClose();
214
}
215
216
//------------------------------------------------------------------------------------------------
217
protected
void
OnLoadoutChange
(
int
id
)
218
{
219
if
(!
m_LoadoutPreview
|| !
m_LoadoutStatistics
)
220
return
;
221
222
//m_LoadoutPreview.SetPreviewedLoadout(m_LoadoutManager.m_aPlayerLoadouts[0]);
223
LoadoutStatSet
statSet =
m_LoadoutStatistics
.GetLodoutStatSets()[
id
];
224
if
(statSet)
225
m_LoadoutPreview
.SetPreviewedLoadout(statSet.
GetLoadout
());
226
}
227
};
228
229
//------------------------------------------------------------------------------------------------
231
enum
ECareerStatId
232
{
233
// General
234
KILLS
,
235
DEATHS
,
236
FRIENDLY_KILLS
,
237
238
// Play times
239
PLAYTIME_RIFFLEMAN
,
240
PLAYIME_SHARPSHOOTER
,
241
242
// Weapons
243
HEADSHOTS
,
244
};
245
id
AddonBuildInfoTool id
ECareerStatId
ECareerStatId
Ids to receive all.
Definition
CareerMenuUI.c:232
HEADSHOTS
@ HEADSHOTS
Definition
CareerMenuUI.c:243
PLAYIME_SHARPSHOOTER
@ PLAYIME_SHARPSHOOTER
Definition
CareerMenuUI.c:240
PLAYTIME_RIFFLEMAN
@ PLAYTIME_RIFFLEMAN
Definition
CareerMenuUI.c:239
GetGame
ArmaReforgerScripted GetGame()
Definition
game.c:1398
SCR_LoadoutManager
void SCR_LoadoutManager(IEntitySource src, IEntity parent)
Definition
SCR_LoadoutManager.c:569
IsFocused
bool IsFocused()
Definition
SCR_MapToolMenuUI.c:464
GetRootWidget
Widget GetRootWidget()
Definition
SCR_ModularButtonComponent.c:189
DEATHS
@ DEATHS
Deaths.
Definition
SCR_PlayerData.c:934
KILLS
@ KILLS
Enemies killed.
Definition
SCR_PlayerData.c:928
FRIENDLY_KILLS
@ FRIENDLY_KILLS
Friendly human kills.
Definition
SCR_PlayerData.c:932
Close
proto native void Close()
Definition
SCR_WorkshopDialogs.c:77
BackendApi
Backend Api instance.
Definition
BackendApi.c:14
BackendAuthenticatorApi
Definition
BackendAuthenticatorApi.c:21
BackendCallback
Definition
Backend_Storage.c:5
ButtonWidget
Definition
ButtonWidget.c:16
CareerBackendData
Definition
CareerBackend.c:44
CareerMenuUI
Definition
CareerMenuUI.c:3
CareerMenuUI::TestingShow
void TestingShow()
Definition
CareerMenuUI.c:124
CareerMenuUI::CreateStatEntry
void CreateStatEntry(Widget wParent, string sName, string sLabel, string sValue)
Definition
CareerMenuUI.c:44
CareerMenuUI::WIDGET_NAME_EDIT
const string WIDGET_NAME_EDIT
Definition
CareerMenuUI.c:5
CareerMenuUI::OnMenuOpen
override void OnMenuOpen()
Definition
CareerMenuUI.c:179
CareerMenuUI::nameNew
string nameNew
Definition
CareerMenuUI.c:80
CareerMenuUI::m_LoadoutPreview
ref SCR_LoadoutPreviewComponent m_LoadoutPreview
Definition
CareerMenuUI.c:16
CareerMenuUI::m_EditPlayerName
ref SCR_EditBoxComponent m_EditPlayerName
Definition
CareerMenuUI.c:15
CareerMenuUI::Back
void Back()
Definition
CareerMenuUI.c:37
CareerMenuUI::Back
ButtonWidget Back
Definition
CareerMenuUI.c:33
CareerMenuUI::nameOld
string nameOld
Definition
CareerMenuUI.c:78
CareerMenuUI::WIDGET_CHARACTER_PREVIEW
const string WIDGET_CHARACTER_PREVIEW
Definition
CareerMenuUI.c:7
CareerMenuUI::m_aBackendValues
ref array< string > m_aBackendValues
Definition
CareerMenuUI.c:25
CareerMenuUI::ENTRY_LAYOUT
const ResourceName ENTRY_LAYOUT
Definition
CareerMenuUI.c:12
CareerMenuUI::m_LoadoutManager
SCR_LoadoutManager m_LoadoutManager
Definition
CareerMenuUI.c:17
CareerMenuUI::STRING_UNKNOWN_STAT
const string STRING_UNKNOWN_STAT
Definition
CareerMenuUI.c:9
CareerMenuUI::OnMenuClose
override void OnMenuClose()
Definition
CareerMenuUI.c:209
CareerMenuUI::WIDGET_LOADOUT_STATS
const string WIDGET_LOADOUT_STATS
Definition
CareerMenuUI.c:6
CareerMenuUI::m_Callback
ref BackendCallback m_Callback
Definition
CareerMenuUI.c:30
CareerMenuUI::OnChange
override bool OnChange(Widget w, bool finished)
Definition
CareerMenuUI.c:62
CareerMenuUI::m_wEditPlayerName
Widget m_wEditPlayerName
Definition
CareerMenuUI.c:21
CareerMenuUI::OnMenuUpdate
override void OnMenuUpdate(float tDelta)
Definition
CareerMenuUI.c:131
CareerMenuUI::OnMenuShow
override void OnMenuShow()
Definition
CareerMenuUI.c:153
CareerMenuUI::UpdateCareerData
void UpdateCareerData()
Definition
CareerMenuUI.c:87
CareerMenuUI::GetBackendValues
array< string > GetBackendValues()
Definition
CareerMenuUI.c:121
CareerMenuUI::m_LoadoutStatistics
ref SCR_LoadoutStatisticsComponent m_LoadoutStatistics
Definition
CareerMenuUI.c:18
CareerMenuUI::OnLoadoutChange
void OnLoadoutChange(int id)
Definition
CareerMenuUI.c:217
CareerMenuUI::m_sInstance
static CareerMenuUI m_sInstance
Definition
CareerMenuUI.c:28
CareerMenuUI::m_BackendData
ref CareerBackendData m_BackendData
Definition
CareerMenuUI.c:29
ChimeraMenuBase
Constant variables used in various menus.
Definition
ChimeraMenuBase.c:72
InputManager
Input management system for user interactions.
Definition
InputManager.c:20
ItemPreviewWidget
Definition
ItemPreviewWidget.c:13
LoadoutStatSet
Definition
SCR_LoadoutStatistics.c:177
LoadoutStatSet::GetLoadout
SCR_BasePlayerLoadout GetLoadout()
Definition
SCR_LoadoutStatistics.c:183
ResourceName
Definition
ResourceName.c:13
SCR_EditBoxComponent
Definition
SCR_EditBoxComponent.c:9
SCR_Global
Definition
Functions.c:7
SCR_LoadoutPreviewComponent
Definition
SCR_LoadoutPreviewComponent.c:2
SCR_LoadoutStatisticsComponent
Class for switching and displaying stats for different loadouts.
Definition
SCR_LoadoutStatistics.c:5
TextWidget
Definition
TextWidget.c:16
UIConstants
Definition
Constants.c:151
Widget
Definition
Widget.c:13
EActionTrigger
EActionTrigger
Definition
EActionTrigger.c:13
MenuBindAttribute
void MenuBindAttribute(string menuItemName="")
Definition
menuManager.c:34
scripts
Game
UI
Menu
CareerMenuUI.c
Generated by
1.17.0