private void StartNewSandbox() { MyLog.Default.WriteLine("StartNewSandbox - Start"); GetSettingsFromControls(); // Load the checkpoint ulong checkpointSizeInBytes; var sesionPath = m_scenarioTypesGroup.SelectedButton.UserData as string; var checkpoint = MyLocalCache.LoadCheckpoint(sesionPath, out checkpointSizeInBytes); if (checkpoint == null) { return; } GetSettingsFromControls(); checkpoint.Settings = m_settings; checkpoint.SessionName = m_nameTextbox.Text; checkpoint.Password = GetPassword(); checkpoint.Description = GetDescription(); checkpoint.Mods = m_mods; SetupWorldGeneratorSettings(checkpoint); MySessionLoader.LoadSingleplayerSession( checkpoint, sesionPath, checkpointSizeInBytes, () => { MySession.Static.Save(Path.Combine(MyFileSystem.SavesPath, checkpoint.SessionName.Replace(':', '-'))); }); }
public WorldGeneratorDialog(InstanceManager instanceManager) { _instanceManager = instanceManager; InitializeComponent(); _loadLocalization(); var scenarios = MyLocalCache.GetAvailableWorldInfos(Path.Combine(MyFileSystem.ContentPath, "CustomWorlds")); foreach (var tup in scenarios) { string directory = tup.Item1; MyWorldInfo info = tup.Item2; string localizedName = MyTexts.GetString(MyStringId.GetOrCompute(info.SessionName)); var checkpoint = MyLocalCache.LoadCheckpoint(directory, out _); checkpoint.OnlineMode = MyOnlineModeEnum.PUBLIC; _checkpoints.Add(new PremadeCheckpointItem { Name = localizedName, Icon = Path.Combine(directory, "thumb.jpg"), Path = directory, Checkpoint = checkpoint }); } /* * var premadeCheckpoints = Directory.EnumerateDirectories(Path.Combine("Content", "CustomWorlds")); * foreach (var path in premadeCheckpoints) * { * var thumbPath = Path.GetFullPath(Directory.EnumerateFiles(path).First(x => x.Contains("thumb"))); * * _checkpoints.Add(new PremadeCheckpointItem * { * Path = path, * Icon = thumbPath, * Name = Path.GetFileName(path) * }); * }*/ PremadeCheckpoints.ItemsSource = _checkpoints; }
#pragma warning restore 649 private void DoLoadSession(string sessionPath) { if (!Path.IsPathRooted(sessionPath)) { sessionPath = Path.Combine(MyFileSystem.SavesPath, sessionPath); } if (!Sandbox.Engine.Platform.Game.IsDedicated) { MySessionLoader.LoadSingleplayerSession(sessionPath); return; } ulong checkpointSize; MyObjectBuilder_Checkpoint checkpoint = MyLocalCache.LoadCheckpoint(sessionPath, out checkpointSize); if (MySession.IsCompatibleVersion(checkpoint)) { if (MySteamWorkshop.DownloadWorldModsBlocking(checkpoint.Mods).Success) { // MySpaceAnalytics.Instance.SetEntry(MyGameEntryEnum.Load); MySession.Load(sessionPath, checkpoint, checkpointSize); _hostServerForSession(MySession.Static, MyMultiplayer.Static); } else { MyLog.Default.WriteLineAndConsole("Unable to download mods"); } } else { MyLog.Default.WriteLineAndConsole(MyTexts.Get(MyCommonTexts.DialogTextIncompatibleWorldVersion) .ToString()); } }
protected override void LoadSandboxInternal(Tuple <string, MyWorldInfo> save, bool MP) { base.LoadSandboxInternal(save, MP); if (save.Item1 == WORKSHOP_PATH_TAG) { var scenario = FindWorkshopScenario(save.Item2.WorkshopId.Value); MySteamWorkshop.CreateWorldInstanceAsync(scenario, MySteamWorkshop.MyWorkshopPathInfo.CreateScenarioInfo(), true, delegate(bool success, string sessionPath) { if (success) { //add briefing from workshop description ulong dummy; var checkpoint = MyLocalCache.LoadCheckpoint(sessionPath, out dummy); checkpoint.Briefing = save.Item2.Briefing; MyLocalCache.SaveCheckpoint(checkpoint, sessionPath); MyAnalyticsHelper.SetEntry(MyGameEntryEnum.Scenario); MyScenarioSystem.LoadMission(sessionPath, /*m_nameTextbox.Text, m_descriptionTextbox.Text,*/ MP, (MyOnlineModeEnum)m_onlineMode.GetSelectedKey(), (short)m_maxPlayersSlider.Value); } else { MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox( messageText: MyTexts.Get(MySpaceTexts.MessageBoxTextWorkshopDownloadFailed), messageCaption: MyTexts.Get(MySpaceTexts.ScreenCaptionWorkshop))); } }); } else { MyAnalyticsHelper.SetEntry(MyGameEntryEnum.Scenario); MyScenarioSystem.LoadMission(save.Item1, /*m_nameTextbox.Text, m_descriptionTextbox.Text,*/ MP, (MyOnlineModeEnum)m_onlineMode.GetSelectedKey(), (short)m_maxPlayersSlider.Value); } }
private void saveConfigButton_Click(object sender, EventArgs e) { SaveConfiguration(); if (!string.IsNullOrEmpty(MySandboxGame.ConfigDedicated.LoadWorld) && !MySandboxGame.ConfigDedicated.SessionSettings.Battle) { ulong sizeInBytes; var path = MySandboxGame.ConfigDedicated.LoadWorld; MyObjectBuilder_Checkpoint checkpoint = MyLocalCache.LoadCheckpoint(path, out sizeInBytes); if (!string.IsNullOrWhiteSpace(MySandboxGame.ConfigDedicated.WorldName)) { checkpoint.SessionName = MySandboxGame.ConfigDedicated.WorldName; } checkpoint.Settings = m_selectedSessionSettings; checkpoint.Mods.Clear(); foreach (ulong publishedFileId in MySandboxGame.ConfigDedicated.Mods) { checkpoint.Mods.Add(new MyObjectBuilder_Checkpoint.ModItem(publishedFileId)); } MyLocalCache.SaveCheckpoint(checkpoint, path); } }
private void gamesListBox_SelectedIndexChanged(object sender, EventArgs e) { if (gamesListBox.SelectedIndex != -1) { ulong sizeInBytes; WorldItem worldItem = (WorldItem)gamesListBox.Items[gamesListBox.SelectedIndex]; ((MyConfigDedicated <MyObjectBuilder_SessionSettings>)MySandboxGame.ConfigDedicated).LoadWorld = worldItem.SessionPath; var loadPath = worldItem.SessionPath; MyObjectBuilder_Checkpoint checkpoint = MyLocalCache.LoadCheckpoint(loadPath, out sizeInBytes); m_selectedSessionSettings = checkpoint.Settings; MySandboxGame.ConfigDedicated.Mods.Clear(); foreach (var mod in checkpoint.Mods) { if (mod.PublishedFileId != 0) { MySandboxGame.ConfigDedicated.Mods.Add(mod.PublishedFileId); } } modIdsTextBox.Text = string.Join(Environment.NewLine, MySandboxGame.ConfigDedicated.Mods.ToArray()); FillSessionSettingsItems(); } }
public void SaveConfig() { Config.Save(_configPath); //TODO: make this work try { var checkpoint = MyLocalCache.LoadCheckpoint(_viewModel.LoadWorld, out ulong size); checkpoint.SessionName = _viewModel.WorldName; checkpoint.Settings = _viewModel.SessionSettings; checkpoint.Mods.Clear(); foreach (var modId in _viewModel.Mods) { checkpoint.Mods.Add(new MyObjectBuilder_Checkpoint.ModItem(modId)); } Debug.Assert(checkpoint != null); Debug.Assert(_viewModel.LoadWorld != null); MyLocalCache.SaveCheckpoint(checkpoint, _viewModel.LoadWorld); } catch (Exception e) { var log = LogManager.GetLogger("Torch"); log.Error("Failed to overwrite sandbox config, changes will not appear on server"); log.Error(e); } }
public static void LoadSingleplayerSession(string sessionPath) { MyLog.Default.WriteLine("LoadSession() - Start"); MyLog.Default.WriteLine(sessionPath); ulong checkpointSizeInBytes; var checkpoint = MyLocalCache.LoadCheckpoint(sessionPath, out checkpointSizeInBytes); CheckDx11AndLoad(checkpoint, sessionPath, checkpointSizeInBytes); }
public static void LoadMission(string sessionPath, bool multiplayer, MyOnlineModeEnum onlineMode, short maxPlayers, MyGameModeEnum gameMode = MyGameModeEnum.Survival) { MyLog.Default.WriteLine("LoadSession() - Start"); MyLog.Default.WriteLine(sessionPath); ulong checkpointSizeInBytes; var checkpoint = MyLocalCache.LoadCheckpoint(sessionPath, out checkpointSizeInBytes); CheckDx11AndLoad(sessionPath, multiplayer, onlineMode, maxPlayers, gameMode, checkpoint, checkpointSizeInBytes); }
private void scenario_SelectedChanged(MyGuiControlRadioButtonGroup group) { SetDefaultName(); // If the scenario selected is "Empty World" it will select Safe as the default environment, but only if this setting wasn't changed before if (!m_isHostilityChanged) { m_environment.SelectItemByKey(0); // It will change with the above code to true m_isHostilityChanged = false; } if (MyFakes.ENABLE_PLANETS) { m_worldGeneratorButton.Enabled = true; if (m_worldGeneratorButton.Enabled) { if (WorldGenerator != null) { WorldGenerator.GetSettings(m_settings); AsteroidAmount = WorldGenerator.AsteroidAmount; } else { //GK: If AsteroidAmount==0 it will cause no Asteroids spawned near player in Asteroids Scenario AsteroidAmount = -1; } } else if (m_settings != null) { AsteroidAmount = 0; m_settings.EnableFlora = true; } } else { UpdateAsteroidAmountEnabled(true); } var checkpointPath = group.SelectedButton.UserData as string; ulong size; var checkpoint = MyLocalCache.LoadCheckpoint(checkpointPath, out size); if (checkpoint != null) { m_settings = CopySettings(checkpoint.Settings); SetSettingsToControls(); } }
private void QuickstartScenario(string scenarioName) { string path = "CustomWorlds"; string sessionPath = Path.Combine(MyFileSystem.ContentPath, path, scenarioName); ulong sizeInBytes; MyObjectBuilder_Checkpoint checkpoint = MyLocalCache.LoadCheckpoint(sessionPath, out sizeInBytes); if (checkpoint != null) { MySessionLoader.LoadSingleplayerSession(checkpoint, sessionPath, sizeInBytes, delegate { MyAsyncSaving.Start(null, Path.Combine(MyFileSystem.SavesPath, checkpoint.SessionName.Replace(':', '-'))); }); } }
public MyServerAction LoadLastCheckpoint() { TryPause(); var checkpoint = MyLocalCache.LoadCheckpoint(); if (checkpoint != null) { CheckpointLoaded(checkpoint); } else { throw new MyDataCorruptedException("Last checkpoint corrupted"); } return(null); }
private void LoadSandbox(bool MP) { MyLog.Default.WriteLine("LoadSandbox() - Start"); var row = m_scenarioTable.SelectedRow; if (row != null) { var save = FindSave(row); if (save != null) { if (save.Item1 == WORKSHOP_PATH_TAG) { var scenario = FindWorkshopScenario(save.Item2.WorkshopId.Value); MySteamWorkshop.CreateWorldInstanceAsync(scenario, MySteamWorkshop.MyWorkshopPathInfo.CreateScenarioInfo(), true, delegate(bool success, string sessionPath) { if (success) { //add briefing from workshop description ulong dummy; var checkpoint = MyLocalCache.LoadCheckpoint(sessionPath, out dummy); checkpoint.Briefing = save.Item2.Briefing; MyLocalCache.SaveCheckpoint(checkpoint, sessionPath); LoadMission(sessionPath, m_nameTextbox.Text, m_descriptionTextbox.Text, MP); } else { MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox( messageText: MyTexts.Get(MySpaceTexts.MessageBoxTextWorkshopDownloadFailed), messageCaption: MyTexts.Get(MySpaceTexts.ScreenCaptionWorkshop))); } }); } else { LoadMission(save.Item1, m_nameTextbox.Text, m_descriptionTextbox.Text, MP); } } } MyLog.Default.WriteLine("LoadSandbox() - End"); }
void OnEditClick(MyGuiControlButton sender) { var row = m_sessionsTable.SelectedRow; if (row == null) { return; } var save = FindSave(row); if (save != null) { ulong dummySizeInBytes; var checkpoint = MyLocalCache.LoadCheckpoint(save.Item1, out dummySizeInBytes); MySession.FixIncorrectSettings(checkpoint.Settings); var worldSettingsScreen = MyGuiSandbox.CreateScreen(MyPerGameSettings.GUI.EditWorldSettingsScreen, checkpoint, save.Item1); MyGuiSandbox.AddScreen(worldSettingsScreen); worldSettingsScreen.Closed += (source) => { m_state = StateEnum.ListNeedsReload; }; } }
public static void LoadSingleplayerSession(string sessionPath, Action afterLoad = null) { MyLog.Default.WriteLine("LoadSession() - Start"); MyLog.Default.WriteLine(sessionPath); ulong checkpointSizeInBytes; var checkpoint = MyLocalCache.LoadCheckpoint(sessionPath, out checkpointSizeInBytes); if (checkpoint == null) { MyLog.Default.WriteLine(MyTexts.Get(MyCommonTexts.WorldFileIsCorruptedAndCouldNotBeLoaded).ToString()); MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox( messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionError), messageText: MyTexts.Get(MyCommonTexts.WorldFileIsCorruptedAndCouldNotBeLoaded), buttonType: MyMessageBoxButtonsType.OK)); MyLog.Default.WriteLine("LoadSession() - End"); return; } CheckDx11AndLoad(checkpoint, sessionPath, checkpointSizeInBytes, afterLoad); }
void SaveAsync(string newSaveName, string sessionPath, MyWorldInfo copyFrom) { // Try a simple path, then a random if it already exists var newSessionPath = MyLocalCache.GetSessionSavesPath(newSaveName, false, false); while (Directory.Exists(newSessionPath)) { newSessionPath = MyLocalCache.GetSessionSavesPath(newSaveName + MyUtils.GetRandomInt(int.MaxValue).ToString("########"), false, false); } Directory.CreateDirectory(newSessionPath); MyUtils.CopyDirectory(sessionPath, newSessionPath); ulong sizeInBytes; var checkpoint = MyLocalCache.LoadCheckpoint(newSessionPath, out sizeInBytes); Debug.Assert(checkpoint != null); checkpoint.SessionName = copyFrom.SessionName; checkpoint.WorkshopId = null; MyLocalCache.SaveCheckpoint(checkpoint, newSessionPath); MyLocalCache.SaveLastLoadedTime(newSessionPath, DateTime.Now); }
void OnEditClick(MyGuiControlButton sender) { var row = m_saveBrowser.SelectedRow; if (row == null) { return; } var save = m_saveBrowser.GetSave(row); if (save != null) { ulong dummySizeInBytes; var checkpoint = MyLocalCache.LoadCheckpoint(save.Item1, out dummySizeInBytes); MySession.FixIncorrectSettings(checkpoint.Settings); var worldSettingsScreen = MyGuiSandbox.CreateScreen(MyPerGameSettings.GUI.EditWorldSettingsScreen, checkpoint, save.Item1); worldSettingsScreen.Closed += source => m_saveBrowser.ForceRefresh(); MyGuiSandbox.AddScreen(worldSettingsScreen); } }
#pragma warning restore 649 private void DoLoadSession(string sessionPath) { if (!Path.IsPathRooted(sessionPath)) { sessionPath = Path.Combine(MyFileSystem.SavesPath, sessionPath); } if (!Sandbox.Engine.Platform.Game.IsDedicated) { MySessionLoader.LoadSingleplayerSession(sessionPath); return; } MyObjectBuilder_Checkpoint checkpoint = MyLocalCache.LoadCheckpoint(sessionPath, out ulong checkpointSize); /*if (MySession.IsCompatibleVersion(checkpoint)) * { * var downloadResult = MyWorkshop.DownloadWorldModsBlocking(checkpoint.Mods.Select(b => * { * b.PublishedServiceName = ModItemUtils.GetDefaultServiceName(); * return b; * }).ToList(), null); * if (downloadResult.Success) * { * MyLog.Default.WriteLineAndConsole("Mods Downloaded"); * // MySpaceAnalytics.Instance.SetEntry(MyGameEntryEnum.Load); * MySession.Load(sessionPath, checkpoint, checkpointSize); * _hostServerForSession(MySession.Static, MyMultiplayer.Static); * } * else * { * MyLog.Default.WriteLineAndConsole("Unable to download mods"); * MyLog.Default.WriteLineAndConsole("Missing Mods:"); * downloadResult.MismatchMods?.ForEach(b => MyLog.Default.WriteLineAndConsole($"\t{b.Title} ({b.Id})")); * } * } * else * MyLog.Default.WriteLineAndConsole(MyTexts.Get(MyCommonTexts.DialogTextIncompatibleWorldVersion) * .ToString());*/ }
public static void AddBattleMaps(List <Tuple <string, MyWorldInfo> > availableMaps, List <MyBattleMapInfo> outBattleMaps, string officialBattlesPath, string workshopBattlesPath) { for (int i = 0; i < availableMaps.Count; ++i) { var save = availableMaps[i]; ulong dummySizeInBytes; var checkpoint = MyLocalCache.LoadCheckpoint(save.Item1, out dummySizeInBytes); if (checkpoint == null) { continue; } foreach (var component in checkpoint.SessionComponents) { var battleComponent = component as MyObjectBuilder_BattleSystemComponent; if (battleComponent != null && battleComponent.IsCastleSiegeMap) { MyBattleMapInfo battleMapInfo = new MyBattleMapInfo(); battleMapInfo.WorldInfo = save.Item2; battleMapInfo.SessionPath = save.Item1; battleMapInfo.BattlePoints = battleComponent.Points; battleMapInfo.MapType = MyBattleMapType.SAVE; if (battleMapInfo.SessionPath.StartsWith(officialBattlesPath)) { battleMapInfo.MapType = MyBattleMapType.OFFICIAL; } else if (workshopBattlesPath != null && battleMapInfo.SessionPath.StartsWith(workshopBattlesPath)) { battleMapInfo.MapType = MyBattleMapType.SUBSCRIBED; } outBattleMaps.Add(battleMapInfo); break; } } } }
private void startButton_Click(object sender, EventArgs e) { saveConfigButton_Click(sender, e); if (!string.IsNullOrEmpty(MySandboxGame.ConfigDedicated.LoadWorld)) { ulong sizeInBytes; var path = MySandboxGame.ConfigDedicated.LoadWorld; MyObjectBuilder_Checkpoint checkpoint = MyLocalCache.LoadCheckpoint(path, out sizeInBytes); if (!string.IsNullOrWhiteSpace(MySandboxGame.ConfigDedicated.WorldName)) { checkpoint.SessionName = MySandboxGame.ConfigDedicated.WorldName; } checkpoint.Settings = m_selectedSessionSettings; checkpoint.Mods.Clear(); foreach (ulong publishedFileId in MySandboxGame.ConfigDedicated.Mods) { checkpoint.Mods.Add(new MyObjectBuilder_Checkpoint.ModItem(publishedFileId)); } MyLocalCache.SaveCheckpoint(checkpoint, path); } if (m_isService) // Service { startService(); } else // Local / Console { Process.Start("SpaceEngineersDedicated.exe", "-console -ignorelastsession"); Close(); } }
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"); }); }
public static void LoadMission(string sessionPath, bool multiplayer, MyOnlineModeEnum onlineMode, short maxPlayers) { MyLog.Default.WriteLine("LoadSession() - Start"); MyLog.Default.WriteLine(sessionPath); ulong checkpointSizeInBytes; var checkpoint = MyLocalCache.LoadCheckpoint(sessionPath, out checkpointSizeInBytes); var persistentEditMode = checkpoint.Settings.ScenarioEditMode; checkpoint.Settings.OnlineMode = onlineMode; checkpoint.Settings.MaxPlayers = maxPlayers; 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; } m_checkpointData = new CheckpointData() { Checkpoint = checkpoint, CheckpointSize = checkpointSizeInBytes, PersistentEditMode = persistentEditMode, SessionPath = sessionPath, }; if (checkpoint.BriefingVideo != null && checkpoint.BriefingVideo.Length > 0 && !MyFakes.XBOX_PREVIEW) { MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox( messageCaption: MyTexts.Get(MySpaceTexts.MessageBoxCaptionVideo), messageText: MyTexts.Get(MySpaceTexts.MessageBoxTextWatchVideo), buttonType: MyMessageBoxButtonsType.YES_NO, callback: OnVideoMessageBox)); } else { var checkpointData = m_checkpointData.Value; m_checkpointData = null; LoadMission(checkpointData); } }
public static void Publish(string sessionPath, MyWorldInfo worlInfo) { if (MyFakes.XBOX_PREVIEW) { MyGuiSandbox.Show(MyCommonTexts.MessageBoxTextErrorFeatureNotAvailableYet, MyCommonTexts.MessageBoxCaptionError); return; } MyStringId textQuestion, captionQuestion; if (worlInfo.WorkshopId.HasValue) { textQuestion = MyCommonTexts.MessageBoxTextDoYouWishToUpdateWorld; captionQuestion = MyCommonTexts.MessageBoxCaptionDoYouWishToUpdateWorld; } else { textQuestion = MyCommonTexts.MessageBoxTextDoYouWishToPublishWorld; captionQuestion = MyCommonTexts.MessageBoxCaptionDoYouWishToPublishWorld; } MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox( styleEnum : MyMessageBoxStyleEnum.Info, buttonType : MyMessageBoxButtonsType.YES_NO, messageText : MyTexts.Get(textQuestion), messageCaption : MyTexts.Get(captionQuestion), callback : delegate(MyGuiScreenMessageBox.ResultEnum val) { if (val == MyGuiScreenMessageBox.ResultEnum.YES) { Action <MyGuiScreenMessageBox.ResultEnum, string[]> onTagsChosen = delegate(MyGuiScreenMessageBox.ResultEnum tagsResult, string[] outTags) { if (tagsResult == MyGuiScreenMessageBox.ResultEnum.YES) { MySteamWorkshop.PublishWorldAsync(sessionPath, worlInfo.SessionName, worlInfo.Description, worlInfo.WorkshopId, outTags, SteamSDK.PublishedFileVisibility.Public, callbackOnFinished : delegate(bool success, Result result, ulong publishedFileId) { if (success) { ulong dummy; var checkpoint = MyLocalCache.LoadCheckpoint(sessionPath, out dummy); worlInfo.WorkshopId = publishedFileId; checkpoint.WorkshopId = publishedFileId; MyLocalCache.SaveCheckpoint(checkpoint, sessionPath); MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox( styleEnum: MyMessageBoxStyleEnum.Info, messageText: MyTexts.Get(MyCommonTexts.MessageBoxTextWorldPublished), messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionWorldPublished), callback: (a) => { MySteam.API.OpenOverlayUrl(string.Format("http://steamcommunity.com/sharedfiles/filedetails/?id={0}", publishedFileId)); })); } else { MyStringId error; switch (result) { case Result.AccessDenied: error = MyCommonTexts.MessageBoxTextPublishFailed_AccessDenied; break; default: error = MyCommonTexts.MessageBoxTextWorldPublishFailed; break; } MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox( messageText: MyTexts.Get(error), messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionWorldPublishFailed))); } }); } }; if (MySteamWorkshop.WorldCategories.Length > 0) { MyGuiSandbox.AddScreen(new MyGuiScreenWorkshopTags(MySteamWorkshop.WORKSHOP_WORLD_TAG, MySteamWorkshop.WorldCategories, null, onTagsChosen)); } else { onTagsChosen(MyGuiScreenMessageBox.ResultEnum.YES, new string[] { MySteamWorkshop.WORKSHOP_WORLD_TAG }); } } })); }
void OnPublishButtonClick(MyGuiControlButton sender) { var row = m_scenarioTable.SelectedRow; if (row == null) { return; } if (row.UserData == null) { return; } string fullPath = (string)(((Tuple <string, MyWorldInfo>)row.UserData).Item1); MyWorldInfo worldInfo = FindSave(m_scenarioTable.SelectedRow).Item2; //var mod = (MyObjectBuilder_Checkpoint.ModItem)row.UserData; //var nameSB = m_selectedRow.GetCell(1).Text; //var name = nameSB.ToString(); MyStringId textQuestion, captionQuestion; if (worldInfo.WorkshopId != null) { textQuestion = MySpaceTexts.MessageBoxTextDoYouWishToUpdateScenario; captionQuestion = MySpaceTexts.MessageBoxCaptionDoYouWishToUpdateScenario; } else { textQuestion = MySpaceTexts.MessageBoxTextDoYouWishToPublishScenario; captionQuestion = MySpaceTexts.MessageBoxCaptionDoYouWishToPublishScenario; } MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox( styleEnum : MyMessageBoxStyleEnum.Info, buttonType : MyMessageBoxButtonsType.YES_NO, messageText : MyTexts.Get(textQuestion), messageCaption : MyTexts.Get(captionQuestion), callback : delegate(MyGuiScreenMessageBox.ResultEnum val) { if (val == MyGuiScreenMessageBox.ResultEnum.YES) { string[] inTags = null; var subscribedItem = GetSubscribedItem(worldInfo.WorkshopId); if (subscribedItem != null) { inTags = subscribedItem.Tags; if (subscribedItem.SteamIDOwner != MySteam.UserId) { MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox( messageText: MyTexts.Get(MySpaceTexts.MessageBoxTextPublishFailed_OwnerMismatchMod),//TODO rename messageCaption: MyTexts.Get(MySpaceTexts.MessageBoxCaptionModPublishFailed))); return; } } /*MyGuiSandbox.AddScreen(new MyGuiScreenWorkshopTags(MySteamWorkshop.WORKSHOP_SCENARIO_TAG, MySteamWorkshop.ScenarioCategories, inTags, delegate(MyGuiScreenMessageBox.ResultEnum tagsResult, string[] outTags) * { * if (tagsResult == MyGuiScreenMessageBox.ResultEnum.YES) * {*/ MySteamWorkshop.PublishScenarioAsync(fullPath, worldInfo.SessionName, worldInfo.Description, worldInfo.WorkshopId, /*outTags,*/ SteamSDK.PublishedFileVisibility.Public, callbackOnFinished : delegate(bool success, Result result, ulong publishedFileId) //TODO public visibility!! { if (success) { ulong dummy; var checkpoint = MyLocalCache.LoadCheckpoint(fullPath, out dummy); worldInfo.WorkshopId = publishedFileId; checkpoint.WorkshopId = publishedFileId; MyLocalCache.SaveCheckpoint(checkpoint, fullPath); MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox( styleEnum: MyMessageBoxStyleEnum.Info, messageText: MyTexts.Get(MySpaceTexts.MessageBoxTextScenarioPublished), messageCaption: MyTexts.Get(MySpaceTexts.MessageBoxCaptionScenarioPublished), callback: (a) => { MySteam.API.OpenOverlayUrl(string.Format("http://steamcommunity.com/sharedfiles/filedetails/?id={0}", publishedFileId)); FillList(); })); } else { MyStringId error; switch (result) { case Result.AccessDenied: error = MySpaceTexts.MessageBoxTextPublishFailed_AccessDenied; break; default: error = MySpaceTexts.MessageBoxTextScenarioPublishFailed; break; } MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox( messageText: MyTexts.Get(error), messageCaption: MyTexts.Get(MySpaceTexts.MessageBoxCaptionModPublishFailed))); } }); /* * } * }));*/ } })); }
public static void LoadSingleplayerSession(string sessionPath) { MyLog.Default.WriteLine("LoadSession() - Start"); MyLog.Default.WriteLine(sessionPath); ulong checkpointSizeInBytes; var checkpoint = MyLocalCache.LoadCheckpoint(sessionPath, out checkpointSizeInBytes); 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; } MyGuiScreenGamePlay.StartLoading(delegate { MySession.Load(sessionPath, checkpoint, checkpointSizeInBytes); }); } 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"); }); }