예제 #1
0
        /// <summary>
        /// Parses the BarColours struct of colours for a certain item/section inside the .ini file.
        /// BarColours defines button colours, text colours and background colours.
        /// </summary>
        /// <param name="iniCategoryTitleName">The category name inside the .ini file storing the properties for "X" type of objects. e.g. Main Colours, Category Colours</param>
        private BarColours ParseColours(string iniCategoryTitleName)
        {
            // Store the colours.
            BarColours colours = new BarColours();

            // Parse the colours.
            colours.BgColour       = ColourLoader.AARRGGBBToColor(_iniData[iniCategoryTitleName]["BGColour"]);
            colours.ButtonBgColour = ColourLoader.AARRGGBBToColor(_iniData[iniCategoryTitleName]["ButtonBGColour"]);
            colours.TextColour     = ColourLoader.AARRGGBBToColor(_iniData[iniCategoryTitleName]["TextColour"]);

            // Return
            return(colours);
        }
예제 #2
0
        /// <summary>
        /// Parses the ButtonMouseAnimation struct of mouse enter/exit kanimations
        /// for a certain item/section inside the .ini file.
        /// </summary>
        /// <param name="iniCategoryTitleName">The category name inside the .ini file storing the properties for "X" type of objects. e.g. Main Colours, Category Colours</param>
        private ButtonMouseAnimation ParseAnimations(string iniCategoryTitleName)
        {
            // Store the animations.
            ButtonMouseAnimation animations = new ButtonMouseAnimation();

            // Parse the animation.
            animations.BlendBgColour = bool.Parse(_iniData[iniCategoryTitleName]["BlendBGColour"]);
            animations.BlendFgColour = bool.Parse(_iniData[iniCategoryTitleName]["BlendFGColour"]);

            animations.AnimationDuration  = Convert.ToInt32(_iniData[iniCategoryTitleName]["AnimationDuration"]);
            animations.AnimationFramerate = Convert.ToInt32(_iniData[iniCategoryTitleName]["AnimationFramerate"]);

            animations.BgTargetColour = ColourLoader.AARRGGBBToColor(_iniData[iniCategoryTitleName]["BGTargetColour"]);
            animations.FgTargetColour = ColourLoader.AARRGGBBToColor(_iniData[iniCategoryTitleName]["FGTargetColour"]);

            // Return
            return(animations);
        }
예제 #3
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 ThemeConfig ParseConfig(string themeDirectory)
        {
            try
            {
                // Check if theme exists, else reset theme.
                if (!Directory.Exists(LoaderPaths.GetModLoaderThemeDirectory() + "/" + themeDirectory))
                {
                    string themeDirectories = Directory.GetDirectories(LoaderPaths.GetModLoaderThemeDirectory())[0];
                    themeDirectory = Path.GetDirectoryName(themeDirectories);
                }

                // Instantiate a new configuration struct.
                ThemeConfig themeProperties = new ThemeConfig();

                // Read the mod loader configuration.
                themeProperties.ThemePropertyLocation = LoaderPaths.GetModLoaderThemeDirectory() + "/" + themeDirectory + "/Theme.ini";
                _iniData = _iniParser.ReadFile(themeProperties.ThemePropertyLocation);

                // Parse the title properties .
                TitleProperties titleProperties = new TitleProperties();
                titleProperties.LoaderTitle          = _iniData["Title"]["LoaderTitle"];
                titleProperties.LoaderTitleDelimiter = _iniData["Title"]["LoaderTitleDelimiter"];
                titleProperties.LoaderTitlePrefix    = bool.Parse(_iniData["Title"]["LoaderTitlePrefix"]);
                titleProperties.DelimiterHasSpaces   = bool.Parse(_iniData["Title"]["DelimiterHasSpaces"]);
                themeProperties.TitleProperties      = titleProperties;

                // Parse font style.
                themeProperties.TitleFontStyle    = ParseFontStyle("Title Font");
                themeProperties.CategoryFontStyle = ParseFontStyle("Category Font");
                themeProperties.TextFontStyle     = ParseFontStyle("Text Font");

                // Parse the border properties.
                themeProperties.BorderProperties = new BorderProperties();
                themeProperties.BorderProperties.BorderColour = ColourLoader.AARRGGBBToColor(_iniData["Border Properties"]["BorderColour"]);
                themeProperties.BorderProperties.BorderWidth  = Convert.ToInt32(_iniData["Border Properties"]["BorderWidth"]);

                // Parse the Main, Title and Category Colours.
                themeProperties.MainColours       = ParseColours("Main Colours");
                themeProperties.TitleColours      = ParseColours("Title Colours");
                themeProperties.CategoryColours   = ParseColours("Category Colours");
                themeProperties.BoxColours        = ParseColours("Box Colours");
                themeProperties.BorderlessColours = ParseColours("Borderless Colours");

                // Parse the Main, Title and Category Enter and Leave Animations
                themeProperties.CategoryEnterAnimation = ParseAnimations("Category Button Mouse Enter Animation");
                themeProperties.CategoryLeaveAnimation = ParseAnimations("Category Button Mouse Leave Animation");

                themeProperties.MainEnterAnimation = ParseAnimations("Main Button Mouse Enter Animation");
                themeProperties.MainLeaveAnimation = ParseAnimations("Main Button Mouse Leave Animation");

                themeProperties.TitleEnterAnimation = ParseAnimations("Title Button Mouse Enter Animation");
                themeProperties.TitleLeaveAnimation = ParseAnimations("Title Button Mouse Leave Animation");

                themeProperties.BoxEnterAnimation = ParseAnimations("Box Mouse Enter Animation");
                themeProperties.BoxLeaveAnimation = ParseAnimations("Box Mouse Leave Animation");

                themeProperties.BorderlessEnterAnimation = ParseAnimations("Borderless Mouse Enter Animation");
                themeProperties.BorderlessLeaveAnimation = ParseAnimations("Borderless Mouse Leave Animation");

                // Return the config file.
                return(themeProperties);
            }
            catch (Exception e)
            {
                MessageBox.Show($"Failed to parse theme: {themeDirectory}, Reloaded will try to instead load its in-library default theme.");
                return(_defaultTheme);
            }
        }