30 protected ResourceName m_Imageset =
"{3262679C50EF4F01}UI/Textures/Icons/icons_wrapperUI.imageset";
31 protected ResourceName m_ImagesetGlow =
"{00FE3DBDFD15227B}UI/Textures/Icons/icons_wrapperUI-glow.imageset";
33 protected ImageWidget m_wIcon;
34 protected ImageWidget m_wGlow;
35 protected OverlayWidget m_wSizeOverlay;
37 [
Attribute(
"", UIWidgets.EditBox,
"Indicator icon to be displayed.")]
38 protected string m_sIcon;
43 [
Attribute(
"0.8", UIWidgets.Slider,
"Indicator scale",
"0.25 2 0.05")]
44 protected float m_fWidgetScale;
46 [
Attribute(
"1", UIWidgets.CheckBox,
"Show the greyed-out indicator, if it is inactive, otherwise it will be hidden.")]
47 protected bool m_bShowGhost;
50 protected bool m_bIsBlinking;
51 protected int m_iBlinkingOffset;
53 protected Color m_aColors[5];
54 protected Color m_aColorsGlow[5];
56 protected const int ICON_SIZE = 64;
67 protected bool IsBlinking()
73 protected void Scale(ImageWidget widget,
float scale)
80 int image = widget.GetImage();
82 widget.GetImageSize(image, imageWidth, imageHeight);
83 widget.SetSize((
float)imageWidth * scale, (
float)imageHeight * scale);
87 protected void Scale(TextWidget widget,
float scale)
92 float sizeY = FrameSlot.GetSizeY(widget);
94 FrameSlot.SetSizeY(widget, sizeY * scale);
98 protected void Scale(OverlayWidget widget,
float scale)
103 FrameSlot.SetSizeX(widget, scale * ICON_SIZE);
104 FrameSlot.SetSizeY(widget, scale * ICON_SIZE);
108 protected void SetIcon(
string icon)
113 m_wIcon.LoadImageFromSet(0, m_Imageset, icon);
114 m_wGlow.LoadImageFromSet(0, m_ImagesetGlow, icon);
116 Scale(m_wSizeOverlay, m_fWidgetScale);
128 m_wIcon.SetColor(Color.FromInt(GUIColors.DISABLED.PackToInt()));
129 m_wGlow.SetColor(Color.FromInt(GUIColors.DISABLED_GLOW.PackToInt()));
133 m_wIcon.SetColor(Color.FromInt(m_aColors[color].PackToInt()));
134 m_wGlow.SetColor(Color.FromInt(m_aColorsGlow[color].PackToInt()));
138 m_wIcon.SetColor(Color.FromInt(GUIColors.ORANGE.PackToInt()));
139 m_wGlow.SetColor(Color.FromInt(GUIColors.ORANGE_DARK.PackToInt()));
143 m_wIcon.SetColor(Color.FromInt(GUIColors.RED.PackToInt()));
144 m_wGlow.SetColor(Color.FromInt(GUIColors.RED_DARK.PackToInt()));
156 override event void DisplayUpdate(IEntity owner,
float timeSlice)
163 bool isBlinking = IsBlinking();
164 int time =
GetGame().GetWorld().GetWorldTime();
168 if (Math.Mod(time - m_iBlinkingOffset, 1000) < 500)
173 m_iBlinkingOffset = Math.Mod(time, 1000);
176 if (UpdateRequired(state))
178 #ifdef DEBUG_VEHICLE_UI
179 PrintFormat(
"%1 Update -> state: %2 | icon: %3",
this, state,
m_sIcon);
185 SetColor(state, m_eColor);
195 override bool DisplayStartDrawInit(IEntity owner)
202 if (m_LayoutPath ==
"")
203 m_LayoutPath =
"{D2E54F91C85CAB6C}UI/layouts/HUD/VehicleInfo/VehicleInfoIcon.layout";
210 override void DisplayStartDraw(IEntity owner)
216 m_wGlow = ImageWidget.Cast(
m_wRoot.FindAnyWidget(
"Glow"));
217 m_wSizeOverlay = OverlayWidget.Cast(
m_wRoot.FindAnyWidget(
"SizeOverlay"));
221 DisplayUpdate(owner, 0);
226 override void DisplayStopDraw(IEntity owner)
232 override void DisplayInit(IEntity owner)