예제 #1
0
        private void LoadConfig()
        {
            var fullPath = Path.Combine(Main.Instance.CurrentInstance.CkanDir(), ConfigPath);

            if (!File.Exists(fullPath))
            {
                return;
            }

            var partManagerPath = Path.Combine(Main.Instance.CurrentInstance.CkanDir(), "PartManager");

            if (!Directory.Exists(partManagerPath))
            {
                Directory.CreateDirectory(partManagerPath);
            }

            var cachePath = Path.Combine(partManagerPath, "cache");

            if (!Directory.Exists(cachePath))
            {
                Directory.CreateDirectory(cachePath);
            }

            var json = File.ReadAllText(fullPath);
            PartManagerConfig config = (PartManagerConfig)JsonConvert.DeserializeObject <PartManagerConfig>(json);

            foreach (var item in config.disabledParts)
            {
                m_DisabledParts.Add(item.Key, ConfigNodeReader.FileToConfigNode(Path.Combine(cachePath, item.Key)));
            }
        }
예제 #2
0
        private void SaveConfig()
        {
            var fullPath = Path.Combine(Main.Instance.CurrentInstance.CkanDir(), ConfigPath);

            if (!Directory.Exists(Path.GetDirectoryName(fullPath)))
            {
                Directory.CreateDirectory(Path.GetDirectoryName(fullPath));
            }

            PartManagerConfig config = new PartManagerConfig();

            config.disabledParts = new List <KeyValuePair <string, string> >();
            foreach (var part in m_DisabledParts)
            {
                config.disabledParts.Add(new KeyValuePair <string, string>(part.Key, null));
            }

            var json = JsonConvert.SerializeObject(config);

            File.WriteAllText(fullPath, json);
        }
예제 #3
0
        private void SaveConfig()
        {
            var fullPath = Path.Combine(Main.Instance.CurrentInstance.CkanDir(), ConfigPath);
            if (!Directory.Exists(Path.GetDirectoryName(fullPath)))
            {
                Directory.CreateDirectory(Path.GetDirectoryName(fullPath));
            }

            var config = new PartManagerConfig();
            config.DisabledParts = new List<KeyValuePair<string, string>>();
            foreach (var part in _mDisabledParts)
            {
                config.DisabledParts.Add(new KeyValuePair<string, string>(part.Key, null));
            }

            var json = JsonConvert.SerializeObject(config);
            File.WriteAllText(fullPath, json);
        }