3 protected bool m_FirstInit =
true;
21 #ifdef PLATFORM_CONSOLE
28 switch (pInputDeviceType)
32 m_TabControlsRoot.FindAnyWidget(
"ConsoleControls").Show(
true);
38 m_TabControlsRoot.FindAnyWidget(
"ConsoleControls").Show(
false);
48 m_ResolutionMultiplier =
y / 1080;
52 Widget tab_controls =
m_Root.FindAnyWidget(
"Tab_Control_Container");
55 Widget tab_child = tab_controls.GetChildren();
60 tab_child = tab_child.GetSibling();
65 Widget tab_control = tab_controls.FindAnyWidget(
"Tab_Control_" + i);
67 if (tab_control && tab_widget)
69 tab_control.SetHandler(
this);
70 m_TabControls.Insert(i, tab_control);
71 m_Tabs.Insert(i, tab_widget);
75 Error(
"Tabber could not find correctly named tab or control at index " + i);
80 #ifdef PLATFORM_CONSOLE
86 m_InitTimer.Run(0.01,
this,
"AlignTabbers");
102 m_InitTimer =
new Timer();
103 m_TabControlsRoot =
m_Root.FindAnyWidget(
"TabControls");
113 Widget tab_controls_container = m_TabControlsRoot.FindAnyWidget(
"Tab_Control_Container" );
114 Widget tab_controls_scroller = m_TabControlsRoot.FindAnyWidget(
"Tab_Control_Scroller" );
116 m_TabControlsRoot.Update();
117 tab_controls_container.Update();
119 Widget tab_child = tab_controls_container.GetChildren();
122 if ( tab_child.IsVisible() )
124 TextWidget tab_text =
TextWidget.Cast( tab_child.FindAnyWidget( tab_child.GetName() +
"_Title" ) );
127 tab_text.GetTextSize( t_x, t_y );
128 tab_child.SetSize( t_x + 10 * m_ResolutionMultiplier, 1 );
129 tab_controls_container.Update();
134 tab_child = tab_child.GetSibling();
137 tab_child = tab_controls_container.GetChildren();
140 tab_controls_container.GetScreenPos( x_f_c, y_f_c );
144 Widget tab_bg = tab_child.FindAnyWidget( tab_child.GetName() +
"_Background" );
145 tab_child.GetScreenPos(
x,
y );
146 tab_bg.SetPos( ( x_f_c -
x ), 0 );
147 tab_bg.SetSize( total_size, 1 );
149 tab_child = tab_child.GetSibling();
152 m_TabControlsRoot.GetSize(
x,
y );
154 m_TabControlsRoot.SetSize( total_size,
y );
155 tab_controls_container.Update();
156 if (tab_controls_scroller)
157 tab_controls_scroller.Update();
158 m_TabControlsRoot.Update();
163 int new_index = m_Tabs.Count();
168 tab.SetName(
"Tab_" + new_index );
169 control.SetName(
"Tab_Control_" + new_index );
170 control_text.SetName(
"Tab_Control_" + new_index +
"_Title" );
171 control.FindAnyWidget(
"Tab_Control_x_Background" ).SetName(
"Tab_Control_" + new_index +
"_Background" );
173 control_text.SetText(
name );
175 control.SetHandler(
this );
176 m_TabControls.Insert( new_index, control );
177 m_Tabs.Insert( new_index, tab );
192 return m_Tabs.Get( index );
197 return m_Tabs.Count();
218 m_SelectedIndex = index;
219 m_OnTabSwitch.Invoke( m_SelectedIndex );
230 int index = m_TabControls.GetKeyByValue( w );
231 if ( m_SelectedIndex == index )
236 Widget tab_control = m_TabControls.Get( index );
239 Widget tab_title =
TextWidget.Cast(tab_control.FindAnyWidget( tab_control.GetName() +
"_Title" ));
240 tab_title.SetColor(
ARGB(255, 255, 0, 0) );
241 tab_control.SetColor(
ARGB(255, 0, 0 ,0) );
249 int index = m_TabControls.GetKeyByValue( w );
250 if ( m_SelectedIndex == index )
255 Widget tab_control = m_TabControls.Get( index );
258 Widget tab_title =
TextWidget.Cast(tab_control.FindAnyWidget( tab_control.GetName() +
"_Title" ));
259 tab_title.SetColor(
ARGB(255, 255, 255, 255) );
260 tab_control.SetColor(
ARGB(0, 0, 0 ,0) );
269 int index = m_TabControls.GetKeyByValue( w );
270 if ( m_SelectedIndex != index )
272 m_OnAttemptTabSwitch.Invoke( m_SelectedIndex, index );
287 if ( w ==
m_Root.FindAnyWidget(
"Tab_Control_Container" ) )
297 if ( w ==
m_Root.FindAnyWidget(
"Tab_Control_Container" ) )
307 Widget tab_control =
m_Root.FindAnyWidget(
"Tab_Control_" + index );
309 tab_control.Show( enable );
315 Widget tab_control = m_TabControls.Get( index );
326 Widget tab_title =
TextWidget.Cast(tab_control.FindAnyWidget( tab_control.GetName() +
"_Title" ));
328 int color_title =
ARGB(255, 255, 0, 0);
329 int color_backg =
ARGB(255, 0, 0 ,0);
331 #ifdef PLATFORM_CONSOLE
332 color_title =
ARGB(255, 255, 255, 255);
333 color_backg =
ARGB(255, 200, 0 ,0);
336 tab_title.SetColor( color_title );
337 tab_control.SetColor( color_backg );
343 Widget tab = m_Tabs.Get( index );
352 Widget tab_control = m_TabControls.Get( index );
362 Widget tab_title =
TextWidget.Cast(tab_control.FindAnyWidget( tab_control.GetName() +
"_Title" ));
363 tab_title.SetColor(
ARGB(255, 255, 255,255) );
364 tab_control.SetColor(
ARGB(0, 0, 0 ,0) );
370 Widget tab = m_Tabs.Get( index );
379 for (
int i = 0; i < m_TabControls.Count(); i++)
388 int next_index = m_SelectedIndex + 1;
390 while ( next_index < m_Tabs.Count() && !m_TabControls[next_index].IsVisible() )
395 if ( next_index >= m_Tabs.Count() )
400 if ( m_SelectedIndex != next_index )
402 m_OnAttemptTabSwitch.Invoke( m_SelectedIndex, next_index );
418 int next_index = m_SelectedIndex - 1;
420 if ( next_index < 0 )
422 next_index = m_TabControls.Count() - 1;
425 while ( next_index > 0 && !m_TabControls[next_index].
IsVisible() )
430 if ( m_SelectedIndex != next_index )
432 m_OnAttemptTabSwitch.Invoke( m_SelectedIndex, next_index );
453 m_FirstInit = performInitAlignment;
460 Widget xbControls =
m_Root.FindAnyWidget(
"ConsoleControls");
463 xbControls.Show(m_TabsCount > 1);
protected void OnInputDeviceChanged(EInputDeviceType pInputDeviceType)
protected void OnInputPresetChanged()
proto native Mission GetMission()
proto native WorkspaceWidget GetWorkspace()
ScriptInvoker GetOnInputPresetChanged()
ScriptInvoker GetOnInputDeviceChanged()
ScriptInvoker Class provide list of callbacks usage:
proto bool Insert(func fn, int flags=EScriptInvokerInsertFlags.IMMEDIATE)
insert method to list
proto native CGame GetGame()
void Error(string err)
Messagebox with error message.
proto void GetScreenSize(out int x, out int y)
int ARGB(int a, int r, int g, int b)