Esempio n. 1
0
        /// <summary>
        /// Retrieves the Mod Loader Colour Configuration File.
        /// </summary>
        /// <param name="themeDirectory">The relative directory of the individual theme to Reloaded-Config/Themes. e.g. Default</param>
        public static ThemeConfig ParseConfig(string themeDirectory)
        {
            // Specifies the location of the current theme property file.
            string themeLocation = LoaderPaths.GetModLoaderThemeDirectory() + "/" + themeDirectory + $"/{Strings.Parsers.ThemeFile}";

            // Try parsing the config file, else return default one.
            ThemeConfig themeConfig;

            try
            {
                themeConfig = File.Exists(themeLocation)
                    ? JsonConvert.DeserializeObject <ThemeConfig>(File.ReadAllText(themeLocation))
                    : ThemeConfig.GetDefaultThemeConfig();
            }
            catch { themeConfig = ThemeConfig.GetDefaultThemeConfig(); }

            themeConfig.ThemePropertyLocation = themeLocation;
            return(themeConfig);
        }