9 protected ref array<ref MultipleStateButtonState> m_aStates;
12 protected ResourceName m_wIconSetTexture;
21 protected int m_iStateSelected;
24 protected bool m_bEnabled =
true;
26 [
Attribute(
"",
"auto",
"Action ID to be displayed as hint")]
27 protected string m_sHintAction;
29 protected TextWidget m_ContentText;
30 protected TextWidget m_ProgressText;
31 protected ImageWidget m_Progress;
32 protected ImageWidget m_wIcon;
33 protected RichTextWidget m_wActionHint;
35 ref ScriptInvoker m_OnStateChange =
new ScriptInvoker;
36 ref ScriptInvoker m_OnHover =
new ScriptInvoker;
37 ref ScriptInvoker m_OnHoverLeave =
new ScriptInvoker;
40 override void HandlerAttached(Widget w)
42 super.HandlerAttached(w);
44 m_ContentText = TextWidget.Cast(
m_wRoot.FindAnyWidget(
"ContentText"));
45 m_Progress = ImageWidget.Cast(
m_wRoot.FindAnyWidget(
"Progress"));
46 m_ProgressText = TextWidget.Cast(
m_wRoot.FindAnyWidget(
"ProgressNumber"));
48 m_wActionHint = RichTextWidget.Cast(
m_wRoot.FindAnyWidget(
"ActionHint"));
50 if (!m_sHintAction.IsEmpty())
51 m_wActionHint.SetText(
string.Format(
"<action name=\"%1\"/>", m_sHintAction));
53 m_wActionHint.SetText(
string.Empty);
64 if (m_aStates.Count() > 0)
65 ChangeState(m_iStateSelected);
69 override bool OnClick(Widget w,
int x,
int y,
int button)
73 super.OnClick(w, x, y, button);
81 void ChangeState(
int state)
86 if (state >= 0 && state < m_aStates.Count())
88 m_iStateSelected = state;
91 string name = m_aStates[state].m_sName;
92 m_ContentText.SetText(name);
95 m_wIcon.LoadImageFromSet(0, m_wIconSetTexture, m_aStates[state].
m_sIcon);
98 if(m_aStates[state].m_cContentColor)
101 m_ContentText.SetColor(m_aStates[state].m_cContentColor);
104 m_wIcon.SetColor(m_aStates[state].m_cContentColor);
108 m_OnStateChange.Invoke(state);
114 m_Progress.SetVisible(
true);
115 m_Progress.SetMaskProgress(0);
116 m_ContentText.SetText(m_aStates[m_iStateSelected].
m_sName);
117 SetProgressText(
"0%");
121 void SetProgress(
int progress)
123 if (!m_Progress.IsVisible())
124 m_Progress.SetVisible(
true);
125 m_Progress.SetMaskProgress(progress/100);
126 SetProgressText(
"" + progress +
"%");
131 void FinishProgress()
133 m_Progress.SetVisible(
false);
138 int GetSelectedItem()
140 return m_iStateSelected;
144 void SetProgressText(
string text)
146 m_ProgressText.SetText(text);
151 void SetHintVisible(
bool show)
153 m_wActionHint.SetVisible(show);
157 void EnableButton(
bool bEnable)
175 bool IsButtonEnabled()
181 override protected void OnMenuSelect()
184 super.OnMenuSelect();
188 override bool OnMouseButtonDown(Widget w,
int x,
int y,
int button)
191 return super.OnMouseButtonDown(w, x, y, button);
196 override bool OnMouseButtonUp(Widget w,
int x,
int y,
int button)
199 return super.OnMouseButtonUp(w, x, y, button);
205 override bool OnMouseEnter(Widget w,
int x,
int y)
210 return super.OnMouseEnter(w, x, y);
216 override bool OnMouseLeave(Widget w, Widget enterW,
int x,
int y)
220 m_OnHoverLeave.Invoke();
221 return super.OnMouseLeave(w, enterW, x, y);
227 override bool OnFocus(Widget w,
int x,
int y)
230 return super.OnFocus(w, x, y);
235 override bool OnFocusLost(Widget w,
int x,
int y)
238 return super.OnFocusLost(w, x, y);
243 string GetCurrentContent()
245 return m_aStates[m_iStateSelected].m_sName;
270 [
Attribute(
"1 1 1 1", UIWidgets.ColorPicker)]
271 ref Color m_cContentColor;