mirror of
https://github.com/knah/VRCMelonAssistant.git
synced 2024-09-30 00:56:15 +13:00
Waifus can now be loaded from built-in themes
This commit is contained in:
parent
709889fc35
commit
7336e00d68
1 changed files with 24 additions and 0 deletions
|
@ -52,7 +52,17 @@ namespace ModAssistant
|
||||||
ResourceDictionary localDictionary = new ResourceDictionary();
|
ResourceDictionary localDictionary = new ResourceDictionary();
|
||||||
localDictionary.Source = local;
|
localDictionary.Source = local;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Load any Waifus that come with these built-in themes, too.
|
||||||
|
* The format must be: Background.png and Sidebar.png as a subfolder with the same name as the theme name.
|
||||||
|
* For example: "Themes/Dark/Background.png", or "Themes/Ugly Kulu-Ya-Lu/Sidebar.png"
|
||||||
|
*/
|
||||||
|
Waifus waifus = new Waifus();
|
||||||
|
waifus.Background = GetImageFromEmbeddedResources(localTheme, "Background");
|
||||||
|
waifus.Sidebar = GetImageFromEmbeddedResources(localTheme, "Sidebar");
|
||||||
|
|
||||||
Theme theme = new Theme(localTheme, localDictionary);
|
Theme theme = new Theme(localTheme, localDictionary);
|
||||||
|
theme.Waifus = waifus;
|
||||||
loadedThemes.Add(localTheme, theme);
|
loadedThemes.Add(localTheme, theme);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -414,6 +424,20 @@ namespace ModAssistant
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static BitmapImage GetImageFromEmbeddedResources(string themeName, string imageName)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream($"ModAssistant.Themes.{themeName}.{imageName}.png"))
|
||||||
|
{
|
||||||
|
byte[] imageBytes = new byte[stream.Length];
|
||||||
|
stream.Read(imageBytes, 0, (int)stream.Length);
|
||||||
|
return GetImageFromStream(imageBytes);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch { return null; } //We're going to ignore errors here because backgrounds/sidebars should be optional.
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Applies waifus from currently loaded Theme.
|
/// Applies waifus from currently loaded Theme.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
Loading…
Reference in a new issue