9 [
Attribute(
"-1", UIWidgets.Auto,
"ID of the element selected by default. When -1, none is selected at start.")]
10 int m_iDefaultSortElement;
13 ref ScriptInvoker m_OnChanged =
new ScriptInvoker;
15 protected ref array<SCR_SortElementComponent> m_aSortElements;
17 protected Widget m_wRoot;
31 return comp.GetSortOrder();
36 bool GetSortOrderAscending()
42 int GetSortElementId()
44 for (
int i = 0; i < m_aSortElements.Count(); i++)
46 if (m_aSortElements[i].GetSortOrder() !=
ESortOrder.NONE)
53 string GetSortElementName()
60 return comp.GetName();
65 int FindElement(
string name)
67 int count = m_aSortElements.Count();
68 for (
int i = 0; i < count; i++)
70 if (m_aSortElements[i].
GetName() == name)
78 void SetCurrentSortElement(
int id,
ESortOrder order,
bool useDefaultSortOrder =
false,
bool invokeOnChanged =
true)
80 if (id < 0 || id >= m_aSortElements.Count())
83 int count = m_aSortElements.Count();
85 for (
int i = 0; i < count; i++)
88 m_aSortElements[i].SetSortOrder(
ESortOrder.NONE);
92 if (useDefaultSortOrder)
93 comp.SetSortOrder(comp.GetDefaultSortOrder());
95 comp.SetSortOrder(order);
102 void SetElementVisible(
int id,
bool visible)
104 if (id < 0 || id >= m_aSortElements.Count())
107 m_aSortElements[id].GetRootWidget().SetVisible(visible);
111 Widget GetRootWidget()
119 void SetFocus(
int id)
121 if (id < 0 || id >= m_aSortElements.Count())
125 GetGame().GetWorkspace().SetFocusedWidget(comp.GetRootWidget());
133 override protected void HandlerAttached(Widget w)
136 m_aSortElements = {};
137 FindAllSortButtons(w, m_aSortElements);
140 if (m_iDefaultSortElement != -1)
141 SetCurrentSortElement(m_iDefaultSortElement,
ESortOrder.NONE, useDefaultSortOrder:
true, invokeOnChanged:
false);
146 comp.m_OnClicked.Insert(OnButtonClicked);
152 protected static void FindAllSortButtons(Widget w, array<SCR_SortElementComponent> components)
156 components.Insert(comp);
158 Widget child = w.GetChildren();
161 FindAllSortButtons(child, components);
162 child = child.GetSibling();
167 protected void OnButtonClicked(SCR_ModularButtonComponent compClicked)
172 if (comp != compClicked && comp.GetSortOrder() !=
ESortOrder.NONE)
191 protected void InvokeOnChanged()