Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
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
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")]
17
18 [Attribute("2", UIWidgets.SpinBox, "Label on gauge ring every N-sections (e.g. if 1 every section is labeled)", "1 10 1")]
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
36 protected int m_iSignalIndex = -1;
37
38 protected float m_fValueRange;
39
40
41 //------------------------------------------------------------------------------------------------
43 {
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
59
62
65
66 // Force min & max values to be always labeled
69
70 // Get gauge value range
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
115 {
118 }
119 }
120
121 return true;
122 }
123
124 //------------------------------------------------------------------------------------------------
125 override float GetValue()
126 {
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 {
153 return;
154
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
171 }
172};
173
ArmaReforgerScripted GetGame()
Definition game.c:1398
Get all prefabs that have the spawner data
proto external Managed FindComponent(typename typeName)
Definition Math.c:13
override bool CreateGaugeRing(IEntity owner)
override SCR_BaseAnalogGaugeData GetGaugeData()
float m_fSectionEveryNthValue
SignalsManagerComponent m_SignalsManagerComponent
override event void DisplayInit(IEntity owner)
override float GetValuePerc(float value)
override void InitGauge(IEntity owner, out bool bSuccess)
override float GetValue()
override event void DisplayStartDraw(IEntity owner)
ref SCR_BaseAnalogGaugeData m_pGaugeData
void CreateRingMark(WorkspaceWidget workspace, float angle, string texture)
void CreateRingLabel(WorkspaceWidget workspace, float angle, float value, bool absValues=true, float labelValueMultiplier=1, int labelValuePrecision=0)
SCR_FieldOfViewSettings Attribute