コード例 #1
0
ファイル: RTSettings.cs プロジェクト: ozraven/RemoteTech
        /// <summary>
        /// Load a preset config into the remotetech settings object.
        /// </summary>
        private static Settings LoadPreset(Settings settings, UrlDir.UrlConfig curSet)
        {
            settings.PreSets.Add(curSet.url);
            RTLog.Notify("Override RTSettings with configs from {0}", curSet.url);
            settings.backupFields();
            ConfigNode.LoadObjectFromConfig(settings, curSet.config);
            settings.restoreBackups();

            return(settings);
        }
コード例 #2
0
        public static Settings Load()
        {
            // Create a new settings object
            Settings settings = new Settings();
            // try to load from the base settings.cfg
            ConfigNode load = ConfigNode.Load(File);

            if (load == null)
            {
                // write new base file to the rt folder
                settings.Save();
            }
            else
            {
                // old or new format?
                if (load.HasNode("RemoteTechSettings"))
                {
                    load = load.GetNode("RemoteTechSettings");
                }
                RTLog.Notify("Load base settings into object with {0}", load);
                // load basic file
                ConfigNode.LoadObjectFromConfig(settings, load);
            }

            // Prefer to load from GameDatabase, to allow easier user customization
            UrlDir.UrlConfig[] configList = GameDatabase.Instance.GetConfigs("RemoteTechSettings");
            foreach (UrlDir.UrlConfig curSet in configList)
            {
                // only third party files
                if (!curSet.url.Equals("RemoteTech/RemoteTech_Settings/RemoteTechSettings"))
                {
                    RTLog.Notify("Override RTSettings with configs from {0}", curSet.url);
                    settings.backupFields();
                    ConfigNode.LoadObjectFromConfig(settings, curSet.config);
                    settings.restoreBackups();
                }
            }

            return(settings);
        }
コード例 #3
0
ファイル: RTSettings.cs プロジェクト: hashashin/RemoteTech-XF
        public static Settings Load()
        {
            // Create a new settings object
            Settings settings = new Settings();
            // try to load from the base settings.cfg
            ConfigNode load = ConfigNode.Load(File);

            if (load == null)
            {
                // write new base file to the rt folder
                settings.Save();
            }
            else
            {
                // old or new format?
                if (load.HasNode("RemoteTechSettings"))
                {
                    load = load.GetNode("RemoteTechSettings");
                }
                RTLog.Notify("Load base settings into object with {0}", load);
                // load basic file
                ConfigNode.LoadObjectFromConfig(settings, load);
            }

            // Prefer to load from GameDatabase, to allow easier user customization
            UrlDir.UrlConfig[] configList = GameDatabase.Instance.GetConfigs("RemoteTechSettings");
            foreach (UrlDir.UrlConfig curSet in configList)
            {
                // only third party files
                if (!curSet.url.Equals("RemoteTech/RemoteTech_Settings/RemoteTechSettings"))
                {
                    RTLog.Notify("Override RTSettings with configs from {0}", curSet.url);
                    settings.backupFields();
                    ConfigNode.LoadObjectFromConfig(settings, curSet.config);
                    settings.restoreBackups();
                }
            }

            return settings;
        }