4 [
Attribute(
"{73B3D8BBB785B5B9}UI/Textures/Common/circleFull.edds", UIWidgets.ResourceNamePicker,
"")]
5 protected ResourceName m_sHintElementTexture;
7 [
Attribute(
"", UIWidgets.ResourceNamePicker,
"")]
8 protected ResourceName m_sHintElementImage;
10 [
Attribute(
"SelectionHintElement", UIWidgets.EditBox,
"Name for generated selection hints widgets")]
11 protected string m_sSelectionHintElementName;
13 [
Attribute(
"0.760 0.392 0.08 1", UIWidgets.ColorPicker)]
14 protected ref Color m_ColorSelected;
16 [
Attribute(
"0.25 0.25 0.25 1", UIWidgets.ColorPicker)]
17 protected ref Color m_ColorDeselected;
20 protected bool m_bSetCustomSize;
23 protected float m_fItemWidth;
26 protected float m_fItemHeight;
29 protected float m_fAnimationTime;
32 protected float m_fItemSpacing;
35 protected int m_iCurrent;
38 protected int m_iItemCount;
41 protected Widget m_wRoot;
42 protected Widget m_wCurrent;
43 protected ref array<Widget> m_aWidgets = {};
46 override void HandlerAttached(Widget w)
53 CreateWidgets(m_iItemCount);
56 if (m_iItemCount > m_iCurrent)
57 SetCurrentItem(m_iCurrent,
false);
61 protected void CreateWidgets(
int count)
66 if (currentCount == count)
68 else if (currentCount < count)
74 int iterations = count - currentCount;
75 for (
int i = 0 ; i < iterations; i++)
82 int iterations = currentCount - count;
83 for (
int i = 0 ; i < iterations; i++)
86 m_aWidgets[currentCount - i - 1].RemoveFromHierarchy();
93 protected void CreateWidget()
95 Widget w =
GetGame().GetWorkspace().CreateWidget(WidgetType.ImageWidgetTypeID, WidgetFlags.VISIBLE |
96 WidgetFlags.STRETCH | WidgetFlags.BLEND | WidgetFlags.INHERIT_CLIPPING, m_ColorDeselected, 0,
m_wRoot);
98 ImageWidget img = ImageWidget.Cast(w);
104 if (m_sHintElementTexture !=
string.Empty)
107 if (m_bSetCustomSize)
108 img.SetSize(m_fItemWidth, m_fItemHeight);
110 img.SetName(m_sSelectionHintElementName);
112 AlignableSlot.SetPadding(img, m_fItemSpacing * 0.5, 0, m_fItemSpacing * 0.5, 0);
113 AlignableSlot.SetVerticalAlign(img, LayoutVerticalAlign.Center);
114 AlignableSlot.SetHorizontalAlign(img, LayoutHorizontalAlign.Center);
118 protected void SetAnimationRate()
120 if (m_fAnimationTime <= 0)
121 m_fAnimationRate = 1000;
123 m_fAnimationRate = 1 / m_fAnimationTime;
128 void SetItemCount(
int count,
bool animate =
true)
130 if (count == m_iItemCount || count == 1)
133 m_iItemCount = count;
134 CreateWidgets(count);
135 SetCurrentItem(m_iCurrent, animate);
151 void SetCurrentItem(
int index,
bool animate =
true)
165 color = m_ColorSelected;
167 color = m_ColorDeselected;
169 ColorizeItem(w, color, animate);
173 m_wCurrent = newWidget;
177 void ColorizeItem(Widget w, Color color,
bool animate)
179 if (!color || !w || w.GetColor() == color)
183 AnimateWidget.Color(w, color, m_fAnimationRate);