public static bool TryLoadScenario(string absPath, ScenarioCategory category, out Scenario scen) { scen = null; try { Scribe.loader.InitLoading(absPath); try { ScribeMetaHeaderUtility.LoadGameDataHeader(ScribeMetaHeaderUtility.ScribeHeaderMode.Scenario, true); Scribe_Deep.Look <Scenario>(ref scen, "scenario", new object[0]); Scribe.loader.FinalizeLoading(); } catch { Scribe.ForceStop(); throw; } scen.fileName = Path.GetFileNameWithoutExtension(new FileInfo(absPath).Name); scen.Category = category; } catch (Exception ex) { Log.Error("Exception loading scenario: " + ex.ToString(), false); scen = null; Scribe.ForceStop(); } return(scen != null); }
public static void LoadGameFromSaveFile(string fileName) { string str = GenText.ToCommaList(from mod in LoadedModManager.RunningMods select mod.ToString(), true); Log.Message("Loading game from file " + fileName + " with mods " + str); DeepProfiler.Start("Loading game from file " + fileName); Current.Game = new Game(); DeepProfiler.Start("InitLoading (read file)"); Scribe.loader.InitLoading(GenFilePaths.FilePathForSavedGame(fileName)); DeepProfiler.End(); ScribeMetaHeaderUtility.LoadGameDataHeader(ScribeMetaHeaderUtility.ScribeHeaderMode.Map, true); if (Scribe.EnterNode("game")) { Current.Game = new Game(); Current.Game.LoadGame(); PermadeathModeUtility.CheckUpdatePermadeathModeUniqueNameOnGameLoad(fileName); DeepProfiler.End(); } else { Log.Error("Could not find game XML node."); Scribe.ForceStop(); } }
public static void LoadGameFromSaveFileNow(string fileName) { string str = (from mod in LoadedModManager.RunningMods select mod.ToString()).ToCommaList(); Log.Message("Loading game from file " + fileName + " with mods " + str); DeepProfiler.Start("Loading game from file " + fileName); Current.Game = new Game(); DeepProfiler.Start("InitLoading (read file)"); Scribe.loader.InitLoading(GenFilePaths.FilePathForSavedGame(fileName)); DeepProfiler.End(); try { ScribeMetaHeaderUtility.LoadGameDataHeader(ScribeMetaHeaderUtility.ScribeHeaderMode.Map, logVersionConflictWarning: true); if (!Scribe.EnterNode("game")) { Log.Error("Could not find game XML node."); Scribe.ForceStop(); return; } Current.Game = new Game(); Current.Game.LoadGame(); } catch (Exception) { Scribe.ForceStop(); throw; } PermadeathModeUtility.CheckUpdatePermadeathModeUniqueNameOnGameLoad(fileName); DeepProfiler.End(); }
public static void CheckVersionAndLoad(string path, ScribeMetaHeaderUtility.ScribeHeaderMode mode, Action loadAct) { try { Scribe.loader.InitLoadingMetaHeaderOnly(path); ScribeMetaHeaderUtility.LoadGameDataHeader(mode, logVersionConflictWarning: false); Scribe.loader.FinalizeLoading(); } catch (Exception ex) { Log.Warning("Exception loading " + path + ": " + ex); Scribe.ForceStop(); } if (!ScribeMetaHeaderUtility.TryCreateDialogsForVersionMismatchWarnings(loadAct)) { loadAct(); } }
public static void CheckVersionAndLoad(string path, ScribeMetaHeaderUtility.ScribeHeaderMode mode, Action loadAct) { try { Scribe.loader.InitLoadingMetaHeaderOnly(path); ScribeMetaHeaderUtility.LoadGameDataHeader(mode, false); Scribe.loader.FinalizeLoading(); } catch (Exception ex) { Log.Warning(string.Concat(new object[] { "Exception loading ", path, ": ", ex }), false); Scribe.ForceStop(); } if (!ScribeMetaHeaderUtility.TryCreateDialogsForVersionMismatchWarnings(loadAct)) { loadAct(); } }