7 protected ref array<ref LoadoutStatSet> m_aLoadouts;
10 protected const ResourceName ENTRY_LAYOUT =
"{C87F7F6734B61688}UI/layouts/Menus/Career/CareerEntry.layout";
13 protected const string WIDGET_LOADOUT_SPIN =
"SpinLoadout";
14 protected const string WIDGET_STAT_LIST =
"vStatList";
17 protected Widget m_wRoot;
18 protected Widget m_wStatList;
19 protected Widget m_wLoadoutSpin;
25 protected ref array<ref Widget> m_aStatWidgets =
new array<ref Widget>();
28 protected int m_iEntryCount = 0;
29 protected int m_iSelected = 0;
31 ref ScriptInvoker m_OnLoadoutChange =
new ScriptInvoker();
34 override void HandlerAttached(Widget w)
37 m_wStatList = w.FindAnyWidget(WIDGET_STAT_LIST);
40 m_wLoadoutSpin = w.FindAnyWidget(WIDGET_LOADOUT_SPIN);
45 m_LoadoutSpin.m_OnChanged.Insert(OnLoadoutChanged);
49 CreateStatEntries(m_iEntryCount);
51 OnLoadoutChanged(
null, m_LoadoutSpin.GetCurrentIndex());
56 protected void SetupLoadoutSpin()
62 int total = m_aLoadouts.Count();
68 m_LoadoutSpin.AddItem(statSet.GetLoadout().GetLoadoutName(), i == total - 1);
74 if (statSet.GetStats())
75 c = statSet.GetStats().Count();
78 if (c > m_iEntryCount)
84 protected void CreateStatEntries(
int count)
86 for (
int i = 0; i < count; i++)
88 Widget entry =
GetGame().GetWorkspace().CreateWidgets(ENTRY_LAYOUT, m_wStatList);
89 m_aStatWidgets.Insert(entry);
90 entry.SetVisible(
false);
98 m_OnLoadoutChange.Invoke(
id);
102 void UpdateStats(
int id)
108 if (m_aLoadouts[
id].GetStats())
109 count = m_aLoadouts[id].GetStats().Count();
112 for (
int i = 0; i < m_aStatWidgets.Count(); i++)
114 Widget entry = m_aStatWidgets[i];
116 bool display = i < count;
118 entry.SetVisible(display);
122 string name = m_aLoadouts[id].GetStats()[i].m_sName;
123 int valueId = m_aLoadouts[id].GetStats()[i].m_iValueId;
126 value = m_CareerUI.GetBackendValues()[valueId];
127 SetStatEntry(
"", name, value, entry);
132 protected void SetStatEntry(
string sName,
string sLabel,
string sValue, Widget wEntry =
null)
137 SetStatLabel(sName, sLabel, wEntry);
138 SetStatValue(sName, sValue, wEntry);
142 protected void SetStatLabel(
string sName,
string sLabel, Widget wEntry =
null)
147 string sLabelName =
"txtLabel";
148 TextWidget wLabel = TextWidget.Cast(wEntry.FindAnyWidget(sLabelName));
150 wLabel.SetText(sLabel);
154 protected void SetStatValue(
string sName,
string sValue, Widget wEntry =
null)
159 string sValueName =
"txtValue";
160 TextWidget wValue = TextWidget.Cast(wEntry.FindAnyWidget(sValueName));
162 wValue.SetText(sValue);
166 array<ref LoadoutStatSet> GetLodoutStatSets() {
return m_aLoadouts; }
167 int GetCurrentLoadoutId() {
return m_iSelected; }
170 void SetCareerUI(
CareerMenuUI careerUI) { m_CareerUI = careerUI; }
181 protected ref array<ref LoadoutStat> m_aStats;
184 array<ref LoadoutStat> GetStats() {
return m_aStats; }