Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_CareerEndScreenUI.c
Go to the documentation of this file.
1//------------------------------------------------------------------------------------------------
3{
8
9 protected Widget m_wHud;
12
13 [Attribute(params: "Stats layout")]
15
16 [Attribute(params: "Header of Stats layout")]
18
19 [Attribute(params: "Stats Progression layout")]
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
34 return;
35
36 m_wHud = m_wFirstColumnWidget.FindAnyWidget("CareerProfileHUD0");
37
38 if (!m_wHud)
39 return;
40
42 if (!m_HudHandler)
43 return;
44 m_HudHandler.PrepareHUD("", "RankTitleText", "", "", "LevelProgress", "PlayerLevel", "ProgressBar0", "");
45
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);
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
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)
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 //------------------------------------------------------------------------------------------------
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};
ArmaReforgerScripted GetGame()
Definition game.c:1398
SCR_EDataStats
void SetEndscreenVisualInfo(notnull SCR_GameOverScreenUIContentData endScreenUIContent)
static ref SCR_PlayerData m_PlayerData
void FillScreen(bool profileDataFound)
void OnDataReceived(SCR_PlayerData playerData)
Data was sent through RPL and now we can use it.
override void GameOverTabInit(notnull SCR_GameOverScreenUIContentData endScreenUIContent)
SCR_CareerSpecializationsUI m_CareerSpecializationsHandler
SCR_CareerProfileHUD m_HudHandler
override void HandlerAttached(Widget w)
static const float WARCRIMES_PUNISHMENT
static const int XP_NEEDED_FOR_LEVEL
static bool IsEmptyOrWhiteSpace(string input)
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
proto external PlayerController GetPlayerController()