public override void OnLevelUnloading() { try { WG_XMLBaseVersion xml = new XML_VersionTwo(); xml.writeXML(currentFileLocation); } catch (Exception e) { Debugging.panelMessage(e.Message); } }
/// <summary> /// /// </summary> private void readFromXML() { // Check the exe directory first currentFileLocation = ColossalFramework.IO.DataLocation.executableDirectory + Path.DirectorySeparatorChar + XML_FILE; bool fileAvailable = File.Exists(currentFileLocation); if (!fileAvailable) { // Switch to default which is the cities skylines in the application data area. currentFileLocation = ColossalFramework.IO.DataLocation.localApplicationData + Path.DirectorySeparatorChar + XML_FILE; fileAvailable = File.Exists(currentFileLocation); } if (fileAvailable) { // Load in from XML - Designed to be flat file for ease WG_XMLBaseVersion reader = null; XmlDocument doc = new XmlDocument(); try { // TODO: Determine version before obtaining the reader doc.Load(currentFileLocation); reader = new XML_VersionTwo(); reader.readXML(doc); } catch (Exception e) { // Game will now use defaults Debugging.panelMessage(e.Message); } } else { Debugging.panelMessage("Configuration file not found. Will output new file to : " + currentFileLocation); } }