mirror of
https://github.com/knah/VRCMelonAssistant.git
synced 2024-06-29 03:20:18 +12:00
Waifus can now be loaded from built-in themes
This commit is contained in:
parent
709889fc35
commit
7336e00d68
|
@ -52,7 +52,17 @@ namespace ModAssistant
|
|||
ResourceDictionary localDictionary = new ResourceDictionary();
|
||||
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.Waifus = waifus;
|
||||
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>
|
||||
/// Applies waifus from currently loaded Theme.
|
||||
/// </summary>
|
||||
|
|
Loading…
Reference in a new issue