Beispiel #1
0
        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);
        }
Beispiel #2
0
        /// <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);
            }
        }
Beispiel #3
0
 private void EventSave()
 {
     try
     {
         WG_XMLBaseVersion xml = new XML_VersionOne();
         xml.writeXML(LoadingExtension.currentFileLocation, DataStore.getInstance());
     }
     catch (Exception e)
     {
         Debugging.panelMessage(e.Message);
     }
 }
Beispiel #4
0
        public override void OnReleased()
        {
            if (isModEnabled)
            {
                isModEnabled = false;

                try
                {
                    WG_XMLBaseVersion xml = new XML_VersionOne();
                    xml.writeXML(currentFileLocation, DataStore.getInstance());
                    DataStore.releaseInstance();
                }
                catch (Exception e)
                {
                    Debugging.panelMessage(e.Message);
                }

                RevertRedirect(true);
            }
        }