Ejemplo n.º 1
0
        private void AddControls()
        {
            Controls.Clear();

            AddCaption(MyTextsWrapperEnum.PlayStory, new Vector2(0, 0.005f));

            Vector2 menuPositionOrigin = new Vector2(0.0f, -m_size.Value.Y / 2.0f + 0.147f);
            Vector2 buttonDelta        = new Vector2(0.15f, 0);
            const MyGuiControlButtonTextAlignment menuButtonTextAlignement = MyGuiControlButtonTextAlignment.CENTERED;

            MyTextsWrapperEnum?otherButtonsForbidden = null;
            MyTextsWrapperEnum?newGameForbidden      = null;
            //MyTextsWrapperEnum newGameText = MyTextsWrapperEnum.StartDemo;
            int buttonPositionCounter = 0;

            if (MyClientServer.LoggedPlayer != null)
            {
                if ((MyClientServer.LoggedPlayer.GetCanAccessDemo() == false) && (MyClientServer.LoggedPlayer.GetCanSave() == false))
                {
                    //Uncomment when other buttons functionality implemented
                    newGameForbidden = MyTextsWrapperEnum.NotAvailableInDemoMode;
                    //otherButtonsForbidden = newGameForbidden = MyTextsWrapperEnum.NotAccessRightsToTestBuild;
                }
                else if (MyClientServer.LoggedPlayer.IsDemoUser())
                {
                    //Uncomment when other buttons functionality implemented
                    newGameForbidden      = null;
                    otherButtonsForbidden = MyTextsWrapperEnum.NotAvailableInDemoMode;
                }
                else if (MyClientServer.LoggedPlayer.GetCanSave() == true)
                {
                    //newGameText = MyTextsWrapperEnum.NewGame;
                    newGameForbidden = null;
                }

                ParallelTasks.Parallel.Start(CheckCheckpointAndChapter);
            }

            //  New Game / Start Demo
            var newGameButton = new MyGuiControlButton(this, menuPositionOrigin + buttonPositionCounter++ *MyGuiConstants.MENU_BUTTONS_POSITION_DELTA,
                                                       MyGuiConstants.MAIN_MENU_BUTTON_SIZE, MyGuiConstants.BUTTON_BACKGROUND_COLOR,
                                                       MyTextsWrapperEnum.NewGame, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE,
                                                       OnNewGameClick, menuButtonTextAlignement, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true, newGameForbidden);

            //  Continue last game
            m_continueLastGame = new MyGuiControlButton(this, menuPositionOrigin + buttonPositionCounter++ *MyGuiConstants.MENU_BUTTONS_POSITION_DELTA,
                                                        MyGuiConstants.MAIN_MENU_BUTTON_SIZE, MyGuiConstants.BUTTON_BACKGROUND_COLOR,
                                                        MyTextsWrapperEnum.ContinueLastGame, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE,
                                                        OnLoadLastCheckpointClick, menuButtonTextAlignement, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER,
                                                        MyFakes.LOAD_LAST_CHECKPOINT_ENABLED, otherButtonsForbidden);
            m_continueLastGame.DrawRedTextureWhenDisabled = false;

            // Show load checkpoint first (it's unknown whether checkpoint exists
            var tmp = newGameButton.GetPosition();

            newGameButton.SetPosition(m_continueLastGame.GetPosition());
            m_continueLastGame.SetPosition(tmp);

            Controls.Add(m_continueLastGame);
            Controls.Add(newGameButton);

            m_continueLastGame.Enabled = false;

            //  Load Chapter
            m_loadChapter = new MyGuiControlButton(this, menuPositionOrigin + buttonPositionCounter++ *MyGuiConstants.MENU_BUTTONS_POSITION_DELTA,
                                                   MyGuiConstants.MAIN_MENU_BUTTON_SIZE, MyGuiConstants.BUTTON_BACKGROUND_COLOR,
                                                   MyTextsWrapperEnum.LoadChapter, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE,
                                                   OnLoadChapterClick, menuButtonTextAlignement, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER,
                                                   //MyClientServer.LoggedPlayer != null && MyClientServer.LoggedPlayer.GetCanAccessEditorForStory()
                                                   true
                                                   /* && !otherButtonsForbidden.HasValue*/, otherButtonsForbidden);
            m_loadChapter.DrawRedTextureWhenDisabled = false;
            Controls.Add(m_loadChapter);

            m_loadChapter.Enabled = false;

            //  Load Checkpoint
            //var loadCheckpoint = new MyGuiControlButton(this, menuPositionOrigin + buttonPositionCounter++ * MyGuiConstants.MENU_BUTTONS_POSITION_DELTA,
            //    MyGuiConstants.MAIN_MENU_BUTTON_SIZE, MyGuiConstants.BUTTON_BACKGROUND_COLOR,
            //    MyTextsWrapperEnum.LoadCheckpoint, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE,
            //    OnLoadCheckpointClick, menuButtonTextAlignement, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER,
            //    MyClientServer.LoggedPlayer != null && MyClientServer.LoggedPlayer.GetCanAccessEditorForStory()/* && !otherButtonsForbidden.HasValue*/, otherButtonsForbidden);
            //loadCheckpoint.DrawRedTextureWhenDisabled = false;
            //Controls.Add(loadCheckpoint);

            //  Join friend’s game - Coop mode
            var join = new MyGuiControlButton(this, menuPositionOrigin + buttonPositionCounter++ *MyGuiConstants.MENU_BUTTONS_POSITION_DELTA,
                                              MyGuiConstants.MAIN_MENU_BUTTON_SIZE, MyGuiConstants.BUTTON_BACKGROUND_COLOR,
                                              MyTextsWrapperEnum.JoinFriendGame, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE,
                                              OnJoinFriendGameClick, menuButtonTextAlignement, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER,
                                              true, otherButtonsForbidden);

            join.DrawRedTextureWhenDisabled = false;
            Controls.Add(join);

            var backButton = new MyGuiControlButton(this, new Vector2(0, 0.178f), MyGuiConstants.MESSAGE_BOX_BUTTON_SIZE,
                                                    MyGuiConstants.BUTTON_BACKGROUND_COLOR,
                                                    MyGuiManager.GetConfirmButton(), null, null, MyTextsWrapperEnum.Back,
                                                    MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, menuButtonTextAlignement, OnBackClick,
                                                    true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true, true);

            Controls.Add(backButton);
        }