예제 #1
0
 private void CheckContinueButtonVisibility()
 {
     if (m_continueButton != null)
     {
         MyObjectBuilder_LastSession lastSession = MyLocalCache.GetLastSession();
         bool visible = lastSession != null && (lastSession.Path == null || Directory.Exists(lastSession.Path)) && (!lastSession.IsLobby || MyGameService.LobbyDiscovery.ContinueToLobbySupported);
         m_continueButton.Visible = visible;
     }
 }
예제 #2
0
    private void CreateMainMenu(Vector2 leftButtonPositionOrigin, out Vector2 lastButtonPosition)
    {
        base.GamepadHelpTextId     = MySpaceTexts.MainMenuScreen_Help_Screen;
        base.EnabledBackgroundFade = false;
        MyGuiControlButton myGuiControlButton = null;
        int num = (MyPerGameSettings.MultiplayerEnabled ? 7 : 6);
        MyObjectBuilder_LastSession lastSession = MyLocalCache.GetLastSession();

        if (lastSession != null && (lastSession.Path == null || MyPlatformGameSettings.GAME_SAVES_TO_CLOUD || Directory.Exists(lastSession.Path)) && (!lastSession.IsLobby || MyGameService.LobbyDiscovery.ContinueToLobbySupported))
        {
            m_continueButton = MakeButton(leftButtonPositionOrigin - num-- *MyGuiConstants.MENU_BUTTONS_POSITION_DELTA - MyGuiConstants.MENU_BUTTONS_POSITION_DELTA / 2f, MyCommonTexts.ScreenMenuButtonContinueGame, OnContinueGameClicked);
            Controls.Add(m_continueButton);
            m_elementGroup.Add(m_continueButton);
            GenerateContinueTooltip(lastSession, m_continueButton, new Vector2(0.003f, -0.0025f));
            m_continueButton.FocusChanged += FocusChangedContinue;
        }
        else
        {
            num--;
        }
        myGuiControlButton = MakeButton(leftButtonPositionOrigin - num-- *MyGuiConstants.MENU_BUTTONS_POSITION_DELTA, MyCommonTexts.ScreenMenuButtonCampaign, OnClickNewGame);
        Controls.Add(myGuiControlButton);
        m_elementGroup.Add(myGuiControlButton);
        myGuiControlButton = MakeButton(leftButtonPositionOrigin - num-- *MyGuiConstants.MENU_BUTTONS_POSITION_DELTA, MyCommonTexts.ScreenMenuButtonLoadGame, OnClickLoad);
        Controls.Add(myGuiControlButton);
        m_elementGroup.Add(myGuiControlButton);
        if (MyPerGameSettings.MultiplayerEnabled)
        {
            myGuiControlButton = MakeButton(leftButtonPositionOrigin - num-- *MyGuiConstants.MENU_BUTTONS_POSITION_DELTA, MyCommonTexts.ScreenMenuButtonJoinGame, OnJoinWorld);
            Controls.Add(myGuiControlButton);
            m_elementGroup.Add(myGuiControlButton);
        }
        myGuiControlButton = MakeButton(leftButtonPositionOrigin - num-- *MyGuiConstants.MENU_BUTTONS_POSITION_DELTA, MyCommonTexts.ScreenMenuButtonOptions, OnClickOptions);
        Controls.Add(myGuiControlButton);
        m_elementGroup.Add(myGuiControlButton);
        lastButtonPosition = myGuiControlButton.Position;

        myGuiControlButton = MakeButton(leftButtonPositionOrigin - num-- *MyGuiConstants.MENU_BUTTONS_POSITION_DELTA, MyCommonTexts.ScreenMenuButtonOptions, OnClickMenuPacks);
        Controls.Add(myGuiControlButton);
        m_elementGroup.Add(myGuiControlButton);
        lastButtonPosition = myGuiControlButton.Position;

        if (MyFakes.ENABLE_MAIN_MENU_INVENTORY_SCENE)
        {
            myGuiControlButton = MakeButton(leftButtonPositionOrigin - num-- *MyGuiConstants.MENU_BUTTONS_POSITION_DELTA, MyCommonTexts.ScreenMenuButtonInventory, OnClickInventory);
            Controls.Add(myGuiControlButton);
            m_elementGroup.Add(myGuiControlButton);
            lastButtonPosition = myGuiControlButton.Position;
        }
        if (!MyPlatformGameSettings.LIMITED_MAIN_MENU)
        {
            m_exitGameButton = MakeButton(leftButtonPositionOrigin - num-- *MyGuiConstants.MENU_BUTTONS_POSITION_DELTA, MyCommonTexts.ScreenMenuButtonExitToWindows, OnClickExitToWindows);
            Controls.Add(m_exitGameButton);
            m_elementGroup.Add(m_exitGameButton);
            lastButtonPosition = m_exitGameButton.Position;
        }
    }
    private void CreateMainMenuControls()
    {
        MyStringId optionsScreen_Help_Menu = MySpaceTexts.OptionsScreen_Help_Menu;
        Vector2    vector = new Vector2(0.001f, (0f - m_size.Value.Y) / 2f + 0.126f);
        int        num    = 0;
        MyObjectBuilder_LastSession lastSession = MyLocalCache.GetLastSession();

        if (lastSession != null && (lastSession.Path == null || MyPlatformGameSettings.GAME_SAVES_TO_CLOUD || Directory.Exists(lastSession.Path)) && (!lastSession.IsLobby || MyGameService.LobbyDiscovery.ContinueToLobbySupported))
        {
            MyGuiControlButton myGuiControlButton = new MyGuiControlButton(vector + num++ *MyGuiConstants.MENU_BUTTONS_POSITION_DELTA, MyGuiControlButtonStyleEnum.Default, null, null, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, null, MyTexts.Get(MyCommonTexts.ScreenMenuButtonContinueGame), 0.8f, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, MyGuiControlHighlightType.WHEN_CURSOR_OVER, delegate
            {
                MyObjectBuilder_LastSession mySession = MyLocalCache.GetLastSession();
                if (mySession == null)
                {
                    return;
                }
                if (mySession.IsOnline)
                {
                    if (mySession.IsLobby)
                    {
                        MyJoinGameHelper.JoinGame(ulong.Parse(mySession.ServerIP));
                        return;
                    }
                    MyGameService.Service.RequestPermissions(Permissions.Multiplayer, attemptResolution : true, delegate(PermissionResult granted)
                    {
                        switch (granted)
                        {
                        case PermissionResult.Granted:
                            MyGameService.Service.RequestPermissions(Permissions.CrossMultiplayer, attemptResolution : true, delegate(PermissionResult crossGranted)
                            {
                                switch (crossGranted)
                                {
                                case PermissionResult.Granted:
                                    MyGameService.Service.RequestPermissions(Permissions.UGC, attemptResolution : true, delegate(PermissionResult ugcGranted)
                                    {
                                        switch (ugcGranted)
                                        {
                                        case PermissionResult.Granted:
                                            JoinServer(mySession);
                                            break;

                                        case PermissionResult.Error:
                                            MySandboxGame.Static.Invoke(delegate
                                            {
                                                MyGuiSandbox.Show(MyCommonTexts.XBoxPermission_MultiplayerError, default(MyStringId), MyMessageBoxStyleEnum.Info);
                                            }, "New Game screen");
                                            break;
                                        }
                                    });
                                    break;

                                case PermissionResult.Error:
                                    MySandboxGame.Static.Invoke(delegate
                                    {
                                        MyGuiSandbox.Show(MyCommonTexts.XBoxPermission_MultiplayerError, default(MyStringId), MyMessageBoxStyleEnum.Info);
                                    }, "New Game screen");
                                    break;
                                }
                            });
                            break;

                        case PermissionResult.Error:
                            MySandboxGame.Static.Invoke(delegate
                            {
                                MyGuiSandbox.Show(MyCommonTexts.XBoxPermission_MultiplayerError, default(MyStringId), MyMessageBoxStyleEnum.Info);
                            }, "New Game screen");
                            break;
                        }
                    });
                }
                else if (!m_parallelLoadIsRunning)
                {
                    m_parallelLoadIsRunning            = true;
                    MyGuiScreenProgress progressScreen = new MyGuiScreenProgress(MyTexts.Get(MySpaceTexts.ProgressScreen_LoadingWorld));
                    MyScreenManager.AddScreen(progressScreen);
                    Parallel.StartBackground(delegate
                    {
                        MySessionLoader.LoadLastSession();
                    }, delegate
                    {
                        progressScreen.CloseScreen();
                        m_parallelLoadIsRunning = false;
                    });
                }
            });

            myGuiControlButton.GamepadHelpTextId = optionsScreen_Help_Menu;
            Controls.Add(myGuiControlButton);
            m_elementGroup.Add(myGuiControlButton);
        }
        else
        {
            num--;
        }

        MyGuiControlButton myGuiControlButton2 = new MyGuiControlButton(vector + num++ *MyGuiConstants.MENU_BUTTONS_POSITION_DELTA, MyGuiControlButtonStyleEnum.Default, null, null, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, null, MyTexts.Get(MyCommonTexts.ScreenMenuButtonCampaign), 0.8f, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, MyGuiControlHighlightType.WHEN_CURSOR_OVER, delegate
        {
            MyGuiSandbox.AddScreen(MyGuiSandbox.CreateScreen <MyGuiScreenNewGame>(new object[3] {
                true, true, true
            }));
        });

        myGuiControlButton2.GamepadHelpTextId = optionsScreen_Help_Menu;
        Controls.Add(myGuiControlButton2);
        m_elementGroup.Add(myGuiControlButton2);



        MyGuiControlButton myGuiControlButton3 = new MyGuiControlButton(vector + num++ *MyGuiConstants.MENU_BUTTONS_POSITION_DELTA, MyGuiControlButtonStyleEnum.Default, null, null, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, null, MyTexts.Get(MyCommonTexts.ScreenMenuButtonLoadGame), 0.8f, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, MyGuiControlHighlightType.WHEN_CURSOR_OVER, delegate
        {
            MyGuiSandbox.AddScreen(new MyGuiScreenLoadSandbox());
        });

        myGuiControlButton3.GamepadHelpTextId = optionsScreen_Help_Menu;
        Controls.Add(myGuiControlButton3);
        m_elementGroup.Add(myGuiControlButton3);


        if (MyPerGameSettings.MultiplayerEnabled)
        {
            MyGuiControlButton myGuiControlButton4 = new MyGuiControlButton(vector + num++ *MyGuiConstants.MENU_BUTTONS_POSITION_DELTA, MyGuiControlButtonStyleEnum.Default, null, null, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, null, MyTexts.Get(MyCommonTexts.ScreenMenuButtonJoinGame), 0.8f, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, MyGuiControlHighlightType.WHEN_CURSOR_OVER, delegate
            {
                if (MyGameService.IsOnline)
                {
                    MyGameService.Service.RequestPermissions(Permissions.Multiplayer, attemptResolution : true, delegate(PermissionResult granted)
                    {
                        switch (granted)
                        {
                        case PermissionResult.Granted:
                            MyGameService.Service.RequestPermissions(Permissions.UGC, attemptResolution : true, delegate(PermissionResult ugcGranted)
                            {
                                switch (ugcGranted)
                                {
                                case PermissionResult.Granted:
                                    MyGameService.Service.RequestPermissions(Permissions.CrossMultiplayer, attemptResolution : true, delegate(PermissionResult crossGranted)
                                    {
                                        MyGuiScreenJoinGame myGuiScreenJoinGame = new MyGuiScreenJoinGame(crossGranted == PermissionResult.Granted);
                                        myGuiScreenJoinGame.Closed += joinGameScreen_Closed;
                                        MyGuiSandbox.AddScreen(myGuiScreenJoinGame);
                                    });
                                    break;

                                case PermissionResult.Error:
                                    MySandboxGame.Static.Invoke(delegate
                                    {
                                        MyGuiSandbox.Show(MyCommonTexts.XBoxPermission_MultiplayerError, default(MyStringId), MyMessageBoxStyleEnum.Info);
                                    }, "New Game screen");
                                    break;
                                }
                            });
                            break;

                        case PermissionResult.Error:
                            MyGuiSandbox.Show(MyCommonTexts.XBoxPermission_MultiplayerError, default(MyStringId), MyMessageBoxStyleEnum.Info);
                            break;
                        }
                    });
                }
                else
                {
                    MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(MyMessageBoxStyleEnum.Error, MyMessageBoxButtonsType.OK, messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionError), messageText: new StringBuilder().AppendFormat(MyTexts.GetString(MyGameService.IsActive ? MyCommonTexts.SteamIsOfflinePleaseRestart : MyCommonTexts.ErrorJoinSessionNoUser), MySession.GameServiceName)));
                }
            });
            myGuiControlButton4.GamepadHelpTextId = optionsScreen_Help_Menu;
            Controls.Add(myGuiControlButton4);
            m_elementGroup.Add(myGuiControlButton4);
        }

        MyGuiControlButton myGuiControlButton5 = new MyGuiControlButton(vector + num++ *MyGuiConstants.MENU_BUTTONS_POSITION_DELTA, MyGuiControlButtonStyleEnum.Default, null, null, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, null, MyTexts.Get(MyCommonTexts.ScreenMenuButtonOptions), 0.8f, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, MyGuiControlHighlightType.WHEN_CURSOR_OVER, delegate
        {
            bool flag = !MyPlatformGameSettings.LIMITED_MAIN_MENU;

            MyGuiSandbox.AddScreen(MyGuiSandbox.CreateScreen <MyOldOptionsAccessMenu>(new object[1] {
                !flag
            }));
        });

        myGuiControlButton5.GamepadHelpTextId = optionsScreen_Help_Menu;
        Controls.Add(myGuiControlButton5);
        m_elementGroup.Add(myGuiControlButton5);

        if (MyFakes.ENABLE_MAIN_MENU_INVENTORY_SCENE)
        {
            MyGuiControlButton myGuiControlButton6 = new MyGuiControlButton(vector + num++ *MyGuiConstants.MENU_BUTTONS_POSITION_DELTA, MyGuiControlButtonStyleEnum.Default, null, null, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, null, MyTexts.Get(MyCommonTexts.ScreenMenuButtonInventory), 0.8f, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, MyGuiControlHighlightType.WHEN_CURSOR_OVER, delegate
            {
                if (MyGameService.IsActive)
                {
                    if (MyGameService.Service.GetInstallStatus(out var _))
                    {
                        if (MySession.Static == null)
                        {
                            MyGuiScreenLoadInventory inventory = MyGuiSandbox.CreateScreen <MyGuiScreenLoadInventory>(Array.Empty <object>());
                            MyGuiScreenLoading screen          = new MyGuiScreenLoading(inventory, null);
                            MyGuiScreenLoadInventory myGuiScreenLoadInventory = inventory;
                            myGuiScreenLoadInventory.OnLoadingAction          = (Action)Delegate.Combine(myGuiScreenLoadInventory.OnLoadingAction, (Action) delegate
                            {
                                MySessionLoader.LoadInventoryScene();
                                MySandboxGame.IsUpdateReady = true;
                                inventory.Initialize(inGame: false, null);
                            });
                            MyGuiSandbox.AddScreen(screen);
                        }
                        else
                        {
                            MyGuiSandbox.AddScreen(MyGuiSandbox.CreateScreen <MyGuiScreenLoadInventory>(new object[2] {
                                false, null
                            }));
                        }
                    }
                    else
                    {
                        MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(MyMessageBoxStyleEnum.Error, MyMessageBoxButtonsType.OK, messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionInfo), messageText: MyTexts.Get(MyCommonTexts.InventoryScreen_InstallInProgress)));
                    }
                }
                else
                {
                    MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(MyMessageBoxStyleEnum.Error, MyMessageBoxButtonsType.OK, messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionError), messageText: MyTexts.Get(MyCommonTexts.SteamIsOfflinePleaseRestart)));
                }
            });
