Skip to content

Commit

Permalink
Fix issue starting games and launchers via protocol after switch to .…
Browse files Browse the repository at this point in the history
…NET 5 and fixes related to search; Add platforms: Arc, Plarium, Rockstar, and Wargaming.net (#45)

* Add IGClient

Also updates to README.md and icon for Battle.net

* Better Amazon implementation by ingesting SQLite database

* Switch to .ini; File browser for export shortcuts

* Switch config items from .json to .ini
* First pass at new feature: Export all shortcuts for a platform to a given folder

* Fixes for small list icons

* Fix small list icons, and enable them by default
Also:
* Don't show Steamworks Common Redistributables

* Additional fixes for #32, misc.

Miscellaneous:
* Add a variable (on by default) to use new campbell terminal colors when clearing image area with images < 48 pt resolution
* Use new configuration item to determine whether to do deeper icon scan instead of whether images are enabled at the moment
* Add a struct for volatile configuration variables when we don't want changes to be saved; e.g., users of conhost and other shells won't have images disabled for good when they run with the other shell

* Fixes for .ini change

* Update to Converter.cs after .ini change
* Undo half-completed move from glc-last.json to .ini
Also:
* Fix command-line only bug
* Put log in .exe's folder
* Allow hyphen (-) in addition to slash (/) for command-line parameters
* Specify which game will be launched with /1 in help

* Add launcher launching

Also:
* Fix reversed logic on fallback icon search setting
* Begin work on in-game settings menu

* Update README.md

* Fix missing Steam aliases

* Update README.md

* Update README.md

* Update README.md

* Update README.md

* Add structure for New games category

* Add New games platform

Also:
* Quit automatically if no games are found.
* Add checks for missing registry keys to prevent spamming logs.
* Fix redundant "WARNING: ERROR" logging.
* Add font detection (disabled for now) so "Raster Fonts" users are warned about lack of proper Unicode support

* Add IsNew field to db code

* Add IsInstalled field and "Not installed" category for future use

* Add Paradox Launcher; Scan for not-installed games

(Not-installed scan disabled by default for now.) Currently only works with Amazon, itch, Indiegala, and Paradox (other platforms will require dealing with web APIs). Trying to start a not-installed game will open appropriate client and in some cases will attempt to install it. Not-installed games are sorted to bottom by default.

* Update README.md

* Go back to doing an alphabetic sort on first scan (even where default sort is frequency, i.e., number of launches)

* Get Steam not-installed games

Note this method requires the user's profile be set as public, and DLCs are included in the list.
Also:
* Enable not-installed game scanning by default.
* Fix broken input mode
* Fix bug where frequency sort was reversed
* Output current selection on input row (helps distinguish games with long titles)

* Update README.md

* Add selected game's platform to right side of bottom row

Also:
* Fix bug in Steam alias generation

* Remove duplicate info bar code

* Add GOG SQLite database parsing

* Update GLC_Social.png

* Improve Big Fish implementation

* Longer sleep to prevent image issues after add of infobar

* Fix for Steam sometimes using an alternate syntax in libraryfolders.vdf

Also some experiments for Microsoft Store support (disabled)

* Oops, forgot to comment out something from Microsoft Store

* Launch Galaxy to install/run GOG games (necessary for syncing saves)

* Minimize Galaxy after launch, fix Bethesda bug, misc. path smarts

* Collect Ubisoft not-installed games

* Add Oculus platform

* Update README.md

* Update Platform.cs

* Platforms moved to their own classes

* Platforms now extend an interface for better extensibility
* Add Oculus platform
* Download images for not-installed games

* Another omnibus

* Move to .NET 5 as preparation for GLC2 and possible cross-platform support.
* Automatically add last run date
* Add rating and allow user to adjust it with +/- (by default)
* More flexibility in sort
* Sort between last run, frequency, rating, and alphabetic only with F7 (by default)
* Syntax simplification
* Experiments with Microsoft Store (enabled for debug builds only)

* Add alias and rating to info bar

Also:
* If currently sorting by rating, then ask for a number rather than using the increment/decrement methods

* Fix Battle.net bug

Also:
* More syntax simplification

* Fix Bethesda bug

* Better game library detection for Battle.net

Also:
* Add number of runs to game database [frequency is an interesting synthesis of recent datetime and number of runs that isn't fully captured by the two numbers, but having the simple number might be nice as well]
* Import some statistics from launcher databases [though perhaps setting(s) should be made to disable this behavior]

* Get proper titles for Oculus games from database blob

* Fix Uplay bug

* Get not-installed Oculus games

* Remove some Oculus debug messages

* Fix Paradox debug message

* Fix issue starting games via protocol after switch to .NET 5

* Fix issue starting launchers via protocol after switch to .NET 5

* Fix issues related to search: #36 #38 #43

* Add Rockstar platform

Also:
* Stop Oculus service before scanning (otherwise database is locked)
* Fix double-counting games when multiple regkey ignore entries are present

* Add Arc platform

* Add Plarium and Wargaming.net platforms

* Fix Wargaming.net bugs
  • Loading branch information
Nutzzz authored Oct 29, 2021
1 parent 5013f12 commit 92bb36e
Show file tree
Hide file tree
Showing 24 changed files with 898 additions and 202 deletions.
93 changes: 49 additions & 44 deletions GameLauncher_Console/GameLauncher_Console/ConsoleHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -511,8 +511,6 @@ public int DisplayMenu(CConfig.ConfigVolatile cfgv, CConfig.Hotkeys keys, CConfi
if (m_ConsoleState == ConsoleState.cState_Insert)
{
code = HandleInsertMenu(nStartY, nStopY, cfgv, cols, false, false, ref game, options);
if (code > -1)
CDock.m_nCurrentSelection = code;
CLogger.LogDebug("HandleInsertMenu:{0},{1}", code, CDock.m_nCurrentSelection);
}
else //if (m_ConsoleState == ConsoleState.cState_Navigate)
Expand Down Expand Up @@ -567,7 +565,11 @@ public int HandleNavigationMenu(int nStartY, int nStopY, CConfig.ConfigVolatile
Console.CursorVisible = false;

ConsoleKey key;
int nLastSelection = CDock.m_nCurrentSelection;
int nLastSelection = 0;
if (IsSelectionValid(CDock.m_nCurrentSelection, options.Length))
nLastSelection = CDock.m_nCurrentSelection;
else
CDock.m_nCurrentSelection = 0;

EnlargeWindow(nStartY, options);

Expand All @@ -585,20 +587,20 @@ public int HandleNavigationMenu(int nStartY, int nStopY, CConfig.ConfigVolatile
{
int maxTitles = (Math.Min(9, Console.WindowHeight - nStartY - CDock.INPUT_BOTTOM_CUSHION - CDock.INPUT_ITEM_CUSHION - 1));
options = GetPlatformTitles(GamePlatform.All).ToArray();
if (DoGameSearch(game, maxTitles, options, out string[] optionsNew, out int nMatches) && nMatches > 0)
if (DoGameSearch(game, maxTitles, options, out int nMatches) && nMatches > 0)
{
CDock.m_nSelectedPlatform = (int)GamePlatform.Search;
CDock.m_nSelectedGame = 0;
nPage = 0;
options = optionsNew;
options = GetPlatformTitles(GamePlatform.Search).ToArray();
if ((bool)CConfig.GetConfigBool(CConfig.CFG_USECMD))
{
if (optionsNew.Length == 1) //nMatches == 1)
if (options.Length == 1) //nMatches == 1)
return (int)DockSelection.cSel_Default;
return (int)DockSelection.cSel_Exit;
}

//DrawMenuTitle(cols);
DrawMenuTitle(cols);
}
else
{
Expand Down Expand Up @@ -626,6 +628,9 @@ public int HandleNavigationMenu(int nStartY, int nStopY, CConfig.ConfigVolatile
if (cfgv.imageSize > 0 && cfgv.imageBorder)
CConsoleImage.ShowImageBorder(CDock.sizeImage, CDock.locImage, CDock.IMG_BORDER_X_CUSHION, CDock.IMG_BORDER_Y_CUSHION);

if (!IsSelectionValid(CDock.m_nCurrentSelection, options.Length))
CDock.m_nCurrentSelection = 0;

if (m_MenuType == MenuType.cType_List)
DrawListMenu(CDock.m_nCurrentSelection, nPage, nStartY, nStopY, cfgv, cols, options);

Expand Down Expand Up @@ -658,7 +663,8 @@ public int HandleNavigationMenu(int nStartY, int nStopY, CConfig.ConfigVolatile
if (CDock.m_nSelectedPlatform > -1)
{
CGame selectedGame = GetPlatformGame((GamePlatform)CDock.m_nSelectedPlatform, CDock.m_nCurrentSelection);
CConsoleImage.ShowImage(CDock.m_nCurrentSelection, selectedGame.Title, selectedGame.Icon, false, CDock.sizeImage, CDock.locImage, imageColour);
if (selectedGame != null)
CConsoleImage.ShowImage(CDock.m_nCurrentSelection, selectedGame.Title, selectedGame.Icon, false, CDock.sizeImage, CDock.locImage, imageColour);
}
else
CConsoleImage.ShowImage(CDock.m_nCurrentSelection, options[CDock.m_nCurrentSelection], options[CDock.m_nCurrentSelection], true, CDock.sizeImage, CDock.locImage, imageColour);
Expand Down Expand Up @@ -866,18 +872,20 @@ public int HandleInsertMenu(int nStartY, int nStopY, CConfig.ConfigVolatile cfgv
{
int maxTitles = (Math.Min(9, Console.WindowHeight - nStartY - CDock.INPUT_BOTTOM_CUSHION - CDock.INPUT_ITEM_CUSHION - 1));
options = GetPlatformTitles(GamePlatform.All).ToArray();
if (DoGameSearch(game, maxTitles, options, out string[] optionsNew, out int nMatches) && nMatches > 0)
if (DoGameSearch(game, maxTitles, options, out int nMatches) && nMatches > 0)
{
CDock.m_nSelectedPlatform = (int)GamePlatform.Search;
options = optionsNew;
CDock.m_nSelectedGame = 0;
nPage = 0;
options = GetPlatformTitles(GamePlatform.Search).ToArray();
if ((bool)CConfig.GetConfigBool(CConfig.CFG_USECMD))
{
if (optionsNew.Length == 1) //nMatches == 1)
if (options.Length == 1) //nMatches == 1)
return (int)DockSelection.cSel_Default;
return (int)DockSelection.cSel_Exit;
}

//DrawMenuTitle(cols);
DrawMenuTitle(cols);
}
else
{
Expand All @@ -887,7 +895,7 @@ public int HandleInsertMenu(int nStartY, int nStopY, CConfig.ConfigVolatile cfgv
Console.WriteLine("{0}: {1}!", CGameData.GetDescription(GamePlatform.Search), CGameData.GetDescription(Match.NoMatches));
if ((bool)CConfig.GetConfigBool(CConfig.CFG_USECMD))
{
//options = new string[0];
options = Array.Empty<string>();
return (int)DockSelection.cSel_Exit;
}

Expand Down Expand Up @@ -1020,29 +1028,32 @@ public void DrawInfoBar(string selection, CConfig.Colours cols)
string ratingString = "";
CGame selectedGame = GetPlatformGame((GamePlatform)CDock.m_nSelectedPlatform, CDock.m_nCurrentSelection);

if (selectedGame.Alias.Length > 0)
aliasString = string.Format(" {0} {1}", CDock.SEPARATOR_SYMBOL, selectedGame.Alias);

if (selectedGame.Rating > 0)
if (selectedGame != null)
{
if (string.IsNullOrEmpty(CDock.RATING_SYMBOL.ToString()))
ratingString = string.Format(" {0} {1} *", CDock.SEPARATOR_SYMBOL, selectedGame.Rating);
else
//ratingString = string.Format(" {0} {1}", CDock.SEPARATOR_SYMBOL, new string(CDock.RATING_SYMBOL, selectedGame.Rating));
ratingString = string.Format(" {0} {1} {2}", CDock.SEPARATOR_SYMBOL, selectedGame.Rating, CDock.RATING_SYMBOL);
}
if (selectedGame.Alias.Length > 0)
aliasString = string.Format(" {0} {1}", CDock.SEPARATOR_SYMBOL, selectedGame.Alias);

leftSide = string.Format("{0} {1} {0}", CDock.SEPARATOR_SYMBOL, selectedGame.Title + aliasString + ratingString);
/*
if (CDock.m_nSelectedPlatform == (int)GamePlatform.All ||
CDock.m_nSelectedPlatform == (int)GamePlatform.Favourites ||
CDock.m_nSelectedPlatform == (int)GamePlatform.Hidden ||
CDock.m_nSelectedPlatform == (int)GamePlatform.New ||
CDock.m_nSelectedPlatform == (int)GamePlatform.NotInstalled ||
CDock.m_nSelectedPlatform == (int)GamePlatform.Search ||
CDock.m_nSelectedPlatform == (int)GamePlatform.Unknown)
*/
rightSide = string.Format("{0} {1} {0}", CDock.SEPARATOR_SYMBOL, selectedGame.PlatformString);
if (selectedGame.Rating > 0)
{
if (string.IsNullOrEmpty(CDock.RATING_SYMBOL.ToString()))
ratingString = string.Format(" {0} {1} *", CDock.SEPARATOR_SYMBOL, selectedGame.Rating);
else
//ratingString = string.Format(" {0} {1}", CDock.SEPARATOR_SYMBOL, new string(CDock.RATING_SYMBOL, selectedGame.Rating));
ratingString = string.Format(" {0} {1} {2}", CDock.SEPARATOR_SYMBOL, selectedGame.Rating, CDock.RATING_SYMBOL);
}

leftSide = string.Format("{0} {1} {0}", CDock.SEPARATOR_SYMBOL, selectedGame.Title + aliasString + ratingString);
/*
if (CDock.m_nSelectedPlatform == (int)GamePlatform.All ||
CDock.m_nSelectedPlatform == (int)GamePlatform.Favourites ||
CDock.m_nSelectedPlatform == (int)GamePlatform.Hidden ||
CDock.m_nSelectedPlatform == (int)GamePlatform.New ||
CDock.m_nSelectedPlatform == (int)GamePlatform.NotInstalled ||
CDock.m_nSelectedPlatform == (int)GamePlatform.Search ||
CDock.m_nSelectedPlatform == (int)GamePlatform.Unknown)
*/
rightSide = string.Format("{0} {1} {0}", CDock.SEPARATOR_SYMBOL, selectedGame.PlatformString);
}
}
else
{
Expand Down Expand Up @@ -1436,7 +1447,7 @@ public static void MakeShortcut(string title, string path, string icon, string l
/// <summary>
/// Search for a game by title or alias
/// </summary>
public static bool DoGameSearch(string strInput, int maxTitles, string[] options, out string[] optionsNew, out int nMatches)
public static bool DoGameSearch(string strInput, int maxTitles, string[] options, out int nMatches)
{
Dictionary<string, int> matches = new();
List<CMatch> searchResults = new();
Expand All @@ -1448,8 +1459,6 @@ public static bool DoGameSearch(string strInput, int maxTitles, string[] options
{
CLogger.LogInfo("{0}: {1}! [{2}]", GetDescription(GamePlatform.Search), GetDescription(Match.ExactTitle), nSelection);
nMatches = 1;
optionsNew = new string[1];
optionsNew[0] = GetPlatformGame(GamePlatform.All, nSelection).Title;
nSelection = 0;
bValid = true;
}
Expand All @@ -1463,14 +1472,11 @@ public static bool DoGameSearch(string strInput, int maxTitles, string[] options
if (consoleOutput) Console.WriteLine("{0}: {1} matches found!", CGameData.GetDescription(GamePlatform.Search), nMatches);
CLogger.LogInfo("{0}: {1} matches found!", CGameData.GetDescription(GamePlatform.Search), nMatches);
int i = 0;
optionsNew = new string[nMatches];
foreach (var match in matches.OrderByDescending(j => j.Value))
{
CLogger.LogInfo("- [{0}%] {1}. {2}", match.Value, i, match.Key);
if (i == 0 && match.Value >= (int)Match.ExactAlias)
{
optionsNew = new string[1];
optionsNew[0] = match.Key;
CDock.m_nCurrentSelection = Array.FindIndex(options, s => s.Equals(match.Key, CDock.IGNORE_CASE));
if (consoleOutput)
{
Expand All @@ -1481,7 +1487,6 @@ public static bool DoGameSearch(string strInput, int maxTitles, string[] options
break;
}
}
else optionsNew[i] = match.Key;

if (consoleOutput)
{
Expand All @@ -1493,14 +1498,14 @@ public static bool DoGameSearch(string strInput, int maxTitles, string[] options
}
if (nMatches == 1) CDock.m_nCurrentSelection = 0;
bValid = true;
if (consoleOutput) { CJsonWrapper.ExportSearch(searchResults); }
}
else
{
CLogger.LogInfo("{0}: {1}!", CGameData.GetDescription(GamePlatform.Search), CGameData.GetDescription(Match.NoMatches));
optionsNew = null;
}
if (consoleOutput) { CJsonWrapper.ExportSearch(searchResults); }
//}

return bValid;
}

Expand Down
60 changes: 35 additions & 25 deletions GameLauncher_Console/GameLauncher_Console/Dock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,23 +89,27 @@ public void MainLoop(string[] args)
{
CPlatform platforms = new();
platforms.AddSupportedPlatform(new PlatformAmazon());
platforms.AddSupportedPlatform(new PlatformArc());
platforms.AddSupportedPlatform(new PlatformBattlenet());
platforms.AddSupportedPlatform(new PlatformBethesda());
platforms.AddSupportedPlatform(new PlatformBigFish());
//platforms.AddSupportedPlatform(new PlatformCustom());
//platforms.AddSupportedPlatform(new PlatformCustom()); // See CPlatform.ScanGames()
platforms.AddSupportedPlatform(new PlatformEpic());
platforms.AddSupportedPlatform(new PlatformGOG());
platforms.AddSupportedPlatform(new PlatformIGClient());
platforms.AddSupportedPlatform(new PlatformItch());
#if DEBUG
// an experiment for now
platforms.AddSupportedPlatform(new PlatformMicrosoft());
#endif
platforms.AddSupportedPlatform(new PlatformOculus());
platforms.AddSupportedPlatform(new PlatformOrigin());
platforms.AddSupportedPlatform(new PlatformParadox());
platforms.AddSupportedPlatform(new PlatformPlarium());
platforms.AddSupportedPlatform(new PlatformRockstar());
platforms.AddSupportedPlatform(new PlatformSteam());
platforms.AddSupportedPlatform(new PlatformUplay());
platforms.AddSupportedPlatform(new PlatformWargaming());
#if DEBUG
// an experiment for now
platforms.AddSupportedPlatform(new PlatformMicrosoft());
#endif
bool import, parseError = false;
import = CJsonWrapper.ImportFromINI(out CConfig.ConfigVolatile cfgv, out CConfig.Hotkeys keys, out CConfig.Colours cols);
if (!import) parseError = true;
Expand Down Expand Up @@ -883,37 +887,39 @@ from part in newTags.Split('|')
case GamePlatform.Battlenet:
PlatformBattlenet.Launch();
break;
case GamePlatform.Rockstar: // TODO?
Process.Start(CPlatform.ROCKSTAR_PROTOCOL);
case GamePlatform.Rockstar:
PlatformRockstar.Launch();
break;
case GamePlatform.Amazon:
PlatformAmazon.Launch();
break;
case GamePlatform.BigFish:
PlatformBigFish.Launch();
break;
case GamePlatform.Arc: // TODO?
Process.Start(CPlatform.ARC_PROTOCOL);
case GamePlatform.Arc:
PlatformArc.Launch();
break;
case GamePlatform.Itch:
PlatformItch.Launch();
break;
case GamePlatform.Paradox:
PlatformParadox.Launch();
break;
case GamePlatform.Plarium: // TODO?
Process.Start(CPlatform.PLARIUM_PROTOCOL);
case GamePlatform.Plarium:
PlatformPlarium.Launch();
break;
case GamePlatform.Twitch: // TODO?
//PlatformTwitch.Launch();
break;
case GamePlatform.Wargaming: // TODO?
Process.Start(CPlatform.WARGAMING_PROTOCOL);
case GamePlatform.Wargaming:
PlatformWargaming.Launch();
break;
case GamePlatform.IGClient:
PlatformIGClient.Launch();
break;
case GamePlatform.Microsoft: // TODO?
PlatformMicrosoft.Launch();
if (OperatingSystem.IsWindows())
PlatformMicrosoft.Launch();
break;
case GamePlatform.Oculus:
PlatformOculus.Launch();
Expand Down Expand Up @@ -1273,7 +1279,10 @@ private bool UninstallGame(CGame game)
Console.WriteLine($"Uninstalling game: {game.Title}");
try
{
Process.Start(game.Uninstaller);
if (OperatingSystem.IsWindows())
StartShellExecute(game.Uninstaller);
else
Process.Start(game.Uninstaller);
return true;
}
catch (Exception e)
Expand Down Expand Up @@ -1302,7 +1311,11 @@ private bool StartGame(CGame game)
PlatformGOG.StartGame(game);
break;
default:
Process.Start(game.Launch);
CLogger.LogInfo($"Launch: {game.Launch}");
if (OperatingSystem.IsWindows())
StartShellExecute(game.Launch);
else
Process.Start(game.Launch);
break;
}
return true;
Expand Down Expand Up @@ -1913,19 +1926,16 @@ public static void DeleteCustomImage(string title)
}

[SupportedOSPlatform("windows")]
public static void StartAndRedirect(string file)
public static void StartShellExecute(string file)
{
StartAndRedirect(file, "", "");
}

[SupportedOSPlatform("windows")]
public static void StartAndRedirect(string file, string args)
{
StartAndRedirect(file, args, "");
Process cmdProcess = new();
cmdProcess.StartInfo.FileName = file;
cmdProcess.StartInfo.UseShellExecute = true;
cmdProcess.Start();
}

[SupportedOSPlatform("windows")]
public static void StartAndRedirect(string file, string args, string dir)
public static void StartAndRedirect(string file, string args = "", string dir = "")
{
Process cmdProcess = new();
cmdProcess.StartInfo.FileName = file;
Expand Down
12 changes: 6 additions & 6 deletions GameLauncher_Console/GameLauncher_Console/GameData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public enum GamePlatform
Bethesda = 8,
[Description("Battle.net")]
Battlenet = 9,
[Description("Rockstar")] // TODO
[Description("Rockstar")]
Rockstar = 10,
[Description("Hidden games")] // TODO
Hidden = 11,
Expand All @@ -51,23 +51,23 @@ public enum GamePlatform
Amazon = 13,
[Description("Big Fish")]
BigFish = 14,
[Description("Arc")] // TODO
[Description("Arc")]
Arc = 15,
[Description("itch")]
Itch = 16,
[Description("Paradox")]
Paradox = 17,
[Description("Plarium Play")] // TODO
[Description("Plarium Play")]
Plarium = 18,
[Description("Twitch")] // TODO
Twitch = 19,
[Description("Wargaming.net")] // TODO
[Description("Wargaming.net")]
Wargaming = 20,
[Description("Indiegala Client")]
IGClient = 21,
[Description("New games")]
New = 22,
[Description("Not installed")] // TODO
[Description("Not installed")]
NotInstalled = 23,
[Description("Microsoft Store")] // TODO
Microsoft = 24,
Expand Down Expand Up @@ -134,7 +134,7 @@ public struct ImportGameData
public List<string> m_tags;
public DateTime m_dateLastRun;
public ushort m_rating;
private uint m_numRuns;
public uint m_numRuns;

public ImportGameData(string strID, string strTitle, string strLaunch, string strIconPath, string strUninstall, string strAlias, bool bInstalled, string strPlatform, bool bFavourite = false, bool bHidden = false, List<string> tags = default, DateTime dateLastRun = default, ushort rating = 0, uint numRuns = 0)
{
Expand Down
Loading

0 comments on commit 92bb36e

Please sign in to comment.