Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
CareerMenuUI.c
Go to the documentation of this file.
1//------------------------------------------------------------------------------------------------
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
19
20 // Widgets
22
23 //private EditBoxWidget m_ProfileEditbox;
24 //private Widget m_ProfileData;
25 protected ref array<string> m_aBackendValues = new array<string>();
26
27 // Values
31
34
35 //------------------------------------------------------------------------------------------------
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
84 }
85
86 //------------------------------------------------------------------------------------------------
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
111 m_aBackendValues[ECareerStatId.PLAYIME_SHARPSHOOTER] = STRING_UNKNOWN_STAT;
112
113 // Weapons
115
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 {
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
158 m_wEditPlayerName.SetEnabled(false);
159 #endif
160
161 // Player name edit
165
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)
197
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 {
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//------------------------------------------------------------------------------------------------
232{
233 // General
237
238 // Play times
241
242 // Weapons
244};
245
AddonBuildInfoTool id
ECareerStatId
Ids to receive all.
@ HEADSHOTS
@ PLAYIME_SHARPSHOOTER
@ PLAYTIME_RIFFLEMAN
ArmaReforgerScripted GetGame()
Definition game.c:1398
void SCR_LoadoutManager(IEntitySource src, IEntity parent)
bool IsFocused()
Widget GetRootWidget()
@ DEATHS
Deaths.
@ KILLS
Enemies killed.
@ FRIENDLY_KILLS
Friendly human kills.
proto native void Close()
Backend Api instance.
Definition BackendApi.c:14
void TestingShow()
void CreateStatEntry(Widget wParent, string sName, string sLabel, string sValue)
const string WIDGET_NAME_EDIT
Definition CareerMenuUI.c:5
override void OnMenuOpen()
ref SCR_LoadoutPreviewComponent m_LoadoutPreview
ref SCR_EditBoxComponent m_EditPlayerName
ButtonWidget Back
const string WIDGET_CHARACTER_PREVIEW
Definition CareerMenuUI.c:7
ref array< string > m_aBackendValues
const ResourceName ENTRY_LAYOUT
SCR_LoadoutManager m_LoadoutManager
const string STRING_UNKNOWN_STAT
Definition CareerMenuUI.c:9
override void OnMenuClose()
const string WIDGET_LOADOUT_STATS
Definition CareerMenuUI.c:6
ref BackendCallback m_Callback
override bool OnChange(Widget w, bool finished)
Widget m_wEditPlayerName
override void OnMenuUpdate(float tDelta)
override void OnMenuShow()
void UpdateCareerData()
array< string > GetBackendValues()
ref SCR_LoadoutStatisticsComponent m_LoadoutStatistics
void OnLoadoutChange(int id)
static CareerMenuUI m_sInstance
ref CareerBackendData m_BackendData
Constant variables used in various menus.
Input management system for user interactions.
SCR_BasePlayerLoadout GetLoadout()
Class for switching and displaying stats for different loadouts.
EActionTrigger
void MenuBindAttribute(string menuItemName="")
Definition menuManager.c:34