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_CollapseWidgetComponent.c
Go to the documentation of this file.
1
enum
EDirection
2
{
3
LEFT
,
4
UP
,
5
RIGHT
,
6
DOWN
7
};
8
9
class
SCR_CollapseWidgetComponent
:
ScriptedWidgetComponent
10
{
11
[
Attribute
(
"false"
)]
12
protected
bool
m_bCollapsed
;
13
14
[
Attribute
(
"0"
,
UIWidgets
.ComboBox,
"Direction of the collapse"
,
""
, ParamEnumArray.FromEnum(
EDirection
))]
15
protected
EDirection
m_eCollapseDirection
;
16
17
[
Attribute
(
"0.5"
)]
18
protected
float
m_fCollapseTime
;
19
20
[
Attribute
(
desc
:
"Is widget slot a frame, or if it's inside a layout slot. FRAME SLOT NOT IMPLEMENTED!"
)]
21
protected
bool
m_bIsFrameSlot
;
22
23
protected
float
m_fDefaultValue
=
float
.MAX;
24
protected
Widget
m_wRoot
;
25
protected
float
m_fTimeout
= 50;
26
27
//ref ScriptInvoker<bool> m_OnToggled = new ScriptInvoker();
28
29
//------------------------------------------------------------------------------------------------
30
override
void
HandlerAttached
(
Widget
w)
31
{
32
m_wRoot
= w;
33
SetCollapseTime
(
m_fCollapseTime
);
34
35
if
(!
m_bCollapsed
)
36
return
;
37
38
// Hack - delayed start (if there should be animation)
39
if
(
m_fCollapseTime
!=
float
.
MAX
)
40
{
41
float
opacity = w.GetOpacity();
42
w.SetOpacity(0);
43
GetGame
().GetCallqueue().CallLater(
ShowWidgetDelayed
,
m_fTimeout
,
false
, opacity);
44
}
45
else
46
{
47
SetCollapsed
(
m_bCollapsed
,
false
);
48
}
49
}
50
51
//------------------------------------------------------------------------------------------------
52
void
ShowWidgetDelayed
(
float
opacity)
53
{
54
AnimateWidget
.
Opacity
(
m_wRoot
, opacity,
UIConstants
.FADE_RATE_FAST);
55
SetCollapsed
(
true
,
false
);
56
}
57
58
//------------------------------------------------------------------------------------------------
59
Widget
GetRootWidget
()
60
{
61
return
m_wRoot
;
62
}
63
64
//------------------------------------------------------------------------------------------------
65
void
SetCollapsed
(
bool
collapsed,
bool
animate =
true
)
66
{
67
if
(
m_bCollapsed
== collapsed && animate)
68
return
;
69
70
m_bCollapsed
= collapsed;
71
72
if
(
m_bIsFrameSlot
)
73
Print
(
"CollapseWidgetComponent frameSlot not implemented"
,
LogLevel
.WARNING);
74
else
75
SetupLayoutAnimation
(
m_fCollapseTime
, animate);
76
}
77
78
//------------------------------------------------------------------------------------------------
79
bool
IsCollapsed
()
80
{
81
return
m_bCollapsed
;
82
}
83
84
//------------------------------------------------------------------------------------------------
85
void
SetCollapseTime
(
float
time)
86
{
87
// Convert to collapse speed
88
if
(time <= 0)
89
m_fCollapseTime
=
float
.MAX;
90
else
91
m_fCollapseTime
= 1 / time;
92
}
93
94
//------------------------------------------------------------------------------------------------
95
float
GetCollapseTime
()
96
{
97
// Collapse speed can never be 0
98
return
1 /
m_fCollapseTime
;
99
}
100
101
//------------------------------------------------------------------------------------------------
102
void
SetCollpseDirection
(
EDirection
direction
)
103
{
104
m_eCollapseDirection
=
direction
;
105
}
106
107
//------------------------------------------------------------------------------------------------
108
EDirection
GetCollapseDirection
()
109
{
110
return
m_eCollapseDirection
;
111
}
112
113
//------------------------------------------------------------------------------------------------
114
protected
void
SetupLayoutAnimation
(
float
speed,
bool
animate)
115
{
116
if
(!
m_wRoot
)
117
return
;
118
119
// Do not try to animate the collapse if animation is too fast
120
if
(
m_fCollapseTime
==
float
.
MAX
)
121
animate =
false
;
122
123
float
left, top, right, bottom, w, h;
124
AlignableSlot
.GetPadding(
m_wRoot
, left, top, right, bottom);
125
m_wRoot
.GetScreenSize(w, h);
126
if
(w <= 0 || h <= 0)
127
{
128
//m_wRoot.Update();
129
m_wRoot
.GetScreenSize(w, h);
130
}
131
132
w =
GetGame
().GetWorkspace().DPIUnscale(w);
133
h =
GetGame
().GetWorkspace().DPIUnscale(h);
134
135
float
paddings[4];
136
137
switch
(
m_eCollapseDirection
)
138
{
139
case
EDirection
.LEFT:
140
if
(
m_bCollapsed
)
141
{
142
if
(
m_fDefaultValue
==
float
.
MAX
)
143
m_fDefaultValue
= left;
144
145
paddings = {-w - right, top, right, bottom};
146
}
147
else
148
{
149
paddings = {
m_fDefaultValue
, top, right, bottom};
150
}
151
break
;
152
case
EDirection
.UP:
153
if
(
m_bCollapsed
)
154
{
155
if
(
m_fDefaultValue
==
float
.
MAX
)
156
m_fDefaultValue
= top;
157
158
paddings = {left, -h - bottom, right, bottom};
159
}
160
else
161
{
162
paddings = {left,
m_fDefaultValue
, right, bottom};
163
}
164
break
;
165
case
EDirection
.RIGHT:
166
if
(
m_bCollapsed
)
167
{
168
if
(
m_fDefaultValue
==
float
.
MAX
)
169
m_fDefaultValue
= right;
170
171
paddings = {left, top, -w - left, bottom};
172
}
173
else
174
{
175
paddings = {left, top,
m_fDefaultValue
, bottom};
176
}
177
break
;
178
case
EDirection
.DOWN:
179
if
(
m_bCollapsed
)
180
{
181
if
(
m_fDefaultValue
==
float
.
MAX
)
182
m_fDefaultValue
= bottom;
183
184
paddings = {left, top, right, -h - top};
185
}
186
else
187
{
188
paddings = {left, top, right,
m_fDefaultValue
};
189
}
190
break
;
191
}
192
193
if
(animate)
194
AnimateWidget
.
Padding
(
m_wRoot
, paddings, speed);
195
else
196
m_wRoot
.SetVisible(!
m_bCollapsed
);
// Do not attempt to set any padding, just hide the widget
197
//AlignableSlot.SetPadding(m_wRoot, paddings[0], paddings[1], paddings[2], paddings[3]);
198
}
199
};
GetGame
ArmaReforgerScripted GetGame()
Definition
game.c:1398
EDirection
EDirection
Definition
SCR_CollapseWidgetComponent.c:2
direction
vector direction
Definition
SCR_DestructibleTreeV2.c:31
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition
SCR_RespawnBriefingComponent.c:17
AlignableSlot
Definition
AlignableSlot.c:13
AnimateWidget
Definition
AnimateWidget.c:3
AnimateWidget::Padding
static WidgetAnimationPadding Padding(Widget widget, float padding[4], float speed)
Definition
AnimateWidget.c:235
AnimateWidget::Opacity
static WidgetAnimationOpacity Opacity(Widget widget, float targetValue, float speed, bool toggleVisibility=false)
Definition
AnimateWidget.c:167
SCR_CollapseWidgetComponent
Definition
SCR_CollapseWidgetComponent.c:10
SCR_CollapseWidgetComponent::m_fDefaultValue
float m_fDefaultValue
Definition
SCR_CollapseWidgetComponent.c:23
SCR_CollapseWidgetComponent::SetCollapsed
void SetCollapsed(bool collapsed, bool animate=true)
Definition
SCR_CollapseWidgetComponent.c:65
SCR_CollapseWidgetComponent::m_eCollapseDirection
EDirection m_eCollapseDirection
Definition
SCR_CollapseWidgetComponent.c:15
SCR_CollapseWidgetComponent::SetCollpseDirection
void SetCollpseDirection(EDirection direction)
Definition
SCR_CollapseWidgetComponent.c:102
SCR_CollapseWidgetComponent::m_fTimeout
float m_fTimeout
Definition
SCR_CollapseWidgetComponent.c:25
SCR_CollapseWidgetComponent::GetCollapseTime
float GetCollapseTime()
Definition
SCR_CollapseWidgetComponent.c:95
SCR_CollapseWidgetComponent::GetCollapseDirection
EDirection GetCollapseDirection()
Definition
SCR_CollapseWidgetComponent.c:108
SCR_CollapseWidgetComponent::m_bIsFrameSlot
bool m_bIsFrameSlot
Definition
SCR_CollapseWidgetComponent.c:21
SCR_CollapseWidgetComponent::SetupLayoutAnimation
void SetupLayoutAnimation(float speed, bool animate)
Definition
SCR_CollapseWidgetComponent.c:114
SCR_CollapseWidgetComponent::IsCollapsed
bool IsCollapsed()
Definition
SCR_CollapseWidgetComponent.c:79
SCR_CollapseWidgetComponent::m_fCollapseTime
float m_fCollapseTime
Definition
SCR_CollapseWidgetComponent.c:18
SCR_CollapseWidgetComponent::SetCollapseTime
void SetCollapseTime(float time)
Definition
SCR_CollapseWidgetComponent.c:85
SCR_CollapseWidgetComponent::HandlerAttached
override void HandlerAttached(Widget w)
Definition
SCR_CollapseWidgetComponent.c:30
SCR_CollapseWidgetComponent::GetRootWidget
Widget GetRootWidget()
Definition
SCR_CollapseWidgetComponent.c:59
SCR_CollapseWidgetComponent::ShowWidgetDelayed
void ShowWidgetDelayed(float opacity)
Definition
SCR_CollapseWidgetComponent.c:52
SCR_CollapseWidgetComponent::m_wRoot
Widget m_wRoot
Definition
SCR_CollapseWidgetComponent.c:24
SCR_CollapseWidgetComponent::m_bCollapsed
bool m_bCollapsed
Definition
SCR_CollapseWidgetComponent.c:12
ScriptedWidgetComponent
Definition
ScriptedWidgetComponent.c:13
UIConstants
Definition
Constants.c:151
UIWidgets
Definition
attributes.c:40
Widget
Definition
Widget.c:13
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
LEFT
@ LEFT
navigation
Definition
GamepadTrigger.c:14
RIGHT
@ RIGHT
Definition
GamepadTrigger.c:15
MAX
@ MAX
Definition
ETurretContextID.c:19
DOWN
@ DOWN
call listener when button/key is pressed
Definition
ControlID.c:22
UP
@ UP
call listener when button/key is released
Definition
ControlID.c:21
scripts
Game
UI
Components
WidgetLibrary
SCR_CollapseWidgetComponent.c
Generated by
1.17.0