Пример #1
0
        public void RunTick()
        {
            // Mouse Handling
            this.MouseOver = this.GetMouseOverState();
            if (this.MouseOver == UIMouseOverState.On)
            {
                UIComponent.ComponentWithFocus = this;

                // Mouse Clicked
                if (Cursor.LeftMouseState == Cursor.MouseDownState.Clicked)
                {
                    UIComponent.ComponentSelected = this;
                }
            }

            // If the Mouse just exited this component:
            //else if(this.MouseOver == UIMouseOverState.Exited) {}

            // Key Handling
            if (UIComponent.ComponentSelected == this)
            {
                InputClient input = Systems.input;

                // Get Characters Pressed (doesn't assist with order)
                string charsPressed = input.GetCharactersPressed();

                UICreoInput comp = (UICreoInput)UIComponent.ComponentSelected;

                if (charsPressed.Length > 0)
                {
                    comp.SetInputText(comp.text + charsPressed);
                }

                // Backspace (+Shift, +Control)
                if (input.LocalKeyDown(Keys.Back) && this.lastBack < Systems.timer.UniFrame)
                {
                    if (input.LocalKeyPressed(Keys.Back))
                    {
                        this.lastBack = Systems.timer.UniFrame + 10;
                    }
                    else
                    {
                        this.lastBack = Systems.timer.UniFrame + 4;
                    }

                    if (input.LocalKeyDown(Keys.LeftShift) || input.LocalKeyDown(Keys.RightShift) || input.LocalKeyDown(Keys.LeftControl) || input.LocalKeyDown(Keys.RightControl))
                    {
                        comp.SetInputText("");
                    }
                    else if (comp.text.Length > 0)
                    {
                        comp.SetInputText(comp.text.Substring(0, comp.text.Length - 1));
                    }
                }
            }
        }
Пример #2
0
        public LoadWorldMenu(short width, short height) : base()
        {
            short centerX = (short)(Systems.screen.viewHalfWidth - (short)(width * 0.5));
            short centerY = (short)(Systems.screen.viewHalfHeight - (short)(height * 0.5));

            this.textBox      = new TextBox(null, centerX, centerY, width, height);
            this.worldIdInput = new UICreoInput(this.textBox, 20, 50, 22);
            this.loadButton   = new UICreoButton(this.textBox, "Load World", 20, 102, null);

            UIComponent.ComponentSelected = this.worldIdInput;
        }
Пример #3
0
        public LoginMenu(short width, short height) : base()
        {
            short centerX = (short)(Systems.screen.viewHalfWidth - (short)(width * 0.5));
            short centerY = (short)(Systems.screen.viewHalfHeight - (short)(height * 0.5));

            this.textBox        = new TextBox(null, centerX, centerY, width, height);
            this.loginInput     = new UICreoInput(this.textBox, 20, 50, 22);
            this.emailInput     = new UICreoInput(this.textBox, 20, 134);
            this.passInput      = new UICreoInput(this.textBox, 20, 218, 45, true);
            this.loginButton    = new UICreoButton(this.textBox, "Login", 20, 302, null);
            this.registerButton = new UICreoButton(this.textBox, "Register", 152, 302, null);
        }