예제 #4
0
    private void ContinueGameInternal()
    {
        MyObjectBuilder_LastSession mySession = MyLocalCache.GetLastSession();

        if (mySession == null)
        {
            return;
        }
        if (mySession.IsOnline)
        {
            if (mySession.IsLobby)
            {
                MyJoinGameHelper.JoinGame(ulong.Parse(mySession.ServerIP));
                return;
            }
            MyGameService.Service.RequestPermissions(Permissions.Multiplayer, attemptResolution : true, delegate(PermissionResult granted)
            {
                switch (granted)
                {
                case PermissionResult.Granted:
                    MyGameService.Service.RequestPermissions(Permissions.CrossMultiplayer, attemptResolution : true, delegate(PermissionResult crossGranted)
                    {
                        switch (crossGranted)
                        {
                        case PermissionResult.Granted:
                            MyGameService.Service.RequestPermissions(Permissions.UGC, attemptResolution : true, delegate(PermissionResult ugcGranted)
                            {
                                switch (ugcGranted)
                                {
                                case PermissionResult.Granted:
                                    JoinServer(mySession);
                                    break;

                                case PermissionResult.Error:
                                    MySandboxGame.Static.Invoke(delegate
                                    {
                                        MyGuiSandbox.Show(MyCommonTexts.XBoxPermission_MultiplayerError, default(MyStringId), MyMessageBoxStyleEnum.Info);
                                    }, "New Game screen");
                                    break;
                                }
                            });
                            break;

                        case PermissionResult.Error:
                            MySandboxGame.Static.Invoke(delegate
                            {
                                MyGuiSandbox.Show(MyCommonTexts.XBoxPermission_MultiplayerError, default(MyStringId), MyMessageBoxStyleEnum.Info);
                            }, "New Game screen");
                            break;
                        }
                    });
                    break;

                case PermissionResult.Error:
                    MySandboxGame.Static.Invoke(delegate
                    {
                        MyGuiSandbox.Show(MyCommonTexts.XBoxPermission_MultiplayerError, default(MyStringId), MyMessageBoxStyleEnum.Info);
                    }, "New Game screen");
                    break;
                }
            });
        }
        else if (!m_parallelLoadIsRunning)
        {
            m_parallelLoadIsRunning = true;
            MyGuiScreenProgress progressScreen = new MyGuiScreenProgress(MyTexts.Get(MySpaceTexts.ProgressScreen_LoadingWorld));
            MyScreenManager.AddScreen(progressScreen);
            Parallel.StartBackground(delegate
            {
                MySessionLoader.LoadLastSession();
            }, delegate
            {
                progressScreen.CloseScreen();
                m_parallelLoadIsRunning = false;
            });
        }
    }