public void RemoveIgnoreFeature()
        {
            string      skipFeatureName     = "[Status Updater] Ignore";
            GameFeature feature             = PlayniteApi.Database.Features.Add(skipFeatureName);
            int         featureRemovedCount = 0;
            var         gameCollection      = PlayniteApi.MainView.SelectedGames;

            foreach (Game game in gameCollection)
            {
                if (game.FeatureIds == null)
                {
                    continue;
                }

                foreach (Guid featureId in game.FeatureIds)
                {
                    if (featureId == feature.Id)
                    {
                        game.FeatureIds.Remove(feature.Id);
                        PlayniteApi.Database.Games.Update(game);
                        featureRemovedCount++;
                        logger.Info(string.Format("Game: {0} Removed ignore feature", game.Name));
                        break;
                    }
                }
            }

            PlayniteApi.Dialogs.ShowMessage(
                string.Format(ResourceProvider.GetString("LOCInstallation_Status_Updater_StatusUpdaterRemoveIgnoreFeatureMessage"),
                              featureRemovedCount.ToString()), "Installation Status Updater"
                );
        }
        private void AddImageSkipFeature(string featureName)
        {
            GameFeature feature           = PlayniteApi.Database.Features.Add(featureName);
            int         featureAddedCount = 0;

            foreach (var game in PlayniteApi.MainView.SelectedGames)
            {
                if (game.FeatureIds == null)
                {
                    game.FeatureIds = new List <Guid> {
                        feature.Id
                    };
                    PlayniteApi.Database.Games.Update(game);
                    featureAddedCount++;
                }
                else if (!game.FeatureIds.Contains(feature.Id))
                {
                    game.FeatureIds.AddMissing(feature.Id);
                    PlayniteApi.Database.Games.Update(game);
                    featureAddedCount++;
                }
            }

            PlayniteApi.Dialogs.ShowMessage(string.Format(ResourceProvider.GetString("LOCSplashScreen_ExcludeFeatureAddResultsMessage"), feature.Name, featureAddedCount), "Splash Screen");
        }
예제 #3
0
 protected virtual void RemoveFeature(GameFeature feature)
 {
     if (_gameFeatures.Contains(feature))
     {
         feature.OnFinished -= RemoveFeature;
         feature.Terminate();
         _gameFeatures.Remove(feature);
     }
 }
예제 #4
0
 protected virtual void AddFeature(GameFeature feature)
 {
     if (!_gameFeatures.Contains(feature))
     {
         feature.Initialize(_arguments);
         feature.OnFinished += RemoveFeature;
         _gameFeatures.Add(feature);
     }
 }
        public static void RenameFeature(IPlayniteAPI PlayniteApi, Guid Id, string NewName)
        {
            GameFeature gameFeature = PlayniteApi.Database.Features.Get(Id);

            if (gameFeature != null)
            {
                gameFeature.Name = NewName;
                PlayniteApi.Database.Features.Update(gameFeature);
            }
            else
            {
                logger.Warn($"Feature doesn't exist - {Id}");
            }
        }
        public void RemoveModeFeature()
        {
            string      featureName         = GetModeFeatureName();
            GameFeature feature             = PlayniteApi.Database.Features.Add(featureName);
            var         gameDatabase        = PlayniteApi.MainView.SelectedGames.Where(g => g.PluginId == BuiltinExtensions.GetIdFromExtension(BuiltinExtension.SteamLibrary));
            int         featureRemovedCount = 0;

            foreach (var game in gameDatabase)
            {
                bool featureRemoved = RemoveFeature(game, feature);
                if (featureRemoved == true)
                {
                    featureRemovedCount++;
                    logger.Info(String.Format("Removed \"{0}\" feature from \"{1}\"", featureName, game.Name));
                }
            }
            PlayniteApi.Dialogs.ShowMessage(String.Format("Removed \"{0}\" feature from {1} game(s).", featureName, featureRemovedCount), "Steam Launcher Utility");
        }
