mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-01-23 01:21:57 -05:00
Launcher: Fix tab being broken from a few commits ago
This commit is contained in:
parent
f6f7b307c1
commit
c5cd193566
9 changed files with 28 additions and 25 deletions
|
@ -24,7 +24,7 @@ namespace Launcher.Gui.Screens {
|
||||||
widgets[view.defIndex + 1].OnClick = (x, y) => game.SetScreen( new MainScreen( game ) );
|
widgets[view.defIndex + 1].OnClick = (x, y) => game.SetScreen( new MainScreen( game ) );
|
||||||
SetupInputHandlers();
|
SetupInputHandlers();
|
||||||
for( int i = 0; i < widgets.Length; i++ ) {
|
for( int i = 0; i < widgets.Length; i++ ) {
|
||||||
LauncherInputWidget input = widgets[i] as LauncherInputWidget;
|
InputWidget input = widgets[i] as InputWidget;
|
||||||
if( input == null ) continue;
|
if( input == null ) continue;
|
||||||
input.Chars.TextChanged = TextChanged;
|
input.Chars.TextChanged = TextChanged;
|
||||||
}
|
}
|
||||||
|
@ -81,7 +81,7 @@ namespace Launcher.Gui.Screens {
|
||||||
Resize();
|
Resize();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextChanged( LauncherInputWidget widget ) {
|
void TextChanged( InputWidget widget ) {
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
int index = Array.IndexOf<Widget>( widgets, widget );
|
int index = Array.IndexOf<Widget>( widgets, widget );
|
||||||
if( index < 3 ) changed |= Parse( 0, ref LauncherSkin.BackgroundCol );
|
if( index < 3 ) changed |= Parse( 0, ref LauncherSkin.BackgroundCol );
|
||||||
|
|
|
@ -120,7 +120,7 @@ namespace Launcher.Gui.Screens {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetText( int index, string text ) {
|
void SetText( int index, string text ) {
|
||||||
((LauncherInputWidget)widgets[index]).SetDrawData( drawer, text );
|
((InputWidget)widgets[index]).SetDrawData( drawer, text );
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetBool( bool value ) {
|
void SetBool( bool value ) {
|
||||||
|
|
|
@ -127,16 +127,16 @@ namespace Launcher.Gui.Screens {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void Set( int index, string text ) {
|
protected void Set( int index, string text ) {
|
||||||
((LauncherInputWidget)widgets[index]).SetDrawData( drawer, text );
|
((InputWidget)widgets[index]).SetDrawData( drawer, text );
|
||||||
((LauncherInputWidget)widgets[index]).Redraw( drawer );
|
((InputWidget)widgets[index]).Redraw( drawer );
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void MouseWheelChanged( object sender, MouseWheelEventArgs e ) {
|
protected virtual void MouseWheelChanged( object sender, MouseWheelEventArgs e ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected LauncherInputWidget curInput;
|
protected InputWidget curInput;
|
||||||
protected virtual void InputClick( int mouseX, int mouseY ) {
|
protected virtual void InputClick( int mouseX, int mouseY ) {
|
||||||
LauncherInputWidget input = (LauncherInputWidget)selectedWidget;
|
InputWidget input = (InputWidget)selectedWidget;
|
||||||
using( drawer ) {
|
using( drawer ) {
|
||||||
drawer.SetBitmap( game.Framebuffer );
|
drawer.SetBitmap( game.Framebuffer );
|
||||||
if( curInput != null ) {
|
if( curInput != null ) {
|
||||||
|
@ -155,7 +155,7 @@ namespace Launcher.Gui.Screens {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void WidgetUnclicked( Widget widget ) {
|
protected override void WidgetUnclicked( Widget widget ) {
|
||||||
LauncherInputWidget input = widget as LauncherInputWidget;
|
InputWidget input = widget as InputWidget;
|
||||||
if( input == null ) return;
|
if( input == null ) return;
|
||||||
input.Active = false;
|
input.Active = false;
|
||||||
RedrawWidget( input );
|
RedrawWidget( input );
|
||||||
|
@ -165,7 +165,7 @@ namespace Launcher.Gui.Screens {
|
||||||
|
|
||||||
protected void SetupInputHandlers() {
|
protected void SetupInputHandlers() {
|
||||||
for( int i = 0; i < widgets.Length; i++ ) {
|
for( int i = 0; i < widgets.Length; i++ ) {
|
||||||
if( !(widgets[i] is LauncherInputWidget) ) continue;
|
if( !(widgets[i] is InputWidget) ) continue;
|
||||||
widgets[i].OnClick = InputClick;
|
widgets[i].OnClick = InputClick;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,8 +94,8 @@ namespace Launcher.Gui.Screens {
|
||||||
Widget widget = widgets[i];
|
Widget widget = widgets[i];
|
||||||
if( widget == null || !widget.Visible ) continue;
|
if( widget == null || !widget.Visible ) continue;
|
||||||
int width = widget.Width, height = widget.Height;
|
int width = widget.Width, height = widget.Height;
|
||||||
if( widgets[i] is LauncherInputWidget )
|
if( widgets[i] is InputWidget )
|
||||||
width = ((LauncherInputWidget)widgets[i]).RealWidth;
|
width = ((InputWidget)widgets[i]).RealWidth;
|
||||||
|
|
||||||
if( e.X >= widget.X && e.Y >= widget.Y &&
|
if( e.X >= widget.X && e.Y >= widget.Y &&
|
||||||
e.X < widget.X + width && e.Y < widget.Y + height ) {
|
e.X < widget.X + width && e.Y < widget.Y + height ) {
|
||||||
|
@ -134,7 +134,8 @@ namespace Launcher.Gui.Screens {
|
||||||
|
|
||||||
Widget widget = widgets[i];
|
Widget widget = widgets[i];
|
||||||
int width = widget.Width;
|
int width = widget.Width;
|
||||||
if( widgets[i] is LauncherInputWidget )
|
if( widgets[i] is InputWidget )
|
||||||
|
width = ((InputWidget)widgets[i]).RealWidth;
|
||||||
moveArgs.X = widget.X + width / 2;
|
moveArgs.X = widget.X + width / 2;
|
||||||
moveArgs.Y = widget.Y + widget.Height / 2;
|
moveArgs.Y = widget.Y + widget.Height / 2;
|
||||||
|
|
||||||
|
@ -149,9 +150,9 @@ namespace Launcher.Gui.Screens {
|
||||||
game.Window.DesktopCursorPos = p;
|
game.Window.DesktopCursorPos = p;
|
||||||
lastClicked = widget;
|
lastClicked = widget;
|
||||||
|
|
||||||
if( widgets[i] is LauncherInputWidget ) {
|
if( widgets[i] is InputWidget ) {
|
||||||
MouseButtonDown( null, pressArgs );
|
MouseButtonDown( null, pressArgs );
|
||||||
((LauncherInputWidget)widgets[i]).Chars.CaretPos = -1;
|
((InputWidget)widgets[i]).Chars.CaretPos = -1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,7 +96,7 @@ namespace Launcher.Gui.Screens {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetupWidgetHandlers() {
|
void SetupWidgetHandlers() {
|
||||||
LauncherInputWidget hashWidget = (LauncherInputWidget)widgets[view.hashIndex];
|
InputWidget hashWidget = (InputWidget)widgets[view.hashIndex];
|
||||||
hashWidget.Chars.ClipboardFilter = HashFilter;
|
hashWidget.Chars.ClipboardFilter = HashFilter;
|
||||||
|
|
||||||
widgets[view.backIndex].OnClick =
|
widgets[view.backIndex].OnClick =
|
||||||
|
|
|
@ -36,8 +36,10 @@ namespace Launcher.Gui.Views {
|
||||||
Makers.Label( this, "Active button", textFont )
|
Makers.Label( this, "Active button", textFont )
|
||||||
.SetLocation( Anchor.Centre, Anchor.Centre, -70, 60 );
|
.SetLocation( Anchor.Centre, Anchor.Centre, -70, 60 );
|
||||||
|
|
||||||
//for( int i = start; i < widgetIndex; i++ )
|
for( int i = start; i < widgetIndex; i++ ) {
|
||||||
// ((LauncherLabelWidget)widgets[i]).DarkenWhenInactive = true;
|
((LabelWidget)widgets[i]).DarkenWhenInactive = true;
|
||||||
|
widgets[i].TabSelectable = true;
|
||||||
|
}
|
||||||
|
|
||||||
Makers.Label( this, "Red", titleFont )
|
Makers.Label( this, "Red", titleFont )
|
||||||
.SetLocation( Anchor.Centre, Anchor.Centre, 30, -130 );
|
.SetLocation( Anchor.Centre, Anchor.Centre, 30, -130 );
|
||||||
|
|
|
@ -15,7 +15,7 @@ namespace Launcher.Gui.Widgets {
|
||||||
public Func<string, string> ClipboardFilter;
|
public Func<string, string> ClipboardFilter;
|
||||||
|
|
||||||
/// <summary> Delegate invoked when the text changes. </summary>
|
/// <summary> Delegate invoked when the text changes. </summary>
|
||||||
public Action<LauncherInputWidget> TextChanged;
|
public Action<InputWidget> TextChanged;
|
||||||
|
|
||||||
/// <summary> Delegate that only lets certain characters be entered. </summary>
|
/// <summary> Delegate that only lets certain characters be entered. </summary>
|
||||||
public Func<char, bool> TextFilter;
|
public Func<char, bool> TextFilter;
|
||||||
|
@ -24,8 +24,8 @@ namespace Launcher.Gui.Widgets {
|
||||||
/// <remarks> -1 to insert/delete characters at end of the text. </remarks>
|
/// <remarks> -1 to insert/delete characters at end of the text. </remarks>
|
||||||
public int CaretPos = -1;
|
public int CaretPos = -1;
|
||||||
|
|
||||||
LauncherInputWidget input;
|
InputWidget input;
|
||||||
public InputText( LauncherInputWidget input ) {
|
public InputText( InputWidget input ) {
|
||||||
this.input = input;
|
this.input = input;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ using Launcher.Drawing;
|
||||||
|
|
||||||
namespace Launcher.Gui.Widgets {
|
namespace Launcher.Gui.Widgets {
|
||||||
/// <summary> Represents text that can have modified by the user. </summary>
|
/// <summary> Represents text that can have modified by the user. </summary>
|
||||||
public sealed class LauncherInputWidget : Widget {
|
public sealed class InputWidget : Widget {
|
||||||
|
|
||||||
public int ButtonWidth, ButtonHeight;
|
public int ButtonWidth, ButtonHeight;
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ namespace Launcher.Gui.Widgets {
|
||||||
|
|
||||||
Font font, hintFont;
|
Font font, hintFont;
|
||||||
int textHeight;
|
int textHeight;
|
||||||
public LauncherInputWidget( LauncherWindow window ) : base( window ) {
|
public InputWidget( LauncherWindow window ) : base( window ) {
|
||||||
Chars = new InputText( this );
|
Chars = new InputText( this );
|
||||||
TabSelectable = true;
|
TabSelectable = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,11 +53,11 @@ namespace Launcher.Gui.Widgets {
|
||||||
|
|
||||||
public static Widget Input( IView view, string text, int width, Font inputFont,
|
public static Widget Input( IView view, string text, int width, Font inputFont,
|
||||||
Font inputHintFont, bool password, int maxChars, string hint ) {
|
Font inputHintFont, bool password, int maxChars, string hint ) {
|
||||||
LauncherInputWidget widget;
|
InputWidget widget;
|
||||||
if( view.widgets[view.widgetIndex] != null ) {
|
if( view.widgets[view.widgetIndex] != null ) {
|
||||||
widget = (LauncherInputWidget)view.widgets[view.widgetIndex];
|
widget = (InputWidget)view.widgets[view.widgetIndex];
|
||||||
} else {
|
} else {
|
||||||
widget = new LauncherInputWidget( view.game );
|
widget = new InputWidget( view.game );
|
||||||
widget.Password = password;
|
widget.Password = password;
|
||||||
widget.Chars.MaxChars = maxChars;
|
widget.Chars.MaxChars = maxChars;
|
||||||
widget.HintText = hint;
|
widget.HintText = hint;
|
||||||
|
|
Loading…
Reference in a new issue