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;
10 [
Attribute(
"2", UIWidgets.SpinBox,
"Section subdivisions on gauge ring",
"1 10 1")]
11 protected int m_iSectionSubdivisions;
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;
18 [
Attribute(
"speed", UIWidgets.EditBox,
"Name of the signal to listen to.")]
19 protected string m_sSignalName;
23 [
Attribute(
"", UIWidgets.EditBox,
"Gauge overlay texture.")]
24 protected string m_sOverlay;
26 [
Attribute(
"", UIWidgets.EditBox,
"Gauge custom needle texture. If not selected, default is used.")]
27 protected string m_sCustomNeedle;
29 protected SignalsManagerComponent m_SignalsManagerComponent;
30 protected int m_iSignalIndex = -1;
32 protected float m_fValueMin, m_fValueMax, m_fValueRange;
33 protected ref array<float> m_aValues =
new array<float>();
41 data.m_sOverlay = m_sOverlay;
42 data.m_sCustomNeedle = m_sCustomNeedle;
48 override void InitGauge(IEntity owner, out
bool bSuccess)
51 array<string> aValueStrings =
new array<string>();
52 m_sValues.Split(
" ", aValueStrings,
true);
57 foreach (
string sValue : aValueStrings)
59 fValue = sValue.ToFloat();
61 if (iValues == 0 || fValue > m_fValueMax)
81 m_fValueRange = m_fValueMax - m_fValueMin;
83 if (m_fValueRange <= 0)
91 override void DestroyGauge()
99 override bool CreateGaugeRing(IEntity owner)
101 bool bSuccess = super.CreateGaugeRing(owner);
108 WorkspaceWidget workspace =
GetGame().GetWorkspace();
110 int steps = sections * m_iSectionSubdivisions;
111 float markAngle = m_fWidgetRange / steps;
117 for (
int i = 0; i <= steps; i++)
119 angle = m_fZeroValueRotation + (i * markAngle);
122 if (i % m_iSectionSubdivisions == 0)
123 texture = m_pGaugeData.m_sRingMarkSection;
125 texture = m_pGaugeData.m_sRingMarkSubsection;
127 CreateRingMark(workspace, angle, texture);
129 if (i == 0 && !m_bShowLabelMin)
132 if (i == steps && !m_bShowLabelMax)
136 if (i % (m_iSectionSubdivisions * m_iLabelEveryNthSection) == 0)
138 index = i / m_iSectionSubdivisions;
141 CreateRingLabel(workspace, angle, value, m_bAbsLabelValues, m_fLabelValueMultiplier, m_iLabelValuePrecision);
149 override float GetValue()
154 if (m_iSignalIndex == -1)
163 override float GetValuePerc(
float value)
165 if (m_fValueRange == 0)
175 float fValuePerc = -1;
176 float fSegmentSize = 1 / iSegments;
178 for (
int i = 0; i < iSegments; i++)
188 fValuePerc = i * fSegmentSize;
189 fValuePerc += fSegmentSize * (value - fMin) / (fMax - fMin);
197 override event void DisplayStartDraw(IEntity owner)
204 super.DisplayStartDraw(owner);
208 override event void DisplayInit(IEntity owner)
210 super.DisplayInit(owner);