4 protected ref array<string> m_aContent;
6 [
Attribute(defvalue:
"{86576034F67F9F64}UI/layouts/Menus/Breadcrumbs/BreadCrumbsElement.layout")]
7 protected ResourceName m_sElementLayout;
9 [
Attribute(defvalue:
"{287A657BF9A33943}UI/layouts/Menus/Breadcrumbs/BreadCrumbsRichElement.layout")]
10 protected ResourceName m_sRichElementLayout;
12 [
Attribute(defvalue:
"{240DC2208952C2C2}UI/layouts/Menus/Breadcrumbs/BreadCrumbsSeparator.layout")]
13 protected ResourceName m_sSeparatorLayout;
15 protected ref array<Widget> m_aElements = {};
16 protected ref array<Widget> m_aSeparators = {};
19 override void HandlerAttached(Widget w)
21 super.HandlerAttached(w);
37 void Set(array<string> values)
47 foreach (
string value : values)
51 m_aContent.Insert(value);
58 void Set(
string value1,
string value2 =
"",
string value3 =
"")
60 array<string> values = { value1, value2, value3 };
65 void SetFormat(
string value,
string arg1,
string arg2 =
"")
69 Widget widget =
GetGame().GetWorkspace().CreateWidgets(m_sElementLayout,
m_wRoot);
73 TextWidget textWidget = TextWidget.Cast(widget);
77 textWidget.SetTextFormat(value, arg1, arg2);
78 m_aContent = { value };
82 void SetRichFormat(
string value,
string arg1,
string arg2 =
"")
86 Widget widget =
GetGame().GetWorkspace().CreateWidgets(m_sRichElementLayout,
m_wRoot);
90 RichTextWidget richTextWidget = RichTextWidget.Cast(widget);
94 richTextWidget.SetTextFormat(value, arg1, arg2);
95 m_aContent = { value };
101 Widget widget =
GetGame().GetWorkspace().CreateWidgets(m_sElementLayout,
m_wRoot);
109 comp.SetBreadCrumb(info);
114 Widget separator =
GetGame().GetWorkspace().CreateWidgets(m_sSeparatorLayout,
m_wRoot);
115 separator.SetVisible(
false);
118 int prevId = m_aSeparators.Count() - 1;
119 if (m_aSeparators.IsIndexValid(prevId))
120 m_aSeparators[prevId].SetVisible(
true);
122 m_aSeparators.Insert(separator);
126 void RemoveLastBreadCrumbElement()
136 int prevId = m_aSeparators.Count() - 1;
137 if (m_aSeparators.IsIndexValid(prevId))
138 m_aSeparators[prevId].SetVisible(
false);
144 Widget lastSeparator = m_aSeparators[prevId];
146 m_wRoot.RemoveChild(lastSeparator);
147 m_aSeparators.RemoveItem(lastSeparator);
151 protected void Refresh()
156 m_aSeparators.Clear();
158 if (!m_aContent || !m_aContent.Count() || !m_sElementLayout)
162 TextWidget textWidget;
163 array<TextWidget> createdWidgets = {};
164 for (
int i, count = m_aContent.Count(); i < count; i++)
166 widget =
GetGame().GetWorkspace().CreateWidgets(m_sElementLayout,
m_wRoot);
170 textWidget = TextWidget.Cast(widget);
174 textWidget.SetText(m_aContent[i]);
175 createdWidgets.Insert(textWidget);
177 if (m_sSeparatorLayout && i < count -1)
178 GetGame().GetWorkspace().CreateWidgets(m_sSeparatorLayout,
m_wRoot);
181 if (!createdWidgets.Count())
184 float left, top, right, bottom;
186 widget = createdWidgets[0];
187 LayoutSlot.GetPadding(widget, left, top, right, bottom);
188 LayoutSlot.SetPadding(widget, 0, top, right, bottom);
190 widget = createdWidgets[createdWidgets.Count() - 1];
191 LayoutSlot.GetPadding(widget, left, top, right, bottom);
192 LayoutSlot.SetPadding(widget, left, top, 0, bottom);