Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_HUDSlotUIComponent.c
Go to the documentation of this file.
1void SCR_HUDSlotResizeCallback(SCR_InfoDisplay display);
3typedef ScriptInvokerBase<SCR_SlotResizeCallback> SCR_HUDSlotResizeInvoker;
4
6{
7// Define member variables that are only included in the Workbench for debugging purposes.
8#ifdef WORKBENCH
9 OverlayWidget m_wDebugOverlay;
10 ImageWidget m_wDebugImg;
11 Widget m_wDebugVertical
12 TextWidget m_wDebugNameText;
13 RichTextWidget m_wDebugHeightText;
14 RichTextWidget m_wDebugWidthText;
15 TextWidget m_wDebugPriorityText;
16#endif
17
19 protected bool m_bInitialized;
22 protected Widget m_wRoot;
24 protected int m_iHeight;
26 protected int m_iWidth;
27
28 protected SCR_HUDGroupUIComponent m_GroupComponent; // The Group this Slot is part of
30
31 [Attribute(desc: "Priority of the Slot")]
32 protected int m_iPriority;
33
34 [Attribute(desc: "Possible height steps for the Slot.")]
35 ref array<int> m_aHeightSteps;
36
37 [Attribute(desc: "Possible width steps for the component.")]
38 ref array<int> m_aWidthSteps;
39
40 [Attribute(desc: "Whether the Slot should be sized to its content.")]
42
43 //------------------------------------------------------------------------------------------------
48 {
49 return m_iHeight;
50 }
51
52 //------------------------------------------------------------------------------------------------
57 {
58 return m_iWidth;
59 }
60
61 //------------------------------------------------------------------------------------------------
66 {
67 return m_iPriority;
68 }
69
70 //------------------------------------------------------------------------------------------------
74 void SetPriority(int newPriority)
75 {
76 m_iPriority = newPriority;
77
78#ifdef WORKBENCH
79 if (m_wDebugPriorityText)
80 m_wDebugPriorityText.SetText("Priority: " + m_iPriority.ToString());
81#endif
82
84 m_GroupComponent.ResizeGroup();
85 }
86
87 //------------------------------------------------------------------------------------------------
95
96 //------------------------------------------------------------------------------------------------
100 void SetHeight(int height, bool notifyResizing = true)
101 {
102 if (m_iHeight == height)
103 return;
104
105 m_iHeight = height;
106
107#ifdef WORKBENCH
109 {
110 DebugHeightInfo();
111 return;
112 }
113#endif
114 Widget contentWidget = GetContentWidget();
115
116 // If the Slot is not set to size to content, set the Height of the content Widget to the new height
117 if (!m_bSizeToContent && contentWidget)
118 {
119 FrameSlot.SetSizeY(contentWidget, m_iHeight);
120 }
121 // Otherwise, set the height of the Slot to the height of the content Widget
122 else if (m_bSizeToContent)
123 {
124 float contentWidth = 0;
125 float contentHeight = 0;
126
127 if (contentWidget)
128 contentWidget.GetScreenSize(contentWidth, contentHeight);
129
130 m_iHeight = m_wWorkspace.DPIUnscale(contentHeight);
131 }
132
133 if (notifyResizing)
134 m_OnResize.Invoke(this);
135 }
136
137 //------------------------------------------------------------------------------------------------
141 void SetWidth(int width, bool notifyResizing = true)
142 {
143 if (m_iWidth == width)
144 return;
145
146 m_iWidth = width;
147#ifdef WORKBENCH
149 {
150 DebugWidthInfo();
151 return;
152 }
153#endif
154 Widget contentWidget = GetContentWidget();
155
156 // If the Slot is not set to size to content, set the Width of the content Widget to the new width
157 if (!m_bSizeToContent && contentWidget)
158 {
159 FrameSlot.SetSizeX(contentWidget, m_iWidth);
160 }
161 // Otherwise, set the width of the component to the width of the content Widget
162 else if (m_bSizeToContent)
163 {
164 float contentWidth = 0;
165 float contentHeight = 0;
166
167 if (contentWidget)
168 contentWidget.GetScreenSize(contentWidth, contentHeight);
169
170 m_iWidth = m_wWorkspace.DPIUnscale(contentWidth);
171 }
172
173 if (notifyResizing)
174 m_OnResize.Invoke(this);
175 }
176
177 //------------------------------------------------------------------------------------------------
182 {
183 return m_wRoot.GetChildren();
184 }
185
186 //------------------------------------------------------------------------------------------------
191 {
192 return m_wRoot;
193 }
194
195 //------------------------------------------------------------------------------------------------
200 {
201 if (m_bInitialized)
202 return;
203
204 Widget child = m_wRoot.GetChildren();
205 if (!child)
206 Print(m_wRoot.GetName() + " Has no Content!", LogLevel.WARNING);
207
208 if (!GetGroupComponent())
209 Debug.Error2("No Group Component", "A Slot's parent must always have a Group Component! Slot: " + m_wRoot.GetName());
210
211 m_wWorkspace = GetGame().GetWorkspace();
212 m_bInitialized = true;
213 }
214
215 //------------------------------------------------------------------------------------------------
220 {
221 Widget parent = m_wRoot.GetParent();
222
223 if (!m_GroupComponent && parent)
225 return m_GroupComponent;
226 }
227
228 //------------------------------------------------------------------------------------------------
229 override void HandlerAttached(Widget w)
230 {
231 m_wRoot = w;
232
233 m_aHeightSteps.Sort();
234 m_aWidthSteps.Sort();
236 }
237
238#ifdef WORKBENCH
239 //------------------------------------------------------------------------------------------------
243 void DebugHeightInfo()
244 {
245 if (!m_wDebugHeightText || !SCR_Global.IsEditMode())
246 return;
247 Widget contentWidget = GetContentWidget();
248
249 if (!contentWidget)
250 contentWidget = m_wRoot.GetChildren();
251
252 FrameSlot.SetSizeY(contentWidget, m_iHeight);
253
254 m_wDebugHeightText.SetText("Height:");
255 foreach (int step : m_aHeightSteps)
256 {
257 if (step == m_iHeight)
258 m_wDebugHeightText.SetText(m_wDebugHeightText.GetText() + " <color name='green'>" + step + "</color>");
259 else
260 m_wDebugHeightText.SetText(m_wDebugHeightText.GetText() + " " + step);
261 }
262
263 if (m_aHeightSteps.IsEmpty())
264 m_wDebugHeightText.SetText(string.Empty);
265
267 {
268 FrameSlot.SetSizeY(m_wDebugOverlay, m_iHeight);
269 m_wDebugHeightText.SetText("Height: <color name='green'>" + m_iHeight + "</color>");
270 }
271 }
272
273 //------------------------------------------------------------------------------------------------
277 void DebugWidthInfo()
278 {
279 if (!m_wDebugWidthText || !SCR_Global.IsEditMode())
280 return;
281
282 FrameSlot.SetSizeX(m_wDebugOverlay, m_iWidth);
283
284 m_wDebugWidthText.SetText("Width:");
285 foreach (int step : m_aWidthSteps)
286 {
287 if (step == m_iWidth)
288 m_wDebugWidthText.SetText(m_wDebugWidthText.GetText() + " <color name='green'>" + step + "</color>");
289 else
290 m_wDebugWidthText.SetText(m_wDebugWidthText.GetText() + " " + step);
291 }
292
293 if (m_aWidthSteps.IsEmpty())
294 m_wDebugWidthText.SetText(string.Empty);
295
297 {
298 if (!m_aWidthSteps.IsEmpty())
299 {
300 m_iWidth = m_aWidthSteps[m_aWidthSteps.Count() - 1];
301 FrameSlot.SetSizeX(m_wDebugOverlay, m_iWidth);
302 }
303
304 m_wDebugWidthText.SetText("Width: <color name='green'>" + m_iWidth + "</color>");
305 }
306 }
307#endif
308}
ArmaReforgerScripted GetGame()
Definition game.c:1398
Widget m_wRoot
void SCR_HUDSlotResizeCallback(SCR_InfoDisplay display)
ScriptInvokerBase< SCR_SlotResizeCallback > SCR_HUDSlotResizeInvoker
func SCR_SlotResizeCallback
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition Debug.c:13
static bool IsEditMode()
Definition Functions.c:1566
int m_iWidth
The width of the Slot.
Widget m_wRoot
The root widget of the Slot.
int m_iHeight
The height of the Slot.
SCR_HUDSlotResizeInvoker GetOnResize()
override void HandlerAttached(Widget w)
bool m_bInitialized
A boolean value indicating whether the Slot has been initialized.
void SetHeight(int height, bool notifyResizing=true)
SCR_HUDGroupUIComponent GetGroupComponent()
void SetWidth(int width, bool notifyResizing=true)
void SetPriority(int newPriority)
ref SCR_HUDSlotResizeInvoker m_OnResize
SCR_HUDGroupUIComponent m_GroupComponent
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