public bool ConfigExists(string path)
        {
            if (path == null)
            {
                throw new ArgumentNullException("path");
            }

            return(File.Exists(Pathfinder.MergePath(this.ConfigPath, path)));
        }
        public void SaveConfig(string path, object data)
        {
            if (path == null)
            {
                throw new ArgumentNullException("path");
            }

            File.WriteAllText(Pathfinder.MergePath(this.ConfigPath, path), JsonConvert.SerializeObject(data, Formatting.Indented));
        }
        public T LoadConfig <T>(string path)
        {
            if (path == null)
            {
                throw new ArgumentNullException("path");
            }

            return(ConfigHelper.Load <T>(Pathfinder.MergePath(this.ConfigPath, path)));
        }
Exemple #4
0
        public Core(string modName, string configDirectoryPath, bool logDebugMessages)
        {
            this.Logger = new Logger(modName, logDebugMessages);

            this.ModName  = modName;
            this.RootPath = this.ConfigPath = Pathfinder.FindModRootPath(modName);

            if (configDirectoryPath != null)
            {
                this.ConfigPath = Pathfinder.MergePath(this.ConfigPath, configDirectoryPath);
            }

            this.Logger.LogDebug($"Initialized {modName} mod at path {this.RootPath}, with config root at {this.ConfigPath}");
        }
        public Core(string modName, string workshopID, string configDirectoryPath, bool logDebugMessages)
        {
            this.Logger = new Logger(modName, logDebugMessages);

            this.ModName = modName;

            if (Pathfinder.FindModRootPath(modName, workshopID, out var path))
            {
                this.RootPath = this.ConfigPath = path;
            }

            if (configDirectoryPath != null)
            {
                this.ConfigPath = Pathfinder.MergePath(this.ConfigPath, configDirectoryPath);
            }

            this.Logger.Log($"Initialized successfully. Version: {Assembly.GetCallingAssembly().GetName().Version}, Path: {this.RootPath}, Config root: {this.ConfigPath}");
        }
Exemple #6
0
 public T LoadConfig <T>(string path)
 {
     return(ConfigHelper.Load <T>(Pathfinder.MergePath(this.ConfigPath, path)));
 }