Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_CareerProfileOverviewUI.c
Go to the documentation of this file.
1 //#define DEBUG_PLAYERPROFILE
3 {
4  protected Widget m_wFirstColumnWidget;
5  protected Widget m_wCareerSpecializationsWidget;
6  protected Widget m_wProfileNotFound;
7 
8  protected Widget m_wHud;
9  protected SCR_CareerProfileHUD m_HudHandler;
10  protected SCR_CareerSpecializationsUI m_CareerSpecializationsHandler;
11  protected SCR_LoadoutPreviewComponent m_LoadoutPreviewHandler;
12 
13  [Attribute("", UIWidgets.Object, category: "Loadout Manager")]
14  protected ref SCR_BasePlayerLoadout m_PlayerLoadout;
15 
16  [Attribute(params: "Stats layout")]
17  protected ResourceName m_StatsLayout;
18 
19  [Attribute(params: "Header of Stats layout")]
20  protected ResourceName m_HeaderStatsLayout;
21 
22  [Attribute(params: "Stats Progression layout")]
23  protected ResourceName m_ProgressionStatsLayout;
24 
25  protected ref SCR_PlayerData m_PlayerData;
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 
36  if (!m_wFirstColumnWidget || !m_wCareerSpecializationsWidget || !m_wProfileNotFound)
37  return;
38 
39  m_wHud = m_wFirstColumnWidget.FindAnyWidget("CareerProfileHUD0");
40  if (!m_wHud)
41  return;
42 
43  m_HudHandler = SCR_CareerProfileHUD.Cast(m_wHud.FindHandler(SCR_CareerProfileHUD));
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;
51  m_LoadoutPreviewHandler = SCR_LoadoutPreviewComponent.Cast(m_wCharacterLoadout.FindHandler(SCR_LoadoutPreviewComponent));
52  m_LoadoutPreviewHandler.SetPreviewedLoadout(m_PlayerLoadout);
53 
54  m_CareerSpecializationsHandler = SCR_CareerSpecializationsUI.Cast(m_wCareerSpecializationsWidget.FindHandler(SCR_CareerSpecializationsUI));
55  if (!m_CareerSpecializationsHandler)
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);
99  FillHudAndStats();
100  FillSpecializationsFrame();
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 
119  m_HudHandler.SetPlayerLevel(Level / SCR_PlayerDataConfigs.XP_NEEDED_FOR_LEVEL);
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  //------------------------------------------------------------------------------------------------
150  protected void FillSpecializationsFrame()
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 
159  m_CareerSpecializationsHandler.FillSpecializations(m_PlayerData, m_StatsLayout, m_HeaderStatsLayout, m_ProgressionStatsLayout);
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 };
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
SCR_CareerProfileOverviewUI
Definition: SCR_CareerProfileOverviewUI.c:2
SCR_SubMenuBase
Definition: SCR_SubMenuBase.c:6
SCR_PlayerData
Definition: SCR_PlayerData.c:2
GetRootWidget
Widget GetRootWidget()
Definition: SCR_UITaskManagerComponent.c:160
SCR_CareerProfileHUD
Definition: SCR_CareerProfileHUD.c:2
SCR_PlayerDataConfigs
Definition: SCR_PlayerDataConfigs.c:102
SCR_DateTimeHelper
Definition: SCR_DateTimeHelper.c:1
Attribute
typedef Attribute
Post-process effect of scripted camera.
SCR_CareerSpecializationsUI
Definition: SCR_CareerSpecializationsUI.c:2
SCR_EDataStats
SCR_EDataStats
Definition: SCR_PlayerData.c:950
SCR_CareerUI
Definition: SCR_CareerUI.c:2
index
SCR_DestructionSynchronizationComponentClass ScriptComponentClass int index
Definition: SCR_DestructionSynchronizationComponent.c:17
params
Configs ServerBrowser KickDialogs params
Definition: SCR_NotificationSenderComponent.c:24
SCR_LoadoutPreviewComponent
Definition: SCR_LoadoutPreviewComponent.c:1
SCR_BasePlayerLoadout
Definition: SCR_BasePlayerLoadout.c:2
category
params category
Definition: SCR_VehicleDamageManagerComponent.c:180