3 protected Widget m_PreviousOption;
4 protected Widget m_NextOption;
6 protected int m_SelectedOptionIndex;
11 m_Options = {
"#server_browser_disabled",
"#server_browser_show",
"#server_browser_hide" };
12 m_ParentClass = parent_c;
14 if (current_index < 0 || current_index >= m_Options.Count())
16 m_SelectedOptionIndex = 0;
20 m_SelectedOptionIndex = current_index;
23 m_Root =
GetGame().GetWorkspace().CreateWidgets(
"gui/layouts/new_ui/option_selector.layout", parent);
24 #ifdef PLATFORM_CONSOLE
25 m_Parent = parent.GetParent().GetParent();
27 #ifdef PLATFORM_WINDOWS
33 m_PreviousOption =
m_Root.FindAnyWidget(
"prev_option");
34 m_NextOption =
m_Root.FindAnyWidget(
"next_option");
36 #ifdef PLATFORM_CONSOLE
37 m_NextOption.Show(
false);
38 m_PreviousOption.Show(
false);
41 m_SelectedOption.SetText(m_Options.Get(m_SelectedOptionIndex));
65 if (w == m_NextOption)
70 else if (w == m_PreviousOption)
92 return super.OnMouseEnter(w,
x,
y);
97 return super.OnMouseLeave(w, enterW,
x,
y);
102 m_SelectedOptionIndex = 0;
104 m_SelectedOption.SetText(m_Options.Get(m_SelectedOptionIndex));
106 m_OptionChanged.Invoke(m_SelectedOptionIndex);
111 m_SelectedOptionIndex++;
112 if (m_SelectedOptionIndex >= m_Options.Count())
114 m_SelectedOptionIndex = 0;
117 m_SelectedOption.SetText(m_Options.Get(m_SelectedOptionIndex));
119 m_OptionChanged.Invoke(m_SelectedOptionIndex);
124 m_SelectedOptionIndex--;
125 if (m_SelectedOptionIndex < 0)
127 m_SelectedOptionIndex = m_Options.Count() - 1;
130 m_SelectedOption.SetText(m_Options.Get(m_SelectedOptionIndex));
132 m_OptionChanged.Invoke(m_SelectedOptionIndex);
143 return m_SelectedOptionIndex != 0;
149 return m_SelectedOptionIndex == 1;
153 bool IsSelectorEnabled()
158 string GetStringValue()
160 return m_Options.Get(m_SelectedOptionIndex);
163 void SetStringOption(
string option,
bool fire_event =
true)
165 int index = m_Options.Find(option);
168 m_SelectedOptionIndex = index;
169 m_SelectedOption.SetText(m_Options.Get(m_SelectedOptionIndex));
172 m_OptionChanged.Invoke(m_SelectedOptionIndex);
178 switch (m_SelectedOptionIndex)
182 m_SelectedOption.SetColor(
ARGB(255, 255, 255, 255));
187 m_SelectedOption.SetColor(
ARGB(255, 0, 255, 0));
192 m_SelectedOption.SetColor(
ARGB(255, 255, 0, 0));
202 return (w ==
m_Parent || w == m_NextOption || w == m_PreviousOption);
210 #ifndef PLATFORM_CONSOLE
211 m_NextOption.ClearFlags(
WidgetFlags.IGNOREPOINTER);
212 m_NextOption.Show(
true);
213 m_PreviousOption.ClearFlags(
WidgetFlags.IGNOREPOINTER);
214 m_PreviousOption.Show(
true);
221 override void Disable()
224 #ifndef PLATFORM_CONSOLE
226 m_NextOption.Show(
false);
227 m_PreviousOption.SetFlags(
WidgetFlags.IGNOREPOINTER);
228 m_PreviousOption.Show(
false);
235 override void ColorNormalConsole(
Widget w)
237 super.ColorNormalConsole(w);
242 if (m_SelectedOption)
244 m_SelectedOption.SetColor(
ARGB(255,255,255,255));
248 override void ColorDisabledConsole(
Widget w)
250 super.ColorDisabledConsole(w);
255 if (m_SelectedOption)
257 m_SelectedOption.SetColor(
ARGB(120,255,255,255));