11 m_Options = {
"#server_browser_disabled",
"#server_browser_show",
"#server_browser_hide" };
15 m_SelectedOptionIndex = 0;
19 m_Root =
GetGame().GetWorkspace().CreateWidgets(
"gui/layouts/new_ui/option_selector.layout", parent);
20#ifdef PLATFORM_CONSOLE
21 m_Parent = parent.GetParent().GetParent();
23#ifdef PLATFORM_WINDOWS
29 m_PreviousOption =
m_Root.FindAnyWidget(
"prev_option");
30 m_NextOption =
m_Root.FindAnyWidget(
"next_option");
32#ifdef PLATFORM_CONSOLE
33 m_NextOption.Show(
false);
34 m_PreviousOption.Show(
false);
37 m_SelectedOption.SetText(m_Options.Get(m_SelectedOptionIndex));
57 if (
w == m_NextOption)
62 else if (
w == m_PreviousOption)
94 m_SelectedOptionIndex = 0;
96 m_SelectedOption.SetText(m_Options.Get(m_SelectedOptionIndex));
98 m_OptionChanged.Invoke(m_SelectedOptionIndex);
103 m_SelectedOptionIndex++;
104 if (m_SelectedOptionIndex >= m_Options.Count())
105 m_SelectedOptionIndex = 0;
107 m_SelectedOption.SetText(m_Options.Get(m_SelectedOptionIndex));
109 m_OptionChanged.Invoke(m_SelectedOptionIndex);
114 m_SelectedOptionIndex--;
115 if (m_SelectedOptionIndex < 0)
116 m_SelectedOptionIndex = m_Options.Count() - 1;
118 m_SelectedOption.SetText(m_Options.Get(m_SelectedOptionIndex));
120 m_OptionChanged.Invoke(m_SelectedOptionIndex);
131 return m_SelectedOptionIndex != 0;
137 return m_SelectedOptionIndex == 1;
148 return m_Options.Get(m_SelectedOptionIndex);
156 m_SelectedOptionIndex =
index;
157 m_SelectedOption.SetText(m_Options.Get(m_SelectedOptionIndex));
160 m_OptionChanged.Invoke(m_SelectedOptionIndex);
166 switch (m_SelectedOptionIndex)
170 m_SelectedOption.SetColor(
ARGB(255, 255, 255, 255));
175 m_SelectedOption.SetColor(
ARGB(255, 0, 255, 0));
180 m_SelectedOption.SetColor(
ARGB(255, 255, 0, 0));
189 return (
w ==
m_Parent ||
w == m_NextOption ||
w == m_PreviousOption);
196#ifndef PLATFORM_CONSOLE
197 m_NextOption.ClearFlags(
WidgetFlags.IGNOREPOINTER);
198 m_NextOption.Show(
true);
199 m_PreviousOption.ClearFlags(
WidgetFlags.IGNOREPOINTER);
200 m_PreviousOption.Show(
true);
210#ifndef PLATFORM_CONSOLE
212 m_NextOption.Show(
false);
213 m_PreviousOption.SetFlags(
WidgetFlags.IGNOREPOINTER);
214 m_PreviousOption.Show(
false);
223 super.ColorNormalConsole(
w);
228 if (m_SelectedOption)
229 m_SelectedOption.SetColor(
ARGB(255, 255, 255, 255));
234 super.ColorDisabledConsole(
w);
239 if (m_SelectedOption)
240 m_SelectedOption.SetColor(
ARGB(120, 255, 255, 255));
void SetStringOption(string option, bool fire_event=true)
int m_SelectedOptionIndex
TextWidget m_SelectedOption
override bool IsFocusable(Widget w)
bool IsEnabled()
Returns 'true' if current index == 1 (default 'enabled' value). Take care, as different selectors may...
override void ColorNormalConsole(Widget w)
bool IsSelectorEnabled()
Returns false for the selector in 'disabled' states.
ref array< string > m_Options
override void ColorDisabledConsole(Widget w)
override bool OnMouseEnter(Widget w, int x, int y)
void OptionSelector(Widget parent, int current_index, ScriptedWidgetEventHandler parent_c, bool disabled)
override bool OnClick(Widget w, int x, int y, int button)
override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
override bool OnMouseButtonUp(Widget w, int x, int y, int button)
array< string > GetOptions()
override void SetNextOption()
override void SetPrevOption()
proto native CGame GetGame()
int ARGB(int a, int r, int g, int b)