예제 #7
0
 public bool RemoveFeature(Game game, GameFeature feature)
 {
     if (game.FeatureIds != null)
     {
         if (game.FeatureIds.Contains(feature.Id))
         {
             game.FeatureIds.Remove(feature.Id);
             PlayniteApi.Database.Games.Update(game);
             return(true);
         }
         else
         {
             return(false);
         }
     }
     else
     {
         return(false);
     }
 }
        private void RemoveImageSkipFeature(string featureName)
        {
            GameFeature feature             = PlayniteApi.Database.Features.Add(featureName);
            int         featureRemovedCount = 0;

            foreach (var game in PlayniteApi.MainView.SelectedGames)
            {
                if (game.FeatureIds != null)
                {
                    if (game.FeatureIds.Contains(feature.Id))
                    {
                        game.FeatureIds.Remove(feature.Id);
                        PlayniteApi.Database.Games.Update(game);
                        featureRemovedCount++;
                        logger.Info(string.Format("Removed \"{0}\" feature from \"{1}\"", feature.Name, game.Name));
                    }
                }
            }
            PlayniteApi.Dialogs.ShowMessage(string.Format(ResourceProvider.GetString("LOCSplashScreen_ExcludeFeatureRemoveResultsMessage"), feature.Name, featureRemovedCount), "Splash Screen");
        }
        private void CheckFeature()
        {
            // Add new feature that not exist
            List <GameFeature> PlayniteFeatures = PlayniteApi.Database.Features.ToList();

            foreach (LmFeatureEquivalences lmFeatureEquivalences in PluginSettings.ListFeatureEquivalences)
            {
                if (lmFeatureEquivalences.Id == null)
                {
                    GameFeature feature = new GameFeature(lmFeatureEquivalences.NewName);
                    lmFeatureEquivalences.Id = feature.Id;

                    Application.Current.Dispatcher?.BeginInvoke((Action) delegate
                    {
                        PlayniteApi.Database.Features.Add(feature);
                        Plugin.SavePluginSettings(PluginSettings);
                    }).Wait();
                }
            }
        }
예제 #10
0
 public bool AddFeature(Game game, GameFeature feature)
 {
     if (game.FeatureIds == null)
     {
         game.FeatureIds = new List <Guid> {
             feature.Id
         };
         PlayniteApi.Database.Games.Update(game);
         return(true);
     }
     else if (game.FeatureIds.Contains(feature.Id) == false)
     {
         game.FeatureIds.AddMissing(feature.Id);
         PlayniteApi.Database.Games.Update(game);
         return(true);
     }
     else
     {
         return(false);
     }
 }
예제 #11
0
        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));
            }
        }
예제 #12
0
        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");
            }
        }
        private bool UpdateFeature(Game game)
        {
            bool IsUpdated = false;
            List <GameFeature> gameFeatures = game.Features;

            if (gameFeatures != null && gameFeatures.Count > 0)
            {
                // Rename
                List <GameFeature> AllFeaturesOld = gameFeatures.FindAll(x => PluginSettings.ListFeatureEquivalences.Any(y => y.OldNames.Any(z => z.ToLower() == x.Name.ToLower())));

                if (AllFeaturesOld.Count > 0)
                {
                    // Remove all
                    foreach (GameFeature feature in AllFeaturesOld)
                    {
                        game.FeatureIds.Remove(feature.Id);
                        IsUpdated = true;
                    }

                    // Set all
                    foreach (LmFeatureEquivalences item in PluginSettings.ListFeatureEquivalences.FindAll(x => x.OldNames.Any(y => AllFeaturesOld.Any(z => z.Name.ToLower() == y.ToLower()))))
                    {
                        if (item.Id != null)
                        {
                            game.FeatureIds.AddMissing((Guid)item.Id);
                            IsUpdated = true;
                        }
                    }

                    if (IsUpdated)
                    {
                        Application.Current.Dispatcher?.BeginInvoke((Action) delegate
                        {
                            PlayniteApi.Database.Games.Update(game);
                        }).Wait();
                    }
                }

                // Exclusion
                if (PluginSettings.ListFeatureExclusion.Count > 0)
                {
                    foreach (string FeatureName in PluginSettings.ListFeatureExclusion)
                    {
                        GameFeature featureDelete = game.Features.Find(x => x.Name.ToLower() == FeatureName.ToLower());
                        if (featureDelete != null)
                        {
                            game.FeatureIds.Remove(featureDelete.Id);
                            IsUpdated = true;
                        }
                    }

                    if (IsUpdated)
                    {
                        Application.Current.Dispatcher?.BeginInvoke((Action) delegate
                        {
                            PlayniteApi.Database.Games.Update(game);
                        }).Wait();
                    }
                }
            }

            return(IsUpdated);
        }
예제 #14
0
 public ClientFeatureAttribute(GameFeature feature)
 {
     _feature = feature;
 }
예제 #15
0
        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");
            }
        }