diff --git a/CHANGELOG.md b/CHANGELOG.md index 5e30005..bce46f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # GameVault App Changelog +##1.17.1 +Recommended Gamevault Server Version: `v15.0.2` +### Changes +- User registration has also been added to the Admin Panel. +- Better handling of the game settings early access check box +- Added 'getallgames' to the clients query API + ## 1.17.0 Recommended Gamevault Server Version: `v15.0.0` ### Changes diff --git a/gamevault/AssemblyInfo.cs b/gamevault/AssemblyInfo.cs index afcbc90..525d34e 100644 --- a/gamevault/AssemblyInfo.cs +++ b/gamevault/AssemblyInfo.cs @@ -11,7 +11,7 @@ //(used if a resource is not found in the page, // app, or any theme specific resource dictionaries) )] -[assembly: AssemblyVersion("1.17.0.0")] +[assembly: AssemblyVersion("1.17.1.0")] [assembly: AssemblyCopyright("© Phalcode™. All Rights Reserved.")] #if DEBUG [assembly: XmlnsDefinition("debug-mode", "Namespace")] diff --git a/gamevault/Converter/GameSettingsEarlyAccessContentConverter.cs b/gamevault/Converter/GameSettingsEarlyAccessContentConverter.cs new file mode 100644 index 0000000..a2829a8 --- /dev/null +++ b/gamevault/Converter/GameSettingsEarlyAccessContentConverter.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Data; + +namespace gamevault.Converter +{ + internal class GameSettingsEarlyAccessContentConverter : IMultiValueConverter + { + public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) + { + if (values[1]!=null) + { + return values[1]; + } + return values[0]; + } + + public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) + { + return null; + } + } +} diff --git a/gamevault/PipeServiceHandler.cs b/gamevault/PipeServiceHandler.cs index 1bfbaab..186b9ed 100644 --- a/gamevault/PipeServiceHandler.cs +++ b/gamevault/PipeServiceHandler.cs @@ -1,16 +1,18 @@ -using System; +using gamevault.Helper; +using gamevault.Models; +using gamevault.UserControls; +using gamevault.ViewModels; +using System; +using System.Collections; using System.Diagnostics; using System.IO; using System.IO.Pipes; using System.Linq; using System.Security.Principal; +using System.Text; using System.Text.Json; using System.Threading.Tasks; using System.Windows; -using gamevault.Helper; -using gamevault.Models; -using gamevault.UserControls; -using gamevault.ViewModels; using Windows.Devices.Sms; namespace gamevault @@ -697,6 +699,11 @@ public enum ActionQueryEnum /// IsLoggedIn, + /// + /// Returns all Games of the server the current profile is connected to + /// + GetAllGames + } /// @@ -773,6 +780,16 @@ private async Task HandleQuery(CommandOptions options) return installDirectory ?? ""; } + case ActionQueryEnum.GetAllGames: + { + try + { + string result = await WebHelper.GetAsync(@$"{SettingsViewModel.Instance.ServerUrl}/api/games?limit=-1"); + return Convert.ToBase64String(Encoding.UTF8.GetBytes(result)); + } + catch { } + return ""; + } case ActionQueryEnum.GetServerUrl: return SettingsViewModel.Instance.ServerUrl; case ActionQueryEnum.GetAppVersion: diff --git a/gamevault/UserControls/AdminConsoleUserControl.xaml b/gamevault/UserControls/AdminConsoleUserControl.xaml index c2c3d0b..07ef644 100644 --- a/gamevault/UserControls/AdminConsoleUserControl.xaml +++ b/gamevault/UserControls/AdminConsoleUserControl.xaml @@ -73,7 +73,7 @@ - + @@ -90,6 +90,18 @@ + diff --git a/gamevault/UserControls/AdminConsoleUserControl.xaml.cs b/gamevault/UserControls/AdminConsoleUserControl.xaml.cs index dbd994e..1e351dd 100644 --- a/gamevault/UserControls/AdminConsoleUserControl.xaml.cs +++ b/gamevault/UserControls/AdminConsoleUserControl.xaml.cs @@ -266,6 +266,9 @@ private void ServerUpdate_Navigate(object sender, RequestNavigateEventArgs e) e.Handled = true; } - + private void RegistrateUser_Click(object sender, RoutedEventArgs e) + { + MainWindowViewModel.Instance.OpenPopup(new RegistrationUserControl()); + } } } diff --git a/gamevault/UserControls/GameSettingsUserControl.xaml b/gamevault/UserControls/GameSettingsUserControl.xaml index c6595b9..2f2e618 100644 --- a/gamevault/UserControls/GameSettingsUserControl.xaml +++ b/gamevault/UserControls/GameSettingsUserControl.xaml @@ -57,6 +57,7 @@ + @@ -634,7 +635,27 @@ - + + + + + + + + + + + + + + + diff --git a/gamevault/UserControls/GameSettingsUserControl.xaml.cs b/gamevault/UserControls/GameSettingsUserControl.xaml.cs index b6f6d67..fb7b229 100644 --- a/gamevault/UserControls/GameSettingsUserControl.xaml.cs +++ b/gamevault/UserControls/GameSettingsUserControl.xaml.cs @@ -983,7 +983,36 @@ private void KeepData_Click(object sender, RoutedEventArgs e) } catch { } } + #endregion + #region EarlyAccessToggleFix + private bool needEarlyAccessToggleFix = false; + private void CheckBox_Click(object sender, RoutedEventArgs e) + { + try + { + if (needEarlyAccessToggleFix) + { + needEarlyAccessToggleFix = false; + var checkBox = sender as CheckBox; + checkBox.IsChecked = true; + } + } + catch { } + } + + private void CheckBox_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e) + { + try + { + if (ViewModel.UpdateGame?.UserMetadata?.EarlyAccess == null && ViewModel.Game?.Metadata?.EarlyAccess == false) + { + needEarlyAccessToggleFix = true; + } + } + catch { } + } + #endregion } } diff --git a/gamevault/UserControls/LibraryUserControl.xaml.cs b/gamevault/UserControls/LibraryUserControl.xaml.cs index aebdc94..157e685 100644 --- a/gamevault/UserControls/LibraryUserControl.xaml.cs +++ b/gamevault/UserControls/LibraryUserControl.xaml.cs @@ -95,7 +95,7 @@ private async void InputTimerElapsed(object sender, EventArgs e) inputTimer?.Stop(); await Search(); } - + private async Task Search() { Guid currentSearchToken = Guid.NewGuid(); @@ -300,11 +300,11 @@ private string ApplyFilter(string filter) } if (uiFilterEarlyAccess.IsChecked == true) { - filter += "&filter.early_access=$eq:true&filter.metadata.early_access=$eq:true"; + filter += "&filter.metadata.early_access=$eq:true"; } if (uiFilterReleaseDateRangeSelector.IsValid()) { - filter += $"&filter.release_date=$btw:{uiFilterReleaseDateRangeSelector.GetYearFrom()}-01-01,{uiFilterReleaseDateRangeSelector.GetYearTo()}-12-31"; + filter += $"&filter.metadata.release_date=$btw:{uiFilterReleaseDateRangeSelector.GetYearFrom()}-01-01,{uiFilterReleaseDateRangeSelector.GetYearTo()}-12-31"; } string genres = uiFilterGenreSelector.GetSelectedEntries(); if (genres != string.Empty) diff --git a/gamevault/UserControls/SettingsComponents/RegistrationUserControl.xaml b/gamevault/UserControls/SettingsComponents/RegistrationUserControl.xaml new file mode 100644 index 0000000..72043a2 --- /dev/null +++ b/gamevault/UserControls/SettingsComponents/RegistrationUserControl.xaml @@ -0,0 +1,130 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/gamevault/UserControls/SettingsComponents/RegistrationUserControl.xaml.cs b/gamevault/UserControls/SettingsComponents/RegistrationUserControl.xaml.cs new file mode 100644 index 0000000..0f0ffeb --- /dev/null +++ b/gamevault/UserControls/SettingsComponents/RegistrationUserControl.xaml.cs @@ -0,0 +1,156 @@ +using gamevault.Helper; +using gamevault.Models; +using gamevault.ViewModels; +using gamevault.Windows; +using System; +using System.Collections.Generic; +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.SettingsComponents +{ + internal class RegistrationUserControlViewModel : ViewModelBase + { + private LoginUser signupUser { get; set; } + public LoginUser SignupUser + { + get + { + if (signupUser == null) + { + signupUser = new LoginUser(); + } + return signupUser; + } + set { signupUser = value; OnPropertyChanged(); } + } + private BindableServerInfo signUpServerInfo { get; set; } = new BindableServerInfo(); + public BindableServerInfo SignUpServerInfo + { + get { return signUpServerInfo; } + set { signUpServerInfo = value; OnPropertyChanged(); } + } + } + public partial class RegistrationUserControl : UserControl + { + private InputTimer InputTimer { get; set; } + private RegistrationUserControlViewModel ViewModel { get; set; } + public RegistrationUserControl() + { + InitializeComponent(); + ViewModel = new RegistrationUserControlViewModel(); + this.DataContext = ViewModel; + InputTimer = new InputTimer(); + InputTimer.Interval = TimeSpan.FromMilliseconds(400); + InputTimer.Tick += ServerUrlInput_Tick; + try + { + ViewModel.SignupUser.ServerUrl = LoginManager.Instance.GetUserProfile()!.ServerUrl; + } + catch { } + } + private async void UserRegistrationTextBox_KeyDown(object sender, System.Windows.Input.KeyEventArgs e) + { + if (e.Key == System.Windows.Input.Key.Enter) + { + //await SaveAndSignUp(); + } + } + private void ServerUrlInput_TextChanged(object sender, RoutedEventArgs e) + { + InputTimer.Stop(); + InputTimer.Data = ((TextBox)sender).Text; + InputTimer.Start(); + } + private async void ServerUrlInput_Tick(object sender, EventArgs e) + { + try + { + InputTimer.Stop(); + string result = await WebHelper.BaseGetAsync($"{ValidateUriScheme(InputTimer?.Data)}/api/status"); + ServerInfo serverInfo = JsonSerializer.Deserialize(result); + + ViewModel.SignUpServerInfo = new BindableServerInfo(serverInfo); + } + catch (Exception ex) + { + string message = WebExceptionHelper.TryGetServerMessage(ex); + ViewModel.SignUpServerInfo = new BindableServerInfo(message == "" ? "Could not connect to server" : message); + } + } + private string ValidateUriScheme(string uri) + { + if (uri.EndsWith("/")) + { + uri = uri.Substring(0, uri.Length - 1); + } + if (!uri.Contains(System.Uri.UriSchemeHttp)) + { + uri = $"{System.Uri.UriSchemeHttps}://{uri}"; + } + return uri; + } + + private async void RegisterNewUser_Click(object sender, RoutedEventArgs e) + { + try + { + ValidateSignUpData(); + LoginState state = await LoginManager.Instance.Register(ViewModel.SignupUser); + if (state != LoginState.Error) + { + MainWindowViewModel.Instance.ClosePopup(); + if(MainWindowViewModel.Instance.ActiveControl.GetType() == typeof(AdminConsoleUserControl)) + { + await MainWindowViewModel.Instance.AdminConsole.InitUserList(); + } + MainWindowViewModel.Instance.AppBarText = "Successfully registrated User"; + return; + } + MainWindowViewModel.Instance.AppBarText = LoginManager.Instance.GetServerLoginResponseMessage(); + } + catch (Exception ex) + { + MainWindowViewModel.Instance.AppBarText = ex.Message; + } + } + private void ValidateSignUpData() + { + if (string.IsNullOrWhiteSpace(ViewModel.SignupUser.ServerUrl)) + { + throw new Exception("Server URL is not set"); + } + ViewModel.SignupUser.ServerUrl = ValidateUriScheme(ViewModel.SignupUser.ServerUrl); + if (string.IsNullOrWhiteSpace(ViewModel.SignupUser.Password) || string.IsNullOrWhiteSpace(ViewModel.SignupUser.RepeatPassword)) + { + throw new Exception("Password is not set"); + } + if (ViewModel.SignupUser.Password != ViewModel.SignupUser.RepeatPassword) + { + throw new Exception("Password must be equal"); + } + if (string.IsNullOrWhiteSpace(ViewModel.SignupUser.Username)) + { + throw new Exception("Username is not set"); + } + + } + private void Close_Click(object sender, RoutedEventArgs e) + { + MainWindowViewModel.Instance.ClosePopup(); + } + + + } +} diff --git a/gamevault/UserControls/SettingsUserControl.xaml b/gamevault/UserControls/SettingsUserControl.xaml index c56e7f7..34358fc 100644 --- a/gamevault/UserControls/SettingsUserControl.xaml +++ b/gamevault/UserControls/SettingsUserControl.xaml @@ -191,11 +191,12 @@ + - + diff --git a/gamevault/UserControls/SettingsUserControl.xaml.cs b/gamevault/UserControls/SettingsUserControl.xaml.cs index 7f6fb76..445592a 100644 --- a/gamevault/UserControls/SettingsUserControl.xaml.cs +++ b/gamevault/UserControls/SettingsUserControl.xaml.cs @@ -18,11 +18,8 @@ using System.Collections.Generic; using System.Windows.Markup; using gamevault.Helper.Integrations; -using AngleSharp.Dom; -using Microsoft.Web.WebView2.Core; -using Microsoft.Web.WebView2.Wpf; using gamevault.Windows; -using static System.Runtime.InteropServices.JavaScript.JSType; +using gamevault.UserControls.SettingsComponents; namespace gamevault.UserControls {