public void SetColor(string theName, string Code, string rgbString, Color theColor, ColourLoader script) { gameObject.name = theName; Name = theName; ReseneCode = Code; rgbColor = rgbString; NameText.text = theName; imageColour.color = theColor; colourLoader = script; }
/// <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); }
// Use this for initialization void Start() { for (int i = 0; i < folderNames.Length; i++) { string folderName = folderNames[i]; Transform parentTransform = parentTransforms[i]; DirectoryInfo dir = new DirectoryInfo("Assets/Resources/" + folderName); FileInfo[] info = dir.GetFiles(); Debug.Log(info.Length.ToString()); string[] fileNames; fileNames = info.Select(f => f.Name).ToArray(); foreach (string name in fileNames) { string objName = name.Split('.')[0]; GameObject loadedObject = (GameObject)Instantiate(Resources.Load(folderName + "/" + objName)); loadedObject.transform.localScale = new Vector3(0.0035f, 0.0035f, 0.0035f); loadedObject.transform.position = parentTransform.position + new Vector3(0.07f, 0.06f, 0f); loadedObject.transform.Rotate(new Vector3(0f, -100f, 0f)); string[] nameParts = objName.Split('_'); string niftiNumber = nameParts[nameParts.Length - 2]; if (parentTransform.Find(niftiNumber) == null) { GameObject emptyObject = Instantiate <GameObject>(new GameObject()); emptyObject.name = niftiNumber; emptyObject.transform.parent = parentTransform; emptyObject.transform.position = parentTransform.position; //emptyObject.transform.localScale = new Vector3(0.005f, 0.005f, 0.005f); loadedObject.transform.parent = emptyObject.transform; } else { Transform niftiParentTransform = parentTransform.Find(niftiNumber); loadedObject.transform.parent = niftiParentTransform.transform; } } ColourLoader colourLoader = parentTransform.gameObject.GetComponent <ColourLoader>(); colourLoader.Invoke("Start", 0f); } }
/// <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); }
/// <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); } }