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_AnalogGaugeNonLinear.c
Go to the documentation of this file.
1
// Default signal based analog gauge, needle movement clamped by Min and Max values, supports 1 needle - standard size
2
class
SCR_AnalogGaugeNonLinear
:
SCR_BaseAnalogGauge
3
{
4
// Attributes: values definition
5
[
Attribute
(
"0 10 30 60 120"
,
UIWidgets
.EditBox,
"Direct definition of values to be displayed on the gauge; float values separated by space"
)]
6
protected
string
m_sValues
;
7
8
9
// Attributes: labels
10
[
Attribute
(
"2"
,
UIWidgets
.SpinBox,
"Section subdivisions on gauge ring"
,
"1 10 1"
)]
11
protected
int
m_iSectionSubdivisions
;
12
13
[
Attribute
(
"1"
,
UIWidgets
.SpinBox,
"Label on gauge ring every N-sections (e.g. if 1 every section is labeled)"
,
"1 10 1"
)]
14
protected
int
m_iLabelEveryNthSection
;
15
16
17
// Attributes: signal
18
[
Attribute
(
"speed"
,
UIWidgets
.EditBox,
"Name of the signal to listen to."
)]
19
protected
string
m_sSignalName
;
20
21
22
// Attributes: custom data
23
[
Attribute
(
""
,
UIWidgets
.EditBox,
"Gauge overlay texture."
)]
24
protected
string
m_sOverlay
;
25
26
[
Attribute
(
""
,
UIWidgets
.EditBox,
"Gauge custom needle texture. If not selected, default is used."
)]
27
protected
string
m_sCustomNeedle
;
28
29
protected
SignalsManagerComponent
m_SignalsManagerComponent
;
30
protected
int
m_iSignalIndex
= -1;
31
32
protected
float
m_fValueMin
,
m_fValueMax
,
m_fValueRange
;
33
protected
ref array<float>
m_aValues
=
new
array<float>();
34
35
//------------------------------------------------------------------------------------------------
36
override
SCR_BaseAnalogGaugeData
GetGaugeData
()
37
{
38
SCR_BaseAnalogGaugeData
data
=
new
SCR_BaseAnalogGaugeData
();
39
40
// Custom attributes
41
data
.m_sOverlay =
m_sOverlay
;
42
data
.m_sCustomNeedle =
m_sCustomNeedle
;
43
44
return
data
;
45
}
46
47
//------------------------------------------------------------------------------------------------
48
override
void
InitGauge
(
IEntity
owner, out
bool
bSuccess)
49
{
50
// Parse and validate value data from the editbox input
51
array<string> aValueStrings =
new
array<string>();
52
m_sValues
.Split(
" "
, aValueStrings,
true
);
53
54
float
fValue;
55
int
iValues = 0;
56
57
foreach
(
string
sValue : aValueStrings)
58
{
59
fValue = sValue.ToFloat();
60
61
if
(iValues == 0 || fValue >
m_fValueMax
)
62
{
63
if
(iValues == 0)
64
m_fValueMin
= fValue;
65
66
iValues++;
67
68
m_aValues
.Insert(fValue);
69
m_fValueMax
= fValue;
70
}
71
}
72
73
// Need at least 2 values (min & max)
74
if
(iValues < 2)
75
{
76
bSuccess =
false
;
77
return
;
78
}
79
80
// Get gauge value range
81
m_fValueRange
=
m_fValueMax
-
m_fValueMin
;
82
83
if
(
m_fValueRange
<= 0)
84
{
85
bSuccess =
false
;
86
return
;
87
}
88
}
89
90
//------------------------------------------------------------------------------------------------
91
override
void
DestroyGauge
()
92
{
93
m_aValues
.Clear();
94
95
super.DestroyGauge();
96
}
97
98
//------------------------------------------------------------------------------------------------
99
override
bool
CreateGaugeRing
(
IEntity
owner)
100
{
101
bool
bSuccess = super.CreateGaugeRing(owner);
102
103
if
(!bSuccess)
104
return
false
;
105
106
int
sections =
m_aValues
.Count() - 1;
107
108
WorkspaceWidget
workspace =
GetGame
().GetWorkspace();
109
110
int
steps = sections *
m_iSectionSubdivisions
;
111
float
markAngle =
m_fWidgetRange
/ steps;
112
float
angle, value;
113
int
index
;
114
115
string
texture;
116
117
for
(
int
i = 0; i <= steps; i++)
118
{
119
angle =
m_fZeroValueRotation
+ (i * markAngle);
120
121
// Add marks on the gauge ring
122
if
(i %
m_iSectionSubdivisions
== 0)
123
texture =
m_pGaugeData
.m_sRingMarkSection;
124
else
125
texture =
m_pGaugeData
.m_sRingMarkSubsection;
126
127
CreateRingMark
(workspace, angle, texture);
128
129
if
(i == 0 && !
m_bShowLabelMin
)
130
continue
;
131
132
if
(i == steps && !
m_bShowLabelMax
)
133
continue
;
134
135
// Add labels to section marks
136
if
(i % (
m_iSectionSubdivisions
*
m_iLabelEveryNthSection
) == 0)
137
{
138
index
= i /
m_iSectionSubdivisions
;
139
value =
m_aValues
[
index
];
140
141
CreateRingLabel
(workspace, angle, value,
m_bAbsLabelValues
,
m_fLabelValueMultiplier
,
m_iLabelValuePrecision
);
142
}
143
}
144
145
return
true
;
146
}
147
148
//------------------------------------------------------------------------------------------------
149
override
float
GetValue
()
150
{
151
if
(!
m_SignalsManagerComponent
)
152
return
0;
153
154
if
(
m_iSignalIndex
== -1)
155
return
0;
156
157
float
value =
m_SignalsManagerComponent
.GetSignalValue(
m_iSignalIndex
);
158
159
return
value;
160
}
161
162
//------------------------------------------------------------------------------------------------
163
override
float
GetValuePerc
(
float
value)
164
{
165
if
(
m_fValueRange
== 0)
166
return
0;
167
168
// Get segment value is in
169
float
fMin, fMax;
170
int
iSegments =
m_aValues
.Count() - 1;
171
172
if
(iSegments <= 0)
173
return
0;
174
175
float
fValuePerc = -1;
176
float
fSegmentSize = 1 / iSegments;
177
178
// Clamp progress to 100% if out of bounds
179
if
(value >
m_aValues
[iSegments])
180
return
1;
181
182
for
(
int
i = 0; i < iSegments; i++)
183
{
184
if
(fValuePerc > -1)
185
continue
;
186
187
fMin =
m_aValues
[i];
188
fMax =
m_aValues
[i + 1];
189
190
if
(value < fMax)
191
{
192
fValuePerc = i * fSegmentSize;
// percentage based on segment
193
fValuePerc += fSegmentSize * (value - fMin) / (fMax - fMin);
// percentage based on progress within segment
194
}
195
}
196
197
return
fValuePerc;
198
}
199
200
//------------------------------------------------------------------------------------------------
201
override
event
void
DisplayStartDraw
(
IEntity
owner)
202
{
203
if
(!
m_SignalsManagerComponent
)
204
return
;
205
206
m_iSignalIndex
=
m_SignalsManagerComponent
.FindSignal(
m_sSignalName
);
207
208
super.DisplayStartDraw(owner);
209
}
210
211
//------------------------------------------------------------------------------------------------
212
override
event
void
DisplayInit
(
IEntity
owner)
213
{
214
super.DisplayInit(owner);
215
216
GenericEntity
genericEntity =
GenericEntity
.Cast(owner);
217
218
if
(!genericEntity)
219
return
;
220
221
m_SignalsManagerComponent
=
SignalsManagerComponent
.Cast(genericEntity.
FindComponent
(
SignalsManagerComponent
));
222
}
223
};
224
GetGame
ArmaReforgerScripted GetGame()
Definition
game.c:1398
index
SCR_DestructionSynchronizationComponentClass ScriptComponentClass int index
Definition
SCR_DestructionSynchronizationComponent.c:17
data
Get all prefabs that have the spawner data
Definition
SCR_EntityCatalogManagerComponent.c:320
GenericEntity
Definition
GenericEntity.c:16
IEntity
Definition
IEntity.c:13
IEntity::FindComponent
proto external Managed FindComponent(typename typeName)
SCR_AnalogGaugeNonLinear
Definition
SCR_AnalogGaugeNonLinear.c:3
SCR_AnalogGaugeNonLinear::m_sValues
string m_sValues
Definition
SCR_AnalogGaugeNonLinear.c:6
SCR_AnalogGaugeNonLinear::m_iLabelEveryNthSection
int m_iLabelEveryNthSection
Definition
SCR_AnalogGaugeNonLinear.c:14
SCR_AnalogGaugeNonLinear::m_iSectionSubdivisions
int m_iSectionSubdivisions
Definition
SCR_AnalogGaugeNonLinear.c:11
SCR_AnalogGaugeNonLinear::DestroyGauge
override void DestroyGauge()
Definition
SCR_AnalogGaugeNonLinear.c:91
SCR_AnalogGaugeNonLinear::GetValue
override float GetValue()
Definition
SCR_AnalogGaugeNonLinear.c:149
SCR_AnalogGaugeNonLinear::InitGauge
override void InitGauge(IEntity owner, out bool bSuccess)
Definition
SCR_AnalogGaugeNonLinear.c:48
SCR_AnalogGaugeNonLinear::m_fValueMin
float m_fValueMin
Definition
SCR_AnalogGaugeNonLinear.c:32
SCR_AnalogGaugeNonLinear::GetValuePerc
override float GetValuePerc(float value)
Definition
SCR_AnalogGaugeNonLinear.c:163
SCR_AnalogGaugeNonLinear::m_iSignalIndex
int m_iSignalIndex
Definition
SCR_AnalogGaugeNonLinear.c:30
SCR_AnalogGaugeNonLinear::m_fValueRange
float m_fValueRange
Definition
SCR_AnalogGaugeNonLinear.c:32
SCR_AnalogGaugeNonLinear::m_fValueMax
float m_fValueMax
Definition
SCR_AnalogGaugeNonLinear.c:32
SCR_AnalogGaugeNonLinear::m_sOverlay
string m_sOverlay
Definition
SCR_AnalogGaugeNonLinear.c:24
SCR_AnalogGaugeNonLinear::m_aValues
ref array< float > m_aValues
Definition
SCR_AnalogGaugeNonLinear.c:33
SCR_AnalogGaugeNonLinear::DisplayInit
override event void DisplayInit(IEntity owner)
Definition
SCR_AnalogGaugeNonLinear.c:212
SCR_AnalogGaugeNonLinear::m_SignalsManagerComponent
SignalsManagerComponent m_SignalsManagerComponent
Definition
SCR_AnalogGaugeNonLinear.c:29
SCR_AnalogGaugeNonLinear::m_sCustomNeedle
string m_sCustomNeedle
Definition
SCR_AnalogGaugeNonLinear.c:27
SCR_AnalogGaugeNonLinear::GetGaugeData
override SCR_BaseAnalogGaugeData GetGaugeData()
Definition
SCR_AnalogGaugeNonLinear.c:36
SCR_AnalogGaugeNonLinear::DisplayStartDraw
override event void DisplayStartDraw(IEntity owner)
Definition
SCR_AnalogGaugeNonLinear.c:201
SCR_AnalogGaugeNonLinear::CreateGaugeRing
override bool CreateGaugeRing(IEntity owner)
Definition
SCR_AnalogGaugeNonLinear.c:99
SCR_AnalogGaugeNonLinear::m_sSignalName
string m_sSignalName
Definition
SCR_AnalogGaugeNonLinear.c:19
SCR_BaseAnalogGaugeData
Definition
SCR_BaseAnalogGauge.c:2
SCR_BaseAnalogGauge
Definition
SCR_BaseAnalogGauge.c:17
SCR_BaseAnalogGauge::m_fZeroValueRotation
float m_fZeroValueRotation
Definition
SCR_BaseAnalogGauge.c:87
SCR_BaseAnalogGauge::m_bAbsLabelValues
bool m_bAbsLabelValues
Definition
SCR_BaseAnalogGauge.c:56
SCR_BaseAnalogGauge::m_fWidgetRange
float m_fWidgetRange
Definition
SCR_BaseAnalogGauge.c:20
SCR_BaseAnalogGauge::m_pGaugeData
ref SCR_BaseAnalogGaugeData m_pGaugeData
Definition
SCR_BaseAnalogGauge.c:68
SCR_BaseAnalogGauge::CreateRingMark
void CreateRingMark(WorkspaceWidget workspace, float angle, string texture)
Definition
SCR_BaseAnalogGauge.c:456
SCR_BaseAnalogGauge::m_bShowLabelMax
bool m_bShowLabelMax
Definition
SCR_BaseAnalogGauge.c:62
SCR_BaseAnalogGauge::m_iLabelValuePrecision
int m_iLabelValuePrecision
Definition
SCR_BaseAnalogGauge.c:53
SCR_BaseAnalogGauge::m_bShowLabelMin
bool m_bShowLabelMin
Definition
SCR_BaseAnalogGauge.c:65
SCR_BaseAnalogGauge::CreateRingLabel
void CreateRingLabel(WorkspaceWidget workspace, float angle, float value, bool absValues=true, float labelValueMultiplier=1, int labelValuePrecision=0)
Definition
SCR_BaseAnalogGauge.c:405
SCR_BaseAnalogGauge::m_fLabelValueMultiplier
float m_fLabelValueMultiplier
Definition
SCR_BaseAnalogGauge.c:50
SignalsManagerComponent
Definition
SignalsManagerComponent.c:13
UIWidgets
Definition
attributes.c:40
WorkspaceWidget
Definition
WorkspaceWidget.c:16
Attribute
SCR_FieldOfViewSettings Attribute
Definition
SendGoalMessage.c:170
scripts
Game
UI
HUD
VehicleInfo
SCR_AnalogGaugeNonLinear.c
Generated by
1.17.0