Launcher: Fix tab being broken from a few commits ago

This commit is contained in:
UnknownShadow200 2016-09-27 10:22:52 +10:00
parent f6f7b307c1
commit c5cd193566
9 changed files with 28 additions and 25 deletions

View file

@ -24,7 +24,7 @@ namespace Launcher.Gui.Screens {
widgets[view.defIndex + 1].OnClick = (x, y) => game.SetScreen( new MainScreen( game ) );
SetupInputHandlers();
for( int i = 0; i < widgets.Length; i++ ) {
LauncherInputWidget input = widgets[i] as LauncherInputWidget;
InputWidget input = widgets[i] as InputWidget;
if( input == null ) continue;
input.Chars.TextChanged = TextChanged;
}
@ -81,7 +81,7 @@ namespace Launcher.Gui.Screens {
Resize();
}
void TextChanged( LauncherInputWidget widget ) {
void TextChanged( InputWidget widget ) {
bool changed = false;
int index = Array.IndexOf<Widget>( widgets, widget );
if( index < 3 ) changed |= Parse( 0, ref LauncherSkin.BackgroundCol );

View file

@ -120,7 +120,7 @@ namespace Launcher.Gui.Screens {
}
void SetText( int index, string text ) {
((LauncherInputWidget)widgets[index]).SetDrawData( drawer, text );
((InputWidget)widgets[index]).SetDrawData( drawer, text );
}
void SetBool( bool value ) {

View file

@ -127,16 +127,16 @@ namespace Launcher.Gui.Screens {
}
protected void Set( int index, string text ) {
((LauncherInputWidget)widgets[index]).SetDrawData( drawer, text );
((LauncherInputWidget)widgets[index]).Redraw( drawer );
((InputWidget)widgets[index]).SetDrawData( drawer, text );
((InputWidget)widgets[index]).Redraw( drawer );
}
protected virtual void MouseWheelChanged( object sender, MouseWheelEventArgs e ) {
}
protected LauncherInputWidget curInput;
protected InputWidget curInput;
protected virtual void InputClick( int mouseX, int mouseY ) {
LauncherInputWidget input = (LauncherInputWidget)selectedWidget;
InputWidget input = (InputWidget)selectedWidget;
using( drawer ) {
drawer.SetBitmap( game.Framebuffer );
if( curInput != null ) {
@ -155,7 +155,7 @@ namespace Launcher.Gui.Screens {
}
protected override void WidgetUnclicked( Widget widget ) {
LauncherInputWidget input = widget as LauncherInputWidget;
InputWidget input = widget as InputWidget;
if( input == null ) return;
input.Active = false;
RedrawWidget( input );
@ -165,7 +165,7 @@ namespace Launcher.Gui.Screens {
protected void SetupInputHandlers() {
for( int i = 0; i < widgets.Length; i++ ) {
if( !(widgets[i] is LauncherInputWidget) ) continue;
if( !(widgets[i] is InputWidget) ) continue;
widgets[i].OnClick = InputClick;
}
}

View file

@ -94,8 +94,8 @@ namespace Launcher.Gui.Screens {
Widget widget = widgets[i];
if( widget == null || !widget.Visible ) continue;
int width = widget.Width, height = widget.Height;
if( widgets[i] is LauncherInputWidget )
width = ((LauncherInputWidget)widgets[i]).RealWidth;
if( widgets[i] is InputWidget )
width = ((InputWidget)widgets[i]).RealWidth;
if( e.X >= widget.X && e.Y >= widget.Y &&
e.X < widget.X + width && e.Y < widget.Y + height ) {
@ -134,7 +134,8 @@ namespace Launcher.Gui.Screens {
Widget widget = widgets[i];
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.Y = widget.Y + widget.Height / 2;
@ -149,9 +150,9 @@ namespace Launcher.Gui.Screens {
game.Window.DesktopCursorPos = p;
lastClicked = widget;
if( widgets[i] is LauncherInputWidget ) {
if( widgets[i] is InputWidget ) {
MouseButtonDown( null, pressArgs );
((LauncherInputWidget)widgets[i]).Chars.CaretPos = -1;
((InputWidget)widgets[i]).Chars.CaretPos = -1;
}
break;
}

View file

@ -96,7 +96,7 @@ namespace Launcher.Gui.Screens {
}
void SetupWidgetHandlers() {
LauncherInputWidget hashWidget = (LauncherInputWidget)widgets[view.hashIndex];
InputWidget hashWidget = (InputWidget)widgets[view.hashIndex];
hashWidget.Chars.ClipboardFilter = HashFilter;
widgets[view.backIndex].OnClick =

View file

@ -36,8 +36,10 @@ namespace Launcher.Gui.Views {
Makers.Label( this, "Active button", textFont )
.SetLocation( Anchor.Centre, Anchor.Centre, -70, 60 );
//for( int i = start; i < widgetIndex; i++ )
// ((LauncherLabelWidget)widgets[i]).DarkenWhenInactive = true;
for( int i = start; i < widgetIndex; i++ ) {
((LabelWidget)widgets[i]).DarkenWhenInactive = true;
widgets[i].TabSelectable = true;
}
Makers.Label( this, "Red", titleFont )
.SetLocation( Anchor.Centre, Anchor.Centre, 30, -130 );

View file

@ -15,7 +15,7 @@ namespace Launcher.Gui.Widgets {
public Func<string, string> ClipboardFilter;
/// <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>
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>
public int CaretPos = -1;
LauncherInputWidget input;
public InputText( LauncherInputWidget input ) {
InputWidget input;
public InputText( InputWidget input ) {
this.input = input;
}

View file

@ -6,7 +6,7 @@ using Launcher.Drawing;
namespace Launcher.Gui.Widgets {
/// <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;
@ -22,7 +22,7 @@ namespace Launcher.Gui.Widgets {
Font font, hintFont;
int textHeight;
public LauncherInputWidget( LauncherWindow window ) : base( window ) {
public InputWidget( LauncherWindow window ) : base( window ) {
Chars = new InputText( this );
TabSelectable = true;
}

View file

@ -53,11 +53,11 @@ namespace Launcher.Gui.Widgets {
public static Widget Input( IView view, string text, int width, Font inputFont,
Font inputHintFont, bool password, int maxChars, string hint ) {
LauncherInputWidget widget;
InputWidget widget;
if( view.widgets[view.widgetIndex] != null ) {
widget = (LauncherInputWidget)view.widgets[view.widgetIndex];
widget = (InputWidget)view.widgets[view.widgetIndex];
} else {
widget = new LauncherInputWidget( view.game );
widget = new InputWidget( view.game );
widget.Password = password;
widget.Chars.MaxChars = maxChars;
widget.HintText = hint;