Exemple #1
0
 protected override void SelectWidget( LauncherWidget widget )
 {
     base.SelectWidget( widget );
     if( signingIn || !resumeValid || widget != widgets[4] ) return;
     const string format = "&eResume to {0}:{1}, as {2}";
     SetStatus( String.Format( format, resumeIp, resumePort, resumeUser ) );
 }
        public static void MakeLabelAt( LauncherWindow game, LauncherWidget[] widgets, ref int widgetIndex,
            string text, Font font, Anchor horAnchor,
            Anchor verAnchor, int x, int y)
        {
            LauncherLabelWidget widget;
            if( widgets[widgetIndex] != null ) {
                widget = (LauncherLabelWidget)widgets[widgetIndex];
            } else {
                widget = new LauncherLabelWidget( game, text );
                widgets[widgetIndex] = widget;
            }

            widget.SetDrawData( game.Drawer, text, font, horAnchor, verAnchor, x, y );
            widgetIndex++;
        }
        public static void MakeBooleanAt( LauncherWindow game, LauncherWidget[] widgets, ref int widgetIndex,
            Anchor horAnchor, Anchor verAnchor, Font font, bool initValue,
            int width, int height, int x, int y, Action<int, int> onClick)
        {
            LauncherBoolWidget widget;
            if( widgets[widgetIndex] != null ) {
                widget = (LauncherBoolWidget)widgets[widgetIndex];
            } else {
                widget = new LauncherBoolWidget( game, font, width, height );
                widget.Value = initValue;
                widget.OnClick = onClick;
                widgets[widgetIndex] = widget;
            }

            widget.SetDrawData( game.Drawer, horAnchor, verAnchor, x, y );
            widgetIndex++;
        }
        public static void MakeButtonAt( LauncherWindow game, LauncherWidget[] widgets, ref int widgetIndex,
            string text, int width, int height, Font font, Anchor horAnchor,
            Anchor verAnchor, int x, int y, Action<int, int> onClick)
        {
            LauncherButtonWidget widget;
            if( widgets[widgetIndex] != null ) {
                widget = (LauncherButtonWidget)widgets[widgetIndex];
            } else {
                widget = new LauncherButtonWidget( game );
                widget.Text = text;
                widget.OnClick = onClick;
                widgets[widgetIndex] = widget;
            }

            widget.Active = false;
            widget.SetDrawData( game.Drawer, text, font, horAnchor, verAnchor, width, height, x, y );
            widgetIndex++;
        }
        public static void MakeInput( LauncherWindow game, LauncherWidget[] widgets, ref int widgetIndex,
            string text, int width, Anchor horAnchor, Anchor verAnchor,
            Font inputFont, Font inputHintFont, Action<int, int> onClick,
            bool password, int x, int y, int maxChars, string hint)
        {
            LauncherInputWidget widget;
            if( widgets[widgetIndex] != null ) {
                widget = (LauncherInputWidget)widgets[widgetIndex];
            } else {
                widget = new LauncherInputWidget( game );
                widget.OnClick = onClick;
                widget.Password = password;
                widget.MaxTextLength = maxChars;
                widget.HintText = hint;
                widgets[widgetIndex] = widget;
            }

            widget.SetDrawData( game.Drawer, text, inputFont, inputHintFont,
                               horAnchor, verAnchor, width, 30, x, y );
            widgetIndex++;
        }
 public UpdatesView( LauncherWindow game )
     : base(game)
 {
     widgets = new LauncherWidget[13];
 }
