void TextChanged(LauncherInputWidget widget)
        {
            bool changed = false;
            int  index   = Array.IndexOf <LauncherWidget>(widgets, widget);

            if (index < 3)
            {
                changed |= Parse(0, ref LauncherSkin.BackgroundCol);
            }
            else if (index < 6)
            {
                changed |= Parse(3, ref LauncherSkin.ButtonBorderCol);
            }
            else if (index < 9)
            {
                changed |= Parse(6, ref LauncherSkin.ButtonHighlightCol);
            }
            else if (index < 12)
            {
                changed |= Parse(9, ref LauncherSkin.ButtonForeCol);
            }
            else if (index < 15)
            {
                changed |= Parse(12, ref LauncherSkin.ButtonForeActiveCol);
            }

            if (changed)
            {
                game.MakeBackground();
                Resize();
            }
        }
        void Draw()
        {
            widgetIndex = 0;
            MakeAllRGBTriplets(false);
            MakeLabelAt("Background", inputFont, Anchor.Centre, Anchor.Centre, -60, -100);
            MakeLabelAt("Button border", inputFont, Anchor.Centre, Anchor.Centre, -65, -60);
            MakeLabelAt("Button highlight", inputFont, Anchor.Centre, Anchor.Centre, -75, -20);
            MakeLabelAt("Button foreground", inputFont, Anchor.Centre, Anchor.Centre, -85, 20);
            MakeLabelAt("Active button foreground", inputFont, Anchor.Centre, Anchor.Centre, -110, 60);
            MakeLabelAt("Red", titleFont, Anchor.Centre, Anchor.Centre, 30, -130);
            MakeLabelAt("Green", titleFont, Anchor.Centre, Anchor.Centre, 95, -130);
            MakeLabelAt("Blue", titleFont, Anchor.Centre, Anchor.Centre, 160, -130);

            MakeButtonAt("Default colours", 160, 35, titleFont, Anchor.Centre,
                         0, 120, (x, y) => ResetColours());
            MakeButtonAt("Back", 80, 35, titleFont, Anchor.Centre,
                         0, 170, (x, y) => game.SetScreen(new MainScreen(game)));
            for (int i = 0; i < widgets.Length; i++)
            {
                LauncherInputWidget input = widgets[i] as LauncherInputWidget;
                if (input != null)
                {
                    input.TextChanged = TextChanged;
                }
            }
        }
Exemple #3
0
        protected override void WidgetUnclicked(LauncherWidget widget)
        {
            LauncherInputWidget input = widget as LauncherInputWidget;

            if (input == null)
            {
                return;
            }
            using ( drawer ) {
                drawer.SetBitmap(game.Framebuffer);
                input.Active = false;
                input.Redraw(drawer, lastInput.Text, inputFont, inputHintFont);
            }
            lastInput = null;
            Dirty     = true;
        }
Exemple #4
0
        protected void MakeInput(string text, int width, Anchor horAnchor, Anchor verAnchor,
                                 bool password, int x, int y, int maxChars, string hint)
        {
            if (widgets[widgetIndex] != null)
            {
                LauncherInputWidget input = (LauncherInputWidget)widgets[widgetIndex];
                input.DrawAt(drawer, text, inputFont, inputHintFont, horAnchor, verAnchor, width, 30, x, y);
                widgetIndex++;
                return;
            }

            LauncherInputWidget widget = new LauncherInputWidget(game);

            widget.OnClick       = InputClick;
            widget.Password      = password;
            widget.MaxTextLength = maxChars;
            widget.HintText      = hint;

            widget.DrawAt(drawer, text, inputFont, inputHintFont, horAnchor, verAnchor, width, 30, x, y);
            widgets[widgetIndex++] = widget;
        }
Exemple #5
0
        protected virtual void InputClick(int mouseX, int mouseY)
        {
            LauncherInputWidget input = (LauncherInputWidget)selectedWidget;

            using ( drawer ) {
                drawer.SetBitmap(game.Framebuffer);
                if (lastInput != null)
                {
                    lastInput.Active = false;
                    lastInput.Redraw(drawer, lastInput.Text, inputFont, inputHintFont);
                }

                input.Active   = true;
                widgetOpenTime = DateTime.UtcNow;
                lastCaretFlash = false;
                input.SetCaretToCursor(mouseX, mouseY, drawer, inputFont);
                input.Redraw(drawer, input.Text, inputFont, inputHintFont);
            }
            lastInput = input;
            Dirty     = true;
        }
        protected virtual void InputClick( int mouseX, int mouseY )
        {
            LauncherInputWidget input = (LauncherInputWidget)selectedWidget;
            using( drawer ) {
                drawer.SetBitmap( game.Framebuffer );
                if( lastInput != null ) {
                    lastInput.Active = false;
                    lastInput.Redraw( drawer, lastInput.Text, inputFont );
                }

                input.Active = true;
                input.Redraw( drawer, input.Text, inputFont );
            }
            lastInput = input;
            Dirty = true;
        }
        protected void MakeInput( string text, int width, Anchor verAnchor, bool password,
            int x, int y, int maxChars)
        {
            if( widgets[widgetIndex] != null ) {
                LauncherInputWidget input = (LauncherInputWidget)widgets[widgetIndex];
                input.DrawAt( drawer, text, inputFont, Anchor.Centre, verAnchor, width, 30, x, y );
                widgetIndex++;
                return;
            }

            LauncherInputWidget widget = new LauncherInputWidget( game );
            widget.OnClick = InputClick;
            widget.Password = password;
            widget.MaximumTextLength = maxChars;

            widget.DrawAt( drawer, text, inputFont, Anchor.Centre, verAnchor, width, 30, x, y );
            widgets[widgetIndex++] = widget;
        }