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_AnalogGauge.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_AnalogGauge
:
SCR_BaseAnalogGauge
3
{
4
// Attributes: values definition
5
[
Attribute
(
"0"
,
UIWidgets
.SpinBox,
"Min. value (usually 0, but can be any value, even negative)"
)]
6
protected
float
m_fValueMin
;
7
8
[
Attribute
(
"120"
,
UIWidgets
.SpinBox,
"Max. value (in the units provided, e.g. km/h)"
,
"0.1 1000000000 0.1"
)]
9
protected
float
m_fValueMax
;
10
11
// Attributes: labels
12
[
Attribute
(
"10"
,
UIWidgets
.SpinBox,
"Section mark on gauge ring every N-units"
)]
13
protected
float
m_fSectionEveryNthValue
;
14
15
[
Attribute
(
"2"
,
UIWidgets
.SpinBox,
"Section subdivisions on gauge ring"
,
"1 10 1"
)]
16
protected
int
m_iSectionSubdivisions
;
17
18
[
Attribute
(
"2"
,
UIWidgets
.SpinBox,
"Label on gauge ring every N-sections (e.g. if 1 every section is labeled)"
,
"1 10 1"
)]
19
protected
int
m_iLabelEveryNthSection
;
20
21
22
// Attributes: signal
23
[
Attribute
(
"speed"
,
UIWidgets
.EditBox,
"Name of the signal to listen to."
)]
24
protected
string
m_sSignalName
;
25
26
27
// Attributes: custom data
28
[
Attribute
(
""
,
UIWidgets
.EditBox,
"Gauge overlay texture."
)]
29
protected
string
m_sOverlay
;
30
31
[
Attribute
(
""
,
UIWidgets
.EditBox,
"Gauge custom needle texture. If not selected, default is used."
)]
32
protected
string
m_sCustomNeedle
;
33
34
35
protected
SignalsManagerComponent
m_SignalsManagerComponent
;
36
protected
int
m_iSignalIndex
= -1;
37
38
protected
float
m_fValueRange
;
39
40
41
//------------------------------------------------------------------------------------------------
42
override
SCR_BaseAnalogGaugeData
GetGaugeData
()
43
{
44
SCR_BaseAnalogGaugeData
data
=
new
SCR_BaseAnalogGaugeData
();
45
46
// Custom attributes
47
data
.m_sOverlay =
m_sOverlay
;
48
data
.m_sCustomNeedle =
m_sCustomNeedle
;
49
50
return
data
;
51
}
52
53
//------------------------------------------------------------------------------------------------
54
override
void
InitGauge
(
IEntity
owner, out
bool
bSuccess)
55
{
56
// Verify markings & label settings
57
if
(
m_fSectionEveryNthValue
<= 0)
58
m_fSectionEveryNthValue
= 10;
59
60
if
(
m_iLabelEveryNthSection
< 1)
61
m_iLabelEveryNthSection
= 1;
62
63
if
(
m_iSectionSubdivisions
< 1)
64
m_iSectionSubdivisions
= 1;
65
66
// Force min & max values to be always labeled
67
m_fValueMax
= (
Math
.Ceil(
m_fValueMax
/ (
m_fSectionEveryNthValue
*
m_iLabelEveryNthSection
))) *
m_fSectionEveryNthValue
*
m_iLabelEveryNthSection
;
68
m_fValueMin
= (
Math
.Floor(
m_fValueMin
/ (
m_fSectionEveryNthValue
*
m_iLabelEveryNthSection
))) *
m_fSectionEveryNthValue
*
m_iLabelEveryNthSection
;
69
70
// Get gauge value range
71
m_fValueRange
=
m_fValueMax
-
m_fValueMin
;
72
73
if
(
m_fValueRange
<= 0)
74
bSuccess =
false
;
75
}
76
77
//------------------------------------------------------------------------------------------------
78
override
bool
CreateGaugeRing
(
IEntity
owner)
79
{
80
bool
bSuccess = super.CreateGaugeRing(owner);
81
82
if
(!bSuccess)
83
return
false
;
84
85
int
sections = (
m_fValueRange
/
m_fSectionEveryNthValue
);
86
87
WorkspaceWidget
workspace =
GetGame
().GetWorkspace();
88
89
int
steps = sections *
m_iSectionSubdivisions
;
90
float
markAngle =
m_fWidgetRange
/ steps;
91
float
angle, value;
92
93
string
texture;
94
95
for
(
int
i = 0; i <= steps; i++)
96
{
97
angle =
m_fZeroValueRotation
+ (i * markAngle);
98
99
// Add marks on the gauge ring
100
if
(i %
m_iSectionSubdivisions
== 0)
101
texture =
m_pGaugeData
.m_sRingMarkSection;
102
else
103
texture =
m_pGaugeData
.m_sRingMarkSubsection;
104
105
CreateRingMark
(workspace, angle, texture);
106
107
if
(i == 0 && !
m_bShowLabelMin
)
108
continue
;
109
110
if
(i == steps && !
m_bShowLabelMax
)
111
continue
;
112
113
// Add labels to section marks
114
if
(i % (
m_iSectionSubdivisions
*
m_iLabelEveryNthSection
) == 0)
115
{
116
value =
m_fValueMin
+ (i /
m_iSectionSubdivisions
*
m_fSectionEveryNthValue
);
117
CreateRingLabel
(workspace, angle, value,
m_bAbsLabelValues
,
m_fLabelValueMultiplier
,
m_iLabelValuePrecision
);
118
}
119
}
120
121
return
true
;
122
}
123
124
//------------------------------------------------------------------------------------------------
125
override
float
GetValue
()
126
{
127
if
(!
m_SignalsManagerComponent
)
128
return
0;
129
130
if
(
m_iSignalIndex
== -1)
131
return
0;
132
133
float
value =
m_SignalsManagerComponent
.GetSignalValue(
m_iSignalIndex
);
134
135
return
value;
136
}
137
138
//------------------------------------------------------------------------------------------------
139
override
float
GetValuePerc
(
float
value)
140
{
141
if
(
m_fValueRange
== 0)
142
return
0;
143
144
float
fValuePerc = (value -
m_fValueMin
) /
m_fValueRange
;
145
146
return
fValuePerc;
147
}
148
149
//------------------------------------------------------------------------------------------------
150
override
event
void
DisplayStartDraw
(
IEntity
owner)
151
{
152
if
(!
m_SignalsManagerComponent
)
153
return
;
154
155
m_iSignalIndex
=
m_SignalsManagerComponent
.FindSignal(
m_sSignalName
);
156
157
super.DisplayStartDraw(owner);
158
}
159
160
//------------------------------------------------------------------------------------------------
161
override
event
void
DisplayInit
(
IEntity
owner)
162
{
163
super.DisplayInit(owner);
164
165
GenericEntity
genericEntity =
GenericEntity
.Cast(owner);
166
167
if
(!genericEntity)
168
return
;
169
170
m_SignalsManagerComponent
=
SignalsManagerComponent
.Cast(genericEntity.
FindComponent
(
SignalsManagerComponent
));
171
}
172
};
173
GetGame
ArmaReforgerScripted GetGame()
Definition
game.c:1398
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)
Math
Definition
Math.c:13
SCR_AnalogGauge
Definition
SCR_AnalogGauge.c:3
SCR_AnalogGauge::CreateGaugeRing
override bool CreateGaugeRing(IEntity owner)
Definition
SCR_AnalogGauge.c:78
SCR_AnalogGauge::GetGaugeData
override SCR_BaseAnalogGaugeData GetGaugeData()
Definition
SCR_AnalogGauge.c:42
SCR_AnalogGauge::m_fSectionEveryNthValue
float m_fSectionEveryNthValue
Definition
SCR_AnalogGauge.c:13
SCR_AnalogGauge::m_iSectionSubdivisions
int m_iSectionSubdivisions
Definition
SCR_AnalogGauge.c:16
SCR_AnalogGauge::m_sOverlay
string m_sOverlay
Definition
SCR_AnalogGauge.c:29
SCR_AnalogGauge::m_sSignalName
string m_sSignalName
Definition
SCR_AnalogGauge.c:24
SCR_AnalogGauge::m_SignalsManagerComponent
SignalsManagerComponent m_SignalsManagerComponent
Definition
SCR_AnalogGauge.c:35
SCR_AnalogGauge::m_iSignalIndex
int m_iSignalIndex
Definition
SCR_AnalogGauge.c:36
SCR_AnalogGauge::m_sCustomNeedle
string m_sCustomNeedle
Definition
SCR_AnalogGauge.c:32
SCR_AnalogGauge::DisplayInit
override event void DisplayInit(IEntity owner)
Definition
SCR_AnalogGauge.c:161
SCR_AnalogGauge::m_fValueMin
float m_fValueMin
Definition
SCR_AnalogGauge.c:6
SCR_AnalogGauge::m_fValueMax
float m_fValueMax
Definition
SCR_AnalogGauge.c:9
SCR_AnalogGauge::GetValuePerc
override float GetValuePerc(float value)
Definition
SCR_AnalogGauge.c:139
SCR_AnalogGauge::m_fValueRange
float m_fValueRange
Definition
SCR_AnalogGauge.c:38
SCR_AnalogGauge::m_iLabelEveryNthSection
int m_iLabelEveryNthSection
Definition
SCR_AnalogGauge.c:19
SCR_AnalogGauge::InitGauge
override void InitGauge(IEntity owner, out bool bSuccess)
Definition
SCR_AnalogGauge.c:54
SCR_AnalogGauge::GetValue
override float GetValue()
Definition
SCR_AnalogGauge.c:125
SCR_AnalogGauge::DisplayStartDraw
override event void DisplayStartDraw(IEntity owner)
Definition
SCR_AnalogGauge.c:150
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_AnalogGauge.c
Generated by
1.17.0