public string UpdateNvidiaAction(Game game, GeforceGame supportedGame) { GameAction geforceNowAction = null; if (game.GameActions != null) { geforceNowAction = game.GameActions .Where(x => x.Arguments != null) .Where(x => Regex.IsMatch(x.Arguments, @"--url-route=""#\?cmsId=\d+&launchSource=External&shortName=game_gfn_pc&parentGameId=""")) .FirstOrDefault(); } if (supportedGame == null && geforceNowAction != null) { game.GameActions.Remove(geforceNowAction); PlayniteApi.Database.Games.Update(game); return("ActionRemoved"); } else if (supportedGame != null && geforceNowAction == null) { GameAction nvidiaGameAction = new GameAction() { Name = "Launch in Nvidia GeForce NOW", Arguments = String.Format("--url-route=\"#?cmsId={0}&launchSource=External&shortName=game_gfn_pc&parentGameId=\"", supportedGame.Id), Path = geforceNowExecutablePath, WorkingDir = geforceNowWorkingPath, IsPlayAction = settings.Settings.SetActionsAsPlayAction, TrackingMode = TrackingMode.Process }; if (game.GameActions == null) { game.GameActions = new System.Collections.ObjectModel.ObservableCollection <GameAction> { nvidiaGameAction }; } else { game.GameActions.Add(nvidiaGameAction); PlayniteApi.Database.Games.Update(game); return("ActionAdded"); } } return(null); }
public string UpdateNvidiaAction(Game game, GeforceGame supportedGame, string geforceNowWorkingPath, string geforceNowExecutablePath) { GameAction geforceNowAction = null; if (game.OtherActions != null) { geforceNowAction = game.OtherActions.Where(x => x.Arguments != null).Where(x => Regex.IsMatch(x.Arguments, @"--url-route=""#\?cmsId=\d+&launchSource=External&shortName=game_gfn_pc&parentGameId=""")).FirstOrDefault(); } if (supportedGame == null && geforceNowAction != null) { game.OtherActions.Remove(geforceNowAction); PlayniteApi.Database.Games.Update(game); string result = "playActionRemoved"; return(result); } else if (supportedGame != null && geforceNowAction == null) { GameAction nvidiaGameAction = new GameAction(); nvidiaGameAction.Name = "Launch in Nvidia GeForce NOW"; var playActionArguments = String.Format("--url-route=\"#?cmsId={0}&launchSource=External&shortName=game_gfn_pc&parentGameId=\"", supportedGame.Id); nvidiaGameAction.Arguments = playActionArguments; nvidiaGameAction.Path = geforceNowExecutablePath; nvidiaGameAction.WorkingDir = geforceNowWorkingPath; AddOtherAction(game, nvidiaGameAction); PlayniteApi.Database.Games.Update(game); string result = "playActionAdded"; return(result); } else { string result = null; return(result); } }
public void MainMethod(bool showDialogs) { string featureName = "NVIDIA GeForce NOW"; GameFeature feature = PlayniteApi.Database.Features.Add(featureName); var supportedGames = DownloadGameList(showDialogs); if (supportedGames.Count() == 0) { // In case download failed. // Also sometimes there are issues with the api and it doesn't return any games in the response return; } var supportedSteamGames = supportedGames.Where(g => g.Store == "Steam"); var supportedEpicGames = supportedGames.Where(g => g.Store == "Epic"); var supportedOriginGames = supportedGames.Where(g => g.Store == "Origin"); var supportedUplayGames = supportedGames.Where(g => g.Store == "Ubisoft Connect"); var supportedGogGames = supportedGames.Where(g => g.Store == "GOG"); int enabledGamesCount = 0; int featureAddedCount = 0; int featureRemovedCount = 0; int setAsInstalledCount = 0; var progRes = PlayniteApi.Dialogs.ActivateGlobalProgress((a) => { var gameDatabase = GetGamesSupportedLibraries(); foreach (var game in gameDatabase) { var gameName = SatinizeString(game.Name); GeforceGame supportedGame = null; switch (game.PluginId.ToString()) { case "cb91dfc9-b977-43bf-8e70-55f46e410fab": //Steam var steamUrl = string.Format("https://store.steampowered.com/app/{0}", game.GameId); supportedGame = supportedSteamGames.FirstOrDefault(g => g.SteamUrl == steamUrl); break; case "00000002-dbd1-46c6-b5d0-b1ba559d10e4": //Epic supportedGame = supportedEpicGames.FirstOrDefault(g => g.Title == gameName); break; case "85dd7072-2f20-4e76-a007-41035e390724": //Origin gameName = SatinizeOriginGameName(gameName); supportedGame = supportedOriginGames.FirstOrDefault(g => g.Title == gameName); break; case "c2f038e5-8b92-4877-91f1-da9094155fc5": //Uplay supportedGame = supportedUplayGames.FirstOrDefault(g => g.Title == gameName); break; case "aebe8b7c-6dc3-4a66-af31-e7375c6b5e9e": //GOG supportedGame = supportedGogGames.FirstOrDefault(g => g.Title == gameName); break; default: break; } if (supportedGame == null) { if (RemoveFeature(game, feature)) { featureRemovedCount++; logger.Info(string.Format("Feature removed from \"{0}\"", game.Name)); } } else { enabledGamesCount++; if (AddFeature(game, feature)) { featureAddedCount++; logger.Info(string.Format("Feature added to \"{0}\"", game.Name)); } if ((settings.Settings.SetEnabledGamesAsInstalled || settings.Settings.ShowPlayActionsOnLaunch) && game.IsInstalled == false) { game.IsInstalled = true; setAsInstalledCount++; PlayniteApi.Database.Games.Update(game); logger.Info(string.Format("Set \"{0}\" as installed", game.Name)); } } } }, new GlobalProgressOptions(ResourceProvider.GetString("LOCNgfn_Enabler_UpdatingProgressMessage"))); if (showDialogs) { string results = string.Format(ResourceProvider.GetString("LOCNgfn_Enabler_UpdateResults1Message"), enabledGamesCount, featureName, featureAddedCount, featureName, featureRemovedCount); if (settings.Settings.SetEnabledGamesAsInstalled == true) { results += string.Format(ResourceProvider.GetString("LOCNgfn_Enabler_UpdateResults3Message"), setAsInstalledCount); } PlayniteApi.Dialogs.ShowMessage(results, "NVIDIA GeForce NOW Enabler"); } else if (setAsInstalledCount > 0) { PlayniteApi.Notifications.Add(new NotificationMessage(new Guid().ToString(), string.Format(ResourceProvider.GetString("LOCNgfn_Enabler_NotificationMessageMarkedInstalledResults"), setAsInstalledCount), NotificationType.Info)); } }
public void MainMethod(bool showDialogs) { string featureName = "NVIDIA GeForce NOW"; GameFeature feature = PlayniteApi.Database.Features.Add(featureName); var supportedGames = DownloadGameList("https://static.nvidiagrid.net/supported-public-game-list/gfnpc.json", showDialogs); if (supportedGames.Count() == 0) { // In case download failed. // Also sometimes there are issues with the api and it doesn't return any games in the response return; } var supportedSteamGames = supportedGames.Where(g => g.Store == "Steam"); var supportedEpicGames = supportedGames.Where(g => g.Store == "Epic"); var supportedOriginGames = supportedGames.Where(g => g.Store == "Origin"); var supportedUplayGames = supportedGames.Where(g => g.Store == "Ubisoft Connect"); var supportedGogGames = supportedGames.Where(g => g.Store == "GOG"); int enabledGamesCount = 0; int featureAddedCount = 0; int featureRemovedCount = 0; int playActionAddedCount = 0; int playActionRemovedCount = 0; int setAsInstalledCount = 0; int setAsUninstalledCount = 0; var progRes = PlayniteApi.Dialogs.ActivateGlobalProgress((a) => { var gameDatabase = GetGamesSupportedLibraries(); foreach (var game in gameDatabase) { var gameName = Regex.Replace(game.Name, @"[^\p{L}\p{Nd}]", "").ToLower(); GeforceGame supportedGame = null; switch (BuiltinExtensions.GetExtensionFromId(game.PluginId)) { case BuiltinExtension.SteamLibrary: var steamUrl = String.Format("https://store.steampowered.com/app/{0}", game.GameId); supportedGame = supportedSteamGames.Where(g => g.SteamUrl == steamUrl).FirstOrDefault(); break; case BuiltinExtension.EpicLibrary: supportedGame = supportedEpicGames.Where(g => g.Title == gameName).FirstOrDefault(); break; case BuiltinExtension.OriginLibrary: supportedGame = supportedOriginGames.Where(g => g.Title == gameName).FirstOrDefault(); break; case BuiltinExtension.UplayLibrary: supportedGame = supportedUplayGames.Where(g => g.Title == gameName).FirstOrDefault(); break; case BuiltinExtension.GogLibrary: supportedGame = supportedGogGames.Where(g => g.Title == gameName).FirstOrDefault(); break; default: break; } if (supportedGame == null) { bool featureRemoved = RemoveFeature(game, feature); if (featureRemoved == true) { featureRemovedCount++; logger.Info(String.Format("Feature removed from \"{0}\"", game.Name)); if (settings.Settings.SetEnabledGamesAsInstalled == true && game.IsInstalled == true) { game.IsInstalled = true; setAsUninstalledCount++; PlayniteApi.Database.Games.Update(game); logger.Info(String.Format("Set \"{0}\" as uninstalled", game.Name)); } } } else { enabledGamesCount++; bool featureAdded = AddFeature(game, feature); if (featureAdded == true) { featureAddedCount++; logger.Info(String.Format("Feature added to \"{0}\"", game.Name)); } if (settings.Settings.SetEnabledGamesAsInstalled == true && game.IsInstalled == false) { game.IsInstalled = true; setAsInstalledCount++; PlayniteApi.Database.Games.Update(game); logger.Info(String.Format("Set \"{0}\" as installed", game.Name)); } } if (settings.Settings.UpdatePlayActions == true) { var updatePlayAction = UpdateNvidiaAction(game, supportedGame); if (updatePlayAction == "ActionAdded") { playActionAddedCount++; logger.Info(String.Format("Play Action added to \"{0}\"", game.Name)); } else if (updatePlayAction == "ActionRemoved") { playActionRemovedCount++; logger.Info(String.Format("Play Action removed from \"{0}\"", game.Name)); } } } }, new GlobalProgressOptions(ResourceProvider.GetString("LOCNgfn_Enabler_UpdatingProgressMessage"))); if (showDialogs == true) { string results = String.Format(ResourceProvider.GetString("LOCNgfn_Enabler_UpdateResults1Message"), enabledGamesCount, featureName, featureAddedCount, featureName, featureRemovedCount); if (settings.Settings.UpdatePlayActions == true) { results += String.Format(ResourceProvider.GetString("LOCNgfn_Enabler_UpdateResults2Message"), playActionAddedCount, playActionRemovedCount); } if (settings.Settings.SetEnabledGamesAsInstalled == true) { results += String.Format(ResourceProvider.GetString("LOCNgfn_Enabler_UpdateResults3Message"), setAsInstalledCount, setAsUninstalledCount); } PlayniteApi.Dialogs.ShowMessage(results, "NVIDIA GeForce NOW Enabler"); } }
public void MainMethod(bool showDialogs) { string featureName = "NVIDIA GeForce NOW"; GameFeature feature = PlayniteApi.Database.Features.Add(featureName); string localAppData = Environment.GetEnvironmentVariable("LocalAppData"); string geforceNowWorkingPath = Path.Combine(localAppData, "NVIDIA Corporation", "GeForceNOW", "CEF"); string geforceNowExecutablePath = Path.Combine(geforceNowWorkingPath, "GeForceNOWStreamer.exe"); var supportedGames = DownloadGameList("https://static.nvidiagrid.net/supported-public-game-list/gfnpc.json", showDialogs); if (supportedGames.Count() == 0) { return; } var supportedSteamGames = supportedGames.Where(g => g.Store == "Steam"); var supportedEpicGames = supportedGames.Where(g => g.Store == "Epic"); var supportedOriginGames = supportedGames.Where(g => g.Store == "Origin"); var supportedUplayGames = supportedGames.Where(g => g.Store == "Ubisoft Connect"); var supportedGogGames = supportedGames.Where(g => g.Store == "GOG"); int enabledGamesCount = 0; int featureAddedCount = 0; int featureRemovedCount = 0; int playActionAddedCount = 0; int playActionRemovedCount = 0; int setAsInstalledCount = 0; int setAsUninstalledCount = 0; var progRes = PlayniteApi.Dialogs.ActivateGlobalProgress((a) => { var gameDatabase = GetGamesSupportedLibraries(); foreach (var game in gameDatabase) { var gameName = Regex.Replace(game.Name, @"[^\p{L}\p{Nd}]", "").ToLower(); GeforceGame supportedGame = null; switch (BuiltinExtensions.GetExtensionFromId(game.PluginId)) { case BuiltinExtension.SteamLibrary: var steamUrl = String.Format("https://store.steampowered.com/app/{0}", game.GameId); supportedGame = supportedSteamGames.Where(g => g.SteamUrl == steamUrl).FirstOrDefault(); break; case BuiltinExtension.EpicLibrary: supportedGame = supportedEpicGames.Where(g => g.Title == gameName).FirstOrDefault(); break; case BuiltinExtension.OriginLibrary: supportedGame = supportedOriginGames.Where(g => g.Title == gameName).FirstOrDefault(); break; case BuiltinExtension.UplayLibrary: supportedGame = supportedUplayGames.Where(g => g.Title == gameName).FirstOrDefault(); break; case BuiltinExtension.GogLibrary: supportedGame = supportedGogGames.Where(g => g.Title == gameName).FirstOrDefault(); break; default: break; } if (supportedGame == null) { bool featureRemoved = RemoveFeature(game, feature); if (featureRemoved == true) { featureRemovedCount++; logger.Info(String.Format("Feature removed from \"{0}\"", game.Name)); if (settings.SetEnabledGamesAsInstalled == true && game.IsInstalled == true) { game.IsInstalled = true; setAsUninstalledCount++; PlayniteApi.Database.Games.Update(game); logger.Info(String.Format("Set \"{0}\" as uninstalled", game.Name)); } } } else { enabledGamesCount++; bool featureAdded = AddFeature(game, feature); if (featureAdded == true) { featureAddedCount++; logger.Info(String.Format("Feature added to \"{0}\"", game.Name)); } if (settings.SetEnabledGamesAsInstalled == true && game.IsInstalled == false) { game.IsInstalled = true; setAsInstalledCount++; PlayniteApi.Database.Games.Update(game); logger.Info(String.Format("Set \"{0}\" as installed", game.Name)); } } if (settings.UpdatePlayActions == true) { string updatePlayAction = UpdateNvidiaAction(game, supportedGame, geforceNowWorkingPath, geforceNowExecutablePath); if (updatePlayAction == "playActionAdded") { playActionAddedCount++; logger.Info(String.Format("Play Action added to \"{0}\"", game.Name)); } else if (updatePlayAction == "playActionRemoved") { playActionRemovedCount++; logger.Info(String.Format("Play Action removed from \"{0}\"", game.Name)); } } } }, new GlobalProgressOptions("Updating NVIDIA GeForce NOW Enabled games")); if (showDialogs == true) { string results = String.Format("NVIDIA GeForce NOW enabled games in library: {0}\n\nAdded \"{1}\" feature to {2} games.\nRemoved \"{3}\" feature from {4} games.", enabledGamesCount, featureName, featureAddedCount, featureName, featureRemovedCount); if (settings.UpdatePlayActions == true) { results += String.Format("\n\nPlay Action added to {0} games.\nPlay Action removed from {1} games.", playActionAddedCount, playActionRemovedCount); } if (settings.SetEnabledGamesAsInstalled == true) { results += String.Format("\n\nSet {0} games as Installed.\nSet {1} games as uninstalled.", setAsInstalledCount, setAsUninstalledCount); } PlayniteApi.Dialogs.ShowMessage(results, "NVIDIA GeForce NOW Enabler"); } }