Exemplo n.º 1
0
        public override void HandleInput(bool receivedFocusInThisUpdate)
        {
            bool handled = false;

            if (FocusedControl == m_commandLine && MyInput.Static.IsKeyPress(MyKeys.Up) && !m_autoComplete.Visible)
            {
                if (IsEnoughDelay(MyConsoleKeys.UP, MyGuiConstants.TEXTBOX_MOVEMENT_DELAY) && !m_autoComplete.Visible)
                {
                    UpdateLastKeyPressTimes(MyConsoleKeys.UP);
                    if (MyConsole.GetLine() == "")
                    {
                        BufferText = m_commandLine.Text;
                    }
                    MyConsole.PreviousLine();
                    if (MyConsole.GetLine() == "")
                    {
                        m_commandLine.Text = BufferText;
                    }
                    else
                    {
                        m_commandLine.Text = MyConsole.GetLine();
                    }
                    m_commandLine.MoveCarriageToEnd();
                }

                //Else the GUI will change focus
                handled = true;
            }

            if (FocusedControl == m_commandLine && MyInput.Static.IsKeyPress(MyKeys.Down) && !m_autoComplete.Visible)
            {
                if (IsEnoughDelay(MyConsoleKeys.DOWN, MyGuiConstants.TEXTBOX_MOVEMENT_DELAY) && !m_autoComplete.Visible)
                {
                    UpdateLastKeyPressTimes(MyConsoleKeys.DOWN);

                    if (MyConsole.GetLine() == "")
                    {
                        BufferText = m_commandLine.Text;
                    }

                    MyConsole.NextLine();
                    if (MyConsole.GetLine() == "")
                    {
                        m_commandLine.Text = BufferText;
                    }
                    else
                    {
                        m_commandLine.Text = MyConsole.GetLine();
                    }
                    m_commandLine.MoveCarriageToEnd();
                }
                handled = true;
            }

            if (FocusedControl == m_commandLine && MyInput.Static.IsKeyPress(MyKeys.Enter) && !m_commandLine.Text.Equals("") && !m_autoComplete.Visible)
            {
                if (IsEnoughDelay(MyConsoleKeys.ENTER, MyGuiConstants.TEXTBOX_MOVEMENT_DELAY))
                {
                    UpdateLastKeyPressTimes(MyConsoleKeys.ENTER);
                    if (!m_autoComplete.Visible)
                    {
                        BufferText = "";
                        MyConsole.ParseCommand(m_commandLine.Text);
                        MyConsole.NextLine();
                        m_displayScreen.Text            = MyConsole.DisplayScreen;
                        m_displayScreen.ScrollbarOffset = 1;
                        m_commandLine.Text = "";
                        handled            = true;
                    }
                }
            }
            if (!handled)
            {
                base.HandleInput(receivedFocusInThisUpdate);
            }
        }