Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_CareerEndScreenUI.c
Go to the documentation of this file.
1 //------------------------------------------------------------------------------------------------
3 {
4  protected Widget m_wRootWidget;
5  protected Widget m_wFirstColumnWidget;
6  protected Widget m_wCareerSpecializationsWidget;
7  protected Widget m_wProfileNotFound;
8 
9  protected Widget m_wHud;
10  protected SCR_CareerProfileHUD m_HudHandler;
11  protected SCR_CareerSpecializationsUI m_CareerSpecializationsHandler;
12 
13  [Attribute(params: "Stats layout")]
14  protected ResourceName m_StatsLayout;
15 
16  [Attribute(params: "Header of Stats layout")]
17  protected ResourceName m_HeaderStatsLayout;
18 
19  [Attribute(params: "Stats Progression layout")]
20  protected ResourceName m_ProgressionStatsLayout;
21 
22  protected static ref SCR_PlayerData m_PlayerData;
23 
24  //------------------------------------------------------------------------------------------------
25  override void GameOverTabInit(notnull SCR_GameOverScreenUIContentData endScreenUIContent)
26  {
27  super.GameOverTabInit(endScreenUIContent);
28 
29  m_wFirstColumnWidget = m_wRootWidget.FindAnyWidget("FirstColumn");
30  m_wCareerSpecializationsWidget = m_wRootWidget.FindAnyWidget("CareerSpecializations0");
31  m_wProfileNotFound = m_wRootWidget.FindAnyWidget("ProfileNotFound");
32 
33  if (!m_wFirstColumnWidget || !m_wCareerSpecializationsWidget || !m_wProfileNotFound)
34  return;
35 
36  m_wHud = m_wFirstColumnWidget.FindAnyWidget("CareerProfileHUD0");
37 
38  if (!m_wHud)
39  return;
40 
41  m_HudHandler = SCR_CareerProfileHUD.Cast(m_wHud.FindHandler(SCR_CareerProfileHUD));
42  if (!m_HudHandler)
43  return;
44  m_HudHandler.PrepareHUD("", "RankTitleText", "", "", "LevelProgress", "PlayerLevel", "ProgressBar0", "");
45 
46  m_CareerSpecializationsHandler = SCR_CareerSpecializationsUI.Cast(m_wCareerSpecializationsWidget.FindHandler(SCR_CareerSpecializationsUI));
47  if (!m_CareerSpecializationsHandler)
48  return;
49 
50  //~ Sets winning faction or any other text and icon linked to the end screen
51  SetEndscreenVisualInfo(endScreenUIContent);
52 
53  if (!m_PlayerData)
54  {
55  SCR_DataCollectorComponent dataCollector = GetGame().GetDataCollector();
56  if (!dataCollector)
57  {
58  Print ("SCR_CareerEndScreenUI: No data collector was found.", LogLevel.ERROR);
59  return;
60  }
61 
62  m_PlayerData = dataCollector.GetPlayerData(0, false);
63 
64  //If there's still no player data, we wait for the invoker on data received to let us now that we got the instance through rpl
65  if (!m_PlayerData)
66  {
67  SCR_DataCollectorCommunicationComponent communicationComponent = SCR_DataCollectorCommunicationComponent.Cast(GetGame().GetPlayerController().FindComponent(SCR_DataCollectorCommunicationComponent));
68  if (communicationComponent)
69  communicationComponent.GetOnDataReceived().Insert(OnDataReceived);
70  }
71  else if (!m_PlayerData.IsDataProgressionReady())
72  m_PlayerData.CalculateStatsChange();
73  }
74 
75  FillFields();
76  }
77 
78  //------------------------------------------------------------------------------------------------
79  protected override void HandlerAttached(Widget w)
80  {
81  super.HandlerAttached(w);
82  m_wRootWidget = w;
83 
84  }
85 
86  //------------------------------------------------------------------------------------------------
88  protected void OnDataReceived(SCR_PlayerData playerData)
89  {
90  m_PlayerData = playerData;
91  m_PlayerData.CalculateStatsChange();
92  FillFields();
93  }
94 
95  //------------------------------------------------------------------------------------------------
96  protected void FillFields()
97  {
98  if (!m_PlayerData)
99  {
100  FillScreen(false);
101  return;
102  }
103  if (!m_PlayerData.IsDataProgressionReady())
104  {
105  Print("SCR_CareerEndScreenUI: Array of EarntPoints from player's PlayerData object is empty.", LogLevel.ERROR);
106  return;
107  }
108 
109  FillScreen(!m_PlayerData.IsEmptyProfile());
110  }
111 
112  //------------------------------------------------------------------------------------------------
113  void FillScreen(bool profileDataFound)
114  {
115  if (profileDataFound)
116  {
117  m_wFirstColumnWidget.SetVisible(true);
118  m_wCareerSpecializationsWidget.SetVisible(true);
119  m_wProfileNotFound.SetVisible(false);
120  FillHudAndStats();
121  FillSpecializationsFrame();
122  }
123  else
124  {
125  m_wFirstColumnWidget.SetVisible(false);
126  m_wCareerSpecializationsWidget.SetVisible(false);
127  m_wProfileNotFound.SetVisible(true);
128  }
129  }
130 
131  //------------------------------------------------------------------------------------------------
132  protected void FillHudAndStats()
133  {
134  int Level = m_PlayerData.GetStat(SCR_EDataStats.LEVEL_EXPERIENCE);
135 
136  m_HudHandler.SetPlayerLevel(Level / SCR_PlayerDataConfigs.XP_NEEDED_FOR_LEVEL);
137  m_HudHandler.SetProgressBarValue(Level % SCR_PlayerDataConfigs.XP_NEEDED_FOR_LEVEL);
138  m_HudHandler.SetPlayerRank(m_PlayerData.GetStat(SCR_EDataStats.RANK));
139  m_HudHandler.SetRandomBackgroundPicture();
140 
141  array<float> EarntPoints = m_PlayerData.GetArrayEarntPoints();
142 
143  m_HudHandler.SetLevelProgressGain(EarntPoints[SCR_EDataStats.LEVEL_EXPERIENCE]);
144 
145  Widget GeneralStatsWidget = m_wFirstColumnWidget.FindAnyWidget("GeneralStatEntries");
146  if (!GeneralStatsWidget)
147  return;
148 
149  //warcrimes = Punishment * "AreThereWarCrimes?"
150  float warCrimes = 0;
151  if (m_PlayerData.GetStat(SCR_EDataStats.WARCRIMES) != 0)
152  warCrimes = SCR_PlayerDataConfigs.WARCRIMES_PUNISHMENT;
153 
154  int minutes = (m_PlayerData.GetStat(SCR_EDataStats.SESSION_DURATION) - m_PlayerData.GetStat(SCR_EDataStats.SESSION_DURATION, false)) / 60;
155 
156  SCR_CareerUI.CreateProgressionStatEntry(GeneralStatsWidget, m_ProgressionStatsLayout, "#AR-CareerProfile_TimePlayed", EarntPoints[SCR_EDataStats.SESSION_DURATION] * warCrimes, EarntPoints[SCR_EDataStats.SESSION_DURATION], "#AR-CareerProfile_Minutes", ""+minutes);
157  }
158 
159  //------------------------------------------------------------------------------------------------
160  protected void FillSpecializationsFrame()
161  {
162  m_CareerSpecializationsHandler.SetShowProgression(true);
163  m_CareerSpecializationsHandler.FillSpecializations(m_PlayerData, m_StatsLayout, m_HeaderStatsLayout, m_ProgressionStatsLayout);
164  m_CareerSpecializationsHandler.FillWarCrimes();
165  }
166 
167  //------------------------------------------------------------------------------------------------
168  protected void SetEndscreenVisualInfo(notnull SCR_GameOverScreenUIContentData endScreenUIContent)
169  {
170  ImageWidget matchFlag = ImageWidget.Cast(m_wFirstColumnWidget.FindAnyWidget("MatchResultFlag"));
171  RichTextWidget MatchFactionWinner = RichTextWidget.Cast(m_wFirstColumnWidget.FindAnyWidget("MatchFactionWinner"));
172  if (!matchFlag || !MatchFactionWinner)
173  return;
174 
175  //~ Set match done text
176  if (!SCR_StringHelper.IsEmptyOrWhiteSpace(endScreenUIContent.m_sSubtitle))
177  MatchFactionWinner.SetTextFormat(endScreenUIContent.m_sSubtitle, endScreenUIContent.m_sSubtitleParam);
178  else
179  MatchFactionWinner.SetVisible(false);
180 
181  //~ Set flag icon
182  if (!SCR_StringHelper.IsEmptyOrWhiteSpace(endScreenUIContent.m_sIcon))
183  matchFlag.LoadImageTexture(0, endScreenUIContent.m_sIcon);
184  else
185  matchFlag.SetVisible(false);
186  }
187 };
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
SCR_StringHelper
Definition: SCR_StringHelper.c:1
SCR_PlayerData
Definition: SCR_PlayerData.c:2
GetPlayerController
proto external PlayerController GetPlayerController()
Definition: SCR_PlayerDeployMenuHandlerComponent.c:307
SCR_CareerProfileHUD
Definition: SCR_CareerProfileHUD.c:2
SCR_PlayerDataConfigs
Definition: SCR_PlayerDataConfigs.c:102
Attribute
typedef Attribute
Post-process effect of scripted camera.
SCR_CareerSpecializationsUI
Definition: SCR_CareerSpecializationsUI.c:2
SCR_BaseGameOverTabUIComponent
Definition: SCR_GameOverTabBaseUIComponent.c:1
SCR_EDataStats
SCR_EDataStats
Definition: SCR_PlayerData.c:950
SCR_CareerUI
Definition: SCR_CareerUI.c:2
SCR_GameOverScreenUIContentData
Definition: SCR_GameOverScreenManagerComponent.c:497
params
Configs ServerBrowser KickDialogs params
Definition: SCR_NotificationSenderComponent.c:24
SCR_CareerEndScreenUI
Definition: SCR_CareerEndScreenUI.c:2