4 protected Widget m_wRootWidget;
5 protected Widget m_wCareerLeftSide;
6 protected Widget m_wCareerRightSide;
7 protected Widget m_wSpiderNet;
11 protected Widget m_wPagingButtons;
17 protected ref array<Widget> m_aSpecializationsStatsWidgets = {};
19 RichTextWidget m_twSpecializationTitle, m_twSpecializationProgress;
22 protected int m_iSelectedLegend = 0;
23 protected ref array<SCR_ButtonLegendComponent> m_aSpLegendButtonHandlers = {};
24 protected ref array<SCR_ButtonSpecializationProgressComponent> m_aSpProgressButtonHandlers = {};
27 protected ResourceName m_sSpProgressLayout;
29 protected ResourceName m_sStatsLayout;
30 protected ResourceName m_sHeaderStatsLayout;
31 protected ResourceName m_sProgressionStatsLayout;
33 protected bool m_bShowProgression =
false;
36 protected override void HandlerAttached(Widget w)
40 m_wCareerLeftSide = m_wRootWidget.FindAnyWidget(
"CareerLeftSide");
41 m_wCareerRightSide = m_wRootWidget.FindAnyWidget(
"CareerRightSide");
43 if (!m_wCareerLeftSide || !m_wCareerRightSide)
46 m_wSpiderNet = m_wCareerLeftSide.FindAnyWidget(
"SpiderNet0");
51 if (!m_SpiderNetHandler)
54 m_wPagingButtons = m_wCareerLeftSide.FindAnyWidget(
"PagingButtons");
56 if (!m_wPagingButtons)
59 Widget navLeft = m_wPagingButtons.FindAnyWidget(
"NavigationButtonNextSp");
60 Widget navRight = m_wPagingButtons.FindAnyWidget(
"NavigationButtonPrevSp");
62 if (!navLeft || !navRight)
68 if (!m_HandlerChangeSpLeft || !m_HandlerChangeSpRight)
72 m_HandlerChangeSpLeft.m_OnActivated.Insert(NavLeft);
73 m_HandlerChangeSpRight.m_OnActivated.Insert(NavRight);
79 int next = m_iSelectedLegend + 1;
80 if (next >= m_aSpLegendButtonHandlers.Count())
82 UpdateSpecialization(next);
88 int prev = m_iSelectedLegend - 1;
90 prev = m_aSpLegendButtonHandlers.Count() - 1;
91 UpdateSpecialization(prev);
95 void SetShowProgression(
bool b)
97 m_bShowProgression = b;
101 void FillSpecializations(
SCR_PlayerData playerData, ResourceName statsLayout, ResourceName headerStatsLayout, ResourceName progressionStatsLayout)
106 m_PlayerData = playerData;
107 m_sStatsLayout = statsLayout;
108 m_sHeaderStatsLayout = headerStatsLayout;
109 m_sProgressionStatsLayout = progressionStatsLayout;
111 m_SpiderNetHandler.RegisterCareerProfileHandler(
this);
112 array<float> SpPoints = {};
115 m_PlayerData.FillArrayWithSpecializationPoints(SpPoints);
116 m_SpiderNetHandler.SetSpPoints(SpPoints);
119 if (m_bShowProgression)
123 m_PlayerData.FillArrayWithSpecializationPoints(SpPoints,
false);
124 m_SpiderNetHandler.SetSpPoints(SpPoints,
false);
126 m_PlayerData.PrepareSpecializationProgressionStatsDisplay();
130 m_PlayerData.PrepareSpecializationStatsDisplay();
133 SetUpSpecializationDisplay();
135 m_SpiderNetHandler.DrawSpiderNet();
141 protected void SetUpSpecializationDisplay()
143 Widget specializationProgressWidget = m_wCareerLeftSide.FindAnyWidget(
"SpecializationsSummary");
144 Widget specializationsPanelWidget = m_wCareerRightSide.FindAnyWidget(
"SpecializationsPanel");
145 if (!specializationProgressWidget || !specializationsPanelWidget)
149 m_twSpecializationTitle = RichTextWidget.Cast(specializationsPanelWidget.FindAnyWidget(
"SpecializationTitleText"));
150 m_twSpecializationProgress = RichTextWidget.Cast(specializationsPanelWidget.FindAnyWidget(
"SpecializationProgressText"));
153 m_SpecializationBar.SetMin(0);
157 Widget progressLeft = specializationProgressWidget.FindAnyWidget(
"LeftSpecializations");
158 Widget progressRight = specializationProgressWidget.FindAnyWidget(
"RightSpecializations");
160 if (!progressLeft || !progressRight)
166 int maxCount = m_PlayerData.GetSpecializationCount(0);
170 if (specializationsCount % 2 != 0)
171 specializationsCount += 1;
173 for (i = 0; i < specializationsCount; i++)
175 tempCount = m_PlayerData.GetSpecializationCount(i);
176 maxCount = Math.Max(tempCount, maxCount);
178 if (i < specializationsCount * 0.5)
179 tempWidget = progressLeft;
181 tempWidget = progressRight;
183 CreateSpecializationProgressButtonWidget(tempWidget, i);
186 for (i = 0; i < maxCount; i++)
190 if (!m_bShowProgression)
191 tempW =
SCR_CareerUI.CreateStatEntry(specializationsPanelWidget, m_sStatsLayout);
193 tempW =
SCR_CareerUI.CreateProgressionStatEntry(specializationsPanelWidget, m_sProgressionStatsLayout);
196 m_aSpecializationsStatsWidgets.Insert(tempW);
201 protected void UpdateSpecializationPanel(
int n)
203 if (n < 0 || n >=
SCR_PlayerDataConfigs.GetInstance().SPECIALIZATIONS_COUNT || !m_twSpecializationTitle || !m_twSpecializationProgress)
207 float value = m_PlayerData.GetSpecializationPoints(n) *
SCR_PlayerDataConfigs.SPPOINTS_CONVERSIONPERCENTAGE;
209 m_twSpecializationTitle.SetText(title);
210 m_twSpecializationProgress.SetText(
""+value.ToString(-1, 2)+
"%");
213 array<float> EarntPoints;
215 if (m_bShowProgression)
217 if (!m_PlayerData.IsDataProgressionReady())
219 EarntPoints = m_PlayerData.GetArrayEarntPoints();
235 float original = m_PlayerData.GetSpecializationPoints(n,
false);
236 float minus = EarntPoints[spEnumId] * warCrimes;
237 float progressed = EarntPoints[spEnumId] - minus;
239 m_SpecializationBar.SetProgressBarValues(original, progressed, minus);
243 m_SpecializationBar.SetValue(value);
247 SpecializationStatsSetVisible(numStats);
249 array<ref SCR_PlayerDataSpecializationDisplay> statsToDisplay =
SCR_PlayerDataConfigs.GetInstance().GetSpecializationArray(n);
251 for (
int i = 0; i < numStats; i++)
253 if (m_bShowProgression)
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());
256 SCR_CareerUI.UpdateStatEntry(m_aSpecializationsStatsWidgets[i], statsToDisplay[i].GetTitle(), statsToDisplay[i].GetUnits(),
""+statsToDisplay[i].
GetValue());
262 protected void SpecializationStatsSetVisible(
int n)
264 int statWidgetsCount = m_aSpecializationsStatsWidgets.Count();
266 if (n < 0 || n > statWidgetsCount)
272 for (i = 0; i < n; i++)
274 m_aSpecializationsStatsWidgets[i].SetVisible(
true);
278 for (i = n; i < statWidgetsCount; i++)
280 m_aSpecializationsStatsWidgets[i].SetVisible(
false);
287 void UpdateSpecialization(
int specializationId)
289 if (!m_aSpecializationsStatsWidgets || m_aSpecializationsStatsWidgets.IsEmpty() || !m_aSpLegendButtonHandlers ||m_aSpLegendButtonHandlers.IsEmpty())
293 m_aSpLegendButtonHandlers[m_iSelectedLegend].Deactivate();
294 m_aSpProgressButtonHandlers[m_iSelectedLegend].Deactivate();
297 m_iSelectedLegend = specializationId;
298 m_aSpLegendButtonHandlers[m_iSelectedLegend].Activate();
299 m_aSpProgressButtonHandlers[m_iSelectedLegend].Activate();
302 m_aSpProgressButtonHandlers[m_iSelectedLegend].SetFocus();
305 UpdateSpecializationPanel(specializationId);
309 void UpdateHoveredSpecialization(
int specializationId,
bool hover)
311 m_aSpLegendButtonHandlers[specializationId].SetOnHover(hover);
312 m_aSpProgressButtonHandlers[specializationId].SetOnHover(hover);
316 protected Widget CreateSpecializationProgressButtonWidget(Widget container,
int id)
318 WorkspaceWidget workspace =
GetGame().GetWorkspace();
322 Widget SpecializationProgressButton = Widget.Cast(workspace.CreateWidgets(m_sSpProgressLayout, container));
323 if (!SpecializationProgressButton)
338 handler.SetButtonId(
id);
339 handler.SetValue(m_PlayerData.GetSpecializationPoints(
id) *
SCR_PlayerDataConfigs.SPPOINTS_CONVERSIONPERCENTAGE);
340 handler.GetOnClicked().Insert(UpdateSpecialization);
341 handler.GetOnMouseEnter().Insert(UpdateHoveredSpecialization);
342 handler.GetOnMouseLeave().Insert(UpdateHoveredSpecialization);
344 AddProgressButtonHandler(handler);
346 return SpecializationProgressButton;
353 m_aSpLegendButtonHandlers.Insert(handler);
360 m_aSpProgressButtonHandlers.Insert(handler);
364 void SetLeftAndRightUIActivate(
bool flag)
366 for (
int i = m_aSpLegendButtonHandlers.Count(); i > 0; i--)
368 m_aSpLegendButtonHandlers[m_iSelectedLegend].SetLeftAndRightUIActivate(flag);
379 Widget WarCrimesPanelWidget = m_wCareerRightSide.FindAnyWidget(
"WarCrimesPanel");
380 if (!WarCrimesPanelWidget)
389 if (m_PlayerData.GetStat(
SCR_EDataStats.WARCRIME_HARMING_FRIENDLIES) > 0)
395 Print (
"SCR_CareerSpecializationsUI:FillWarCrimes: War Crimes amount not 0 but Harming Friendlies is 0", LogLevel.ERROR);