/// <summary> /// Time in ms /// </summary> public MyGuiScreenPerformanceWarning(MyGuiScreenLoading loading) : base(new Vector2(0.5f, 0.5f), MyGuiConstants.SCREEN_BACKGROUND_COLOR, Vector2.One) { DrawMouseCursor = true; m_closeOnEsc = false; m_loading = loading; }
public static void StartLoading(Action loadingAction, string customLoadingBackground = null, string customLoadingtext = null) { MyAnalyticsHelper.LoadingStarted(); var newGameplayScreen = new MyGuiScreenGamePlay(); newGameplayScreen.OnLoadingAction += loadingAction; var loadScreen = new MyGuiScreenLoading(newGameplayScreen, MyGuiScreenGamePlay.Static, customLoadingBackground, customLoadingtext); loadScreen.OnScreenLoadingFinished += delegate { MyModAPIHelper.OnSessionLoaded(); MyGuiSandbox.AddScreen(MyGuiSandbox.CreateScreen(MyPerGameSettings.GUI.HUDScreen)); }; MyGuiSandbox.AddScreen(loadScreen); }
private void OnClickInventory(MyGuiControlButton obj) { 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))); } }
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))); } });