Added Uplay to RunShortcut

HeliosPlus now runs Uplay Games and
correctly waits until they have exited before
changing back. It won't wait for Uplay updates
however, as I really don't know how Uplay
marks things as being updated. So I don't
know how to look for the updates occurring!
This commit is contained in:
Terry MacDonald
2020-11-15 21:06:38 +13:00
parent c7444e379c
commit a56e68d94e
3 changed files with 49 additions and 19 deletions

View File

@ -151,7 +151,7 @@ namespace HeliosPlus.GameLibraries
} }
} }
public override bool IsUpdating /*public override bool IsUpdating
{ {
get get
{ {
@ -184,7 +184,7 @@ namespace HeliosPlus.GameLibraries
throw; throw;
} }
} }
} }*/
public bool CopyTo(UplayGame uplayGame) public bool CopyTo(UplayGame uplayGame)
{ {
@ -213,10 +213,10 @@ namespace HeliosPlus.GameLibraries
return name + " " + Language.Running; return name + " " + Language.Running;
} }
if (IsUpdating) /*if (IsUpdating)
{ {
return name + " " + Language.Updating; return name + " " + Language.Updating;
} }*/
return name; return name;
} }

View File

@ -321,7 +321,7 @@ namespace HeliosPlus.GameLibraries
// Yay us :). // Yay us :).
// First we want to know the index of the start_game entry to use later // First we want to know the index of the start_game entry to use later
int startGameIndex = uplayEntryLines.FindIndex(a => a.StartsWith(" start_game:")); //int startGameIndex = uplayEntryLines.FindIndex(a => a.StartsWith(" start_game:"));
MatchCollection mc; MatchCollection mc;
// First we check if there are any localization CONSTANTS that we will need to map later. // First we check if there are any localization CONSTANTS that we will need to map later.
@ -346,7 +346,7 @@ namespace HeliosPlus.GameLibraries
// for each game record grab: // for each game record grab:
UplayAppInfo uplayGameAppInfo = new UplayAppInfo(); UplayAppInfo uplayGameAppInfo = new UplayAppInfo();
// name: (lookup the id in lookup table to find the name if needed) /* // name: (lookup the id in lookup table to find the name if needed)
if (uplayEntryLines.Exists(a => a.StartsWith(" name:", StringComparison.InvariantCultureIgnoreCase))) if (uplayEntryLines.Exists(a => a.StartsWith(" name:", StringComparison.InvariantCultureIgnoreCase)))
{ {
mc = Regex.Matches(uplayEntry, @" name\: (.*)"); mc = Regex.Matches(uplayEntry, @" name\: (.*)");
@ -359,11 +359,11 @@ namespace HeliosPlus.GameLibraries
} }
else else
continue; continue;
*/
// icon_image: (lookup the id in lookup table to find the ICON) // icon_image: (lookup the id in lookup table to find the ICON)
if (uplayEntryLines.Exists(a => a.StartsWith(" icon_image:", StringComparison.InvariantCultureIgnoreCase))) /*if (uplayEntryLines.Exists(a => a.StartsWith(" icon_image:", StringComparison.InvariantCultureIgnoreCase)))
{ {
mc = Regex.Matches(uplayEntry, @" icon_image: (.*)"); mc = Regex.Matches(uplayEntry, @"icon_image: (.*)");
string iconImageFileName = mc[0].Groups[1].ToString(); string iconImageFileName = mc[0].Groups[1].ToString();
// if the icon_image contains a localization reference, then dereference it // if the icon_image contains a localization reference, then dereference it
if (localizations.ContainsKey(iconImageFileName)) if (localizations.ContainsKey(iconImageFileName))
@ -376,7 +376,7 @@ namespace HeliosPlus.GameLibraries
{ {
uplayGameAppInfo.GameUplayIconPath = uplayGameIconPath; uplayGameAppInfo.GameUplayIconPath = uplayGameIconPath;
} }
} }*/
// find the exe name looking at root: -> start_game: -> online: -> executables: -> path: -> relative: (get ACU.exe) // find the exe name looking at root: -> start_game: -> online: -> executables: -> path: -> relative: (get ACU.exe)
// Lookup the Game registry key from looking at root: -> start_game: -> online: -> executables: -> working_directory: -> register: (get HKEY_LOCAL_MACHINE\SOFTWARE\Ubisoft\Launcher\Installs\720\InstallDir) // Lookup the Game registry key from looking at root: -> start_game: -> online: -> executables: -> working_directory: -> register: (get HKEY_LOCAL_MACHINE\SOFTWARE\Ubisoft\Launcher\Installs\720\InstallDir)
@ -386,25 +386,55 @@ namespace HeliosPlus.GameLibraries
//if (uplayEntryLines.Find (a => a.StartsWith(" icon_image:", StringComparison.InvariantCultureIgnoreCase))) //if (uplayEntryLines.Find (a => a.StartsWith(" icon_image:", StringComparison.InvariantCultureIgnoreCase)))
bool gotGameIconPath = false;
bool gotGameName = false;
string gameFileName = ""; string gameFileName = "";
bool gotGameFileName = false; bool gotGameFileName = false;
string gameId = ""; string gameId = "";
bool gotGameId = false; bool gotGameId = false;
for (int i = startGameIndex; i<= (startGameIndex+30); i++) for (int i = 0; i <= 50; i++)
{ {
// Stop this loop once we have both filname and gameid // Stop this loop once we have both filname and gameid
if (gotGameFileName && gotGameId) if (gotGameFileName && gotGameId && gotGameIconPath && gotGameName)
break; break;
// This line contains the Game Name
if (uplayEntryLines[i].StartsWith(" name:", StringComparison.InvariantCultureIgnoreCase) && !gotGameName)
{
mc = Regex.Matches(uplayEntryLines[i], @" name\: (.*)");
uplayGameAppInfo.GameName = mc[0].Groups[1].ToString();
// if the name contains a localization reference, then dereference it
if (localizations.ContainsKey(uplayGameAppInfo.GameName))
{
uplayGameAppInfo.GameName = localizations[uplayGameAppInfo.GameName];
}
gotGameName = true;
}
else if (uplayEntryLines[i].StartsWith(" icon_image:", StringComparison.InvariantCultureIgnoreCase) && !gotGameIconPath)
{
mc = Regex.Matches(uplayEntryLines[i], @"icon_image: (.*)");
string iconImageFileName = mc[0].Groups[1].ToString();
// if the icon_image contains a localization reference, then dereference it
if (localizations.ContainsKey(iconImageFileName))
{
iconImageFileName = localizations[iconImageFileName];
}
//61fdd16f06ae08158d0a6d476f1c6bd5.ico
string uplayGameIconPath = _uplayPath + @"data\games\" + iconImageFileName;
if (File.Exists(uplayGameIconPath) && uplayGameIconPath.EndsWith(".ico"))
{
uplayGameAppInfo.GameUplayIconPath = uplayGameIconPath;
}
gotGameIconPath = true;
}
// This line contains the filename // This line contains the filename
if (uplayEntryLines[i].StartsWith(" relative:") && !gotGameFileName) else if (uplayEntryLines[i].StartsWith(" relative:") && !gotGameFileName)
{ {
mc = Regex.Matches(uplayEntryLines[i], @"relative: (.*)"); mc = Regex.Matches(uplayEntryLines[i], @"relative: (.*)");
gameFileName = mc[0].Groups[1].ToString(); gameFileName = mc[0].Groups[1].ToString();
gotGameFileName = true; gotGameFileName = true;
} }
// This line contains the registryKey // This line contains the registryKey
if (uplayEntryLines[i].StartsWith(" register: HKEY_LOCAL_MACHINE") && !gotGameId) else if (uplayEntryLines[i].StartsWith(" register: HKEY_LOCAL_MACHINE") && !gotGameId)
{ {
// Lookup the GameId within the registry key // Lookup the GameId within the registry key
mc = Regex.Matches(uplayEntryLines[i], @"Installs\\(\d+)\\InstallDir"); mc = Regex.Matches(uplayEntryLines[i], @"Installs\\(\d+)\\InstallDir");
@ -419,7 +449,7 @@ namespace HeliosPlus.GameLibraries
// From that we lookup the actual game path // From that we lookup the actual game path
uplayGameAppInfo.GameInstallDir = Path.GetFullPath(uplayGameInstallKey.GetValue("InstallDir", "").ToString()).TrimEnd('\\'); uplayGameAppInfo.GameInstallDir = Path.GetFullPath(uplayGameInstallKey.GetValue("InstallDir", "").ToString()).TrimEnd('\\');
uplayGameAppInfo.GameExe = uplayGameAppInfo.GameInstallDir + gameFileName; uplayGameAppInfo.GameExe = Path.Combine(uplayGameAppInfo.GameInstallDir,gameFileName);
uplayGameAppInfo.GameID = uint.Parse(gameId); uplayGameAppInfo.GameID = uint.Parse(gameId);
// Then we have the gameID, the thumbimage, the icon, the name, the exe path // Then we have the gameID, the thumbimage, the icon, the name, the exe path

View File

@ -731,7 +731,7 @@ namespace HeliosPlus
} }
// Start the URI Handler to run Uplay // Start the URI Handler to run Uplay
Console.WriteLine($"Starting Steam Game: {uplayGameToRun.Name}"); Console.WriteLine($"Starting Uplay Game: {uplayGameToRun.Name}");
var uplayProcess = Process.Start(address); var uplayProcess = Process.Start(address);
// Wait for Steam game to update if needed // Wait for Steam game to update if needed
@ -745,10 +745,10 @@ namespace HeliosPlus
Thread.Sleep(300); Thread.Sleep(300);
if (!uplayGameToRun.IsUpdating) /*if (!uplayGameToRun.IsUpdating)
{ {
ticks += 300; ticks += 300;
} }*/
} }
// Store the Steam Process ID for later // Store the Steam Process ID for later