4 protected ref array<ResourceName> m_aElementIcons;
5 protected ref array<float> m_aElementIconRotations;
8 protected string m_sIconWidgetName;
10 protected ImageWidget m_IconWidget;
11 protected ref ScriptInvoker Event_OnCreateElement =
new ScriptInvoker;
12 protected ref Color m_cIconDisabledColor =
new Color (0.8, 0.8, 0.8, 1);
14 protected override void UpdateName()
21 if (m_aElementIcons && m_iSelectedItem >= 0 && m_iSelectedItem < m_aElementIcons.Count() && m_aElementIcons[m_iSelectedItem] !=
string.Empty)
23 m_IconWidget.LoadImageTexture(0, m_aElementIcons[m_iSelectedItem]);
24 m_IconWidget.SetImage(0);
25 m_IconWidget.SetRotation(m_aElementIconRotations[m_iSelectedItem]);
26 m_IconWidget.SetVisible(
true);
29 m_IconWidget.SetVisible(
false);
34 int AddItemAndIcon(
string item, ResourceName icon,
float rotation = 0, Managed
data =
null)
37 m_aElementIcons =
new array<ResourceName>;
39 if (!m_aElementIconRotations)
40 m_aElementIconRotations =
new array<float>;
42 m_aElementIcons.Insert(icon);
43 m_aElementIconRotations.Insert(
rotation);
45 int i = super.AddItem(item,
false,
data);
50 ImageWidget GetIconWidget()
56 override int AddItem(
string item,
bool last =
false, Managed
data =
null)
58 m_aElementIcons.Insert(
string.Empty);
59 int i = super.AddItem(item, last,
data);
64 override void ClearAll()
66 m_aElementIcons.Clear();
70 void AllowFocus(
bool allowFocus)
73 m_wContentRoot.ClearFlags(WidgetFlags.NOFOCUS);
75 m_wContentRoot.SetFlags(WidgetFlags.NOFOCUS);
79 ScriptInvoker GetOnCreateElement()
81 return Event_OnCreateElement;
85 protected override void OnCreateElement(Widget elementWidget,
int index)
87 ImageWidget iconWidget = ImageWidget.Cast(elementWidget.FindAnyWidget(
"Icon"));
94 if (m_aElementIcons &&
index >= 0 &&
index < m_aElementIcons.Count() && m_aElementIcons[
index] !=
string.Empty)
96 iconWidget.LoadImageTexture(0, m_aElementIcons[
index]);
97 iconWidget.SetImage(0);
98 iconWidget.SetRotation(m_aElementIconRotations[m_iSelectedItem]);
99 iconWidget.SetVisible(
true);
103 iconWidget.SetVisible(
false);
107 Event_OnCreateElement.Invoke(elementWidget,
index);
110 void SetElementEnabled(
int index,
bool enable)
112 if (
index >= 0 &&
index < m_aElementWidgets.Count())
114 m_aElementWidgets[
index].SetEnabled(enable);
116 ImageWidget iconWidget = ImageWidget.Cast(m_aElementWidgets[
index].FindAnyWidget(
"Icon"));
121 iconWidget.SetColor(Color.FromInt(Color.WHITE));
123 iconWidget.SetColor(m_cIconDisabledColor);
128 override void RemoveItem(
int item,
bool last =
false)
130 if (item < m_aElementIcons.Count())
131 m_aElementIcons.Remove(item);
133 super.RemoveItem(item, last);
136 override void HandlerAttached(Widget w)
139 super.HandlerAttached(w);