/// <summary>
        /// Writes out the Config file to the Config file location.
        /// </summary>
        /// <param name="config">The Config file to write to disk.</param>
        public static void WriteConfig(LoaderConfig config)
        {
            // Convert structure to JSON
            string json = JsonConvert.SerializeObject(config, Formatting.Indented);

            // Write to disk
            File.WriteAllText(LoaderPaths.GetModLoaderConfig(), json);
        }
        /// <summary>
        /// Writes out the config file to the config file location/
        /// </summary>
        /// <param name="config">The config file to write to disk.</param>
        public static void WriteConfig(Config config)
        {
            // Convert structure to JSON
            string json = JsonConvert.SerializeObject(config, Strings.Parsers.SerializerSettings);

            // Write to disk
            File.WriteAllText(LoaderPaths.GetModLoaderConfig(), json);
        }
Exemple #3
0
        /// <summary>
        /// Writes out the config file to an .ini file.
        /// </summary>
        /// <param name="config"></param>
        public void WriteConfig(Config config)
        {
            // Change the values of the current fields.
            _iniData["Mod Loader Configuration"]["Current_Theme"]          = config.CurrentTheme;
            _iniData["Mod Loader Configuration"]["Controller_Config_Type"] = Enum.GetName(typeof(Remapper.DirectInputConfigType), config.DirectInputConfigType);

            // Write the file out to disk
            _iniParser.WriteFile(LoaderPaths.GetModLoaderConfig(), _iniData);
        }
 /// <summary>
 /// Retrieves the Mod Loader configuration file struct.
 /// </summary>
 /// <returns>Parses a Mod Loader configuration file.</returns>
 public static LoaderConfig ParseConfig()
 {
     // Try parsing the Config file, else return default one.
     try
     {
         return(File.Exists(LoaderPaths.GetModLoaderConfig())
             ? JsonConvert.DeserializeObject <LoaderConfig>(File.ReadAllText(LoaderPaths.GetModLoaderConfig()))
             : new LoaderConfig());
     }
     catch { return(new LoaderConfig()); }
 }
Exemple #5
0
        /// <summary>
        /// Retrieves the Mod Loader configuration file struct.
        /// </summary>
        /// <returns></returns>
        public Config ParseConfig()
        {
            // Instantiate a new configuration struct.
            Config config = new Config();

            // Read the mod loader configuration.
            _iniData = _iniParser.ReadFile(LoaderPaths.GetModLoaderConfig());

            // Parse the mod loader configuration.
            config.CurrentTheme          = _iniData["Mod Loader Configuration"]["Current_Theme"];
            config.DirectInputConfigType = (Remapper.DirectInputConfigType)Enum.Parse(typeof(Remapper.DirectInputConfigType), _iniData["Mod Loader Configuration"]["Controller_Config_Type"]);

            // Return the config file.
            return(config);
        }