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_WLibProgressBar.c
Go to the documentation of this file.
1
//---- REFACTOR NOTE START: This code will need to be refactored as current implementation is not conforming to the standards ----
2
// Does not inherit from wlib base classes, duplicates code instead.
3
5
//------------------------------------------------------------------------------------------------
6
class
SCR_WLibProgressBarComponent
:
ScriptedWidgetComponent
7
{
8
protected
const
string
WIDGET_CHANGE
=
"Change"
;
9
10
[
Attribute
(
"0"
)]
11
protected
float
m_fMin
;
12
13
[
Attribute
(
"1"
)]
14
protected
float
m_fMax
;
15
16
[
Attribute
(
"0.5"
)]
17
protected
float
m_fValue
;
18
19
[
Attribute
(
"false"
)]
20
protected
bool
m_bReverseDirection
;
21
22
[
Attribute
(
"true"
,
desc
:
"Use constant speed of the animation. If false, every change will take the same time."
)]
23
protected
bool
m_bConstantAnimationSpeed
;
24
25
[
Attribute
(
"0.0"
)]
26
protected
float
m_fAnimationTime
;
27
28
[
Attribute
(
"0.760 0.392 0.078 1"
)]
29
ref
Color
m_SliderColor
;
30
31
[
Attribute
(
"0 0 0 0.3"
)]
32
ref
Color
m_BackgroundColor
;
33
34
protected
Widget
m_wRoot
;
35
protected
Widget
m_wBar
;
36
protected
Widget
m_wChange
;
37
protected
Widget
m_wSpacer
;
38
39
protected
float
m_fChange
;
40
41
//------------------------------------------------------------------------------------------------
42
override
void
HandlerAttached
(
Widget
w)
43
{
44
m_wRoot
= w;
45
m_wSpacer
= w.FindAnyWidget(
"Spacer"
);
46
m_wChange
= w.FindAnyWidget(
WIDGET_CHANGE
);
47
m_wBar
= w.FindAnyWidget(
"Bar"
);
48
49
if
(
m_wBar
)
50
{
51
m_wBar
.SetColor(
m_SliderColor
);
52
if
(
m_bReverseDirection
)
53
m_wBar
.SetZOrder(1);
54
}
55
56
Widget
background = w.FindAnyWidget(
"Background"
);
57
if
(background)
58
background.SetColor(
m_BackgroundColor
);
59
60
UpdateVisuals
(
false
);
61
}
62
63
//------------------------------------------------------------------------------------------------
64
void
SetMin
(
float
value)
65
{
66
m_fMin
= value;
67
UpdateVisuals
();
68
}
69
70
//------------------------------------------------------------------------------------------------
71
void
SetMax
(
float
value)
72
{
73
m_fMax
= value;
74
UpdateVisuals
();
75
}
76
77
//------------------------------------------------------------------------------------------------
78
void
SetValue
(
float
value,
bool
animate =
true
)
79
{
80
m_fValue
= value;
81
UpdateVisuals
(animate);
82
}
83
84
//------------------------------------------------------------------------------------------------
85
void
SetChange
(
float
value)
86
{
87
m_fChange
= value;
88
UpdateVisuals
(
false
);
89
}
90
91
//------------------------------------------------------------------------------------------------
92
void
UpdateVisuals
(
bool
animate =
true
)
93
{
94
if
(!
m_wSpacer
|| !
m_wBar
)
95
return
;
96
97
float
progress, currentProgress, change;
98
float
range =
m_fMax
-
m_fMin
;
99
if
(range <= 0)
100
return
;
101
102
currentProgress =
HorizontalLayoutSlot
.GetFillWeight(
m_wBar
);
103
progress =
m_fValue
/ range;
104
change =
m_fChange
/ range;
105
progress =
Math
.Clamp(progress, 0, 1);
106
107
if
(animate &&
m_fAnimationTime
> 0 && currentProgress != progress)
108
{
109
float
speed = 1 /
m_fAnimationTime
;
110
if
(
m_bConstantAnimationSpeed
)
111
speed = speed * (1 /
Math
.AbsFloat(currentProgress - progress));
112
113
AnimateWidget
.
LayoutFill
(
m_wBar
, progress, speed);
114
AnimateWidget
.
LayoutFill
(
m_wChange
, change, speed);
115
AnimateWidget
.
LayoutFill
(
m_wSpacer
, 1 - progress - change, speed);
116
}
117
else
118
{
119
HorizontalLayoutSlot
.SetFillWeight(
m_wBar
, progress);
120
HorizontalLayoutSlot
.SetFillWeight(
m_wChange
, change);
121
HorizontalLayoutSlot
.SetFillWeight(
m_wSpacer
, 1 - progress - change);
122
}
123
}
124
125
//------------------------------------------------------------------------------------------------
126
void
StopProgressAnimation
()
127
{
128
AnimateWidget
.
StopAnimation
(
m_wBar
,
WidgetAnimationLayoutFill
);
129
AnimateWidget
.
StopAnimation
(
m_wSpacer
,
WidgetAnimationLayoutFill
);
130
float
progress =
HorizontalLayoutSlot
.GetFillWeight(
m_wBar
);
131
float
value = progress *
m_fMax
-
m_fMin
;
132
SetValue
(value,
false
);
133
}
134
135
//------------------------------------------------------------------------------------------------
136
void
SetSliderColor
(
Color
newColor)
137
{
138
m_SliderColor
= newColor;
139
m_wBar
.SetColor(
m_SliderColor
);
140
}
141
142
//------------------------------------------------------------------------------------------------
143
void
SetSliderChangeColor
(
Color
newColor)
144
{
145
if
(
m_wChange
)
146
m_wChange
.SetColor(newColor);
147
}
148
149
//------------------------------------------------------------------------------------------------
150
float
GetMin
()
151
{
152
return
m_fMin
;
153
}
154
155
//------------------------------------------------------------------------------------------------
156
float
GetMax
()
157
{
158
return
m_fMax
;
159
}
160
161
//------------------------------------------------------------------------------------------------
162
float
GetValue
()
163
{
164
return
m_fValue
;
165
}
166
167
//------------------------------------------------------------------------------------------------
168
Widget
GetRootWidget
()
169
{
170
return
m_wRoot
;
171
}
172
173
//------------------------------------------------------------------------------------------------
174
float
GetAnimationSpeed
()
175
{
176
return
m_fAnimationTime
;
177
}
178
179
//------------------------------------------------------------------------------------------------
180
bool
IsUsingAnimationTime
()
181
{
182
return
m_bConstantAnimationSpeed
;
183
}
184
185
//------------------------------------------------------------------------------------------------
186
void
SetUsingAnimationTime
(
bool
enable)
187
{
188
m_bConstantAnimationSpeed
= enable;
189
}
190
191
//------------------------------------------------------------------------------------------------
192
void
SetAnimationTime
(
float
value)
193
{
194
m_fAnimationTime
= value;
195
}
196
197
//------------------------------------------------------------------------------------------------
198
static
SCR_WLibProgressBarComponent
GetProgressBar
(
string
name,
Widget
parent,
bool
searchAllChildren =
true
)
199
{
200
if
(!parent || name ==
string
.Empty)
201
return
null;
202
203
Widget
w;
204
if
(searchAllChildren)
205
w = parent.FindAnyWidget(name);
206
else
207
w = parent.FindWidget(name);
208
209
if
(!w)
210
{
211
Print
(
string
.Format(
"SCR_WLibProgressBarComponent.GetProgressBar: widget not found: %1"
, name),
LogLevel
.WARNING);
212
Debug
.DumpStack();
213
return
null;
214
}
215
216
return
SCR_WLibProgressBarComponent
.Cast(w.FindHandler(
SCR_WLibProgressBarComponent
));
217
}
218
};
219
220
//---- REFACTOR NOTE END ----
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition
SCR_RespawnBriefingComponent.c:17
AnimateWidget
Definition
AnimateWidget.c:3
AnimateWidget::StopAnimation
static bool StopAnimation(Widget w, typename typeName)
Definition
AnimateWidget.c:26
AnimateWidget::LayoutFill
static WidgetAnimationLayoutFill LayoutFill(Widget widget, float targetValue, float speed)
Definition
AnimateWidget.c:246
Color
Definition
Color.c:13
Debug
Definition
Debug.c:13
HorizontalLayoutSlot
Definition
HorizontalLayoutSlot.c:13
Math
Definition
Math.c:13
SCR_WLibProgressBarComponent
Minimalist progress bar.
Definition
SCR_WLibProgressBar.c:7
SCR_WLibProgressBarComponent::WIDGET_CHANGE
const string WIDGET_CHANGE
Definition
SCR_WLibProgressBar.c:8
SCR_WLibProgressBarComponent::SetChange
void SetChange(float value)
Definition
SCR_WLibProgressBar.c:85
SCR_WLibProgressBarComponent::m_wSpacer
Widget m_wSpacer
Definition
SCR_WLibProgressBar.c:37
SCR_WLibProgressBarComponent::SetSliderChangeColor
void SetSliderChangeColor(Color newColor)
Definition
SCR_WLibProgressBar.c:143
SCR_WLibProgressBarComponent::m_bConstantAnimationSpeed
bool m_bConstantAnimationSpeed
Definition
SCR_WLibProgressBar.c:23
SCR_WLibProgressBarComponent::m_fAnimationTime
float m_fAnimationTime
Definition
SCR_WLibProgressBar.c:26
SCR_WLibProgressBarComponent::m_fMin
float m_fMin
Definition
SCR_WLibProgressBar.c:11
SCR_WLibProgressBarComponent::StopProgressAnimation
void StopProgressAnimation()
Definition
SCR_WLibProgressBar.c:126
SCR_WLibProgressBarComponent::GetRootWidget
Widget GetRootWidget()
Definition
SCR_WLibProgressBar.c:168
SCR_WLibProgressBarComponent::m_fChange
float m_fChange
Definition
SCR_WLibProgressBar.c:39
SCR_WLibProgressBarComponent::SetValue
void SetValue(float value, bool animate=true)
Definition
SCR_WLibProgressBar.c:78
SCR_WLibProgressBarComponent::HandlerAttached
override void HandlerAttached(Widget w)
Definition
SCR_WLibProgressBar.c:42
SCR_WLibProgressBarComponent::SetMin
void SetMin(float value)
Definition
SCR_WLibProgressBar.c:64
SCR_WLibProgressBarComponent::m_fMax
float m_fMax
Definition
SCR_WLibProgressBar.c:14
SCR_WLibProgressBarComponent::m_wChange
Widget m_wChange
Definition
SCR_WLibProgressBar.c:36
SCR_WLibProgressBarComponent::m_wBar
Widget m_wBar
Definition
SCR_WLibProgressBar.c:35
SCR_WLibProgressBarComponent::GetMax
float GetMax()
Definition
SCR_WLibProgressBar.c:156
SCR_WLibProgressBarComponent::m_BackgroundColor
ref Color m_BackgroundColor
Definition
SCR_WLibProgressBar.c:32
SCR_WLibProgressBarComponent::SetAnimationTime
void SetAnimationTime(float value)
Definition
SCR_WLibProgressBar.c:192
SCR_WLibProgressBarComponent::GetValue
float GetValue()
Definition
SCR_WLibProgressBar.c:162
SCR_WLibProgressBarComponent::m_wRoot
Widget m_wRoot
Definition
SCR_WLibProgressBar.c:34
SCR_WLibProgressBarComponent::UpdateVisuals
void UpdateVisuals(bool animate=true)
Definition
SCR_WLibProgressBar.c:92
SCR_WLibProgressBarComponent::SetSliderColor
void SetSliderColor(Color newColor)
Definition
SCR_WLibProgressBar.c:136
SCR_WLibProgressBarComponent::SetMax
void SetMax(float value)
Definition
SCR_WLibProgressBar.c:71
SCR_WLibProgressBarComponent::IsUsingAnimationTime
bool IsUsingAnimationTime()
Definition
SCR_WLibProgressBar.c:180
SCR_WLibProgressBarComponent::m_bReverseDirection
bool m_bReverseDirection
Definition
SCR_WLibProgressBar.c:20
SCR_WLibProgressBarComponent::m_SliderColor
ref Color m_SliderColor
Definition
SCR_WLibProgressBar.c:29
SCR_WLibProgressBarComponent::SetUsingAnimationTime
void SetUsingAnimationTime(bool enable)
Definition
SCR_WLibProgressBar.c:186
SCR_WLibProgressBarComponent::GetProgressBar
static SCR_WLibProgressBarComponent GetProgressBar(string name, Widget parent, bool searchAllChildren=true)
Definition
SCR_WLibProgressBar.c:198
SCR_WLibProgressBarComponent::GetMin
float GetMin()
Definition
SCR_WLibProgressBar.c:150
SCR_WLibProgressBarComponent::m_fValue
float m_fValue
Definition
SCR_WLibProgressBar.c:17
SCR_WLibProgressBarComponent::GetAnimationSpeed
float GetAnimationSpeed()
Definition
SCR_WLibProgressBar.c:174
ScriptedWidgetComponent
Definition
ScriptedWidgetComponent.c:13
WidgetAnimationLayoutFill
Definition
WidgetAnimations.c:140
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
scripts
Game
UI
Components
WidgetLibrary
SCR_WLibProgressBar.c
Generated by
1.17.0