From 401e76c6e421aea0e576fe14b1630e1d4fae39a5 Mon Sep 17 00:00:00 2001 From: Terry MacDonald Date: Sat, 14 Nov 2020 18:00:57 +1300 Subject: [PATCH] Can create Uplay shortcuts now Added support to read Uplay games and to load them into the interface. Also added the ability to save the Uplay shortcuts. Now need to test and then add the ability to run Uplay Games! --- HeliosPlus/GameLibraries/SteamLibrary.cs | 4 +-- HeliosPlus/GameLibraries/UplayLibrary.cs | 4 +-- HeliosPlus/UIForms/ShortcutForm.cs | 35 ++++++++++++++++-------- 3 files changed, 28 insertions(+), 15 deletions(-) diff --git a/HeliosPlus/GameLibraries/SteamLibrary.cs b/HeliosPlus/GameLibraries/SteamLibrary.cs index 7c6883a..63a41b3 100644 --- a/HeliosPlus/GameLibraries/SteamLibrary.cs +++ b/HeliosPlus/GameLibraries/SteamLibrary.cs @@ -17,7 +17,7 @@ namespace HeliosPlus.GameLibraries { #region Class Variables // Common items to the class - private static List _allSteamGames = new List(); + private static List _allSteamGames = new List(); private static string steamAppIdRegex = @"/^[0-9A-F]{1,10}$"; private static string _steamExe; private static string _steamPath; @@ -52,7 +52,7 @@ namespace HeliosPlus.GameLibraries #endregion #region Class Properties - public static List AllInstalledGames + public static List AllInstalledGames { get { diff --git a/HeliosPlus/GameLibraries/UplayLibrary.cs b/HeliosPlus/GameLibraries/UplayLibrary.cs index 7c998b0..28bc461 100644 --- a/HeliosPlus/GameLibraries/UplayLibrary.cs +++ b/HeliosPlus/GameLibraries/UplayLibrary.cs @@ -19,7 +19,7 @@ namespace HeliosPlus.GameLibraries { #region Class Variables // Common items to the class - private static List _allUplayGames = new List(); + private static List _allUplayGames = new List(); private static string uplayAppIdRegex = @"/^[0-9A-F]{1,10}$"; private static string _uplayExe; private static string _uplayPath; @@ -51,7 +51,7 @@ namespace HeliosPlus.GameLibraries #endregion #region Class Properties - public static List AllInstalledGames + public static List AllInstalledGames { get { diff --git a/HeliosPlus/UIForms/ShortcutForm.cs b/HeliosPlus/UIForms/ShortcutForm.cs index 37d1782..955b849 100644 --- a/HeliosPlus/UIForms/ShortcutForm.cs +++ b/HeliosPlus/UIForms/ShortcutForm.cs @@ -27,6 +27,7 @@ namespace HeliosPlus.UIForms private ShortcutPermanence _permanence = ShortcutPermanence.Temporary; List _startPrograms = new List(); private ShortcutItem _shortcutToEdit = null; + List allGames; private bool _isNewShortcut = true; private bool _isUnsaved = true; private bool _loadedShortcut = false; @@ -451,22 +452,27 @@ namespace HeliosPlus.UIForms } // If the game is a SteamGame - /*else if (txt_game_launcher.Text == SupportedGameLibrary.Uplay.ToString()) + else if (txt_game_launcher.Text == SupportedGameLibrary.Uplay.ToString()) { // Find the UplayGame - _steamGameToUse = (from UplayGame in SteamLibrary.AllInstalledGames where UplayGame.GameId == _shortcutToEdit.GameAppId).First(); + _gameToUse = new GameStruct(); + _gameToUse.GameToPlay = (from uplayGame in SteamLibrary.AllInstalledGames where uplayGame.Id == _gameId select uplayGame).First(); + _gameToUse.StartTimeout = Convert.ToUInt32(nud_timeout_game.Value); + _gameToUse.GameArguments = txt_args_game.Text; + _gameToUse.GameArgumentsRequired = cb_args_game.Checked; - _shortcutToEdit.UpdateGameShortcut( - Name, + _shortcutToEdit = new ShortcutItem( + txt_shortcut_save_name.Text, _profileToUse, - _steamGameToUse, + _gameToUse, _permanence, - _steamGameToUse.GameIconPath, + _gameToUse.GameToPlay.IconPath, _startPrograms, - _autoName + _autoName, + _uuid ); - }*/ + } } else if (rb_standalone.Checked) { @@ -700,9 +706,15 @@ namespace HeliosPlus.UIForms bool foundChosenProfileInLoadedProfiles = false; ProfileItem chosenProfile = null; + // Populate a full list of games + // Start with the Steam Games + allGames = SteamLibrary.AllInstalledGames; + // Then add the Uplay Games + allGames.AddRange(UplayLibrary.AllInstalledGames); - // Load the Games ListView - foreach (var game in SteamLibrary.AllInstalledGames.OrderBy(game => game.Name)) + + // Load the Steam Games into the Games ListView + foreach (var game in allGames.OrderBy(game => game.Name)) { // Get the bitmap out of the IconPath // IconPath can be an ICO, or an EXE @@ -734,6 +746,7 @@ namespace HeliosPlus.UIForms }); } + // If it is a new Shortcut then we don't have to load anything! if (_isNewShortcut) { @@ -989,7 +1002,7 @@ namespace HeliosPlus.UIForms if (lv_games.SelectedItems.Count > 0) { txt_game_name.Text = lv_games.SelectedItems[0].Text; - foreach (SteamGame game in SteamLibrary.AllInstalledGames) + foreach (Game game in allGames) { if (game.Name == txt_game_name.Text) {