diff --git a/src/Ryujinx/App.axaml.cs b/src/Ryujinx/App.axaml.cs index 0bc2ef8c1f..57adde8b48 100644 --- a/src/Ryujinx/App.axaml.cs +++ b/src/Ryujinx/App.axaml.cs @@ -4,7 +4,6 @@ using Avalonia.Markup.Xaml; using Avalonia.Platform; using Avalonia.Styling; using Avalonia.Threading; -using Ryujinx.Ava.Common; using Ryujinx.Ava.Common.Locale; using Ryujinx.Ava.UI.Helpers; using Ryujinx.Ava.UI.Windows; @@ -115,14 +114,12 @@ namespace Ryujinx.Ava ShowRestartDialog(); } - - ThemeManager.OnThemeChanged(); } /// /// Converts a PlatformThemeVariant value to the corresponding ThemeVariant value. /// - public static ThemeVariant ConvertThemeVariant(PlatformThemeVariant platformThemeVariant) => + private ThemeVariant ConvertThemeVariant(PlatformThemeVariant platformThemeVariant) => platformThemeVariant switch { PlatformThemeVariant.Dark => ThemeVariant.Dark, @@ -130,16 +127,11 @@ namespace Ryujinx.Ava _ => ThemeVariant.Default, }; - public static ThemeVariant DetectSystemTheme() + private ThemeVariant DetectSystemTheme() { - if (Application.Current is App app) - { - var colorValues = app.PlatformSettings.GetColorValues(); + var colorValues = PlatformSettings.GetColorValues(); - return ConvertThemeVariant(colorValues.ThemeVariant); - } - - return ThemeVariant.Default; + return ConvertThemeVariant(colorValues.ThemeVariant); } } } diff --git a/src/Ryujinx/Common/ThemeManager.cs b/src/Ryujinx/Common/ThemeManager.cs deleted file mode 100644 index 8c52c2a66a..0000000000 --- a/src/Ryujinx/Common/ThemeManager.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; - -namespace Ryujinx.Ava.Common -{ - public static class ThemeManager - { - public static event EventHandler ThemeChanged; - - public static void OnThemeChanged() - { - ThemeChanged?.Invoke(null, EventArgs.Empty); - } - } -} diff --git a/src/Ryujinx/UI/ViewModels/AboutWindowViewModel.cs b/src/Ryujinx/UI/ViewModels/AboutWindowViewModel.cs index 4b604565b9..6020f40e0c 100644 --- a/src/Ryujinx/UI/ViewModels/AboutWindowViewModel.cs +++ b/src/Ryujinx/UI/ViewModels/AboutWindowViewModel.cs @@ -1,8 +1,6 @@ using Avalonia.Media.Imaging; using Avalonia.Platform; -using Avalonia.Styling; using Avalonia.Threading; -using Ryujinx.Ava.Common; using Ryujinx.Ava.Common.Locale; using Ryujinx.Common.Utilities; using Ryujinx.UI.Common.Configuration; @@ -13,7 +11,7 @@ using System.Threading.Tasks; namespace Ryujinx.Ava.UI.ViewModels { - public class AboutWindowViewModel : BaseModel, IDisposable + public class AboutWindowViewModel : BaseModel { private Bitmap _githubLogo; private Bitmap _discordLogo; @@ -87,38 +85,24 @@ namespace Ryujinx.Ava.UI.ViewModels public AboutWindowViewModel() { - UpdateLogoTheme(ConfigurationState.Instance.UI.BaseStyle.Value); + Version = Program.Version; + + if (ConfigurationState.Instance.UI.BaseStyle.Value == "Light") + { + GithubLogo = new Bitmap(AssetLoader.Open(new Uri("resm:Ryujinx.UI.Common.Resources.Logo_GitHub_Light.png?assembly=Ryujinx.UI.Common"))); + DiscordLogo = new Bitmap(AssetLoader.Open(new Uri("resm:Ryujinx.UI.Common.Resources.Logo_Discord_Light.png?assembly=Ryujinx.UI.Common"))); + PatreonLogo = new Bitmap(AssetLoader.Open(new Uri("resm:Ryujinx.UI.Common.Resources.Logo_Patreon_Light.png?assembly=Ryujinx.UI.Common"))); + TwitterLogo = new Bitmap(AssetLoader.Open(new Uri("resm:Ryujinx.UI.Common.Resources.Logo_Twitter_Light.png?assembly=Ryujinx.UI.Common"))); + } + else + { + GithubLogo = new Bitmap(AssetLoader.Open(new Uri("resm:Ryujinx.UI.Common.Resources.Logo_GitHub_Dark.png?assembly=Ryujinx.UI.Common"))); + DiscordLogo = new Bitmap(AssetLoader.Open(new Uri("resm:Ryujinx.UI.Common.Resources.Logo_Discord_Dark.png?assembly=Ryujinx.UI.Common"))); + PatreonLogo = new Bitmap(AssetLoader.Open(new Uri("resm:Ryujinx.UI.Common.Resources.Logo_Patreon_Dark.png?assembly=Ryujinx.UI.Common"))); + TwitterLogo = new Bitmap(AssetLoader.Open(new Uri("resm:Ryujinx.UI.Common.Resources.Logo_Twitter_Dark.png?assembly=Ryujinx.UI.Common"))); + } + Dispatcher.UIThread.InvokeAsync(DownloadPatronsJson); - - ThemeManager.ThemeChanged += ThemeManager_ThemeChanged; - } - - private void ThemeManager_ThemeChanged(object sender, EventArgs e) - { - Dispatcher.UIThread.Post(() => UpdateLogoTheme(ConfigurationState.Instance.UI.BaseStyle.Value)); - } - - private void UpdateLogoTheme(string theme) - { - bool isDarkTheme = theme == "Dark" || (theme == "Auto" && App.DetectSystemTheme() == ThemeVariant.Dark); - - string basePath = "resm:Ryujinx.UI.Common.Resources."; - string themeSuffix = isDarkTheme ? "Dark.png" : "Light.png"; - - GithubLogo = LoadBitmap($"{basePath}Logo_GitHub_{themeSuffix}?assembly=Ryujinx.UI.Common"); - DiscordLogo = LoadBitmap($"{basePath}Logo_Discord_{themeSuffix}?assembly=Ryujinx.UI.Common"); - PatreonLogo = LoadBitmap($"{basePath}Logo_Patreon_{themeSuffix}?assembly=Ryujinx.UI.Common"); - TwitterLogo = LoadBitmap($"{basePath}Logo_Twitter_{themeSuffix}?assembly=Ryujinx.UI.Common"); - } - - private Bitmap LoadBitmap(string uri) - { - return new Bitmap(Avalonia.Platform.AssetLoader.Open(new Uri(uri))); - } - - public void Dispose() - { - ThemeManager.ThemeChanged -= ThemeManager_ThemeChanged; } private async Task DownloadPatronsJson()