5 protected const string WIDGET_NAME_EDIT =
"editPlayerName";
6 protected const string WIDGET_LOADOUT_STATS =
"hLoadoutPanel";
7 protected const string WIDGET_CHARACTER_PREVIEW =
"CharacterPreview";
9 protected const string STRING_UNKNOWN_STAT =
"Unknown";
12 const ResourceName ENTRY_LAYOUT =
"{C87F7F6734B61688}UI/layouts/Menus/Career/CareerEntry.layout";
21 protected Widget m_wEditPlayerName;
25 protected ref array<string> m_aBackendValues =
new array<string>();
44 protected void CreateStatEntry(Widget wParent,
string sName,
string sLabel,
string sValue)
46 Widget entry =
GetGame().GetWorkspace().CreateWidgets(ENTRY_LAYOUT, wParent);
50 string sLabelName =
"txtLabel";
51 TextWidget wLabel = TextWidget.Cast(entry.FindAnyWidget(sLabelName));
53 wLabel.SetText(sLabel);
62 override bool OnChange(Widget w,
int x,
int y,
bool finished)
64 if (!finished || !m_EditPlayerName || w != m_EditPlayerName.GetRootWidget())
80 string nameNew = m_EditPlayerName.GetValue();
81 nameNew = nameNew.Trim();
83 m_EditPlayerName.SetValue(nameOld);
87 void UpdateCareerData()
91 Widget wClassList =
GetGame().GetWorkspace().FindAnyWidget(
"vStatList");
93 if (m_aBackendValues.Count() == 0)
97 int count = stats.GetVariableCount();
98 for (
int i = 0; i < count; i++)
100 m_aBackendValues.Insert(
"");
105 m_aBackendValues[
ECareerStatId.KILLS] = m_BackendData.GetKills().ToString();
106 m_aBackendValues[
ECareerStatId.DEATHS] = m_BackendData.GetDeaths().ToString();
107 m_aBackendValues[
ECareerStatId.FRIENDLY_KILLS] = m_BackendData.GetFriendlyKills().ToString();
110 m_aBackendValues[
ECareerStatId.PLAYTIME_RIFFLEMAN] = STRING_UNKNOWN_STAT;
111 m_aBackendValues[
ECareerStatId.PLAYIME_SHARPSHOOTER] = STRING_UNKNOWN_STAT;
114 m_aBackendValues[
ECareerStatId.HEADSHOTS] = STRING_UNKNOWN_STAT;
116 if (m_LoadoutStatistics)
117 m_LoadoutStatistics.UpdateStats(m_LoadoutStatistics.GetCurrentLoadoutId());
121 array<string> GetBackendValues() {
return m_aBackendValues; }
124 protected void TestingShow()
131 override void OnMenuUpdate(
float tDelta)
133 if (!m_BackendData &&
GetGame().GetBackendApi().IsAuthenticated())
136 BackendApi backendApi =
GetGame().GetBackendApi();
138 backendApi.PlayerRequest(EBackendRequest.EBREQ_GAME_CharacterGet,
m_Callback, m_BackendData, 0);
141 super.OnMenuUpdate(tDelta);
145 override void OnMenuShow()
148 #ifndef PLATFORM_WINDOWS
149 if (m_wEditPlayerName)
150 m_wEditPlayerName.SetEnabled(
false);
154 m_wEditPlayerName =
GetRootWidget().FindAnyWidget(WIDGET_NAME_EDIT);
155 if (m_wEditPlayerName)
158 if (m_EditPlayerName)
161 m_EditPlayerName.m_OnConfirm.Insert(OnPlayerNameConfirm);
163 string profileName =
SCR_Global.GetProfileName();
164 m_EditPlayerName.SetValue(profileName);
171 override void OnMenuOpen()
175 InputManager inputManager =
GetGame().GetInputManager();
176 inputManager.AddActionListener(
"MenuBack", EActionTrigger.PRESSED, Back );
179 Widget wCharacterPreview =
GetRootWidget().FindAnyWidget(WIDGET_CHARACTER_PREVIEW);
180 if (wCharacterPreview)
186 Widget wLoadoutStats =
GetRootWidget().FindAnyWidget(WIDGET_LOADOUT_STATS);
190 if (m_LoadoutStatistics)
192 m_LoadoutStatistics.SetCareerUI(
this);
193 m_LoadoutStatistics.m_OnLoadoutChange.Insert(OnLoadoutChange);
194 OnLoadoutChange(m_LoadoutStatistics.GetCurrentLoadoutId());
201 override void OnMenuClose()
209 protected void OnLoadoutChange(
int id)
211 if (!m_LoadoutPreview || !m_LoadoutStatistics)
215 LoadoutStatSet statSet = m_LoadoutStatistics.GetLodoutStatSets()[id];
217 m_LoadoutPreview.SetPreviewedLoadout(statSet.GetLoadout());
224 override void OnSuccess(
int code )
229 override void OnError(
int code,
int restCode,
int apiCode )
231 Print(
"[BackendCallback] OnError: "+
GetGame().GetBackendApi().GetErrorCode(code));
233 override void OnTimeout()
235 Print(
"[BackendCallback] OnTimeout");