From 7a233345a9d460d26c1b255d6160178572f82561 Mon Sep 17 00:00:00 2001 From: Zagrthos <36556009+Zagrthos@users.noreply.github.com> Date: Wed, 21 Aug 2024 23:35:28 +0200 Subject: [PATCH 01/13] Add new setting to hide non-downloaded DLSS versions --- src/Pages/SettingsPage.xaml | 10 ++++++++++ src/Pages/SettingsPage.xaml.cs | 14 +++++++++++++- src/Settings.cs | 18 +++++++++++++++++- 3 files changed, 40 insertions(+), 2 deletions(-) diff --git a/src/Pages/SettingsPage.xaml b/src/Pages/SettingsPage.xaml index ab1ffbf..cf7a482 100644 --- a/src/Pages/SettingsPage.xaml +++ b/src/Pages/SettingsPage.xaml @@ -64,6 +64,16 @@ + + + + + This setting will hide not downloaded DLSS versions in the selector. + + Date: Wed, 21 Aug 2024 23:37:59 +0200 Subject: [PATCH 02/13] Implement the new setting inside the selector --- src/UserControls/DLSSPickerControl.xaml.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/UserControls/DLSSPickerControl.xaml.cs b/src/UserControls/DLSSPickerControl.xaml.cs index be9d6a2..f001c40 100644 --- a/src/UserControls/DLSSPickerControl.xaml.cs +++ b/src/UserControls/DLSSPickerControl.xaml.cs @@ -28,7 +28,8 @@ public sealed partial class DLSSPickerControl : UserControl public DLSSPickerControl(Game game) { _game = game; - DLSSRecords.AddRange(App.CurrentApp.MainWindow.CurrentDLSSRecords); + bool hideNotDownloaded = Settings.Instance.HideNotDownloadedVersions; + DLSSRecords.AddRange(App.CurrentApp.MainWindow.CurrentDLSSRecords.Where(r => r.LocalRecord.IsDownloaded == hideNotDownloaded)); this.InitializeComponent(); DataContext = this; From 9630971653cec610efa271be69ef23ab7b6c8b74 Mon Sep 17 00:00:00 2001 From: Zagrthos <36556009+Zagrthos@users.noreply.github.com> Date: Wed, 21 Aug 2024 23:38:11 +0200 Subject: [PATCH 03/13] Add a new dialog if no DLSS files are downloaded --- src/Pages/GameGridPage.xaml.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/Pages/GameGridPage.xaml.cs b/src/Pages/GameGridPage.xaml.cs index a3018e3..bc863c3 100644 --- a/src/Pages/GameGridPage.xaml.cs +++ b/src/Pages/GameGridPage.xaml.cs @@ -237,6 +237,21 @@ async void MainGridView_SelectionChanged(object sender, SelectionChangedEventArg DefaultButton = ContentDialogButton.Primary, Content = $"DLSS was not detected in {game.Title}.", }; + + await dialog.ShowAsync(); + return; + } + + if (Settings.Instance.HideNotDownloadedVersions && App.CurrentApp.MainWindow.CurrentDLSSRecords.Where(static r => r.LocalRecord.IsDownloaded).Count() is 0) + { + dialog = new(XamlRoot) + { + Title = "Error", + PrimaryButtonText = "Okay", + DefaultButton = ContentDialogButton.Primary, + Content = "You have not downloaded any DLSS version. Please download one from the library page.", + }; + await dialog.ShowAsync(); return; } From 2485c74afd0f72f37409ae760a276298a61a37b1 Mon Sep 17 00:00:00 2001 From: Zagrthos <36556009+Zagrthos@users.noreply.github.com> Date: Wed, 21 Aug 2024 23:38:41 +0200 Subject: [PATCH 04/13] Formatting of Setting.cs --- src/Settings.cs | 40 ++++++++++++++++++---------------------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/src/Settings.cs b/src/Settings.cs index a679849..aa47aa0 100644 --- a/src/Settings.cs +++ b/src/Settings.cs @@ -1,5 +1,5 @@ -using Microsoft.UI.Xaml; -using System; +using System; +using Microsoft.UI.Xaml; namespace DLSS_Swapper { @@ -10,9 +10,9 @@ public class Settings public static Settings Instance => _instance ??= Settings.FromJson(); // We default this to false to prevent saves firing when loading from json. - bool _autoSave = false; + private bool _autoSave = false; - bool _hasShownWarning = false; + private bool _hasShownWarning = false; public bool HasShownWarning { get { return _hasShownWarning; } @@ -29,7 +29,7 @@ public bool HasShownWarning } } - bool _hasShownMultiplayerWarning = false; + private bool _hasShownMultiplayerWarning = false; public bool HasShownMultiplayerWarning { get { return _hasShownMultiplayerWarning; } @@ -46,7 +46,7 @@ public bool HasShownMultiplayerWarning } } - bool _hideNonDLSSGames = true; + private bool _hideNonDLSSGames = true; public bool HideNonDLSSGames { get { return _hideNonDLSSGames; } @@ -63,8 +63,7 @@ public bool HideNonDLSSGames } } - - bool _groupGameLibrariesTogether = false; + private bool _groupGameLibrariesTogether = false; public bool GroupGameLibrariesTogether { get { return _groupGameLibrariesTogether; } @@ -81,7 +80,7 @@ public bool GroupGameLibrariesTogether } } - ElementTheme _appTheme = ElementTheme.Default; + private ElementTheme _appTheme = ElementTheme.Default; public ElementTheme AppTheme { get { return _appTheme; } @@ -98,7 +97,7 @@ public ElementTheme AppTheme } } - bool _allowExperimental = false; + private bool _allowExperimental = false; public bool AllowExperimental { get { return _allowExperimental; } @@ -115,8 +114,7 @@ public bool AllowExperimental } } - - bool _allowUntrusted = false; + private bool _allowUntrusted = false; public bool AllowUntrusted { get { return _allowUntrusted; } @@ -150,6 +148,7 @@ public bool HideNotDownloadedVersions } } + private DateTimeOffset _lastRecordsRefresh = DateTimeOffset.MinValue; public DateTimeOffset LastRecordsRefresh { get { return _lastRecordsRefresh; } @@ -166,8 +165,7 @@ public DateTimeOffset LastRecordsRefresh } } - - ulong _lastPromptWasForVersion = 0L; + private ulong _lastPromptWasForVersion = 0L; public ulong LastPromptWasForVersion { get { return _lastPromptWasForVersion; } @@ -184,9 +182,8 @@ public ulong LastPromptWasForVersion } } - // Don't forget to change this back to off. - LoggingLevel _loggingLevel = LoggingLevel.Error; + private LoggingLevel _loggingLevel = LoggingLevel.Error; public LoggingLevel LoggingLevel { get { return _loggingLevel; } @@ -203,7 +200,7 @@ public LoggingLevel LoggingLevel } } - uint _enabledGameLibraries = uint.MaxValue; + private uint _enabledGameLibraries = uint.MaxValue; public uint EnabledGameLibraries { get { return _enabledGameLibraries; } @@ -220,8 +217,7 @@ public uint EnabledGameLibraries } } - - bool _wasLoadingGames = false; + private bool _wasLoadingGames = false; public bool WasLoadingGames { get { return _wasLoadingGames; } @@ -238,18 +234,18 @@ public bool WasLoadingGames } } - void SaveJson() + private void SaveJson() { AsyncHelper.RunSync(() => Storage.SaveSettingsJsonAsync(this)); } - static Settings FromJson() + private static Settings FromJson() { Settings settings = null; var settingsFromJson = AsyncHelper.RunSync(() => Storage.LoadSettingsJsonAsync()); // If we couldn't load settings then save the defaults. - if (settingsFromJson == null) + if (settingsFromJson is null) { settings = new Settings(); settings.SaveJson(); From 3e3cf27853e98c043447103f23815948f156c9dc Mon Sep 17 00:00:00 2001 From: Zagrthos <36556009+Zagrthos@users.noreply.github.com> Date: Wed, 21 Aug 2024 23:39:20 +0200 Subject: [PATCH 05/13] Restructure the hotpath of DLSSPickerControl ctor --- src/UserControls/DLSSPickerControl.xaml.cs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/UserControls/DLSSPickerControl.xaml.cs b/src/UserControls/DLSSPickerControl.xaml.cs index f001c40..a967916 100644 --- a/src/UserControls/DLSSPickerControl.xaml.cs +++ b/src/UserControls/DLSSPickerControl.xaml.cs @@ -34,16 +34,13 @@ public DLSSPickerControl(Game game) this.InitializeComponent(); DataContext = this; - // TODO: If you select an imported DLSS var detectedVersion = DLSSRecords.FirstOrDefault(v => v.MD5Hash == game.CurrentDLSSHash); - if (detectedVersion == null) - { - - } - else + if (detectedVersion is not null) { DLSSRecordsListView.SelectedItem = detectedVersion; } + // TODO: If you select an imported DLSS + // else { } } internal DLSSRecord GetSelectedDLSSRecord() From 80505c52b200c33dbc5b54c534c5b44c9b7c4fd8 Mon Sep 17 00:00:00 2001 From: Zagrthos <36556009+Zagrthos@users.noreply.github.com> Date: Wed, 21 Aug 2024 23:39:38 +0200 Subject: [PATCH 06/13] Formatting of DLSSPickerControl --- src/UserControls/DLSSPickerControl.xaml.cs | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/src/UserControls/DLSSPickerControl.xaml.cs b/src/UserControls/DLSSPickerControl.xaml.cs index a967916..2275d2f 100644 --- a/src/UserControls/DLSSPickerControl.xaml.cs +++ b/src/UserControls/DLSSPickerControl.xaml.cs @@ -1,19 +1,7 @@ -using DLSS_Swapper.Data; -using Microsoft.UI.Xaml; -using Microsoft.UI.Xaml.Controls; -using Microsoft.UI.Xaml.Controls.Primitives; -using Microsoft.UI.Xaml.Data; -using Microsoft.UI.Xaml.Input; -using Microsoft.UI.Xaml.Media; -using Microsoft.UI.Xaml.Navigation; -using MvvmHelpers; -using System; -using System.Collections.Generic; -using System.IO; +using System.Collections.Generic; using System.Linq; -using System.Runtime.InteropServices.WindowsRuntime; -using Windows.Foundation; -using Windows.Foundation.Collections; +using DLSS_Swapper.Data; +using Microsoft.UI.Xaml.Controls; // To learn more about WinUI, the WinUI project structure, // and more about our project templates, see: http://aka.ms/winui-project-info. @@ -22,8 +10,8 @@ namespace DLSS_Swapper.UserControls { public sealed partial class DLSSPickerControl : UserControl { - Game _game; - public List DLSSRecords { get; } = new List(); + private readonly Game _game; + public List DLSSRecords { get; } = []; public DLSSPickerControl(Game game) { From b3837b4b7d6c5aa37cc0d296c139c5064e65c0e1 Mon Sep 17 00:00:00 2001 From: Zagrthos <36556009+Zagrthos@users.noreply.github.com> Date: Wed, 21 Aug 2024 23:39:53 +0200 Subject: [PATCH 07/13] Formatting and improving of SettingsPage.xaml.cs --- src/Pages/SettingsPage.xaml.cs | 53 +++++++++++++--------------------- 1 file changed, 20 insertions(+), 33 deletions(-) diff --git a/src/Pages/SettingsPage.xaml.cs b/src/Pages/SettingsPage.xaml.cs index c9c2417..ea3b5bc 100644 --- a/src/Pages/SettingsPage.xaml.cs +++ b/src/Pages/SettingsPage.xaml.cs @@ -1,27 +1,14 @@ -using CommunityToolkit.WinUI.UI.Controls; -using Microsoft.UI.Xaml; -using Microsoft.UI.Xaml.Controls; -using Microsoft.UI.Xaml.Controls.Primitives; -using Microsoft.UI.Xaml.Data; -using Microsoft.UI.Xaml.Documents; -using Microsoft.UI.Xaml.Input; -using Microsoft.UI.Xaml.Media; -using Microsoft.UI.Xaml.Navigation; -using MvvmHelpers.Commands; -using MvvmHelpers.Interfaces; -using System; +using System; using System.Collections.Generic; +using System.Diagnostics; using System.IO; using System.Linq; -using System.Runtime.InteropServices.WindowsRuntime; using System.Threading.Tasks; -using Windows.Foundation; -using Windows.Foundation.Collections; -using Windows.Foundation.Diagnostics; -using Windows.System; -using Windows.UI.ViewManagement; -using System.Diagnostics; using DLSS_Swapper.UserControls; +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Controls; +using Microsoft.UI.Xaml.Documents; +using MvvmHelpers.Commands; namespace DLSS_Swapper.Pages { @@ -32,7 +19,6 @@ public sealed partial class SettingsPage : Page { //https://github.com/microsoft/Xaml-Controls-Gallery/blob/6450265cc94da5b2fac5e1e22d1be35dc66c402e/XamlControlsGallery/Navigation/NavigationRootPage.xaml.cs#L32 - public string Version => App.CurrentApp.GetVersionString(); private AsyncCommand _checkForUpdateCommand; @@ -60,11 +46,10 @@ public SettingsPage() { this.InitializeComponent(); - // Initilize defaults. - LightThemeRadioButton.IsChecked = Settings.Instance.AppTheme == ElementTheme.Light; - DarkThemeRadioButton.IsChecked = Settings.Instance.AppTheme == ElementTheme.Dark; - DefaultThemeRadioButton.IsChecked = Settings.Instance.AppTheme == ElementTheme.Default; + LightThemeRadioButton.IsChecked = Settings.Instance.AppTheme is ElementTheme.Light; + DarkThemeRadioButton.IsChecked = Settings.Instance.AppTheme is ElementTheme.Dark; + DefaultThemeRadioButton.IsChecked = Settings.Instance.AppTheme is ElementTheme.Default; AllowUntrustedToggleSwitch.IsOn = Settings.Instance.AllowUntrusted; AllowExperimentalToggleSwitch.IsOn = Settings.Instance.AllowExperimental; @@ -74,9 +59,9 @@ public SettingsPage() DataContext = this; } - void ThemeRadioButton_Checked(object sender, RoutedEventArgs e) + private void ThemeRadioButton_Checked(object sender, RoutedEventArgs e) { - if (DataContext == null) + if (DataContext is null) { return; } @@ -98,9 +83,9 @@ void ThemeRadioButton_Checked(object sender, RoutedEventArgs e) } } - void AllowExperimental_Toggled(object sender, RoutedEventArgs e) + private void AllowExperimental_Toggled(object sender, RoutedEventArgs e) { - if (DataContext == null) + if (DataContext is null) { return; } @@ -112,9 +97,9 @@ void AllowExperimental_Toggled(object sender, RoutedEventArgs e) } } - void AllowUntrusted_Toggled(object sender, RoutedEventArgs e) + private void AllowUntrusted_Toggled(object sender, RoutedEventArgs e) { - if (DataContext == null) + if (DataContext is null) { return; } @@ -138,19 +123,21 @@ private void HideNotDownloaded_Toggled(object sender, RoutedEventArgs e) Settings.Instance.HideNotDownloadedVersions = toggleSwitch.IsOn; } } + + private async Task CheckForUpdatesAsync() { IsCheckingForUpdates = true; var githubUpdater = new Data.GitHub.GitHubUpdater(); var newUpdate = await githubUpdater.CheckForNewGitHubRelease(); - if (newUpdate == null) + if (newUpdate is null) { - var dialog = new EasyContentDialog(XamlRoot) { CloseButtonText = "Okay", DefaultButton = ContentDialogButton.Close, Content = "No new updates are available.", }; + await dialog.ShowAsync(); IsCheckingForUpdates = false; @@ -164,7 +151,7 @@ private void HideNotDownloaded_Toggled(object sender, RoutedEventArgs e) private void LoggingComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { - if (DataContext == null) + if (DataContext is null) { return; } From 004c662958f4b555fc74cb57b239731b7a4e0cca Mon Sep 17 00:00:00 2001 From: Zagrthos <36556009+Zagrthos@users.noreply.github.com> Date: Wed, 21 Aug 2024 23:40:06 +0200 Subject: [PATCH 08/13] Formatting and improving of SettingsPage.xaml --- src/Pages/SettingsPage.xaml | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/src/Pages/SettingsPage.xaml b/src/Pages/SettingsPage.xaml index cf7a482..9a93f55 100644 --- a/src/Pages/SettingsPage.xaml +++ b/src/Pages/SettingsPage.xaml @@ -1,12 +1,10 @@  @@ -32,7 +30,6 @@ - - -