From 5f6d9eef6bebd0ddfb3396efb40801de2cf46100 Mon Sep 17 00:00:00 2001 From: Evan Husted Date: Mon, 14 Oct 2024 15:01:31 -0500 Subject: [PATCH] misc: Use a method to create window titles. --- src/Ryujinx/App.axaml.cs | 7 ++++++- src/Ryujinx/UI/ViewModels/MainWindowViewModel.cs | 2 +- src/Ryujinx/UI/Windows/AmiiboWindow.axaml.cs | 4 ++-- src/Ryujinx/UI/Windows/CheatWindow.axaml.cs | 4 ++-- src/Ryujinx/UI/Windows/MainWindow.axaml.cs | 2 +- src/Ryujinx/UI/Windows/SettingsWindow.axaml.cs | 2 +- 6 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/Ryujinx/App.axaml.cs b/src/Ryujinx/App.axaml.cs index 9c1ccaf8d..465094e9f 100644 --- a/src/Ryujinx/App.axaml.cs +++ b/src/Ryujinx/App.axaml.cs @@ -19,9 +19,14 @@ namespace Ryujinx.Ava { public class App : Application { + internal static string FormatTitle(LocaleKeys? windowTitleKey = null) + => windowTitleKey is null + ? $"Ryujinx {Program.Version}" + : $"Ryujinx {Program.Version} - {LocaleManager.Instance[windowTitleKey.Value]}"; + public override void Initialize() { - Name = $"Ryujinx {Program.Version}"; + Name = FormatTitle(); AvaloniaXamlLoader.Load(this); diff --git a/src/Ryujinx/UI/ViewModels/MainWindowViewModel.cs b/src/Ryujinx/UI/ViewModels/MainWindowViewModel.cs index 0b7edf1e4..a77b56e47 100644 --- a/src/Ryujinx/UI/ViewModels/MainWindowViewModel.cs +++ b/src/Ryujinx/UI/ViewModels/MainWindowViewModel.cs @@ -1705,7 +1705,7 @@ namespace Ryujinx.Ava.UI.ViewModels Dispatcher.UIThread.InvokeAsync(() => { - Title = $"Ryujinx {Program.Version}"; + Title = App.FormatTitle(); }); } diff --git a/src/Ryujinx/UI/Windows/AmiiboWindow.axaml.cs b/src/Ryujinx/UI/Windows/AmiiboWindow.axaml.cs index 66378f8ad..af14ddb96 100644 --- a/src/Ryujinx/UI/Windows/AmiiboWindow.axaml.cs +++ b/src/Ryujinx/UI/Windows/AmiiboWindow.axaml.cs @@ -18,7 +18,7 @@ namespace Ryujinx.Ava.UI.Windows InitializeComponent(); - Title = $"Ryujinx {Program.Version} - " + LocaleManager.Instance[LocaleKeys.Amiibo]; + Title = App.FormatTitle(LocaleKeys.Amiibo); } public AmiiboWindow() @@ -31,7 +31,7 @@ namespace Ryujinx.Ava.UI.Windows if (Program.PreviewerDetached) { - Title = $"Ryujinx {Program.Version} - " + LocaleManager.Instance[LocaleKeys.Amiibo]; + Title = App.FormatTitle(LocaleKeys.Amiibo); } } diff --git a/src/Ryujinx/UI/Windows/CheatWindow.axaml.cs b/src/Ryujinx/UI/Windows/CheatWindow.axaml.cs index da8025b83..0a02e5f01 100644 --- a/src/Ryujinx/UI/Windows/CheatWindow.axaml.cs +++ b/src/Ryujinx/UI/Windows/CheatWindow.axaml.cs @@ -30,7 +30,7 @@ namespace Ryujinx.Ava.UI.Windows InitializeComponent(); - Title = $"Ryujinx {Program.Version} - " + LocaleManager.Instance[LocaleKeys.CheatWindowTitle]; + Title = App.FormatTitle(LocaleKeys.CheatWindowTitle); } public CheatWindow(VirtualFileSystem virtualFileSystem, string titleId, string titleName, string titlePath) @@ -95,7 +95,7 @@ namespace Ryujinx.Ava.UI.Windows DataContext = this; - Title = $"Ryujinx {Program.Version} - " + LocaleManager.Instance[LocaleKeys.CheatWindowTitle]; + Title = App.FormatTitle(LocaleKeys.CheatWindowTitle); } public void Save() diff --git a/src/Ryujinx/UI/Windows/MainWindow.axaml.cs b/src/Ryujinx/UI/Windows/MainWindow.axaml.cs index 1aa3bab7b..8a155b3cb 100644 --- a/src/Ryujinx/UI/Windows/MainWindow.axaml.cs +++ b/src/Ryujinx/UI/Windows/MainWindow.axaml.cs @@ -79,7 +79,7 @@ namespace Ryujinx.Ava.UI.Windows UiHandler = new AvaHostUIHandler(this); - ViewModel.Title = $"Ryujinx {Program.Version}"; + ViewModel.Title = App.FormatTitle(); // NOTE: Height of MenuBar and StatusBar is not usable here, since it would still be 0 at this point. StatusBarHeight = StatusBarView.StatusBar.MinHeight; diff --git a/src/Ryujinx/UI/Windows/SettingsWindow.axaml.cs b/src/Ryujinx/UI/Windows/SettingsWindow.axaml.cs index 4d7871886..2fe1bd19c 100644 --- a/src/Ryujinx/UI/Windows/SettingsWindow.axaml.cs +++ b/src/Ryujinx/UI/Windows/SettingsWindow.axaml.cs @@ -14,7 +14,7 @@ namespace Ryujinx.Ava.UI.Windows public SettingsWindow(VirtualFileSystem virtualFileSystem, ContentManager contentManager) { - Title = $"Ryujinx {Program.Version} - {LocaleManager.Instance[LocaleKeys.Settings]}"; + Title = App.FormatTitle(LocaleKeys.Settings); ViewModel = new SettingsViewModel(virtualFileSystem, contentManager); DataContext = ViewModel;