Arma Reforger Explorer
1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Toggle main menu visibility
Loading...
Searching...
No Matches
SCR_HUDSlotUIComponent.c
Go to the documentation of this file.
1
void
SCR_HUDSlotResizeCallback
(SCR_InfoDisplay display);
2
typedef
func
SCR_SlotResizeCallback
;
3
typedef
ScriptInvokerBase<SCR_SlotResizeCallback>
SCR_HUDSlotResizeInvoker
;
4
5
class
SCR_HUDSlotUIComponent
:
ScriptedWidgetComponent
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
;
20
protected
WorkspaceWidget
m_wWorkspace
;
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
29
protected
ref
SCR_HUDSlotResizeInvoker
m_OnResize
=
new
SCR_HUDSlotResizeInvoker
();
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."
)]
41
bool
m_bSizeToContent
;
42
43
//------------------------------------------------------------------------------------------------
47
int
GetHeight
()
48
{
49
return
m_iHeight
;
50
}
51
52
//------------------------------------------------------------------------------------------------
56
int
GetWidth
()
57
{
58
return
m_iWidth
;
59
}
60
61
//------------------------------------------------------------------------------------------------
65
int
GetPriority
()
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
83
if
(
m_GroupComponent
)
84
m_GroupComponent
.ResizeGroup();
85
}
86
87
//------------------------------------------------------------------------------------------------
91
SCR_HUDSlotResizeInvoker
GetOnResize
()
92
{
93
return
m_OnResize
;
94
}
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
108
if
(
SCR_Global
.
IsEditMode
())
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
148
if
(
SCR_Global
.
IsEditMode
())
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
//------------------------------------------------------------------------------------------------
181
Widget
GetContentWidget
()
182
{
183
return
m_wRoot
.GetChildren();
184
}
185
186
//------------------------------------------------------------------------------------------------
190
Widget
GetRootWidget
()
191
{
192
return
m_wRoot
;
193
}
194
195
//------------------------------------------------------------------------------------------------
199
void
Initialize
()
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
//------------------------------------------------------------------------------------------------
219
protected
SCR_HUDGroupUIComponent
GetGroupComponent
()
220
{
221
Widget
parent =
m_wRoot
.GetParent();
222
223
if
(!
m_GroupComponent
&& parent)
224
m_GroupComponent
=
SCR_HUDGroupUIComponent
.Cast(parent.FindHandler(
SCR_HUDGroupUIComponent
));
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();
235
GetGroupComponent
();
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
266
if
(
m_bSizeToContent
)
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
296
if
(
m_bSizeToContent
)
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
}
GetGame
ArmaReforgerScripted GetGame()
Definition
game.c:1398
func
func
Definition
SCR_AIThreatSystem.c:6
m_wRoot
Widget m_wRoot
Definition
SCR_GameModeCleanSweep.c:25
SCR_HUDSlotResizeCallback
void SCR_HUDSlotResizeCallback(SCR_InfoDisplay display)
SCR_HUDSlotResizeInvoker
ScriptInvokerBase< SCR_SlotResizeCallback > SCR_HUDSlotResizeInvoker
Definition
SCR_HUDSlotUIComponent.c:3
SCR_SlotResizeCallback
func SCR_SlotResizeCallback
Definition
SCR_HUDSlotUIComponent.c:2
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition
SCR_RespawnBriefingComponent.c:17
Debug
Definition
Debug.c:13
FrameSlot
Definition
FrameSlot.c:13
ImageWidget
Definition
ImageWidget.c:13
OverlayWidget
Definition
OverlayWidget.c:16
RichTextWidget
Definition
RichTextWidget.c:13
SCR_Global
Definition
Functions.c:7
SCR_Global::IsEditMode
static bool IsEditMode()
Definition
Functions.c:1566
SCR_HUDGroupUIComponent
Definition
SCR_HUDGroupUIComponent.c:2
SCR_HUDSlotUIComponent
Definition
SCR_HUDSlotUIComponent.c:6
SCR_HUDSlotUIComponent::m_iPriority
int m_iPriority
Definition
SCR_HUDSlotUIComponent.c:32
SCR_HUDSlotUIComponent::m_iWidth
int m_iWidth
The width of the Slot.
Definition
SCR_HUDSlotUIComponent.c:26
SCR_HUDSlotUIComponent::m_wRoot
Widget m_wRoot
The root widget of the Slot.
Definition
SCR_HUDSlotUIComponent.c:22
SCR_HUDSlotUIComponent::m_aHeightSteps
ref array< int > m_aHeightSteps
Definition
SCR_HUDSlotUIComponent.c:35
SCR_HUDSlotUIComponent::m_iHeight
int m_iHeight
The height of the Slot.
Definition
SCR_HUDSlotUIComponent.c:24
SCR_HUDSlotUIComponent::m_bSizeToContent
bool m_bSizeToContent
Definition
SCR_HUDSlotUIComponent.c:41
SCR_HUDSlotUIComponent::GetHeight
int GetHeight()
Definition
SCR_HUDSlotUIComponent.c:47
SCR_HUDSlotUIComponent::GetPriority
int GetPriority()
Definition
SCR_HUDSlotUIComponent.c:65
SCR_HUDSlotUIComponent::m_wWorkspace
WorkspaceWidget m_wWorkspace
Definition
SCR_HUDSlotUIComponent.c:20
SCR_HUDSlotUIComponent::m_aWidthSteps
ref array< int > m_aWidthSteps
Definition
SCR_HUDSlotUIComponent.c:38
SCR_HUDSlotUIComponent::GetOnResize
SCR_HUDSlotResizeInvoker GetOnResize()
Definition
SCR_HUDSlotUIComponent.c:91
SCR_HUDSlotUIComponent::HandlerAttached
override void HandlerAttached(Widget w)
Definition
SCR_HUDSlotUIComponent.c:229
SCR_HUDSlotUIComponent::m_bInitialized
bool m_bInitialized
A boolean value indicating whether the Slot has been initialized.
Definition
SCR_HUDSlotUIComponent.c:19
SCR_HUDSlotUIComponent::SetHeight
void SetHeight(int height, bool notifyResizing=true)
Definition
SCR_HUDSlotUIComponent.c:100
SCR_HUDSlotUIComponent::GetWidth
int GetWidth()
Definition
SCR_HUDSlotUIComponent.c:56
SCR_HUDSlotUIComponent::Initialize
void Initialize()
Definition
SCR_HUDSlotUIComponent.c:199
SCR_HUDSlotUIComponent::GetGroupComponent
SCR_HUDGroupUIComponent GetGroupComponent()
Definition
SCR_HUDSlotUIComponent.c:219
SCR_HUDSlotUIComponent::SetWidth
void SetWidth(int width, bool notifyResizing=true)
Definition
SCR_HUDSlotUIComponent.c:141
SCR_HUDSlotUIComponent::GetContentWidget
Widget GetContentWidget()
Definition
SCR_HUDSlotUIComponent.c:181
SCR_HUDSlotUIComponent::SetPriority
void SetPriority(int newPriority)
Definition
SCR_HUDSlotUIComponent.c:74
SCR_HUDSlotUIComponent::m_OnResize
ref SCR_HUDSlotResizeInvoker m_OnResize
Definition
SCR_HUDSlotUIComponent.c:29
SCR_HUDSlotUIComponent::m_GroupComponent
SCR_HUDGroupUIComponent m_GroupComponent
Definition
SCR_HUDSlotUIComponent.c:28
SCR_HUDSlotUIComponent::GetRootWidget
Widget GetRootWidget()
Definition
SCR_HUDSlotUIComponent.c:190
ScriptedWidgetComponent
Definition
ScriptedWidgetComponent.c:13
TextWidget
Definition
TextWidget.c:16
Widget
Definition
Widget.c:13
WorkspaceWidget
Definition
WorkspaceWidget.c:16
Print
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
LogLevel
Enum with severity of the logging message.
Definition
LogLevel.c:14
Attribute
SCR_FieldOfViewSettings Attribute
Definition
SendGoalMessage.c:170
scripts
Game
UI
HUD
SCR_HUDSlotUIComponent.c
Generated by
1.17.0