Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_CollapseWidgetComponent.c
Go to the documentation of this file.
8
10{
11 [Attribute("false")]
12 protected bool m_bCollapsed;
13
14 [Attribute("0", UIWidgets.ComboBox, "Direction of the collapse", "", ParamEnumArray.FromEnum(EDirection))]
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;
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 {
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 //------------------------------------------------------------------------------------------------
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
73 Print("CollapseWidgetComponent frameSlot not implemented", LogLevel.WARNING);
74 else
76 }
77
78 //------------------------------------------------------------------------------------------------
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 //------------------------------------------------------------------------------------------------
96 {
97 // Collapse speed can never be 0
98 return 1 / m_fCollapseTime;
99 }
100
101 //------------------------------------------------------------------------------------------------
106
107 //------------------------------------------------------------------------------------------------
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};
ArmaReforgerScripted GetGame()
Definition game.c:1398
vector direction
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
static WidgetAnimationPadding Padding(Widget widget, float padding[4], float speed)
static WidgetAnimationOpacity Opacity(Widget widget, float targetValue, float speed, bool toggleVisibility=false)
void SetCollapsed(bool collapsed, bool animate=true)
void SetCollpseDirection(EDirection direction)
void SetupLayoutAnimation(float speed, bool animate)
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
@ LEFT
navigation
@ RIGHT
@ MAX
@ DOWN
call listener when button/key is pressed
Definition ControlID.c:22
@ UP
call listener when button/key is released
Definition ControlID.c:21