public LoadSaveScreen(LoadSaveMode mode, string title) : base(title) { this.mode = mode; isConfirmed = false; chosenOne = ""; for (int i = 0; i < 10; i++) { slot[i] = new MenuEntry(string.Format("{0:00}.", i + 1), "-- empty --"); } BuildSavesList(); LabelWidth = 60; for (int i = 0; i < 10; i++) { MenuEntries.Add(slot[i]); slot[i].Selected += OnSaveSelected; } MenuEntries.Add(new MenuEntry("", true)); MenuEntry exit = new MenuEntry("Cancel"); MenuEntries.Add(exit); exit.Selected += OnCancel; ActiveMenuItemChanged += activeMenuItemChanged; activeMenuItemChanged(null, new ActiveMenuItemEventArgs(PlayerIndex.One, 0)); }
/// <summary> /// Clear vars stored in ScribeVars. /// </summary> public static void Clear() { mode = LoadSaveMode.Inactive; curParent = null; curXmlParent = null; curPathRelToParent = null; }
/// <summary> /// Set vars in ScribeVars to loader vars. /// </summary> public static void Set() { mode = Scribe.mode; curParent = Scribe.loader.curParent; curXmlParent = Scribe.loader.curXmlParent; curPathRelToParent = Scribe.loader.curPathRelToParent; }
public static void InitWriting(string groupName) { mode = LoadSaveMode.Saving; saveStream = new FileStream(FilePathForSavechars(groupName), FileMode.Create, FileAccess.Write, FileShare.None); XmlWriterSettings xmlWriterSettings = new XmlWriterSettings(); xmlWriterSettings.Indent = true; xmlWriterSettings.IndentChars = "\t"; writer = XmlWriter.Create(saveStream, xmlWriterSettings); writer.WriteStartDocument(); }
public static void InitWriting(string filePath, string documentElementName) { //DebugLoadIDsSavingErrorsChecker.Clear(); Scribe.mode = LoadSaveMode.Saving; Scribe.saveStream = new FileStream(filePath, FileMode.Create, FileAccess.Write, FileShare.None); XmlWriterSettings xmlWriterSettings = new XmlWriterSettings(); xmlWriterSettings.Indent = true; xmlWriterSettings.IndentChars = "\t"; Scribe.writer = XmlWriter.Create(Scribe.saveStream, xmlWriterSettings); Scribe.writer.WriteStartDocument(); Scribe.EnterNode(documentElementName); }
private void InvokeExposableCallbacks(ThingWithComps target, Dictionary <string, string> vars, LoadSaveMode mode) { ExposeMode = mode; currentVars = vars; if (target is IAutoReplaceExposable t) { t.ExposeAutoReplaceValues(this); } foreach (var comp in target.AllComps) { if (comp is IAutoReplaceExposable c) { c.ExposeAutoReplaceValues(this); } } currentVars = null; ExposeMode = LoadSaveMode.Inactive; }
public static void FinalizeWriting() { if (Scribe.writer != null) { Scribe.ExitNode(); Scribe.writer.WriteEndDocument(); Scribe.writer.Flush(); Scribe.writer.Close(); Scribe.writer = null; } if (Scribe.saveStream != null) { Scribe.saveStream.Flush(); Scribe.saveStream.Close(); Scribe.saveStream = null; } Scribe.mode = LoadSaveMode.Inactive; //DebugLoadIDsSavingErrorsChecker.CheckForErrorsAndClear(); }
public static void InitLoading(string filePath) { using (StreamReader streamReader = new StreamReader(filePath)) { using (XmlTextReader xmlTextReader = new XmlTextReader(streamReader)) { try { XmlDocument xmlDocument = new XmlDocument(); xmlDocument.Load(xmlTextReader); Scribe.curParent = xmlDocument.DocumentElement; } catch (Exception ex) { //Log.Error("Exception while init loading file: " + filePath + "\n" + ex.ToString()); throw ex; } } } Scribe.mode = LoadSaveMode.LoadingVars; }
public static void InitLoadingMetaHeaderOnly(string filePath) { using (StreamReader streamReader = new StreamReader(filePath)) { using (XmlTextReader xmlTextReader = new XmlTextReader(streamReader)) { if (!ScribeMetaUtility.ReadToMetaElement(xmlTextReader)) { Scribe.mode = LoadSaveMode.Inactive; return; } using (XmlReader xmlReader = xmlTextReader.ReadSubtree()) { XmlDocument xmlDocument = new XmlDocument(); xmlDocument.Load(xmlReader); XmlElement xmlElement = xmlDocument.CreateElement("root"); xmlElement.AppendChild(xmlDocument.DocumentElement); Scribe.curParent = xmlElement; } } } Scribe.mode = LoadSaveMode.LoadingVars; }
public static void SaveToFile(Map map, string groupName) { try { InitWriting(groupName); int i = 1; EnterNode("Colonists"); EnterNode("ColonistAmount"); writer.WriteAttributeString("amount", ColonistNum.Amount.ToString()); ExitNode(); foreach (Colonist colonist in ColonistManager.Population) { WriteColonist(colonist, i); i++; } ExitNode(); } finally { FinalizeWriting(); mode = LoadSaveMode.Inactive; } GC.Collect(); }
public static void ForceStop() { mode = LoadSaveMode.Inactive; saver.ForceStop(); loader.ForceStop(); }
public static void ForceStop() { Scribe.mode = LoadSaveMode.Inactive; Scribe.saver.ForceStop(); Scribe.loader.ForceStop(); }
public static void SaveState() { Scribe.oldMode = Scribe.mode; Scribe.oldParent = Scribe.curParent; }