Esempio n. 1
0
        public override void RecreateControls(bool constructor)
        {
            base.RecreateControls(constructor);

            BuildControls();

            if (m_isNewGame)
            {
                SetDefaultValues();
            }
            else
            {
                LoadValues();
                m_nameTextbox.MoveCarriageToEnd();
                m_descriptionTextbox.MoveCarriageToEnd();
            }
        }
Esempio n. 2
0
        public override void RecreateControls(bool constructor)
        {
            base.RecreateControls(constructor);

            BuildControls();

            if (m_isNewGame)
            {
                SetDefaultValues();
                new MyGuiControlScreenSwitchPanel(this, MyTexts.Get(MyCommonTexts.WorldSettingsScreen_Description));
            }
            else
            {
                LoadValues();
                m_nameTextbox.MoveCarriageToEnd();
                m_descriptionTextbox.MoveCarriageToEnd();
            }
        }
        public MyGuiScreenSaveAs(MyWorldInfo copyFrom, string sessionPath, List <string> existingSessionNames)
            : base(new Vector2(0.5f, 0.5f), MyGuiConstants.SCREEN_BACKGROUND_COLOR, new Vector2(0.5f, 0.35f))
        {
            EnabledBackgroundFade = true;

            AddCaption(MyCommonTexts.ScreenCaptionSaveAs);

            float textboxPositionY = -0.02f;

            m_nameTextbox = new MyGuiControlTextbox(
                position: new Vector2(0, textboxPositionY),
                defaultText: copyFrom.SessionName,
                maxLength: 75);

            m_okButton = new MyGuiControlButton(
                text: MyTexts.Get(MyCommonTexts.Ok),
                onButtonClick: OnOkButtonClick,
                originAlign: MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM);
            m_cancelButton = new MyGuiControlButton(
                text: MyTexts.Get(MyCommonTexts.Cancel),
                onButtonClick: OnCancelButtonClick,
                originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM);

            Vector2 buttonOrigin = new Vector2(0f, Size.Value.Y * 0.4f);
            Vector2 buttonOffset = new Vector2(0.01f, 0f);

            m_okButton.Position     = buttonOrigin - buttonOffset;
            m_cancelButton.Position = buttonOrigin + buttonOffset;

            Controls.Add(m_nameTextbox);
            Controls.Add(m_okButton);
            Controls.Add(m_cancelButton);

            m_nameTextbox.MoveCarriageToEnd();
            m_copyFrom             = copyFrom;
            m_sessionPath          = sessionPath;
            m_existingSessionNames = existingSessionNames;

            CloseButtonEnabled = true;
            CloseButtonOffset  = new Vector2(-0.005f, 0.0035f);
            OnEnterCallback    = OnEnterPressed;
        }
Esempio n. 4
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);
            }
        }