Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_CareerSpecializationsUI.c
Go to the documentation of this file.
1//------------------------------------------------------------------------------------------------
3{
9
10 //Controller navigation buttons
14
16
17 protected ref array<Widget> m_aSpecializationsStatsWidgets = {};
18
21
22 protected int m_iSelectedLegend = 0;
23 protected ref array<SCR_ButtonLegendComponent> m_aSpLegendButtonHandlers = {};
24 protected ref array<SCR_ButtonSpecializationProgressComponent> m_aSpProgressButtonHandlers = {};
25
26 [Attribute(params: "SpecializationProgress layout")]
28
32
33 protected bool m_bShowProgression = false;
34
35 //------------------------------------------------------------------------------------------------
36 protected override void HandlerAttached(Widget w)
37 {
38 m_wRootWidget = w;
39
40 m_wCareerLeftSide = m_wRootWidget.FindAnyWidget("CareerLeftSide");
41 m_wCareerRightSide = m_wRootWidget.FindAnyWidget("CareerRightSide");
42
44 return;
45
46 m_wSpiderNet = m_wCareerLeftSide.FindAnyWidget("SpiderNet0");
47 if (!m_wSpiderNet)
48 return;
49
52 return;
53
54 m_wPagingButtons = m_wCareerLeftSide.FindAnyWidget("PagingButtons");
55
57 return;
58
59 Widget navLeft = m_wPagingButtons.FindAnyWidget("NavigationButtonNextSp");
60 Widget navRight = m_wPagingButtons.FindAnyWidget("NavigationButtonPrevSp");
61
62 if (!navLeft || !navRight)
63 return;
64
67
69 return;
70
71 //Navigation actions found in the CareerProfileContext and also in the EndgameScreenContext
72 m_HandlerChangeSpLeft.m_OnActivated.Insert(NavLeft);
73 m_HandlerChangeSpRight.m_OnActivated.Insert(NavRight);
74 }
75
76 //------------------------------------------------------------------------------------------------
77 protected void NavLeft(SCR_InputButtonComponent handler, string action)
78 {
79 int next = m_iSelectedLegend + 1;
80 if (next >= m_aSpLegendButtonHandlers.Count())
81 next = 0;
83 }
84
85 //------------------------------------------------------------------------------------------------
86 protected void NavRight(SCR_InputButtonComponent handler, string action)
87 {
88 int prev = m_iSelectedLegend - 1;
89 if (prev < 0)
90 prev = m_aSpLegendButtonHandlers.Count() - 1;
92 }
93
94 //------------------------------------------------------------------------------------------------
95 void SetShowProgression(bool b)
96 {
98 }
99
100 //------------------------------------------------------------------------------------------------
101 void FillSpecializations(SCR_PlayerData playerData, ResourceName statsLayout, ResourceName headerStatsLayout, ResourceName progressionStatsLayout)
102 {
103 if (!playerData)
104 return;
105
106 m_PlayerData = playerData;
107 m_sStatsLayout = statsLayout;
108 m_sHeaderStatsLayout = headerStatsLayout;
109 m_sProgressionStatsLayout = progressionStatsLayout;
110
111 m_SpiderNetHandler.RegisterCareerProfileHandler(this);
112 array<float> SpPoints = {};
113
114 //Prepare vertices for the spidernet
115 m_PlayerData.FillArrayWithSpecializationPoints(SpPoints);
116 m_SpiderNetHandler.SetSpPoints(SpPoints);
117
118 //Progression with previous stats?
120 {
121 //Prepare old vertices for the spidernet
122 SpPoints.Clear();
123 m_PlayerData.FillArrayWithSpecializationPoints(SpPoints, false);
124 m_SpiderNetHandler.SetSpPoints(SpPoints, false);
125
126 m_PlayerData.PrepareSpecializationProgressionStatsDisplay();
127 }
128 else
129 {
130 m_PlayerData.PrepareSpecializationStatsDisplay();
131 }
132
134 //Draw spidernet
135 m_SpiderNetHandler.DrawSpiderNet();
136 }
137
140 //------------------------------------------------------------------------------------------------
142 {
143 Widget specializationProgressWidget = m_wCareerLeftSide.FindAnyWidget("SpecializationsSummary");
144 Widget specializationsPanelWidget = m_wCareerRightSide.FindAnyWidget("SpecializationsPanel");
145 if (!specializationProgressWidget || !specializationsPanelWidget)
146 return;
147
148 //Specializations Panel
149 m_twSpecializationTitle = RichTextWidget.Cast(specializationsPanelWidget.FindAnyWidget("SpecializationTitleText"));
150 m_twSpecializationProgress = RichTextWidget.Cast(specializationsPanelWidget.FindAnyWidget("SpecializationProgressText"));
151 m_SpecializationBar = SCR_ProgressBarWithSegments.Cast(SCR_WLibProgressBarComponent.GetProgressBar("SpecializationBar", specializationsPanelWidget, true));
152
153 m_SpecializationBar.SetMin(0);
155
156 //Specializations Progress Summary
157 Widget progressLeft = specializationProgressWidget.FindAnyWidget("LeftSpecializations");
158 Widget progressRight = specializationProgressWidget.FindAnyWidget("RightSpecializations");
159
160 if (!progressLeft || !progressRight)
161 return;
162
163 Widget tempWidget;
164
165 int tempCount;
166 int maxCount = m_PlayerData.GetSpecializationCount(0);
167 int i;
168 int specializationsCount = SCR_PlayerDataConfigs.GetInstance().SPECIALIZATIONS_COUNT;
169
170 if (specializationsCount % 2 != 0)
171 specializationsCount += 1;
172
173 for (i = 0; i < specializationsCount; i++)
174 {
175 tempCount = m_PlayerData.GetSpecializationCount(i);
176 maxCount = Math.Max(tempCount, maxCount);
177
178 if (i < specializationsCount * 0.5)
179 tempWidget = progressLeft;
180 else
181 tempWidget = progressRight;
182
184 }
185
186 for (i = 0; i < maxCount; i++)
187 {
188 Widget tempW;
189
191 tempW = SCR_CareerUI.CreateStatEntry(specializationsPanelWidget, m_sStatsLayout);
192 else
193 tempW = SCR_CareerUI.CreateProgressionStatEntry(specializationsPanelWidget, m_sProgressionStatsLayout);
194
195 if (tempW)
196 m_aSpecializationsStatsWidgets.Insert(tempW);
197 }
198 }
199
200 //------------------------------------------------------------------------------------------------
201 protected void UpdateSpecializationPanel(int n)
202 {
204 return;
205
206 string title = ""+(n+ 1)+". "+SCR_PlayerDataConfigs.GetInstance().GetSpecializationName(n);
207 float value = m_PlayerData.GetSpecializationPoints(n) * SCR_PlayerDataConfigs.SPPOINTS_CONVERSIONPERCENTAGE;
208
209 m_twSpecializationTitle.SetText(title);
210 m_twSpecializationProgress.SetText(""+value.ToString(-1, 2)+"%");
211
212 float warCrimes = 0;
213 array<float> EarntPoints;
214
216 {
217 if (!m_PlayerData.IsDataProgressionReady())
218 return;
219 EarntPoints = m_PlayerData.GetArrayEarntPoints();
220
221 if (m_PlayerData.GetStat(SCR_EDataStats.WARCRIMES) != 0)
223
224 int spEnumId;
225 switch (n)
226 {
227 case 0: spEnumId = SCR_EDataStats.SPPOINTS0;
228 break;
229 case 1: spEnumId = SCR_EDataStats.SPPOINTS1;
230 break;
231 case 2: spEnumId = SCR_EDataStats.SPPOINTS2;
232 break;
233 default: return;
234 }
235 float original = m_PlayerData.GetSpecializationPoints(n, false);
236 float minus = EarntPoints[spEnumId] * warCrimes;
237 float progressed = EarntPoints[spEnumId] - minus;
238
239 m_SpecializationBar.SetProgressBarValues(original, progressed, minus);
240 }
241 else
242 {
243 m_SpecializationBar.SetValue(value);
244 }
245
248
249 array<ref SCR_PlayerDataSpecializationDisplay> statsToDisplay = SCR_PlayerDataConfigs.GetInstance().GetSpecializationArray(n);
250
251 for (int i = 0; i < numStats; i++)
252 {
254 SCR_CareerUI.UpdateStatProgressionEntry(m_aSpecializationsStatsWidgets[i], statsToDisplay[i].GetTitle(), EarntPoints[statsToDisplay[i].GetEnumId()] * warCrimes, EarntPoints[statsToDisplay[i].GetEnumId()], statsToDisplay[i].GetUnits(), ""+statsToDisplay[i].GetValue());
255 else
256 SCR_CareerUI.UpdateStatEntry(m_aSpecializationsStatsWidgets[i], statsToDisplay[i].GetTitle(), statsToDisplay[i].GetUnits(), ""+statsToDisplay[i].GetValue());
257 }
258 }
259
261 //------------------------------------------------------------------------------------------------
262 protected void SpecializationStatsSetVisible(int n)
263 {
264 int statWidgetsCount = m_aSpecializationsStatsWidgets.Count();
265
266 if (n < 0 || n > statWidgetsCount)
267 return;
268
269 int i;
270
271 //Make n stats visible
272 for (i = 0; i < n; i++)
273 {
274 m_aSpecializationsStatsWidgets[i].SetVisible(true);
275 }
276
277 //Make the remaining ones invisible
278 for (i = n; i < statWidgetsCount; i++)
279 {
280 m_aSpecializationsStatsWidgets[i].SetVisible(false);
281 }
282 }
283
286 //------------------------------------------------------------------------------------------------
287 void UpdateSpecialization(int specializationId)
288 {
290 return;
291
292 //Deactivate old selected legend
295
296 //Activate new selected legend
297 m_iSelectedLegend = specializationId;
300
301 //We set the focus in case the player uses a controller
303
304 //Update panel
305 UpdateSpecializationPanel(specializationId);
306 }
307
308 //------------------------------------------------------------------------------------------------
309 void UpdateHoveredSpecialization(int specializationId, bool hover)
310 {
311 m_aSpLegendButtonHandlers[specializationId].SetOnHover(hover);
312 m_aSpProgressButtonHandlers[specializationId].SetOnHover(hover);
313 }
314
315 //------------------------------------------------------------------------------------------------
317 {
318 WorkspaceWidget workspace = GetGame().GetWorkspace();
319 if (!workspace)
320 return null;
321
322 Widget SpecializationProgressButton = workspace.CreateWidgets(m_sSpProgressLayout, container);
323 if (!SpecializationProgressButton)
324 return null;
325
327 if (!handler)
328 return null;
329
330 //If ID is higher to the number of Specializations, we fill it empty and make it invisible because its created for layout purposes
332 {
333 handler.SetValue(0);
334 handler.Hide();
335 return null;
336 }
337
338 handler.SetButtonId(id);
339 handler.SetValue(m_PlayerData.GetSpecializationPoints(id) * SCR_PlayerDataConfigs.SPPOINTS_CONVERSIONPERCENTAGE);
340 handler.GetOnClicked().Insert(UpdateSpecialization);
343
345
346 return SpecializationProgressButton;
347 }
348
349 //------------------------------------------------------------------------------------------------
351 {
352 if (handler)
353 m_aSpLegendButtonHandlers.Insert(handler);
354 }
355
356 //------------------------------------------------------------------------------------------------
358 {
359 if (handler)
360 m_aSpProgressButtonHandlers.Insert(handler);
361 }
362
363 //------------------------------------------------------------------------------------------------
365 {
366 for (int i = m_aSpLegendButtonHandlers.Count(); i > 0; i--)
367 {
368 m_aSpLegendButtonHandlers[m_iSelectedLegend].SetLeftAndRightUIActivate(flag);
369 }
370 }
371
372 //War crimes
373 //------------------------------------------------------------------------------------------------
375 {
376 //TODO: choose the texture dynamically: m_wImgTitleIcon.LoadImageFromSet(0, image, imageName);
377 //where image is the resourceName of imageset, and imageName is the string of the specific icon in the imageset
378
379 Widget WarCrimesPanelWidget = m_wCareerRightSide.FindAnyWidget("WarCrimesPanel");
380 if (!WarCrimesPanelWidget)
381 return;
382
383 SCR_WarCrimesPanelUI handler = SCR_WarCrimesPanelUI.Cast(WarCrimesPanelWidget.FindHandler(SCR_WarCrimesPanelUI));
384 if (!handler)
385 return;
386
387 if (m_PlayerData.GetStat(SCR_EDataStats.WARCRIMES) > 0)
388 {
389 if (m_PlayerData.GetStat(SCR_EDataStats.WARCRIME_HARMING_FRIENDLIES) > 0)
390 {
391 handler.CreateWarCrimeEntry(SCR_EWarCrimes.HARMINGFRIENDLIES);
392 }
393 else
394 {
395 Print ("SCR_CareerSpecializationsUI:FillWarCrimes: War Crimes amount not 0 but Harming Friendlies is 0", LogLevel.ERROR);
396 }
397 }
398 }
399};
ArmaReforgerScripted GetGame()
Definition game.c:1398
SCR_EDataStats
override int GetValue()
Definition Math.c:13
void UpdateSpecialization(int specializationId)
void FillSpecializations(SCR_PlayerData playerData, ResourceName statsLayout, ResourceName headerStatsLayout, ResourceName progressionStatsLayout)
void AddProgressButtonHandler(SCR_ButtonSpecializationProgressComponent handler)
void NavRight(SCR_InputButtonComponent handler, string action)
void AddLegendButtonHandler(SCR_ButtonLegendComponent handler)
Widget CreateSpecializationProgressButtonWidget(Widget container, int id)
void SpecializationStatsSetVisible(int n)
Makes n stat widgets of the Specialization Panel visible, and the remaining ones invisible.
SCR_InputButtonComponent m_HandlerChangeSpLeft
void NavLeft(SCR_InputButtonComponent handler, string action)
SCR_ProgressBarWithSegments m_SpecializationBar
ref array< SCR_ButtonSpecializationProgressComponent > m_aSpProgressButtonHandlers
ref array< SCR_ButtonLegendComponent > m_aSpLegendButtonHandlers
SCR_InputButtonComponent m_HandlerChangeSpRight
void UpdateHoveredSpecialization(int specializationId, bool hover)
ref array< Widget > m_aSpecializationsStatsWidgets
static SCR_PlayerDataConfigs GetInstance()
static const float SPPOINTS_CONVERSIONPERCENTAGE
static const float WARCRIMES_PUNISHMENT
array< ref SCR_PlayerDataSpecializationDisplay > GetSpecializationArray(int n)
Minimalist progress bar.
static SCR_WLibProgressBarComponent GetProgressBar(string name, Widget parent, bool searchAllChildren=true)
void CreateWarCrimeEntry(SCR_EWarCrimes crime)
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
Enum with severity of the logging message.
Definition LogLevel.c:14
SCR_FieldOfViewSettings Attribute