From b6d55c81056fab859f8e62f6c4a75d75fca5ac1e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 30 Oct 2023 04:45:28 +0000 Subject: [PATCH 01/15] Bump Microsoft.Xaml.Behaviors.Wpf from 1.1.39 to 1.1.77 Bumps [Microsoft.Xaml.Behaviors.Wpf](https://github.com/microsoft/XamlBehaviorsWpf) from 1.1.39 to 1.1.77. - [Release notes](https://github.com/microsoft/XamlBehaviorsWpf/releases) - [Commits](https://github.com/microsoft/XamlBehaviorsWpf/compare/v1.1.39...v1.1.77) --- updated-dependencies: - dependency-name: Microsoft.Xaml.Behaviors.Wpf dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Gavilya/Gavilya.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gavilya/Gavilya.csproj b/Gavilya/Gavilya.csproj index 79ce1d2..1815a81 100644 --- a/Gavilya/Gavilya.csproj +++ b/Gavilya/Gavilya.csproj @@ -51,7 +51,7 @@ - + From 7fd0f30e58120a0ec3768fcab272c84a923a23ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Peyronnet?= Date: Sat, 4 Nov 2023 11:41:46 +0100 Subject: [PATCH 02/15] Added translations (#426) --- Gavilya/Properties/Resources.Designer.cs | 29 +++++++++++++++++++++++- Gavilya/Properties/Resources.en-US.resx | 9 ++++++++ Gavilya/Properties/Resources.fr-FR.resx | 9 ++++++++ Gavilya/Properties/Resources.resx | 9 ++++++++ Gavilya/Properties/Resources.zh-CN.resx | 9 ++++++++ 5 files changed, 64 insertions(+), 1 deletion(-) diff --git a/Gavilya/Properties/Resources.Designer.cs b/Gavilya/Properties/Resources.Designer.cs index 645d71f..9b18d0e 100644 --- a/Gavilya/Properties/Resources.Designer.cs +++ b/Gavilya/Properties/Resources.Designer.cs @@ -124,7 +124,7 @@ public static string AddGame { } /// - /// Looks up a localized string similar to Add a game by clicking on the "Add" button or drag and drop an executable file here.. + /// Looks up a localized string similar to Add a game by clicking on the "Add" button.. /// public static string AddGameWelcome { get { @@ -672,6 +672,15 @@ public static string EditProfile { } } + /// + /// Looks up a localized string similar to Enable search keyboard shortcut. + /// + public static string EnableSearchShortcut { + get { + return ResourceManager.GetString("EnableSearchShortcut", resourceCulture); + } + } + /// /// Looks up a localized string similar to Epic Games Store. /// @@ -1203,6 +1212,15 @@ public static string InvalidGameNumber { } } + /// + /// Looks up a localized string similar to Keyboard shortcut. + /// + public static string KeybordShortcut { + get { + return ResourceManager.GetString("KeybordShortcut", resourceCulture); + } + } + /// /// Looks up a localized string similar to Language. /// @@ -2130,6 +2148,15 @@ public static string SearchF { } } + /// + /// Looks up a localized string similar to Keyboard shortcut related settings.. + /// + public static string SearchKeyboardShortcutDesc { + get { + return ResourceManager.GetString("SearchKeyboardShortcutDesc", resourceCulture); + } + } + /// /// Looks up a localized string similar to Second. /// diff --git a/Gavilya/Properties/Resources.en-US.resx b/Gavilya/Properties/Resources.en-US.resx index dccad61..60c4ee8 100644 --- a/Gavilya/Properties/Resources.en-US.resx +++ b/Gavilya/Properties/Resources.en-US.resx @@ -1008,4 +1008,13 @@ Migrate from v3 + + Keyboard shortcut + + + Enable search keyboard shortcut + + + Keyboard shortcut related settings. + \ No newline at end of file diff --git a/Gavilya/Properties/Resources.fr-FR.resx b/Gavilya/Properties/Resources.fr-FR.resx index 8c86fe3..bed1c89 100644 --- a/Gavilya/Properties/Resources.fr-FR.resx +++ b/Gavilya/Properties/Resources.fr-FR.resx @@ -1008,4 +1008,13 @@ Migrer depuis la v3 + + Raccourci clavier + + + Activer le raccourci clavier de recherche + + + Paramètres liés aux raccourcis clavier. + \ No newline at end of file diff --git a/Gavilya/Properties/Resources.resx b/Gavilya/Properties/Resources.resx index bc0825f..f6da385 100644 --- a/Gavilya/Properties/Resources.resx +++ b/Gavilya/Properties/Resources.resx @@ -1009,4 +1009,13 @@ Migrate from v3 + + Keyboard shortcut + + + Enable search keyboard shortcut + + + Keyboard shortcut related settings. + \ No newline at end of file diff --git a/Gavilya/Properties/Resources.zh-CN.resx b/Gavilya/Properties/Resources.zh-CN.resx index 7b610fc..5f9f29c 100644 --- a/Gavilya/Properties/Resources.zh-CN.resx +++ b/Gavilya/Properties/Resources.zh-CN.resx @@ -1008,4 +1008,13 @@ 从 v3 迁移 + + 键盘快捷键 + + + 启用搜索快捷键 + + + 键盘快捷键相关设置 + \ No newline at end of file From 5fd675731376bad3a15efff2bb7256414a3565d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Peyronnet?= Date: Sat, 4 Nov 2023 11:42:06 +0100 Subject: [PATCH 03/15] Added the possibility to disable Search shortcut (#426) --- Gavilya/App.xaml.cs | 2 + Gavilya/Models/Settings.cs | 3 ++ Gavilya/ViewModels/MainViewModel.cs | 7 +++- .../ViewModels/Settings/SearchViewModel.cs | 13 ++++++ Gavilya/Views/SettingsViews/SearchView.xaml | 42 +++++++++++++++++++ 5 files changed, 66 insertions(+), 1 deletion(-) diff --git a/Gavilya/App.xaml.cs b/Gavilya/App.xaml.cs index c49417e..d53a1f8 100644 --- a/Gavilya/App.xaml.cs +++ b/Gavilya/App.xaml.cs @@ -53,6 +53,8 @@ protected override void OnStartup(StartupEventArgs e) Language.zh_CN => "zh-CN", }); + currentProfile.Settings.EnableSearchShortcut ??= true; + if (currentProfile.Settings.MakeAutoSave && IsSaveDay(currentProfile.Settings.AutoSaveDay) && !File.Exists($@"{currentProfile.Settings.SavePath}\GavilyaProfiles_{DateTime.Now:yyyy_MM_dd}.g4v")) { profiles.Backup(currentProfile.Settings.SavePath); diff --git a/Gavilya/Models/Settings.cs b/Gavilya/Models/Settings.cs index b1e5a82..ed56af8 100644 --- a/Gavilya/Models/Settings.cs +++ b/Gavilya/Models/Settings.cs @@ -100,6 +100,8 @@ public class Settings /// public bool ShowHiddenGames { get; set; } + public bool? EnableSearchShortcut { get; set; } + public Settings() { IsFirstRun = true; @@ -117,6 +119,7 @@ public Settings() DefaultView = View.Card; CurrentTheme = ""; ShowHiddenGames = false; + EnableSearchShortcut = true; } } diff --git a/Gavilya/ViewModels/MainViewModel.cs b/Gavilya/ViewModels/MainViewModel.cs index 73ce17e..986bac7 100644 --- a/Gavilya/ViewModels/MainViewModel.cs +++ b/Gavilya/ViewModels/MainViewModel.cs @@ -196,7 +196,12 @@ private void RegisterKeyBoardShortcuts() }; var openSearch = Combination.FromString("Control+K"); - Action openSearchAction = () => { SearchOpen = !SearchOpen; SearchHeight = CurrentSettings.NumberOfSearchResultsToDisplay * 45; }; + Action openSearchAction = () => + { + if (!(_currentSettings.EnableSearchShortcut ?? true)) return; + SearchOpen = !SearchOpen; + SearchHeight = CurrentSettings.NumberOfSearchResultsToDisplay * 45; + }; var assignment = new Dictionary { diff --git a/Gavilya/ViewModels/Settings/SearchViewModel.cs b/Gavilya/ViewModels/Settings/SearchViewModel.cs index d716699..0ba61c8 100644 --- a/Gavilya/ViewModels/Settings/SearchViewModel.cs +++ b/Gavilya/ViewModels/Settings/SearchViewModel.cs @@ -36,7 +36,11 @@ public class SearchViewModel : ViewModelBase private string _maxResults; public string MaxResults { get => _maxResults; set { _maxResults = value; OnPropertyChanged(nameof(MaxResults)); } } + private bool _enableShortcut; + public bool EnableShortcut { get => _enableShortcut; set { _enableShortcut = value; OnPropertyChanged(nameof(EnableShortcut)); } } + public ICommand SaveCommand { get; } + public ICommand EnableShortcutCommand { get; } public SearchViewModel(Profile profile, ProfileData profileData, MainViewModel mainViewModel) { _profile = profile; @@ -44,8 +48,10 @@ public SearchViewModel(Profile profile, ProfileData profileData, MainViewModel m _mainViewModel = mainViewModel; MaxResults = profile.Settings.NumberOfSearchResultsToDisplay.ToString(); + EnableShortcut = profile.Settings.EnableSearchShortcut ?? true; SaveCommand = new RelayCommand(Save); + EnableShortcutCommand = new RelayCommand(SetEnableShortcut); } private void Save(object? obj) @@ -57,4 +63,11 @@ private void Save(object? obj) _mainViewModel.CurrentSettings = _profileData.Profiles[_profileData.Profiles.IndexOf(_profile)].Settings; } } + + private void SetEnableShortcut(object? obj) + { + _profileData.Profiles[_profileData.Profiles.IndexOf(_profile)].Settings.EnableSearchShortcut = EnableShortcut; + _profileData.Save(); + _mainViewModel.CurrentSettings = _profileData.Profiles[_profileData.Profiles.IndexOf(_profile)].Settings; + } } diff --git a/Gavilya/Views/SettingsViews/SearchView.xaml b/Gavilya/Views/SettingsViews/SearchView.xaml index 98b588b..033808a 100644 --- a/Gavilya/Views/SettingsViews/SearchView.xaml +++ b/Gavilya/Views/SettingsViews/SearchView.xaml @@ -100,6 +100,48 @@ + + + + + + + + + + + + + From 42e21e6a5a88937c8c4aaf4b841ccb25b02aaa57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Peyronnet?= Date: Sat, 4 Nov 2023 11:58:52 +0100 Subject: [PATCH 04/15] Added the possibility to get a random game (#427) --- Gavilya/Models/GameList.cs | 7 +++++++ Gavilya/ViewModels/HomePageViewModel.cs | 15 ++++++++++++++- Gavilya/ViewModels/MainViewModel.cs | 4 ++-- Gavilya/ViewModels/NavBarViewModel.cs | 2 +- Gavilya/Views/HomePageView.xaml | 23 ++++++++++++++++++++++- 5 files changed, 46 insertions(+), 5 deletions(-) diff --git a/Gavilya/Models/GameList.cs b/Gavilya/Models/GameList.cs index 0d75d1a..0ee0b5b 100644 --- a/Gavilya/Models/GameList.cs +++ b/Gavilya/Models/GameList.cs @@ -236,4 +236,11 @@ public GameList GetRecommandedGames() return new(); } } + + public Game GetRandomGame() + { + Random random = new(); + int i = random.Next(0, Count); + return this[i]; + } } diff --git a/Gavilya/ViewModels/HomePageViewModel.cs b/Gavilya/ViewModels/HomePageViewModel.cs index 11d8858..9e74b41 100644 --- a/Gavilya/ViewModels/HomePageViewModel.cs +++ b/Gavilya/ViewModels/HomePageViewModel.cs @@ -35,6 +35,7 @@ namespace Gavilya.ViewModels; public class HomePageViewModel : ViewModelBase { private readonly GameList _games; + private readonly List _tags; private readonly MainViewModel _mainViewModel; public string GreetingMessage => $"{Properties.Resources.Hello} {Environment.UserName}{Properties.Resources.ExclamationMark}"; public List Favorites => _games.Where(g => g.IsFavorite && (_mainViewModel.CurrentSettings.ShowHiddenGames ? true : !g.IsHidden)).Select(g => new MinimalGameViewModel(g, _games, _mainViewModel)).ToList(); @@ -49,9 +50,13 @@ public class HomePageViewModel : ViewModelBase private Visibility _placeholderVis = Visibility.Collapsed; public Visibility PlaceholderVis { get => _placeholderVis; set { _placeholderVis = value; OnPropertyChanged(nameof(PlaceholderVis)); } } - public HomePageViewModel(GameList games, MainViewModel mainViewModel) + + public ICommand RandomGameCommand { get; } + + public HomePageViewModel(GameList games, List tags, MainViewModel mainViewModel) { _games = games; + _tags = tags; _mainViewModel = mainViewModel; if (_games.Count == 0) @@ -60,5 +65,13 @@ public HomePageViewModel(GameList games, MainViewModel mainViewModel) ContentVis = Visibility.Collapsed; } StatsView = new(_games, _mainViewModel.CurrentSettings.ShowHiddenGames); + + RandomGameCommand = new RelayCommand(GetRandomGame); + } + + private void GetRandomGame(object? obj) + { + var game = _games.GetRandomGame(); + _mainViewModel.CurrentViewModel = new GamePageViewModel(game, _games, _tags, _mainViewModel); } } diff --git a/Gavilya/ViewModels/MainViewModel.cs b/Gavilya/ViewModels/MainViewModel.cs index 986bac7..b75793c 100644 --- a/Gavilya/ViewModels/MainViewModel.cs +++ b/Gavilya/ViewModels/MainViewModel.cs @@ -124,7 +124,7 @@ public MainViewModel(Window window, Profile profile, ProfileData profiles, Page? Page.Library => new LibPageViewModel(Games, profile.Tags, this), Page.Recent => new RecentPageViewModel(Games, profile.Tags, this), Page.Profile => new ProfileViewModel(profile, profiles, Games, this), - _ => new HomePageViewModel(Games, this) + _ => new HomePageViewModel(Games, profile.Tags, this) }; Query = ""; @@ -266,7 +266,7 @@ private void DeleteGames(object obj) CurrentViewModel = CurrentViewModel switch { - HomePageViewModel => new HomePageViewModel(Games, this), + HomePageViewModel => new HomePageViewModel(Games, _tags, this), RecentPageViewModel => new RecentPageViewModel(Games, _tags, this), LibPageViewModel => new LibPageViewModel(Games, _tags, this), _ => CurrentViewModel diff --git a/Gavilya/ViewModels/NavBarViewModel.cs b/Gavilya/ViewModels/NavBarViewModel.cs index c718781..d774ff5 100644 --- a/Gavilya/ViewModels/NavBarViewModel.cs +++ b/Gavilya/ViewModels/NavBarViewModel.cs @@ -108,7 +108,7 @@ public NavBarViewModel(MainViewModel mainViewModel, Profile profile, ProfileData private void HomePage(object? obj) { - _mainViewModel.CurrentViewModel = new HomePageViewModel(Games, _mainViewModel); + _mainViewModel.CurrentViewModel = new HomePageViewModel(Games, _tags, _mainViewModel); } private void LibraryPage(object? obj) diff --git a/Gavilya/Views/HomePageView.xaml b/Gavilya/Views/HomePageView.xaml index e06ca06..6647d07 100644 --- a/Gavilya/Views/HomePageView.xaml +++ b/Gavilya/Views/HomePageView.xaml @@ -8,7 +8,7 @@ xmlns:local="clr-namespace:Gavilya.Views" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:vm="clr-namespace:Gavilya.ViewModels" - d:DesignHeight="450" + d:DesignHeight="1450" d:DesignWidth="800" FontFamily="..\Fonts\#Hauora" Foreground="{DynamicResource Foreground}" @@ -115,6 +115,27 @@ FontSize="18" FontWeight="ExtraBold" Text="{x:Static lang:Resources.RecommandedGames}" /> + From 4d7f820cf81886be2017c338353ff497b5dee5f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Peyronnet?= Date: Sat, 4 Nov 2023 12:00:47 +0100 Subject: [PATCH 05/15] Version 4.2.0.2311-pre1 --- Gavilya/Gavilya.csproj | 2 +- Gavilya/Helpers/Context.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Gavilya/Gavilya.csproj b/Gavilya/Gavilya.csproj index 1815a81..efb09d1 100644 --- a/Gavilya/Gavilya.csproj +++ b/Gavilya/Gavilya.csproj @@ -8,7 +8,7 @@ True app.manifest Gavilya - 4.1.0.2310 + 4.2.0.2311-pre1 Léo Corporation Gavilya is a simple game launcher for Windows. © 2023 diff --git a/Gavilya/Helpers/Context.cs b/Gavilya/Helpers/Context.cs index b282ea6..30c098e 100644 --- a/Gavilya/Helpers/Context.cs +++ b/Gavilya/Helpers/Context.cs @@ -25,6 +25,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE namespace Gavilya.Helpers; public static class Context { - public static string Version => "4.1.0.2310"; + public static string Version => "4.2.0.2311-pre1"; public static string LastVersionLink => "https://raw.githubusercontent.com/Leo-Corporation/LeoCorp-Docs/master/Liens/Update%20System/Gavilya/Version.txt"; } From fd50890b5f19acd4f203fa2d673b0bd076929385 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Peyronnet?= Date: Sun, 5 Nov 2023 11:00:43 +0100 Subject: [PATCH 06/15] Added tooltip text (#428) --- Gavilya/Properties/Resources.Designer.cs | 9 +++++++++ Gavilya/Properties/Resources.en-US.resx | 3 +++ Gavilya/Properties/Resources.fr-FR.resx | 3 +++ Gavilya/Properties/Resources.resx | 3 +++ Gavilya/Properties/Resources.zh-CN.resx | 3 +++ 5 files changed, 21 insertions(+) diff --git a/Gavilya/Properties/Resources.Designer.cs b/Gavilya/Properties/Resources.Designer.cs index 9b18d0e..26cf5e3 100644 --- a/Gavilya/Properties/Resources.Designer.cs +++ b/Gavilya/Properties/Resources.Designer.cs @@ -1815,6 +1815,15 @@ public static string PagesNames { } } + /// + /// Looks up a localized string similar to Pin/Unpin window. + /// + public static string PinUnpinWindow { + get { + return ResourceManager.GetString("PinUnpinWindow", resourceCulture); + } + } + /// /// Looks up a localized string similar to Platforms. /// diff --git a/Gavilya/Properties/Resources.en-US.resx b/Gavilya/Properties/Resources.en-US.resx index 60c4ee8..cf3da34 100644 --- a/Gavilya/Properties/Resources.en-US.resx +++ b/Gavilya/Properties/Resources.en-US.resx @@ -1017,4 +1017,7 @@ Keyboard shortcut related settings. + + Pin/Unpin window + \ No newline at end of file diff --git a/Gavilya/Properties/Resources.fr-FR.resx b/Gavilya/Properties/Resources.fr-FR.resx index bed1c89..cefa358 100644 --- a/Gavilya/Properties/Resources.fr-FR.resx +++ b/Gavilya/Properties/Resources.fr-FR.resx @@ -1017,4 +1017,7 @@ Paramètres liés aux raccourcis clavier. + + Epingler/Désépingler la fenêtre + \ No newline at end of file diff --git a/Gavilya/Properties/Resources.resx b/Gavilya/Properties/Resources.resx index f6da385..ed1e659 100644 --- a/Gavilya/Properties/Resources.resx +++ b/Gavilya/Properties/Resources.resx @@ -1018,4 +1018,7 @@ Keyboard shortcut related settings. + + Pin/Unpin window + \ No newline at end of file diff --git a/Gavilya/Properties/Resources.zh-CN.resx b/Gavilya/Properties/Resources.zh-CN.resx index 5f9f29c..86d8f44 100644 --- a/Gavilya/Properties/Resources.zh-CN.resx +++ b/Gavilya/Properties/Resources.zh-CN.resx @@ -1017,4 +1017,7 @@ 键盘快捷键相关设置 + + 插针/解针窗口 + \ No newline at end of file From 8eece92ffdff1b1c3755d9a1eb5856ea49df141e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Peyronnet?= Date: Sun, 5 Nov 2023 11:01:07 +0100 Subject: [PATCH 07/15] Added the possibility to pin the window (#428) --- Gavilya/MainWindow.xaml | 29 +++++++++++++++++++++++++---- Gavilya/ViewModels/MainViewModel.cs | 13 +++++++++++++ 2 files changed, 38 insertions(+), 4 deletions(-) diff --git a/Gavilya/MainWindow.xaml b/Gavilya/MainWindow.xaml index 68bde9b..c9e496a 100644 --- a/Gavilya/MainWindow.xaml +++ b/Gavilya/MainWindow.xaml @@ -62,6 +62,7 @@ + - + + + + + + diff --git a/Gavilya/Components/ExecutableSelectorComponent.xaml.cs b/Gavilya/Components/ExecutableSelectorComponent.xaml.cs new file mode 100644 index 0000000..86a8a41 --- /dev/null +++ b/Gavilya/Components/ExecutableSelectorComponent.xaml.cs @@ -0,0 +1,39 @@ +/* +MIT License + +Copyright (c) Léo Corporation + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ + +using System.Windows.Controls; + +namespace Gavilya.Components +{ + /// + /// Interaction logic for ExecutableSelectorComponent.xaml + /// + public partial class ExecutableSelectorComponent : UserControl + { + public ExecutableSelectorComponent() + { + InitializeComponent(); + } + } +} diff --git a/Gavilya/ViewModels/ExecutableViewModel.cs b/Gavilya/ViewModels/ExecutableViewModel.cs new file mode 100644 index 0000000..bccbc14 --- /dev/null +++ b/Gavilya/ViewModels/ExecutableViewModel.cs @@ -0,0 +1,54 @@ +/* +MIT License + +Copyright (c) Léo Corporation + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ + +using Gavilya.Commands; +using System.Windows.Input; + +namespace Gavilya.ViewModels; + +public class ExecutableViewModel : ViewModelBase +{ + private readonly GameEditionViewModel _gameEditionViewModel; + + public string Name { get; } + public string FilePath { get; } + + public ICommand ClickCommand { get; } + + public ExecutableViewModel(string name, string filePath, GameEditionViewModel gameEditionViewModel) + { + Name = name; + FilePath = filePath; + _gameEditionViewModel = gameEditionViewModel; + + ClickCommand = new RelayCommand(Click); + } + + private void Click(object? obj) + { + _gameEditionViewModel.Name = Name; + _gameEditionViewModel.Command = FilePath; + _gameEditionViewModel.IsExeSelectorOpen = false; + } +} From 4e3e094d54efa75a663986b1a97c836a79408251 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Peyronnet?= Date: Sun, 5 Nov 2023 12:00:18 +0100 Subject: [PATCH 09/15] Added Game scanner (#429) --- Gavilya/Services/GameScannerService.cs | 61 ++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 Gavilya/Services/GameScannerService.cs diff --git a/Gavilya/Services/GameScannerService.cs b/Gavilya/Services/GameScannerService.cs new file mode 100644 index 0000000..e9ec770 --- /dev/null +++ b/Gavilya/Services/GameScannerService.cs @@ -0,0 +1,61 @@ +/* +MIT License + +Copyright (c) Léo Corporation + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ + +using Gavilya.ViewModels; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Gavilya.Services; + +public class GameScannerService +{ + public List ScanForExecutables(string directory, GameEditionViewModel gameEditionViewModel) + { + List executableFiles = new(); + + try + { + // Recursively search for files with .exe extension in the directory and its subdirectories + foreach (string filePath in Directory.GetFiles(directory, "*.*", SearchOption.AllDirectories) + .Where(file => file.EndsWith(".exe", StringComparison.OrdinalIgnoreCase)) + ) + { + string fileName = Path.GetFileName(filePath); + FileVersionInfo fileVersionInfo = FileVersionInfo.GetVersionInfo(filePath); // Get the version + executableFiles.Add(new(string.IsNullOrEmpty(fileVersionInfo.ProductName) ? fileName : fileVersionInfo.ProductName, filePath, gameEditionViewModel)); + } + + return executableFiles; + } + catch + { + return executableFiles; + } + } +} From 4ad792e030627906f15a55a5ab90d200e65b5492 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Peyronnet?= Date: Sun, 5 Nov 2023 12:00:32 +0100 Subject: [PATCH 10/15] Added Scan button text (#429) --- Gavilya/Properties/Resources.Designer.cs | 9 +++++++++ Gavilya/Properties/Resources.en-US.resx | 3 +++ Gavilya/Properties/Resources.fr-FR.resx | 3 +++ Gavilya/Properties/Resources.resx | 3 +++ Gavilya/Properties/Resources.zh-CN.resx | 3 +++ 5 files changed, 21 insertions(+) diff --git a/Gavilya/Properties/Resources.Designer.cs b/Gavilya/Properties/Resources.Designer.cs index 26cf5e3..f0fbabe 100644 --- a/Gavilya/Properties/Resources.Designer.cs +++ b/Gavilya/Properties/Resources.Designer.cs @@ -2121,6 +2121,15 @@ public static string SaveSettings { } } + /// + /// Looks up a localized string similar to Scan a directory. + /// + public static string ScanDirectory { + get { + return ResourceManager.GetString("ScanDirectory", resourceCulture); + } + } + /// /// Looks up a localized string similar to Screenshots. /// diff --git a/Gavilya/Properties/Resources.en-US.resx b/Gavilya/Properties/Resources.en-US.resx index cf3da34..8d0f33a 100644 --- a/Gavilya/Properties/Resources.en-US.resx +++ b/Gavilya/Properties/Resources.en-US.resx @@ -1020,4 +1020,7 @@ Pin/Unpin window + + Scan a directory + \ No newline at end of file diff --git a/Gavilya/Properties/Resources.fr-FR.resx b/Gavilya/Properties/Resources.fr-FR.resx index cefa358..718055e 100644 --- a/Gavilya/Properties/Resources.fr-FR.resx +++ b/Gavilya/Properties/Resources.fr-FR.resx @@ -1020,4 +1020,7 @@ Epingler/Désépingler la fenêtre + + Scanner un dossier + \ No newline at end of file diff --git a/Gavilya/Properties/Resources.resx b/Gavilya/Properties/Resources.resx index ed1e659..2531ffe 100644 --- a/Gavilya/Properties/Resources.resx +++ b/Gavilya/Properties/Resources.resx @@ -1021,4 +1021,7 @@ Pin/Unpin window + + Scan a directory + \ No newline at end of file diff --git a/Gavilya/Properties/Resources.zh-CN.resx b/Gavilya/Properties/Resources.zh-CN.resx index 86d8f44..6e02995 100644 --- a/Gavilya/Properties/Resources.zh-CN.resx +++ b/Gavilya/Properties/Resources.zh-CN.resx @@ -1020,4 +1020,7 @@ 插针/解针窗口 + + 扫描目录 + \ No newline at end of file From 5bbd0e22fafa022911a36528328787ccd01b6e40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Peyronnet?= Date: Sun, 5 Nov 2023 12:00:48 +0100 Subject: [PATCH 11/15] Added the possibility to scan a directory for executables (#429) --- Gavilya/ViewModels/ExecutableViewModel.cs | 4 +- Gavilya/ViewModels/GameEditionViewModel.cs | 25 ++++++++ Gavilya/Views/GameEditionView.xaml | 66 ++++++++++++++++++++++ 3 files changed, 93 insertions(+), 2 deletions(-) diff --git a/Gavilya/ViewModels/ExecutableViewModel.cs b/Gavilya/ViewModels/ExecutableViewModel.cs index bccbc14..d5ba736 100644 --- a/Gavilya/ViewModels/ExecutableViewModel.cs +++ b/Gavilya/ViewModels/ExecutableViewModel.cs @@ -36,8 +36,8 @@ public class ExecutableViewModel : ViewModelBase public ICommand ClickCommand { get; } - public ExecutableViewModel(string name, string filePath, GameEditionViewModel gameEditionViewModel) - { + public ExecutableViewModel(string name, string filePath, GameEditionViewModel gameEditionViewModel) + { Name = name; FilePath = filePath; _gameEditionViewModel = gameEditionViewModel; diff --git a/Gavilya/ViewModels/GameEditionViewModel.cs b/Gavilya/ViewModels/GameEditionViewModel.cs index 2b1a26d..737aee1 100644 --- a/Gavilya/ViewModels/GameEditionViewModel.cs +++ b/Gavilya/ViewModels/GameEditionViewModel.cs @@ -27,6 +27,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE using Gavilya.Helpers; using Gavilya.Models; using Gavilya.Models.Rawg; +using Gavilya.Services; using Microsoft.Win32; using System; using System.Collections.Generic; @@ -163,6 +164,9 @@ public bool CanExecute private bool _isUwpOpen = false; public bool IsUwpOpen { get => _isUwpOpen; set { _isUwpOpen = value; OnPropertyChanged(nameof(IsUwpOpen)); } } + private bool _isExeSelectorOpen = false; + public bool IsExeSelectorOpen { get => _isExeSelectorOpen; set { _isExeSelectorOpen = value; OnPropertyChanged(nameof(IsExeSelectorOpen)); } } + private bool _isRawgOpen = false; public bool IsRawgOpen { get => _isRawgOpen; set { _isRawgOpen = value; OnPropertyChanged(nameof(IsRawgOpen)); } } @@ -194,6 +198,9 @@ public bool CanExecute private List _uwpApps; public List UwpApps { get => _uwpApps; set { _uwpApps = value; OnPropertyChanged(nameof(UwpApps)); } } + private List _exeApps; + public List ExeApps { get => _exeApps; set { _exeApps = value; OnPropertyChanged(nameof(ExeApps)); } } + private Visibility _dragAreaVis = Visibility.Collapsed; public Visibility DragAreaVis { get => _dragAreaVis; set { _dragAreaVis = value; OnPropertyChanged(nameof(DragAreaVis)); } } @@ -229,6 +236,8 @@ public bool CanExecute public ICommand ShowConvertSectionCommand { get; } public ICommand ProcessHelpCommand { get; } public ICommand DropCommand { get; } + public ICommand ScanCommand { get; } + public ICommand CloseExeSelectorCommand { get; } /// /// This constructor is used when editing an exisiting game. @@ -255,6 +264,7 @@ public GameEditionViewModel(Game game, GameList games, List tags, MainViewM ShowConvertSectionCommand = new RelayCommand(ShowConvert); ProcessHelpCommand = new RelayCommand(ShowProcessHelp); DropCommand = new RelayCommand(ExecuteDrop); + ScanCommand = new RelayCommand(Scan); // Load properties Name = game.Name; @@ -322,6 +332,7 @@ public GameEditionViewModel(GameType gameType, GameList games, List tags, M RawgSearchCommand = new RelayCommand(SearchRawg); ProcessHelpCommand = new RelayCommand(ShowProcessHelp); DropCommand = new RelayCommand(ExecuteDrop); + ScanCommand = new RelayCommand(Scan); SelectedTags = new(); @@ -483,4 +494,18 @@ private void ShowProcessHelp(object? obj) { MessageBox.Show(Properties.Resources.ProcessNameHelp, Properties.Resources.Help, MessageBoxButton.OK, MessageBoxImage.Information); } + + private void Scan(object? obj) + { + using System.Windows.Forms.FolderBrowserDialog dialog = new(); + System.Windows.Forms.DialogResult result = dialog.ShowDialog(); + + if (result == System.Windows.Forms.DialogResult.OK) + { + string selectedPath = dialog.SelectedPath; + GameScannerService gameScannerService = new(); + ExeApps = gameScannerService.ScanForExecutables(selectedPath, this); + IsExeSelectorOpen = true; + } + } } diff --git a/Gavilya/Views/GameEditionView.xaml b/Gavilya/Views/GameEditionView.xaml index fdb05e4..53fd895 100644 --- a/Gavilya/Views/GameEditionView.xaml +++ b/Gavilya/Views/GameEditionView.xaml @@ -86,13 +86,79 @@ +