Exemple #7
0
 public MainView( LauncherWindow game )
     : base(game)
 {
     widgets = new LauncherWidget[16];
 }
 public ColoursView( LauncherWindow game )
     : base(game)
 {
     widgets = new LauncherWidget[25];
 }
 public DirectConnectView( LauncherWindow game )
     : base(game)
 {
     widgets = new LauncherWidget[8];
 }
 public ResourcesView( LauncherWindow game )
     : base(game)
 {
     widgets = new LauncherWidget[4];
 }
        protected virtual void MouseMove( object sender, MouseMoveEventArgs e )
        {
            if( supressMove ) { supressMove = false; return; }
            mouseMoved = true;

            for( int i = 0; i < widgets.Length; i++ ) {
                LauncherWidget widget = widgets[i];
                if( widget == null ) continue;
                if( e.X >= widget.X && e.Y >= widget.Y &&
                   e.X < widget.X + widget.Width && e.Y < widget.Y + widget.Height ) {
                    if( selectedWidget == widget ) return;

                    if( selectedWidget != null )
                        UnselectWidget( selectedWidget );
                    SelectWidget( widget );
                    selectedWidget = widget;
                    return;
                }
            }

            if( selectedWidget == null ) return;
            UnselectWidget( selectedWidget );
            selectedWidget = null;
        }
        protected void MouseButtonDown( object sender, MouseButtonEventArgs e )
        {
            if( e.Button != MouseButton.Left ) return;

            if( lastClicked != null && lastClicked != selectedWidget )
                WidgetUnclicked( lastClicked );
            if( selectedWidget != null && selectedWidget.OnClick != null )
                selectedWidget.OnClick( e.X, e.Y );
            lastClicked = selectedWidget;
        }
 protected override void WidgetUnclicked( LauncherWidget widget )
 {
     LauncherInputWidget input = widget as LauncherInputWidget;
     if( input == null ) return;
     input.Active = false;
     RedrawWidget( input );
     lastInput = null;
     Dirty = true;
 }
Exemple #14
0
 protected override void UnselectWidget( LauncherWidget widget )
 {
     base.UnselectWidget( widget );
     if( signingIn || !resumeValid || widget != widgets[4] ) return;
     SetStatus( "" );
 }
 protected override void SelectWidget( LauncherWidget widget )
 {
     base.SelectWidget( widget );
     if( widget is LauncherInputWidget ) {
         widgetOpenTime = DateTime.UtcNow;
         lastCaretFlash = false;
     }
 }
        protected void HandleTab()
        {
            if( tabDown ) return;
            tabDown = true;
            int index = lastClicked == null ? -1 :
                Array.IndexOf<LauncherWidget>( widgets, lastClicked );
            int dir = (game.Window.Keyboard[Key.ShiftLeft]
                       || game.Window.Keyboard[Key.ShiftRight]) ? -1 : 1;
            index += dir;
            Utils.Clamp( ref index, 0, widgets.Length - 1);

            for( int j = 0; j < widgets.Length * 2; j++ ) {
                int i = (j * dir + index) % widgets.Length;
                if( i < 0 ) i += widgets.Length;

                if( widgets[i] is LauncherInputWidget || widgets[i] is LauncherButtonWidget ) {
                    LauncherWidget widget = widgets[i];
                    moveArgs.X = widget.X + widget.Width / 2;
                    moveArgs.Y = widget.Y + widget.Height / 2;

                    pressArgs.Button = MouseButton.Left;
                    pressArgs.IsPressed = true;
                    pressArgs.X = moveArgs.X;
                    pressArgs.Y = moveArgs.Y;

                    MouseMove( null, moveArgs );
                    Point p = game.Window.PointToScreen( Point.Empty );
                    p.Offset( moveArgs.X, moveArgs.Y );
                    game.Window.DesktopCursorPos = p;
                    lastClicked = widget;

                    if( widgets[i] is LauncherInputWidget ) {
                        MouseButtonDown( null, pressArgs );
                        ((LauncherInputWidget)widgets[i]).CaretPos = -1;
                    }
                    break;
                }
            }
        }
 protected virtual void WidgetUnclicked( LauncherWidget widget )
 {
 }
 /// <summary> Called when the user has moved their mouse away from a previously selected widget. </summary>
 protected virtual void UnselectWidget( LauncherWidget widget )
 {
     LauncherButtonWidget button = widget as LauncherButtonWidget;
     if( button != null ) {
         button.Active = false;
         button.RedrawBackground();
         RedrawWidget( button );
     }
 }
 protected void RedrawWidget( LauncherWidget widget )
 {
     using( drawer ) {
         drawer.SetBitmap( game.Framebuffer );
         widget.Redraw( drawer );
     }
     Dirty = true;
 }
Exemple #20
0
 public ServersView( LauncherWindow game )
     : base(game)
 {
     widgets = new LauncherWidget[7];
 }
 public ChooseModeView( LauncherWindow game )
     : base(game)
 {
     widgets = new LauncherWidget[14];
 }