public void OnSettingsUI(UIHelperBase helper) { UIHelper concrete = helper as UIHelper; if (File.Exists(LoadingExtension.currentFileLocation)) { // Load in from XML - Designed to be flat file for ease WG_XMLBaseVersion reader = new XML_VersionOne(); XmlDocument doc = new XmlDocument(); try { doc.Load(LoadingExtension.currentFileLocation); int version = Convert.ToInt32(doc.DocumentElement.Attributes["version"].InnerText); reader.readXML(doc, DataStore.getInstance()); } catch (Exception) { } } UIHelperBase group = concrete.AddGroup("Population modifiers"); group.AddButton("Save", EventSave); group.AddTextfield("Res Height", Convert.ToString(DataStore.getInstance().resHeightLimit), newResHeight); }
/// <summary> /// /// </summary> private void readFromXML() { currentFileLocation = ColossalFramework.IO.DataLocation.localApplicationData + Path.DirectorySeparatorChar + XML_FILE; bool fileAvailable = File.Exists(currentFileLocation); if (fileAvailable) { // Load in from XML - Designed to be flat file for ease WG_XMLBaseVersion reader = new XML_VersionOne(); XmlDocument doc = new XmlDocument(); try { doc.Load(currentFileLocation); int version = Convert.ToInt32(doc.DocumentElement.Attributes["version"].InnerText); reader.readXML(doc, DataStore.getInstance()); } catch (Exception e) { // Game will now use defaults Debugging.bufferWarning("The following exception(s) were detected while loading the XML file. Some (or all) values may not be loaded."); Debugging.bufferWarning(e.Message); UnityEngine.Debug.LogException(e); } } else { UnityEngine.Debug.Log("Configuration file not found. Will output new file to : " + currentFileLocation); } }