Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_CareerProfileOverviewUI.c
Go to the documentation of this file.
1//#define DEBUG_PLAYERPROFILE
3{
7
8 protected Widget m_wHud;
12
13 [Attribute("", UIWidgets.Object, category: "Loadout Manager")]
15
16 [Attribute(params: "Stats layout")]
18
19 [Attribute(params: "Header of Stats layout")]
21
22 [Attribute(params: "Stats Progression layout")]
24
26
27 //------------------------------------------------------------------------------------------------
28 override void OnTabCreate(Widget menuRoot, ResourceName buttonsLayout, int index)
29 {
30 super.OnTabCreate(menuRoot, buttonsLayout, index);
31
32 m_wFirstColumnWidget = GetRootWidget().FindAnyWidget("FirstColumn");
33 m_wCareerSpecializationsWidget = GetRootWidget().FindAnyWidget("CareerSpecializations0");
34 m_wProfileNotFound = GetRootWidget().FindAnyWidget("ProfileNotFound");
35
37 return;
38
39 m_wHud = m_wFirstColumnWidget.FindAnyWidget("CareerProfileHUD0");
40 if (!m_wHud)
41 return;
42
44 if (!m_HudHandler)
45 return;
46 m_HudHandler.PrepareHUD("", "RankTitleText", "BackgroundUserPicture", "CharacterLoadout", "LevelProgress", "PlayerLevel", "ProgressBar0", "");
47
48 Widget m_wCharacterLoadout = m_wHud.FindAnyWidget("CharacterLoadout");
49 if (!m_wCharacterLoadout)
50 return;
52 m_LoadoutPreviewHandler.SetPreviewedLoadout(m_PlayerLoadout);
53
56 return;
57
58 if (!m_PlayerData)
59 m_PlayerData = new SCR_PlayerData(0, false); //We use ID 0 to indicate that it's the local user
60
61 if (m_PlayerData.IsDataReady())
62 FillFields();
63 else
64 m_PlayerData.GetDataReadyInvoker().Insert(FillFields);
65 }
66
67 //------------------------------------------------------------------------------------------------
68 override void OnMenuUpdate(float tDelta)
69 {
70 super.OnMenuUpdate(tDelta);
71
72 GetGame().GetInputManager().ActivateContext("CareerProfileContext");
73 }
74
75 //------------------------------------------------------------------------------------------------
76 protected void FillFields()
77 {
78 if (!m_PlayerData || !m_PlayerData.IsDataReady())
79 {
80 Print("SCR_CareerEndScreenUI: Array of EarntPoints from player's PlayerData object is empty.", LogLevel.ERROR);
81 return;
82 }
83
84 #ifdef DEBUG_PLAYERPROFILE
85 m_PlayerData.DebugCalculateStats();
86 #endif
87
88 FillScreen(!m_PlayerData.IsEmptyProfile());
89 }
90
91 //------------------------------------------------------------------------------------------------
92 void FillScreen(bool profileDataFound)
93 {
94 if (profileDataFound)
95 {
96 m_wFirstColumnWidget.SetVisible(true);
97 m_wCareerSpecializationsWidget.SetVisible(true);
98 m_wProfileNotFound.SetVisible(false);
101 }
102 else
103 {
104 m_wFirstColumnWidget.SetVisible(false);
105 m_wCareerSpecializationsWidget.SetVisible(false);
106 m_wProfileNotFound.SetVisible(true);
107 }
108 }
109
110 //------------------------------------------------------------------------------------------------
111 protected void FillHudAndStats()
112 {
113 #ifdef DEBUG_PLAYERPROFILE
114 Print("SCR_CareerProfileOverviewUI: Debugging FillHudAndStats!", LogLevel.DEBUG);
115 #endif
116
117 int Level = m_PlayerData.GetStat(SCR_EDataStats.LEVEL_EXPERIENCE);
118
120 m_HudHandler.SetProgressBarValue(Level % SCR_PlayerDataConfigs.XP_NEEDED_FOR_LEVEL);
121 m_HudHandler.SetPlayerRank(m_PlayerData.GetStat(SCR_EDataStats.RANK));
122 m_HudHandler.SetRandomBackgroundPicture();
123
124 Widget RankStatsWidget = m_wFirstColumnWidget.FindAnyWidget("RankStatEntries");
125 if (!RankStatsWidget)
126 return;
127
128 #ifdef DEBUG_PLAYERPROFILE
129 array<float> EarntPoints = m_PlayerData.GetArrayEarntPoints();
130
131 m_HudHandler.SetLevelProgressGain(EarntPoints[SCR_EDataStats.LEVELEXPERIENCE]);
132
133 float warCrimes = (m_PlayerData.GetWarCrimes()) * (SCR_PlayerDataConfigs.WARCRIMESPUNISHMENT);
134 int minutes = (m_PlayerData.GetSessionDuration() - m_PlayerData.GetSessionDuration(false)) / 60;
135 SCR_CareerUI.CreateProgressionStatEntry(RankStatsWidget, m_ProgressionStatsLayout, "#AR-CareerProfile_TimePlayed", Math.Floor(EarntPoints[SCR_EDataStats.SESSIONDURATION] * warCrimes), Math.Floor(EarntPoints[SCR_EDataStats.SESSIONDURATION]), "#AR-CareerProfile_Minutes", ""+Math.Floor(minutes));
136 #else
137 int days, hours, minutes, seconds;
138 SCR_DateTimeHelper.GetDayHourMinuteSecondFromSeconds(m_PlayerData.GetStat(SCR_EDataStats.SESSION_DURATION), days, hours, minutes, seconds);
139
140 SCR_CareerUI.CreateStatEntry(RankStatsWidget, m_StatsLayout, "#AR-CareerProfile_TimePlayed", "#AR-CareerProfile_TimePlayed_TotalValue", ""+days, ""+hours, ""+minutes);
141 SCR_CareerUI.CreateStatEntry(RankStatsWidget, m_StatsLayout, "#AR-CareerProfile_Deaths", "#AR-CareerProfile_Times", ""+Math.Floor(m_PlayerData.GetStat(SCR_EDataStats.DEATHS)));
142 SCR_CareerUI.CreateHeaderStatEntry(RankStatsWidget, m_HeaderStatsLayout, "#AR-CareerProfile_Distance");
143 SCR_CareerUI.CreateStatEntry(RankStatsWidget, m_StatsLayout, "#AR-CareerProfile_DistanceTravelled_ByFoot", "#AR-CareerProfile_KMs", ""+Math.Floor(m_PlayerData.GetStat(SCR_EDataStats.DISTANCE_WALKED)/1000));
144 SCR_CareerUI.CreateStatEntry(RankStatsWidget, m_StatsLayout, "#AR-CareerProfile_DistanceTravelled_AsDriver", "#AR-CareerProfile_KMs", ""+Math.Floor(m_PlayerData.GetStat(SCR_EDataStats.DISTANCE_DRIVEN)/1000));
145 SCR_CareerUI.CreateStatEntry(RankStatsWidget, m_StatsLayout, "#AR-CareerProfile_DistanceTravelled_AsPassenger", "#AR-CareerProfile_KMs", ""+Math.Floor(m_PlayerData.GetStat(SCR_EDataStats.DISTANCE_AS_OCCUPANT)/1000));
146 #endif
147 }
148
149 //------------------------------------------------------------------------------------------------
151 {
152 #ifdef DEBUG_PLAYERPROFILE
153 Print("SCR_CareerProfileOverviewUI: Debugging FillSpecializationsFrame!", LogLevel.DEBUG);
154 m_CareerSpecializationsHandler.SetShowProgression(true);
155 #else
156 m_CareerSpecializationsHandler.SetShowProgression(false);
157 #endif
158
160 m_CareerSpecializationsHandler.FillWarCrimes();
161
162 /*
163 EInputDeviceType device = GetGame().GetInputManager().GetLastUsedInputDevice();
164 ControllerActive(device, device);
165
166 GetGame().OnInputDeviceUserChangedInvoker().Insert(ControllerActive);
167 */
168 }
169
170 //------------------------------------------------------------------------------------------------
171 protected void ControllerActive(EInputDeviceType oldDevice, EInputDeviceType newDevice)
172 {
173 if (newDevice == EInputDeviceType.GAMEPAD || newDevice == EInputDeviceType.JOYSTICK)
174 {
175 Print("Device is gamepad or joystick now", LogLevel.DEBUG);
176 //m_CareerSpecializationsHandler.SetLeftAndRightUIActivate(true);
177 }
178 else
179 {
180 if (oldDevice != EInputDeviceType.GAMEPAD || newDevice != EInputDeviceType.JOYSTICK)
181 return;
182 Print("Device is mouse or keyboard now", LogLevel.DEBUG);
183 //m_CareerSpecializationsHandler.SetLeftAndRightUIActivate(false);
184 }
185 }
186};
ArmaReforgerScripted GetGame()
Definition game.c:1398
SCR_DestructionSynchronizationComponentClass ScriptComponentClass int index
SCR_EDataStats
Definition Math.c:13
override void OnTabCreate(Widget menuRoot, ResourceName buttonsLayout, int index)
SCR_LoadoutPreviewComponent m_LoadoutPreviewHandler
SCR_CareerSpecializationsUI m_CareerSpecializationsHandler
void FillScreen(bool profileDataFound)
override void OnMenuUpdate(float tDelta)
ref SCR_BasePlayerLoadout m_PlayerLoadout
void ControllerActive(EInputDeviceType oldDevice, EInputDeviceType newDevice)
static const int XP_NEEDED_FOR_LEVEL
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