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_InventoryProgressBar.c
Go to the documentation of this file.
1
class
SCR_InventoryProgressBar
:
ScriptedWidgetComponent
2
{
3
[
Attribute
(
"0 0 0 1"
)]
4
protected
ref
Color
m_ColorLow
;
5
6
[
Attribute
(
"0.5 0.5 0.5 1"
)]
7
protected
ref
Color
m_ColorMiddle
;
8
9
[
Attribute
(
"1 1 1 1"
)]
10
protected
ref
Color
m_ColorHigh
;
11
12
[
Attribute
(
"0 1 0 1"
)]
13
protected
ref
Color
m_ColorPreviewPositive
;
14
15
[
Attribute
(
"1 0 0 1"
)]
16
protected
ref
Color
m_ColorPreviewNegative
;
17
18
[
Attribute
(
"1"
)]
19
protected
bool
m_bFlipColors
;
20
21
[
Attribute
(
"ProgressBar"
)]
22
protected
string
m_sProgressBarName
;
23
24
[
Attribute
(
"ProgressBarTemp"
)]
25
protected
string
m_sProgressBarNamePreview
;
26
27
protected
ProgressBarWidget
m_wProgressBar
;
28
protected
ProgressBarWidget
m_wProgressBarPreview
;
29
protected
bool
m_bColorsFlipped
;
30
31
protected
const
float
LOW_TRESHOLD
= 0.3;
32
protected
const
float
MID_DIFF
= 0.05;
33
protected
const
float
HIGH_TRESHOLD
= 0.8;
34
35
//------------------------------------------------------------------------------------------------
36
override
void
HandlerAttached
(
Widget
w)
37
{
38
m_wProgressBar
=
ProgressBarWidget
.Cast(w.FindAnyWidget(
m_sProgressBarName
));
39
if
(!
m_wProgressBar
)
40
{
41
m_wProgressBar
=
ProgressBarWidget
.Cast(w);
42
if
(!
m_wProgressBar
)
43
{
44
Print
(
"Cannot find ProgressBarWidget in the hierarchy."
,
LogLevel
.ERROR);
45
return
;
46
}
47
}
48
49
m_wProgressBarPreview
=
ProgressBarWidget
.Cast(w.FindAnyWidget(
m_sProgressBarNamePreview
));
50
if
(!
m_wProgressBarPreview
)
51
{
52
m_wProgressBarPreview
=
ProgressBarWidget
.Cast(w);
53
if
(!
m_wProgressBarPreview
)
54
{
55
Print
(
"Cannot find ProgressBarWidget in the hierarchy."
,
LogLevel
.ERROR);
56
return
;
57
}
58
}
59
60
if
(
m_bFlipColors
)
61
{
62
Color
temp =
m_ColorHigh
;
63
m_ColorHigh
=
m_ColorLow
;
64
m_ColorLow
= temp;
65
}
66
67
m_wProgressBarPreview
.SetColor(
m_ColorPreviewPositive
);
68
69
UpdateProgressBar
();
70
}
71
72
void
SetProgressRange
(
float
min,
float
max)
73
{
74
if
(!
m_wProgressBar
|| !
m_wProgressBarPreview
|| max <= 0)
75
return
;
76
77
m_wProgressBar
.SetMin(min);
78
m_wProgressBar
.SetMax(max);
79
80
m_wProgressBarPreview
.SetMin(min);
81
m_wProgressBarPreview
.SetMax(max);
82
83
UpdateProgressBar
();
84
}
85
86
void
SetCurrentProgress
(
float
progress)
87
{
88
if
(!
m_wProgressBar
)
89
return
;
90
91
m_wProgressBar
.SetCurrent(progress);
92
UpdateProgressBar
();
93
}
94
95
void
SetCurrentProgressPreview
(
float
progress)
96
{
97
if
(!
m_wProgressBarPreview
)
98
return
;
99
100
m_wProgressBarPreview
.SetCurrent(progress);
101
}
102
103
void
SetPreviewColor
(
bool
enabled)
104
{
105
if
(enabled)
106
m_wProgressBarPreview
.SetColor(
m_ColorPreviewPositive
);
107
else
108
m_wProgressBarPreview
.SetColor(
m_ColorPreviewNegative
);
109
}
110
111
void
FlipColors
()
112
{
113
if
(
m_bColorsFlipped
)
114
return
;
115
116
Color
temp =
m_ColorHigh
;
117
m_ColorHigh
=
m_ColorLow
;
118
m_ColorLow
= temp;
119
m_bColorsFlipped
=
true
;
120
121
UpdateProgressBar
();
122
}
123
124
protected
void
UpdateProgressBar
()
125
{
126
float
progress01 =
Math
.InverseLerp(
m_wProgressBar
.GetMin(),
m_wProgressBar
.GetMax(),
m_wProgressBar
.GetCurrent());
127
if
(progress01 < 0.5)
128
{
129
m_wProgressBar
.SetColor(
m_ColorLow
.LerpNew(
m_ColorMiddle
,
Math
.InverseLerp(
LOW_TRESHOLD
, 0.5 -
MID_DIFF
,
Math
.Clamp(progress01,
LOW_TRESHOLD
, 0.5 -
MID_DIFF
))));
130
}
131
else
132
{
133
m_wProgressBar
.SetColor(
m_ColorMiddle
.LerpNew(
m_ColorHigh
,
Math
.InverseLerp(0.5 +
MID_DIFF
,
HIGH_TRESHOLD
,
Math
.Clamp(progress01, 0.5 +
MID_DIFF
,
HIGH_TRESHOLD
))));
134
}
135
}
136
}
Color
Definition
Color.c:13
Math
Definition
Math.c:13
ProgressBarWidget
Definition
ProgressBarWidget.c:13
SCR_InventoryProgressBar
Definition
SCR_InventoryProgressBar.c:2
SCR_InventoryProgressBar::m_ColorHigh
ref Color m_ColorHigh
Definition
SCR_InventoryProgressBar.c:10
SCR_InventoryProgressBar::m_ColorPreviewNegative
ref Color m_ColorPreviewNegative
Definition
SCR_InventoryProgressBar.c:16
SCR_InventoryProgressBar::m_ColorPreviewPositive
ref Color m_ColorPreviewPositive
Definition
SCR_InventoryProgressBar.c:13
SCR_InventoryProgressBar::LOW_TRESHOLD
const float LOW_TRESHOLD
Definition
SCR_InventoryProgressBar.c:31
SCR_InventoryProgressBar::m_bColorsFlipped
bool m_bColorsFlipped
Definition
SCR_InventoryProgressBar.c:29
SCR_InventoryProgressBar::SetCurrentProgressPreview
void SetCurrentProgressPreview(float progress)
Definition
SCR_InventoryProgressBar.c:95
SCR_InventoryProgressBar::FlipColors
void FlipColors()
Definition
SCR_InventoryProgressBar.c:111
SCR_InventoryProgressBar::m_sProgressBarNamePreview
string m_sProgressBarNamePreview
Definition
SCR_InventoryProgressBar.c:25
SCR_InventoryProgressBar::m_wProgressBarPreview
ProgressBarWidget m_wProgressBarPreview
Definition
SCR_InventoryProgressBar.c:28
SCR_InventoryProgressBar::HIGH_TRESHOLD
const float HIGH_TRESHOLD
Definition
SCR_InventoryProgressBar.c:33
SCR_InventoryProgressBar::SetPreviewColor
void SetPreviewColor(bool enabled)
Definition
SCR_InventoryProgressBar.c:103
SCR_InventoryProgressBar::m_ColorLow
ref Color m_ColorLow
Definition
SCR_InventoryProgressBar.c:4
SCR_InventoryProgressBar::m_wProgressBar
ProgressBarWidget m_wProgressBar
Definition
SCR_InventoryProgressBar.c:27
SCR_InventoryProgressBar::SetProgressRange
void SetProgressRange(float min, float max)
Definition
SCR_InventoryProgressBar.c:72
SCR_InventoryProgressBar::HandlerAttached
override void HandlerAttached(Widget w)
Definition
SCR_InventoryProgressBar.c:36
SCR_InventoryProgressBar::SetCurrentProgress
void SetCurrentProgress(float progress)
Definition
SCR_InventoryProgressBar.c:86
SCR_InventoryProgressBar::m_sProgressBarName
string m_sProgressBarName
Definition
SCR_InventoryProgressBar.c:22
SCR_InventoryProgressBar::m_bFlipColors
bool m_bFlipColors
Definition
SCR_InventoryProgressBar.c:19
SCR_InventoryProgressBar::m_ColorMiddle
ref Color m_ColorMiddle
Definition
SCR_InventoryProgressBar.c:7
SCR_InventoryProgressBar::MID_DIFF
const float MID_DIFF
Definition
SCR_InventoryProgressBar.c:32
SCR_InventoryProgressBar::UpdateProgressBar
void UpdateProgressBar()
Definition
SCR_InventoryProgressBar.c:124
ScriptedWidgetComponent
Definition
ScriptedWidgetComponent.c:13
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
Inventory
SCR_InventoryProgressBar.c
Generated by
1.17.0