public static void UnloadAndExitToMenu() { MyScreenManager.CloseAllScreensNowExcept(null); MyGuiSandbox.Update(VRage.Game.MyEngineConstants.UPDATE_STEP_SIZE_IN_MILLISECONDS); if (MySession.Static != null) { MySession.Static.Unload(); MySession.Static = null; } if (MyMusicController.Static != null) { MyMusicController.Static.Unload(); MyMusicController.Static = null; MyAudio.Static.MusicAllowed = true; } if (MyMultiplayer.Static != null) { MyMultiplayer.Static.Dispose(); } // This will quit actual game-play screen and move us to fly-through with main menu on top MyGuiSandbox.BackToMainMenu(); }
private void DoUnloadSession() { if (!Sandbox.Engine.Platform.Game.IsDedicated) { MyScreenManager.CloseAllScreensExcept(null); MyGuiSandbox.Update(16); } if (MySession.Static != null) { MySession.Static.Unload(); MySession.Static = null; } { var musicCtl = _getMusicControllerStatic(); if (musicCtl != null) { _musicControllerUnload(musicCtl); _setMusicControllerStatic(null); MyAudio.Static.MusicAllowed = true; } } if (MyMultiplayer.Static != null) { MyMultiplayer.Static.Dispose(); } if (!Sandbox.Engine.Platform.Game.IsDedicated) { MyGuiSandbox.AddScreen(MyGuiSandbox.CreateScreen(MyPerGameSettings.GUI.MainMenu)); } }
public static void LoadMultiplayerScenarioWorld(MyObjectBuilder_World world, MyMultiplayerBase multiplayerSession) { Debug.Assert(MySession.Static != null); MyLog.Default.WriteLine("LoadMultiplayerScenarioWorld() - Start"); if (world.Checkpoint.BriefingVideo != null && world.Checkpoint.BriefingVideo.Length > 0) { MyGuiSandbox.OpenUrlWithFallback(world.Checkpoint.BriefingVideo, "Scenario briefing video", true); } if (!MySteamWorkshop.CheckLocalModsAllowed(world.Checkpoint.Mods, false)) { MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox( messageCaption : MyTexts.Get(MyCommonTexts.MessageBoxCaptionError), messageText : MyTexts.Get(MyCommonTexts.DialogTextLocalModsDisabledInMultiplayer), buttonType : MyMessageBoxButtonsType.OK, callback : delegate(MyGuiScreenMessageBox.ResultEnum result) { MySessionLoader.UnloadAndExitToMenu(); })); MyLog.Default.WriteLine("LoadMultiplayerScenarioWorld() - End"); return; } MySteamWorkshop.DownloadModsAsync(world.Checkpoint.Mods, onFinishedCallback : delegate(bool success, string mismatchMods) { if (success) { CheckMismatchmods(mismatchMods, callback : delegate(ResultEnum val) { MyScreenManager.CloseAllScreensNowExcept(null); MyGuiSandbox.Update(MyEngineConstants.UPDATE_STEP_SIZE_IN_MILLISECONDS); StartLoading(delegate { MySession.Static.LoadMultiplayerWorld(world, multiplayerSession); if (ScenarioWorldLoaded != null) { ScenarioWorldLoaded(); } }); }); } else { MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox( messageCaption : MyTexts.Get(MyCommonTexts.MessageBoxCaptionError), messageText : MyTexts.Get(MyCommonTexts.DialogTextDownloadModsFailed), buttonType : MyMessageBoxButtonsType.OK, callback : delegate(MyGuiScreenMessageBox.ResultEnum result) { MySessionLoader.UnloadAndExitToMenu(); })); } MyLog.Default.WriteLine("LoadMultiplayerScenarioWorld() - End"); }, onCancelledCallback : delegate() { MySessionLoader.UnloadAndExitToMenu(); }); }
public static void LoadMultiplayerBattleWorld(MyObjectBuilder_World world, MyMultiplayerBase multiplayerSession) { MyLog.Default.WriteLine("LoadMultiplayerBattleWorld() - Start"); if (!MySteamWorkshop.CheckLocalModsAllowed(world.Checkpoint.Mods, false)) { MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox( messageCaption : MyTexts.Get(MyCommonTexts.MessageBoxCaptionError), messageText : MyTexts.Get(MyCommonTexts.DialogTextLocalModsDisabledInMultiplayer), buttonType : MyMessageBoxButtonsType.OK, callback : delegate(MyGuiScreenMessageBox.ResultEnum result) { MyGuiScreenMainMenu.ReturnToMainMenu(); })); MyLog.Default.WriteLine("LoadMultiplayerBattleWorld() - End"); return; } MySteamWorkshop.DownloadModsAsync(world.Checkpoint.Mods, onFinishedCallback : delegate(bool success, string mismatchMods) { if (success) { MyScreenManager.CloseAllScreensNowExcept(null); MyGuiSandbox.Update(VRage.Game.MyEngineConstants.UPDATE_STEP_SIZE_IN_MILLISECONDS); CheckMismatchmods(mismatchMods, callback : delegate(VRage.Game.ModAPI.ResultEnum val) { MyGuiScreenGamePlay.StartLoading(delegate { if (MySession.Static == null) { MySession.CreateWithEmptyWorld(multiplayerSession); MySession.Static.Settings.Battle = true; } MySession.Static.LoadMultiplayerWorld(world, multiplayerSession); Debug.Assert(MySession.Static.Battle); if (BattleWorldLoaded != null) { BattleWorldLoaded(); } }); }); } else { MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox( messageCaption : MyTexts.Get(MyCommonTexts.MessageBoxCaptionError), messageText : MyTexts.Get(MyCommonTexts.DialogTextDownloadModsFailed), buttonType : MyMessageBoxButtonsType.OK, callback : delegate(MyGuiScreenMessageBox.ResultEnum result) { MyGuiScreenMainMenu.ReturnToMainMenu(); })); } MyLog.Default.WriteLine("LoadMultiplayerBattleWorld() - End"); }, onCancelledCallback : delegate() { MyGuiScreenMainMenu.UnloadAndExitToMenu(); }); }
private static void LoadMission(CheckpointData data) { var checkpoint = data.Checkpoint; MySteamWorkshop.DownloadModsAsync(checkpoint.Mods, delegate(bool success, string mismatchMods) { if (success || (checkpoint.Settings.OnlineMode == MyOnlineModeEnum.OFFLINE) && MySteamWorkshop.CanRunOffline(checkpoint.Mods)) { //Sandbox.Audio.MyAudio.Static.Mute = true; MyScreenManager.CloseAllScreensNowExcept(null); MyGuiSandbox.Update(VRage.Game.MyEngineConstants.UPDATE_STEP_SIZE_IN_MILLISECONDS); MyGuiScreenLoadSandbox.CheckMismatchmods(mismatchMods, callback : delegate(VRage.Game.ModAPI.ResultEnum val) { // May be called from gameplay, so we must make sure we unload the current game if (MySession.Static != null) { MySession.Static.Unload(); MySession.Static = null; } //seed 0 has special meaning - please randomize at mission start. New seed will be saved and game will run with it ever since. // if you use this, YOU CANNOT HAVE ANY PROCEDURAL ASTEROIDS ALREADY SAVED if (checkpoint.Settings.ProceduralSeed == 0) { checkpoint.Settings.ProceduralSeed = MyRandom.Instance.Next(); } MyGuiScreenGamePlay.StartLoading(delegate { checkpoint.Settings.Scenario = true; MySession.LoadMission(data.SessionPath, checkpoint, data.CheckpointSize, data.PersistentEditMode); }); }); } else { MyLog.Default.WriteLine(MyTexts.Get(MyCommonTexts.DialogTextDownloadModsFailed).ToString()); MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox( messageCaption : MyTexts.Get(MyCommonTexts.MessageBoxCaptionError), messageText : MyTexts.Get(MyCommonTexts.DialogTextDownloadModsFailed), buttonType : MyMessageBoxButtonsType.OK, callback : delegate(MyGuiScreenMessageBox.ResultEnum result) { if (MyFakes.QUICK_LAUNCH != null) { MyGuiScreenMainMenu.ReturnToMainMenu(); } })); } MyLog.Default.WriteLine("LoadSession() - End"); }); }
private static bool LoadMultiplayerSession(MyObjectBuilder_World world, MyMultiplayerBase multiplayerSession) { MyLog.Default.WriteLine("LoadSession() - Start"); if (!MyWorkshop.CheckLocalModsAllowed(world.Checkpoint.Mods, allowLocalMods: false)) { MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(MyMessageBoxStyleEnum.Error, MyMessageBoxButtonsType.OK, messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionError), messageText: MyTexts.Get(MyCommonTexts.DialogTextLocalModsDisabledInMultiplayer))); MyLog.Default.WriteLine("LoadSession() - End"); return(false); } MyWorkshop.DownloadModsAsync(world.Checkpoint.Mods, delegate(bool success) { if (success) { MyScreenManager.CloseAllScreensNowExcept(null); MyGuiSandbox.Update(16); if (MySession.Static != null) { MySession.Static.Unload(); MySession.Static = null; } string CustomBackgroundImage = null; GetCustomLoadingScreenPath(world.Checkpoint.Mods, out CustomBackgroundImage); MySessionLoader.StartLoading(delegate { LoadMultiplayer.Invoke(null, new object[] { world, multiplayerSession }); //MySession.LoadMultiplayer(world, multiplayerSession); }, null, CustomBackgroundImage, null); } else { multiplayerSession.Dispose(); MySessionLoader.UnloadAndExitToMenu(); if (MyGameService.IsOnline) { MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(MyMessageBoxStyleEnum.Error, MyMessageBoxButtonsType.OK, messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionError), messageText: MyTexts.Get(MyCommonTexts.DialogTextDownloadModsFailed))); } else { MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(MyMessageBoxStyleEnum.Error, MyMessageBoxButtonsType.OK, messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionError), messageText: new StringBuilder(string.Format(MyTexts.GetString(MyCommonTexts.DialogTextDownloadModsFailedSteamOffline), MySession.GameServiceName)))); } } MyLog.Default.WriteLine("LoadSession() - End"); }, delegate { multiplayerSession.Dispose(); MySessionLoader.UnloadAndExitToMenu(); }); return(false); }
public static void LoadMultiplayerSession(MyObjectBuilder_World world, MyMultiplayerBase multiplayerSession) { MyLog.Default.WriteLine("LoadSession() - Start"); if (!MySteamWorkshop.CheckLocalModsAllowed(world.Checkpoint.Mods, false)) { MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox( messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionError), messageText: MyTexts.Get(MyCommonTexts.DialogTextLocalModsDisabledInMultiplayer), buttonType: MyMessageBoxButtonsType.OK)); MyLog.Default.WriteLine("LoadSession() - End"); return; } MySteamWorkshop.DownloadModsAsync(world.Checkpoint.Mods, onFinishedCallback : delegate(bool success) { if (success) { //Sandbox.Audio.MyAudio.Static.Mute = true; MyScreenManager.CloseAllScreensNowExcept(null); MyGuiSandbox.Update(VRage.Game.MyEngineConstants.UPDATE_STEP_SIZE_IN_MILLISECONDS); // May be called from gameplay, so we must make sure we unload the current game if (MySession.Static != null) { MySession.Static.Unload(); MySession.Static = null; } MyGuiScreenGamePlay.StartLoading(delegate { MySession.LoadMultiplayer(world, multiplayerSession); }); } else { if (MyMultiplayer.Static != null) { MyMultiplayer.Static.Dispose(); } MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox( messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionError), messageText: MyTexts.Get(MyCommonTexts.DialogTextDownloadModsFailed), buttonType: MyMessageBoxButtonsType.OK)); } MyLog.Default.WriteLine("LoadSession() - End"); }, onCancelledCallback : delegate() { multiplayerSession.Dispose(); }); }
public static void UnloadAndExitToMenu() { MyScreenManager.CloseAllScreensNowExcept(null); MyGuiSandbox.Update(MyEngineConstants.UPDATE_STEP_SIZE_IN_MILLISECONDS); if (MySession.Static != null) { MySession.Static.Unload(); MySession.Static = null; } // This will quit actual game-play screen and move us to fly-through with main menu on top MyGuiSandbox.BackToMainMenu(); }
public static void LoadSingleplayerSession(MyObjectBuilder_Checkpoint checkpoint, string sessionPath, ulong checkpointSizeInBytes) { if (!MySession.IsCompatibleVersion(checkpoint)) { MyLog.Default.WriteLine(MyTexts.Get(MyCommonTexts.DialogTextIncompatibleWorldVersion).ToString()); MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox( messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionError), messageText: MyTexts.Get(MyCommonTexts.DialogTextIncompatibleWorldVersion), buttonType: MyMessageBoxButtonsType.OK)); MyLog.Default.WriteLine("LoadSession() - End"); return; } if (!MySteamWorkshop.CheckLocalModsAllowed(checkpoint.Mods, checkpoint.Settings.OnlineMode == MyOnlineModeEnum.OFFLINE)) { MyLog.Default.WriteLine(MyTexts.Get(MyCommonTexts.DialogTextLocalModsDisabledInMultiplayer).ToString()); MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox( messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionError), messageText: MyTexts.Get(MyCommonTexts.DialogTextLocalModsDisabledInMultiplayer), buttonType: MyMessageBoxButtonsType.OK)); MyLog.Default.WriteLine("LoadSession() - End"); return; } MySteamWorkshop.DownloadModsAsync(checkpoint.Mods, delegate(bool success) { if (success || (checkpoint.Settings.OnlineMode == MyOnlineModeEnum.OFFLINE) && MySteamWorkshop.CanRunOffline(checkpoint.Mods)) { //Sandbox.Audio.MyAudio.Static.Mute = true; MyScreenManager.CloseAllScreensNowExcept(null); MyGuiSandbox.Update(VRage.Game.MyEngineConstants.UPDATE_STEP_SIZE_IN_MILLISECONDS); // May be called from gameplay, so we must make sure we unload the current game if (MySession.Static != null) { MySession.Static.Unload(); MySession.Static = null; } MyGuiScreenGamePlay.StartLoading(delegate { MyAnalyticsHelper.SetEntry(MyGameEntryEnum.Load); MySession.Load(sessionPath, checkpoint, checkpointSizeInBytes); }); } else { MyLog.Default.WriteLine(MyTexts.Get(MyCommonTexts.DialogTextDownloadModsFailed).ToString()); if (MySteam.IsOnline) { MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox( messageCaption : MyTexts.Get(MyCommonTexts.MessageBoxCaptionError), messageText : MyTexts.Get(MyCommonTexts.DialogTextDownloadModsFailed), buttonType : MyMessageBoxButtonsType.OK, callback : delegate(MyGuiScreenMessageBox.ResultEnum result) { if (MyFakes.QUICK_LAUNCH != null) { MyGuiScreenMainMenu.ReturnToMainMenu(); } })); } else { MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox( messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionError), messageText: MyTexts.Get(MyCommonTexts.DialogTextDownloadModsFailedSteamOffline), buttonType: MyMessageBoxButtonsType.OK)); } } MyLog.Default.WriteLine("LoadSession() - End"); }); }
public static void LoadMultiplayerSession(MyObjectBuilder_World world, MyMultiplayerBase multiplayerSession) { MyLog.Default.WriteLine("LoadSession() - Start"); if (!MySteamWorkshop.CheckLocalModsAllowed(world.Checkpoint.Mods, false)) { MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox( messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionError), messageText: MyTexts.Get(MyCommonTexts.DialogTextLocalModsDisabledInMultiplayer), buttonType: MyMessageBoxButtonsType.OK)); MyLog.Default.WriteLine("LoadSession() - End"); return; } var customLoadingScreenPath = GetCustomLoadingScreenImagePath(world.Checkpoint.CustomLoadingScreenImage); MySteamWorkshop.DownloadModsAsync(world.Checkpoint.Mods, onFinishedCallback : delegate(bool success, string mismatchMods) { if (success) { CheckMismatchmods(mismatchMods, delegate(ResultEnum val) { if (val == ResultEnum.OK) { //Sandbox.Audio.MyAudio.Static.Mute = true; MyScreenManager.CloseAllScreensNowExcept(null); MyGuiSandbox.Update(MyEngineConstants.UPDATE_STEP_SIZE_IN_MILLISECONDS); // May be called from gameplay, so we must make sure we unload the current game if (MySession.Static != null) { MySession.Static.Unload(); MySession.Static = null; } StartLoading(delegate { MySession.LoadMultiplayer(world, multiplayerSession); }, customLoadingScreenPath, world.Checkpoint.CustomLoadingScreenText); } else { MySessionLoader.UnloadAndExitToMenu(); } }); } else { if (MyMultiplayer.Static != null) { MyMultiplayer.Static.Dispose(); } if (MySteam.IsOnline) { MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox( messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionError), messageText: MyTexts.Get(MyCommonTexts.DialogTextDownloadModsFailed), buttonType: MyMessageBoxButtonsType.OK)); } else { MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox( messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionError), messageText: MyTexts.Get(MyCommonTexts.DialogTextDownloadModsFailedSteamOffline), buttonType: MyMessageBoxButtonsType.OK)); } } MyLog.Default.WriteLine("LoadSession() - End"); }, onCancelledCallback : delegate() { multiplayerSession.Dispose(); }); }
public void LoadMission(string sessionPath, string name, string description, bool multiplayer) { MyLog.Default.WriteLine("LoadSession() - Start"); MyLog.Default.WriteLine(sessionPath); ulong checkpointSizeInBytes; var checkpoint = MyLocalCache.LoadCheckpoint(sessionPath, out checkpointSizeInBytes); checkpoint.Settings.OnlineMode = (MyOnlineModeEnum)m_onlineMode.GetSelectedKey(); checkpoint.Settings.MaxPlayers = (short)m_maxPlayersSlider.Value; checkpoint.Settings.Scenario = true; checkpoint.Settings.GameMode = MyGameModeEnum.Survival; checkpoint.Settings.ScenarioEditMode = false; if (!MySession.IsCompatibleVersion(checkpoint)) { MyLog.Default.WriteLine(MyTexts.Get(MySpaceTexts.DialogTextIncompatibleWorldVersion).ToString()); MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox( messageCaption: MyTexts.Get(MySpaceTexts.MessageBoxCaptionError), messageText: MyTexts.Get(MySpaceTexts.DialogTextIncompatibleWorldVersion), buttonType: MyMessageBoxButtonsType.OK)); MyLog.Default.WriteLine("LoadSession() - End"); return; } if (!MySteamWorkshop.CheckLocalModsAllowed(checkpoint.Mods, checkpoint.Settings.OnlineMode == MyOnlineModeEnum.OFFLINE)) { MyLog.Default.WriteLine(MyTexts.Get(MySpaceTexts.DialogTextLocalModsDisabledInMultiplayer).ToString()); MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox( messageCaption: MyTexts.Get(MySpaceTexts.MessageBoxCaptionError), messageText: MyTexts.Get(MySpaceTexts.DialogTextLocalModsDisabledInMultiplayer), buttonType: MyMessageBoxButtonsType.OK)); MyLog.Default.WriteLine("LoadSession() - End"); return; } MySteamWorkshop.DownloadModsAsync(checkpoint.Mods, delegate(bool success) { if (success || (checkpoint.Settings.OnlineMode == MyOnlineModeEnum.OFFLINE) && MySteamWorkshop.CanRunOffline(checkpoint.Mods)) { //Sandbox.Audio.MyAudio.Static.Mute = true; MyScreenManager.CloseAllScreensNowExcept(null); MyGuiSandbox.Update(MyEngineConstants.UPDATE_STEP_SIZE_IN_MILLISECONDS); // May be called from gameplay, so we must make sure we unload the current game if (MySession.Static != null) { MySession.Static.Unload(); MySession.Static = null; } //seed 0 has special meaning - please randomize at mission start. New seed will be saved and game will run with it ever since. // if you use this, YOU CANNOT HAVE ANY PROCEDURAL ASTEROIDS ALREADY SAVED if (checkpoint.Settings.ProceduralSeed == 0) { checkpoint.Settings.ProceduralSeed = MyRandom.Instance.Next(); } MyGuiScreenGamePlay.StartLoading(delegate { checkpoint.Settings.Scenario = true; MySession.LoadMission(sessionPath, checkpoint, checkpointSizeInBytes, name, description); }); } else { MyLog.Default.WriteLine(MyTexts.Get(MySpaceTexts.DialogTextDownloadModsFailed).ToString()); MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox( messageCaption : MyTexts.Get(MySpaceTexts.MessageBoxCaptionError), messageText : MyTexts.Get(MySpaceTexts.DialogTextDownloadModsFailed), buttonType : MyMessageBoxButtonsType.OK, callback : delegate(MyGuiScreenMessageBox.ResultEnum result) { if (MyFakes.QUICK_LAUNCH != null) { MyGuiScreenMainMenu.ReturnToMainMenu(); } })); } MyLog.Default.WriteLine("LoadSession() - End"); }); }