public static ThemeSkinset Import(string path) { path = path.Replace("\\", "/"); var skinset = new ThemeSkinset(); var isVariant = path.GetPathTerm().Contains("+"); skinset.name = path.GetPathTerm().Remove("+"); skinset.path = path; foreach (var skinFile in File.FindAll(path + "/*.guiskin", Theme.debug)) { if (!isVariant && skinFile.path.Contains("/+")) { continue; } var active = skinset.skins.AddNew(); var filter = skinFile.name.Contains("#") ? skinFile.name.Parse("#", ".") : ""; var skinName = skinFile.name.Remove("#" + filter); if (skinName == skinset.name) { skinset.skins.Remove(active); active = skinset.main.AddNew(); } active.name = skinName; active.path = skinFile.path; active.skin = skinFile.GetAsset <GUISkin>(); if (active.skin.IsNull()) { Log.Warning("[Themes] GUISkin (" + skinName + ") could not be loaded. This usually occurs when the guiSkin was saved as binary in a newer version."); skinset.skins.Remove(active); continue; } active.skinset = skinset; var field = skinName.Split(".").Last(); var parent = skinName.Replace("." + field, ""); var typeDirect = Reflection.GetUnityType(skinName); var typeParent = Reflection.GetUnityType(parent); var flags = field.Contains("s_Current") ? Reflection.privateFlags : Reflection.staticFlags; if (typeDirect.IsNull() && (typeParent.IsNull() || !typeParent.HasVariable(field))) { if (Theme.debug) { Log.Warning("[Themes] No matching class/field found for GUISkin -- " + skinFile.name + ". Possible version conflict."); } continue; } active.GetScope = () => { return(!typeDirect.IsNull() ? typeDirect : typeParent.InstanceVariable(field)); }; active.scopedStyles = !typeDirect.IsNull() ? active.GetScope().GetVariables <GUIStyle>(null, flags) : active.GetScope().GetVariables <GUIStyle>(); } foreach (var variantPath in Directory.GetDirectories(path).Where(x => x.GetPathTerm().Contains("+"))) { var variant = ThemeSkinset.Import(variantPath); variant.active = false; skinset.variants.Add(variant); } return(skinset); }
//================================= // Files //================================= public static List <ThemeSkinset> Import() { var imported = new List <ThemeSkinset>(); foreach (var path in Directory.GetDirectories(Theme.storagePath + "Skinsets")) { imported.Add(ThemeSkinset.Import(path)); } return(imported); }
public Theme Use(Theme other) { this.UseVariables(other, typeof(InternalAttribute).AsList()); if (this.name.IsEmpty()) { this.name = other.name; } if (this.path.IsEmpty()) { this.path = other.path; } this.skinset = other.skinset; this.iconset = other.iconset; this.palette = other.palette; this.fontset = other.fontset; return(this); }
public void Deserialize(string data) { foreach (var line in data.GetLines()) { if (line.Trim().IsEmpty()) { continue; } var term = line.Parse("", " ").Trim(); var value = line.Parse(" ").Trim().Trim("=").Trim(); if (term.Matches("CustomizablePalette", true)) { this.customizablePalette = value.ToBool(); } else if (term.Matches("CustomizableFontset", true)) { this.customizableFontset = value.ToBool(); } else if (term.Matches("CustomizableIconset", true)) { this.customizableIconset = value.ToBool(); } else if (term.Matches("Palette", true)) { this.palette = ThemePalette.all.Find(x => x.name == value) ?? new ThemePalette(); } else if (term.Matches("Fontset", true)) { this.fontset = ThemeFontset.all.Find(x => x.name == value) ?? new ThemeFontset(); } else if (term.Matches("Iconset", true)) { this.iconset = ThemeIconset.all.Find(x => x.name == value) ?? new ThemeIconset(); } else if (term.Matches("Skinset", true)) { var variants = value.Split("+"); this.defaultVariants = variants.Skip(1).ToArray(); this.skinset = ThemeSkinset.all.Find(x => x.name == variants[0]) ?? new ThemeSkinset(); } } }
public static void DumpAssets() { ThemeSkinset.DumpAssets(""); }
public static void DumpAssetsAll() { ThemeSkinset.DumpAssets("", true); }