Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_CareerUI.c
Go to the documentation of this file.
1 //------------------------------------------------------------------------------------------------
2 class SCR_CareerUI: Managed
3 {
4  //------------------------------------------------------------------------------------------------
5  private void SCR_CareerUI()
6  {}
7 
9  //------------------------------------------------------------------------------------------------
10  static Widget CreateStatEntry(Widget container, ResourceName statsLayout, string text = "", string localizedValue = "", string value1 = "", string value2 = "", string value3 = "")
11  {
12  WorkspaceWidget workspace = GetGame().GetWorkspace();
13  if (!workspace)
14  return null;
15 
16  Widget StatEntry = Widget.Cast(workspace.CreateWidgets(statsLayout, container));
17  if (!StatEntry)
18  return null;
19 
20  RichTextWidget statName, statValue;
21 
22  statName = RichTextWidget.Cast(StatEntry.FindAnyWidget("StatName"));
23  statValue = RichTextWidget.Cast(StatEntry.FindAnyWidget("StatValue"));
24  if (!statName || !statValue)
25  return null;
26 
27  statName.SetText(text);
28  statValue.SetTextFormat(localizedValue, value1, value2, value3);
29 
30  return StatEntry;
31  }
32 
34  //------------------------------------------------------------------------------------------------
35  static Widget CreateProgressionStatEntry(Widget container, ResourceName statsProgressionLayout, string text = "", float progressionMinus = 0, float progression = 0, string localizedValue = "", string value1 = "", string value2 = "", string value3 = "")
36  {
37  WorkspaceWidget workspace = GetGame().GetWorkspace();
38  if (!workspace)
39  return null;
40 
41  Widget StatProgressionEntry = Widget.Cast(workspace.CreateWidgets(statsProgressionLayout, container));
42  if (!StatProgressionEntry)
43  return null;
44 
45  RichTextWidget statName, statProgressionMinus, statProgression, statValue;
46 
47  statName = RichTextWidget.Cast(StatProgressionEntry.FindAnyWidget("StatName"));
48  statProgressionMinus = RichTextWidget.Cast(StatProgressionEntry.FindAnyWidget("StatProgressionMinus"));
49  statProgression = RichTextWidget.Cast(StatProgressionEntry.FindAnyWidget("StatProgression"));
50  statValue = RichTextWidget.Cast(StatProgressionEntry.FindAnyWidget("StatValue"));
51  if (!statName || !statProgressionMinus || !statProgression || !statValue)
52  return null;
53 
54  statName.SetText(text);
55 
56  if (progressionMinus != 0)
57  statProgressionMinus.SetText("-"+progressionMinus+" | ");
58  else
59  statProgressionMinus.SetText("");
60 
61  if (progression != 0)
62  statProgression.SetText("+"+ progression);
63  else
64  statProgression.SetText("");
65 
66  statValue.SetTextFormat(localizedValue, value1, value2, value3);
67 
68  return StatProgressionEntry;
69  }
70 
72  //------------------------------------------------------------------------------------------------
73  static Widget CreateHeaderStatEntry(Widget container, ResourceName headerStatsLayout, string text = "")
74  {
75  WorkspaceWidget workspace = GetGame().GetWorkspace();
76  if (!workspace)
77  return null;
78 
79  Widget HeaderEntry = Widget.Cast(workspace.CreateWidgets(headerStatsLayout, container));
80  if (!HeaderEntry)
81  return null;
82 
83  RichTextWidget textWidget;
84 
85  textWidget = RichTextWidget.Cast(HeaderEntry.FindAnyWidget("HeaderStatText"));
86  if (!textWidget)
87  return null;
88 
89  textWidget.SetText(text);
90 
91  return HeaderEntry;
92  }
93 
95  //------------------------------------------------------------------------------------------------
96  static void UpdateStatEntry(Widget StatEntry, string name, string localizedValue, string value1 = "", string value2 = "", string value3 = "")
97  {
98  if (!StatEntry)
99  return;
100 
101  RichTextWidget statName, statValue;
102 
103  statName = RichTextWidget.Cast(StatEntry.FindAnyWidget("StatName"));
104  statValue = RichTextWidget.Cast(StatEntry.FindAnyWidget("StatValue"));
105  if (!statName || !statValue)
106  return;
107 
108  statName.SetText(name);
109  statValue.SetTextFormat(localizedValue, value1, value2, value3);
110  }
111 
113  //------------------------------------------------------------------------------------------------
114  static void UpdateStatProgressionEntry(Widget StatProgressionEntry, string name, float progressionMinus, float progression, string localizedValue, string value1 = "", string value2 = "", string value3 = "")
115  {
116  if (!StatProgressionEntry)
117  return;
118 
119  RichTextWidget statName, statProgressionMinus, statProgression, statValue;
120 
121  statName = RichTextWidget.Cast(StatProgressionEntry.FindAnyWidget("StatName"));
122  statProgressionMinus = RichTextWidget.Cast(StatProgressionEntry.FindAnyWidget("StatProgressionMinus"));
123  statProgression = RichTextWidget.Cast(StatProgressionEntry.FindAnyWidget("StatProgression"));
124  statValue = RichTextWidget.Cast(StatProgressionEntry.FindAnyWidget("StatValue"));
125  if (!statName || !statProgressionMinus || !statProgression || !statValue)
126  return;
127 
128  statName.SetText(name);
129 
130  if (progressionMinus != 0)
131  statProgressionMinus.SetText(" | -"+progressionMinus);
132  else
133  statProgressionMinus.SetText("");
134 
135  if (progression != 0)
136  statProgression.SetText("+"+ progression);
137  else
138  statProgression.SetText("");
139 
140  statValue.SetTextFormat(localizedValue, value1, value2, value3);
141  }
142 };
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
SCR_CareerUI
Definition: SCR_CareerUI.c:2