From 7142e206b61cdc0c5702896fb865c921bf26c235 Mon Sep 17 00:00:00 2001 From: Yelo420 Date: Mon, 25 Dec 2023 19:29:39 +0100 Subject: [PATCH 01/12] Implemented to display whether and how many filters are active Bug fix: Standard release date filters did not work if no release year was set in existing games Bug fix: If the profile picture of another user has been changed, the profile picture has been changed in the top left-hand corner. --- CHANGELOG.md | 7 +++ .../GeneralControls/DateRangeSelector.xaml | 17 ++++++ .../GeneralControls/DateRangeSelector.xaml.cs | 56 +++++++++++++++++++ .../GeneralControls/TagSelector.xaml.cs | 5 +- .../UserControls/NewLibraryUserControl.xaml | 34 ++++++----- .../NewLibraryUserControl.xaml.cs | 26 +++++---- .../UserSettingsUserControl.xaml.cs | 5 +- gamevault/ViewModels/NewLibraryViewModel.cs | 6 ++ gamevault/ViewModels/SettingsViewModel.cs | 2 +- 9 files changed, 127 insertions(+), 31 deletions(-) create mode 100644 gamevault/UserControls/GeneralControls/DateRangeSelector.xaml create mode 100644 gamevault/UserControls/GeneralControls/DateRangeSelector.xaml.cs diff --git a/CHANGELOG.md b/CHANGELOG.md index abbc04c..5f06c83 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # GameVault App Changelog +## 1.8.1 +Recommended Gamevault Server Version: `v10.0.1` +### Changes +- Implemented to display whether and how many filters are active +- Bug fix: Standard release date filters did not work if no release year was set in existing games +- Bug fix: If the profile picture of another user has been changed, the profile picture has been changed in the top left-hand corner. + ## 1.8.0 Recommended Gamevault Server Version: `v10.0.0` ### Changes diff --git a/gamevault/UserControls/GeneralControls/DateRangeSelector.xaml b/gamevault/UserControls/GeneralControls/DateRangeSelector.xaml new file mode 100644 index 0000000..270d5dd --- /dev/null +++ b/gamevault/UserControls/GeneralControls/DateRangeSelector.xaml @@ -0,0 +1,17 @@ + + + + + + + + + diff --git a/gamevault/UserControls/GeneralControls/DateRangeSelector.xaml.cs b/gamevault/UserControls/GeneralControls/DateRangeSelector.xaml.cs new file mode 100644 index 0000000..e66fb4c --- /dev/null +++ b/gamevault/UserControls/GeneralControls/DateRangeSelector.xaml.cs @@ -0,0 +1,56 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Text.RegularExpressions; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace gamevault.UserControls +{ + /// + /// Interaction logic for DateRangeSelector.xaml + /// + public partial class DateRangeSelector : UserControl + { + public string YearToPlaceholder { get; set; } + public string YearFromPlaceholder { get; set; } = "1980"; + public event EventHandler EntriesUpdated; + public DateRangeSelector() + { + InitializeComponent(); + YearToPlaceholder = DateTime.Now.Year.ToString(); + this.DataContext = this; + } + public bool IsValid() + { + return uiFilterYearFrom.Text != string.Empty && uiFilterYearTo.Text != string.Empty; + } + public string GetYearFrom() + { + return uiFilterYearFrom.Text; + } + public string GetYearTo() + { + return uiFilterYearTo.Text; + } + private void StackPanel_LostFocus(object sender, RoutedEventArgs e) + { + if(EntriesUpdated!=null && IsValid()) + EntriesUpdated(this, e); + } + private void YearSelector_Changed(object sender, TextCompositionEventArgs e) + { + Regex regex = new Regex("[^0-9]+"); + e.Handled = (((TextBox)e.Source).Text == "" && e.Text == "0") || regex.IsMatch(e.Text); + } + } +} diff --git a/gamevault/UserControls/GeneralControls/TagSelector.xaml.cs b/gamevault/UserControls/GeneralControls/TagSelector.xaml.cs index 0d8873e..d90b986 100644 --- a/gamevault/UserControls/GeneralControls/TagSelector.xaml.cs +++ b/gamevault/UserControls/GeneralControls/TagSelector.xaml.cs @@ -39,7 +39,6 @@ public Selection SelectionType public event EventHandler EntriesUpdated; private bool loaded = false; private InputTimer debounceTimer { get; set; } - private Genre_Tag[] selectionEntries { get; set; } private List selectedEntries = new List(); public TagSelector() { @@ -69,6 +68,10 @@ public string GetSelectedEntries() { return string.Join(",", selectedEntries.Select(o => o.Name)); } + public bool HasEntries() + { + return selectedEntries.Any(); + } private async void DebounceTimerElapsed(object? sender, EventArgs e) { debounceTimer.Stop(); diff --git a/gamevault/UserControls/NewLibraryUserControl.xaml b/gamevault/UserControls/NewLibraryUserControl.xaml index 095bbe8..95a9a71 100644 --- a/gamevault/UserControls/NewLibraryUserControl.xaml +++ b/gamevault/UserControls/NewLibraryUserControl.xaml @@ -54,16 +54,18 @@ - - - - - - - - - - + + + + + + + + + + + + @@ -72,15 +74,11 @@ - + - - - - - + - + @@ -220,7 +218,7 @@ - + diff --git a/gamevault/UserControls/NewLibraryUserControl.xaml.cs b/gamevault/UserControls/NewLibraryUserControl.xaml.cs index 3d42862..0d8a564 100644 --- a/gamevault/UserControls/NewLibraryUserControl.xaml.cs +++ b/gamevault/UserControls/NewLibraryUserControl.xaml.cs @@ -39,7 +39,6 @@ public NewLibraryUserControl() ViewModel = new NewLibraryViewModel(); this.DataContext = ViewModel; InitTimer(); - uiFilterYearTo.Text = DateTime.Now.Year.ToString(); } private async void Library_Loaded(object sender, RoutedEventArgs e) { @@ -219,9 +218,9 @@ private string ApplyFilter(string filter) { filter += "&filter.early_access=$eq:true"; } - if (int.TryParse(uiFilterYearFrom.Text, out int yearFrom) && int.TryParse(uiFilterYearTo.Text, out int yearTo)) + if (uiFilterReleaseDateRangeSelector.IsValid()) { - filter += $"&filter.release_date=$btw:{yearFrom}-01-01,{yearTo}-12-31"; + filter += $"&filter.release_date=$btw:{uiFilterReleaseDateRangeSelector.GetYearFrom()}-01-01,{uiFilterReleaseDateRangeSelector.GetYearTo()}-12-31"; } string genres = uiFilterGenreSelector.GetSelectedEntries(); if (genres != string.Empty) @@ -242,13 +241,10 @@ private void SelectedGameFilterSortBy_SelectionChanged(object sender, SelectionC } private async void FilterUpdated(object sender, EventArgs e) { + RefreshFilterCounter(); await Search(); } - private void YearSelector_Changed(object sender, TextCompositionEventArgs e) - { - Regex regex = new Regex("[^0-9]+"); - e.Handled = (((TextBox)e.Source).Text == "" && e.Text == "0") || regex.IsMatch(e.Text); - } + private async void RandomGame_Click(object sender, MouseButtonEventArgs e) { @@ -291,6 +287,18 @@ private async void Download_Click(object sender, MouseButtonEventArgs e) e.Handled = true; await MainWindowViewModel.Instance.Downloads.TryStartDownload((Game)(((FrameworkElement)sender).DataContext)); } + private void RefreshFilterCounter() + { + int filterCount = 0; + filterCount += uiFilterGameTypeSelector.HasEntries() ? 1 : 0; + filterCount += uiFilterGenreSelector.HasEntries() ? 1 : 0; + filterCount += uiFilterTagSelector.HasEntries() ? 1 : 0; + filterCount += uiFilterEarlyAccess.IsOn ? 1 : 0; + filterCount += ViewModel.SelectedGameFilterSortBy.Key != "Title" ? 1 : 0; + //filterCount += ViewModel.OrderByValue != "DESC" ? 1 : 0; + filterCount += (uiFilterReleaseDateRangeSelector.IsValid()) ? 1 : 0; + ViewModel.FilterCounter = filterCount == 0 ? string.Empty : filterCount.ToString(); + } public void RefreshGame(Game gameToRefreshParam) { Game? gameToRefresh = ViewModel.GameCards.Where(g => g.ID == gameToRefreshParam.ID).FirstOrDefault(); @@ -301,7 +309,5 @@ public void RefreshGame(Game gameToRefreshParam) ViewModel.GameCards[index] = gameToRefreshParam; } } - - } } diff --git a/gamevault/UserControls/UserSettingsUserControl.xaml.cs b/gamevault/UserControls/UserSettingsUserControl.xaml.cs index d86bc2c..4109170 100644 --- a/gamevault/UserControls/UserSettingsUserControl.xaml.cs +++ b/gamevault/UserControls/UserSettingsUserControl.xaml.cs @@ -281,9 +281,12 @@ await Task.Run(() => //Update Data Context for Library. So that the images are also refreshed there directly if (success) { - MainWindowViewModel.Instance.UserIcon = ViewModel.User; await MainWindowViewModel.Instance.AdminConsole.InitUserList(); await MainWindowViewModel.Instance.Community.InitUserList(); + if (LoginManager.Instance.GetCurrentUser().ID == ViewModel.User.ID) + { + MainWindowViewModel.Instance.UserIcon = ViewModel.User; + } } } catch (WebException ex) diff --git a/gamevault/ViewModels/NewLibraryViewModel.cs b/gamevault/ViewModels/NewLibraryViewModel.cs index f337820..b839da6 100644 --- a/gamevault/ViewModels/NewLibraryViewModel.cs +++ b/gamevault/ViewModels/NewLibraryViewModel.cs @@ -17,6 +17,7 @@ internal class NewLibraryViewModel : ViewModelBase private Visibility scrollToTopVisibility { get; set; } private Visibility filterVisibility = Visibility.Collapsed; private KeyValuePair m_SelectedGameFilterSortBy { get; set; } + private string filterCounter { get; set; } #endregion public ObservableCollection GameCards { @@ -68,5 +69,10 @@ public KeyValuePair SelectedGameFilterSortBy set { m_SelectedGameFilterSortBy = value; } } public string OrderByValue = "ASC"; + public string FilterCounter + { + get { return filterCounter; } + set { filterCounter = value; OnPropertyChanged(); } + } } } diff --git a/gamevault/ViewModels/SettingsViewModel.cs b/gamevault/ViewModels/SettingsViewModel.cs index 102e01c..39cac32 100644 --- a/gamevault/ViewModels/SettingsViewModel.cs +++ b/gamevault/ViewModels/SettingsViewModel.cs @@ -181,7 +181,7 @@ public string Version { get { - return "1.8.0"; + return "1.8.1"; } } From 1606bc7e6fc9fc6b5e6c11663a8ba49aa4ebb073 Mon Sep 17 00:00:00 2001 From: Yelo420 Date: Mon, 25 Dec 2023 19:50:19 +0100 Subject: [PATCH 02/12] Bug fix: Game Type is now displayed in more user friendly values --- CHANGELOG.md | 1 + gamevault/Models/Genre_Tag.cs | 1 + .../GeneralControls/TagSelector.xaml.cs | 32 ++++++++----------- .../UserControls/NewLibraryUserControl.xaml | 2 +- 4 files changed, 16 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5f06c83..5c46509 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ Recommended Gamevault Server Version: `v10.0.1` - Implemented to display whether and how many filters are active - Bug fix: Standard release date filters did not work if no release year was set in existing games - Bug fix: If the profile picture of another user has been changed, the profile picture has been changed in the top left-hand corner. +- Bug fix: Game Type is now displayed in more user friendly values ## 1.8.0 Recommended Gamevault Server Version: `v10.0.0` diff --git a/gamevault/Models/Genre_Tag.cs b/gamevault/Models/Genre_Tag.cs index e20c3cc..bcdd69b 100644 --- a/gamevault/Models/Genre_Tag.cs +++ b/gamevault/Models/Genre_Tag.cs @@ -15,5 +15,6 @@ public struct Genre_Tag public int? RawgId { get; set; } [JsonPropertyName("name")] public string? Name { get; set; } + public string? OriginName { get; set; } } } diff --git a/gamevault/UserControls/GeneralControls/TagSelector.xaml.cs b/gamevault/UserControls/GeneralControls/TagSelector.xaml.cs index d90b986..15b991a 100644 --- a/gamevault/UserControls/GeneralControls/TagSelector.xaml.cs +++ b/gamevault/UserControls/GeneralControls/TagSelector.xaml.cs @@ -1,24 +1,15 @@ -using ControlzEx.Standard; -using gamevault.Converter; +using gamevault.Converter; using gamevault.Helper; using gamevault.Models; using gamevault.ViewModels; using System; using System.Collections.Generic; -using System.ComponentModel.Design; using System.Linq; -using System.Text; using System.Text.Json; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Navigation; -using System.Windows.Shapes; namespace gamevault.UserControls { @@ -66,6 +57,9 @@ private void InitTimer() } public string GetSelectedEntries() { + if (SelectionType == Selection.GameType) + return string.Join(",", selectedEntries.Select(o => o.OriginName)); + return string.Join(",", selectedEntries.Select(o => o.Name)); } public bool HasEntries() @@ -109,16 +103,16 @@ await Task.Run(() => } else { - //EnumDescriptionConverter conv = new EnumDescriptionConverter(); - //List list = new List(); - //foreach (GameType type in Enum.GetValues(typeof(GameType))) - //{ - // if (type == GameType.UNDETECTABLE) - // continue; + EnumDescriptionConverter conv = new EnumDescriptionConverter(); + List list = new List(); + foreach (GameType type in Enum.GetValues(typeof(GameType))) + { + if (type == GameType.UNDETECTABLE) + continue; - // list.Add(new Genre_Tag() { DisplayName = type.ToString(), Name = (string)conv.Convert(type, null, null, null) }); - //} - data = new Genre_Tag[3] { new Genre_Tag() { Name = "WINDOWS_SETUP" }, new Genre_Tag() { Name = "WINDOWS_PORTABLE" }, new Genre_Tag() { Name = "LINUX_PORTABLE" } }; + list.Add(new Genre_Tag() { OriginName = type.ToString(), Name = (string)conv.Convert(type, null, null, null) }); + } + data = list.ToArray(); data = data.Where(x => x.Name.Contains(debounceTimer.Data, StringComparison.OrdinalIgnoreCase)).ToArray(); } uiSelectionEntries.ItemsSource = data; diff --git a/gamevault/UserControls/NewLibraryUserControl.xaml b/gamevault/UserControls/NewLibraryUserControl.xaml index 95a9a71..7f18f09 100644 --- a/gamevault/UserControls/NewLibraryUserControl.xaml +++ b/gamevault/UserControls/NewLibraryUserControl.xaml @@ -55,7 +55,7 @@ - + From fadbdb223bc38a773bf11e5b85a8aae6ae7c6745 Mon Sep 17 00:00:00 2001 From: Yelo420 Date: Mon, 25 Dec 2023 23:08:21 +0100 Subject: [PATCH 03/12] Added clear all filters Button --- CHANGELOG.md | 1 + .../GeneralControls/DateRangeSelector.xaml.cs | 8 +- .../GeneralControls/TagSelector.xaml | 4 +- .../GeneralControls/TagSelector.xaml.cs | 5 + .../GeneralControls/UserEditUserControl.xaml | 32 ------ .../UserEditUserControl.xaml.cs | 97 ------------------- .../UserControls/NewLibraryUserControl.xaml | 25 ++++- .../NewLibraryUserControl.xaml.cs | 14 +++ gamevault/ViewModels/NewLibraryViewModel.cs | 2 +- 9 files changed, 51 insertions(+), 137 deletions(-) delete mode 100644 gamevault/UserControls/GeneralControls/UserEditUserControl.xaml delete mode 100644 gamevault/UserControls/GeneralControls/UserEditUserControl.xaml.cs diff --git a/CHANGELOG.md b/CHANGELOG.md index 5c46509..8e25821 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ Recommended Gamevault Server Version: `v10.0.1` ### Changes - Implemented to display whether and how many filters are active +- Added clear all filters Button - Bug fix: Standard release date filters did not work if no release year was set in existing games - Bug fix: If the profile picture of another user has been changed, the profile picture has been changed in the top left-hand corner. - Bug fix: Game Type is now displayed in more user friendly values diff --git a/gamevault/UserControls/GeneralControls/DateRangeSelector.xaml.cs b/gamevault/UserControls/GeneralControls/DateRangeSelector.xaml.cs index e66fb4c..00abefe 100644 --- a/gamevault/UserControls/GeneralControls/DateRangeSelector.xaml.cs +++ b/gamevault/UserControls/GeneralControls/DateRangeSelector.xaml.cs @@ -42,10 +42,14 @@ public string GetYearTo() { return uiFilterYearTo.Text; } + public void ClearSelection() + { + uiFilterYearFrom.Text = string.Empty; uiFilterYearTo.Text = string.Empty; + } private void StackPanel_LostFocus(object sender, RoutedEventArgs e) { - if(EntriesUpdated!=null && IsValid()) - EntriesUpdated(this, e); + if (EntriesUpdated != null && IsValid()) + EntriesUpdated(this, e); } private void YearSelector_Changed(object sender, TextCompositionEventArgs e) { diff --git a/gamevault/UserControls/GeneralControls/TagSelector.xaml b/gamevault/UserControls/GeneralControls/TagSelector.xaml index c0a0274..ad60a70 100644 --- a/gamevault/UserControls/GeneralControls/TagSelector.xaml +++ b/gamevault/UserControls/GeneralControls/TagSelector.xaml @@ -18,9 +18,9 @@ - + - + diff --git a/gamevault/UserControls/GeneralControls/TagSelector.xaml.cs b/gamevault/UserControls/GeneralControls/TagSelector.xaml.cs index 15b991a..3e3ff83 100644 --- a/gamevault/UserControls/GeneralControls/TagSelector.xaml.cs +++ b/gamevault/UserControls/GeneralControls/TagSelector.xaml.cs @@ -66,6 +66,11 @@ public bool HasEntries() { return selectedEntries.Any(); } + public void ClearEntries() + { + selectedEntries.Clear(); + uiSelectedEntries.ItemsSource = null; + } private async void DebounceTimerElapsed(object? sender, EventArgs e) { debounceTimer.Stop(); diff --git a/gamevault/UserControls/GeneralControls/UserEditUserControl.xaml b/gamevault/UserControls/GeneralControls/UserEditUserControl.xaml deleted file mode 100644 index 6fa8310..0000000 --- a/gamevault/UserControls/GeneralControls/UserEditUserControl.xaml +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - - - - -