20 [
Attribute(
"#AR-ValueUnit_Milliseconds", UIWidgets.EditBox,
"Pattern defining how the value and units are displayed (e.g. '%1 ms'.")]
21 protected string m_sFormattingPattern;
23 [
Attribute(
"50", UIWidgets.SpinBox,
"Threshold value for 'warning visual' style. Set it to same or higher value than 'm_iValueError' to disable 'warning visual' style.")]
24 protected int m_iValueWarning;
26 [
Attribute(
"100", UIWidgets.SpinBox,
"Threshold value for 'error visual' style.")]
27 protected int m_iValueError;
29 [
Attribute(
"999", UIWidgets.SpinBox,
"Max. value that can be displayed in the widget. Used to cap the value and also to reserve the space for the value text, to prevent visual glitches.")]
30 protected int m_iValueMax;
32 [
Attribute(
"ping-high", UIWidgets.EditBox,
"OK icon, used when value is bellow 'm_iValueWarning' threshold.")]
33 protected string m_sIconOK;
35 [
Attribute(
"ping-high", UIWidgets.EditBox,
"Warning icon, used when value is above 'm_iValueWarning', but under 'm_iValueError' threshold.")]
36 protected string m_sIconWarning;
38 [
Attribute(
"ping-high", UIWidgets.EditBox,
"Error icon, used when value is above 'm_iValueError' threshold.")]
39 protected string m_sIconError;
41 [
Attribute(
"", UIWidgets.EditBox,
"Label displayed next to the icon (optional).")]
42 protected string m_sLabel;
44 [
Attribute(
"1", UIWidgets.SpinBox,
"How often the display is updated (in seconds).",
"1 10")]
45 protected int m_iUpdateInterval;
50 [
Attribute(
"0", UIWidgets.CheckBox,
"Should the indicator be shown in single player game?")]
51 protected bool m_bShowInSinglePlayer;
53 [
Attribute(
"1", UIWidgets.CheckBox,
"Should the indicator be shown on server?")]
54 protected bool m_bShowOnServer;
56 protected string m_Imageset =
"{3262679C50EF4F01}UI/Textures/Icons/icons_wrapperUI.imageset";
57 protected string m_ImagesetGlow =
"{00FE3DBDFD15227B}UI/Textures/Icons/icons_wrapperUI-glow.imageset";
59 RplIdentity m_RplIdentity;
63 protected bool m_bShowInDefaultState;
65 protected float m_fTimeElapsed;
66 protected int m_iRecords;
68 protected float m_fValueToShow;
69 protected float m_fValueRecorded;
72 override bool DisplayStartDrawInit(IEntity owner)
74 if (m_iUpdateInterval <= 0)
77 if (!Replication.IsRunning() && !m_bShowInSinglePlayer)
80 if (Replication.IsRunning() && Replication.IsServer() && !m_bShowOnServer)
83 m_RplIdentity = RplIdentity.Local();
89 override void DisplayStartDraw(IEntity owner)
100 string text = WidgetManager.Translate(m_sFormattingPattern, m_iValueMax);
101 m_Widgets.m_wTextPlaceholder.SetText(text);
105 float value = GetValue();
110 override void DisplayUpdate(IEntity owner,
float timeSlice)
117 float value = GetValue();
124 m_fValueRecorded = m_fValueRecorded + value;
128 if (m_eValueCalc ==
EStatsPanelEval.SHOW_HIGHEST && value > m_fValueRecorded) m_fValueRecorded = value;
129 else if (m_eValueCalc ==
EStatsPanelEval.SHOW_LOWEST && value < m_fValueRecorded) m_fValueRecorded = value;
139 m_fValueToShow = m_fValueRecorded/m_iRecords;
141 m_fValueToShow = m_fValueRecorded;
143 Update(m_fValueToShow);
148 m_fValueRecorded = 0;
153 protected float GetValue()
159 protected void Update(
float value)
161 value = Math.Clamp(Math.Round(value), 0, m_iValueMax);
171 string text = WidgetManager.Translate(m_sFormattingPattern, value);
178 if (m_iValueError >= m_iValueWarning)
180 if (value > m_iValueError)
182 else if (value > m_iValueWarning)
188 if (value < m_iValueError)
190 else if (value < m_iValueWarning)
210 color = GUIColors.ORANGE_BRIGHT2;
212 colorGlow = GUIColors.DEFAULT_GLOW;
213 icon = m_sIconWarning;
218 color = GUIColors.RED_BRIGHT2;
220 colorGlow = GUIColors.DEFAULT_GLOW;
226 color = GUIColors.DEFAULT;
227 colorGlow = GUIColors.DEFAULT_GLOW;
233 m_Widgets.m_wColorOpacity.SetOpacity(opacity);
234 m_Widgets.m_wColorOpacity.SetColor(color);
237 m_Widgets.m_wIcon.LoadImageFromSet(0, m_Imageset, icon);
238 m_Widgets.m_wIconGlow.LoadImageFromSet(0, m_ImagesetGlow, icon);
239 m_Widgets.m_wIconGlow.SetColor(colorGlow);
242 m_Widgets.m_wText.SetShadow(20, colorGlow.PackToInt(), 0.35);