コード例 #1
0
        public GameAchievements GetManual(Game game)
        {
            GameAchievements gameAchievements = GetDefault(game);

            SteamAchievements steamAPI = new SteamAchievements(_PlayniteApi, PluginSettings, PluginUserDataPath);

            steamAPI.SetLocal();
            gameAchievements          = steamAPI.GetAchievements(game);
            gameAchievements.IsManual = true;

            Add(gameAchievements);

#if DEBUG
            logger.Debug($"{PluginName} [Ignored] - GetManual({game.Id.ToString()}) - gameAchievements: {JsonConvert.SerializeObject(gameAchievements)}");
#endif

            return(gameAchievements);
        }
コード例 #2
0
        /// <summary>
        /// Generate database achivements for the game if achievement exist and game not exist in database.
        /// </summary>
        /// <param name="game"></param>
        public GameAchievements GetFromWeb(Game game)
        {
            GameAchievements gameAchievements = GetDefault(game);

            Guid   GameId         = game.Id;
            Guid   GameSourceId   = game.SourceId;
            string GameSourceName = PlayniteTools.GetSourceName(_PlayniteApi, game);

            List <Achievements> Achievements = new List <Achievements>();

            // Generate database only this source
            if (VerifToAddOrShow(_plugin, _PlayniteApi, PluginSettings, PluginUserDataPath, GameSourceName))
            {
#if DEBUG
                logger.Debug($"SuccessStory [Ignored] - VerifToAddOrShow({game.Name}, {GameSourceName}) - OK");
#endif

                // TODO one func
                if (GameSourceName.ToLower() == "gog")
                {
                    if (gogAPI == null)
                    {
                        gogAPI = new GogAchievements(_PlayniteApi, PluginSettings, PluginUserDataPath);
                    }
                    gameAchievements = gogAPI.GetAchievements(game);
                }

                if (GameSourceName.ToLower() == "steam")
                {
                    SteamAchievements steamAPI = new SteamAchievements(_PlayniteApi, PluginSettings, PluginUserDataPath);
                    gameAchievements = steamAPI.GetAchievements(game);
                }

                if (GameSourceName.ToLower() == "origin")
                {
                    if (originAPI == null)
                    {
                        originAPI = new OriginAchievements(_PlayniteApi, PluginSettings, PluginUserDataPath);
                    }
                    gameAchievements = originAPI.GetAchievements(game);
                }

                if (GameSourceName.ToLower() == "xbox")
                {
                    if (xboxAPI == null)
                    {
                        xboxAPI = new XboxAchievements(_PlayniteApi, PluginSettings, PluginUserDataPath);
                    }
                    gameAchievements = xboxAPI.GetAchievements(game);
                }

                if (GameSourceName.ToLower() == "playnite" || GameSourceName.ToLower() == "hacked")
                {
                    SteamAchievements steamAPI = new SteamAchievements(_PlayniteApi, PluginSettings, PluginUserDataPath);
                    steamAPI.SetLocal();
                    gameAchievements = steamAPI.GetAchievements(game);
                }

                if (GameSourceName.ToLower() == "retroachievements")
                {
                    RetroAchievements retroAchievementsAPI = new RetroAchievements(_PlayniteApi, PluginSettings, PluginUserDataPath);
                    gameAchievements = retroAchievementsAPI.GetAchievements(game);
                }

                if (GameSourceName.ToLower() == "rpcs3")
                {
                    Rpcs3Achievements rpcs3Achievements = new Rpcs3Achievements(_PlayniteApi, PluginSettings, PluginUserDataPath);
                    gameAchievements = rpcs3Achievements.GetAchievements(game);
                }

#if DEBUG
                logger.Debug($"SuccessStory [Ignored] - Achievements for {game.Name} - {GameSourceName} - {JsonConvert.SerializeObject(gameAchievements)}");
#endif
            }
            else
            {
#if DEBUG
                logger.Debug($"SuccessStory [Ignored] - VerifToAddOrShow({game.Name}, {GameSourceName}) - KO");
#endif
            }

            return(gameAchievements);
        }
        /// <summary>
        /// Generate database achivements for the game if achievement exist and game not exist in database.
        /// </summary>
        /// <param name="GameAdded"></param>
        public void Add(Game GameAdded, SuccessStorySettings settings)
        {
            GameAchievements GameAchievements = new GameAchievements();

            Guid   GameId                 = GameAdded.Id;
            Guid   GameSourceId           = GameAdded.SourceId;
            string GameSourceName         = PlayniteTools.GetSourceName(GameAdded, _PlayniteApi);
            string PluginDatabaseGamePath = PluginDatabasePath + GameId.ToString() + ".json";

            List <Achievements> Achievements = new List <Achievements>();

            // Generate database only this source
            if (VerifToAddOrShow(_plugin, _PlayniteApi, GameSourceName, settings, _PluginUserDataPath))
            {
                // Generate only not exist
                if (!File.Exists(PluginDatabaseGamePath))
                {
#if DEBUG
                    logger.Debug($"SuccessStory - VerifToAddOrShow({GameAdded.Name}, {GameSourceName}) - OK");
#endif

                    // TODO one func
                    if (GameSourceName.ToLower() == "gog")
                    {
                        if (gogAPI == null)
                        {
                            gogAPI = new GogAchievements(_PlayniteApi, settings, _PluginUserDataPath);
                        }
                        GameAchievements = gogAPI.GetAchievements(GameAdded);
                    }

                    if (GameSourceName.ToLower() == "steam")
                    {
                        SteamAchievements steamAPI = new SteamAchievements(_PlayniteApi, settings, _PluginUserDataPath);
                        GameAchievements = steamAPI.GetAchievements(GameAdded);
                    }

                    if (GameSourceName.ToLower() == "origin")
                    {
                        if (originAPI == null)
                        {
                            originAPI = new OriginAchievements(_PlayniteApi, settings, _PluginUserDataPath);
                        }
                        GameAchievements = originAPI.GetAchievements(GameAdded);
                    }

                    if (GameSourceName.ToLower() == "xbox")
                    {
                        if (xboxAPI == null)
                        {
                            xboxAPI = new XboxAchievements(_PlayniteApi, settings, _PluginUserDataPath);
                        }
                        GameAchievements = xboxAPI.GetAchievements(GameAdded);
                    }

                    if (GameSourceName.ToLower() == "playnite")
                    {
                        SteamAchievements steamAPI = new SteamAchievements(_PlayniteApi, settings, _PluginUserDataPath);
                        steamAPI.SetLocal();
                        GameAchievements = steamAPI.GetAchievements(GameAdded);
                    }

                    if (GameSourceName.ToLower() == "retroachievements")
                    {
                        RetroAchievements retroAchievementsAPI = new RetroAchievements(_PlayniteApi, settings, _PluginUserDataPath);
                        GameAchievements = retroAchievementsAPI.GetAchievements(GameAdded);
                    }

#if DEBUG
                    logger.Debug($"SuccessStory - Achievements for {GameAdded.Name} - {GameSourceName} - {JsonConvert.SerializeObject(GameAchievements)}");
#endif

                    if (GameAchievements != null)
                    {
                        File.WriteAllText(PluginDatabaseGamePath, JsonConvert.SerializeObject(GameAchievements));
                    }
                }
            }
            else
            {
#if DEBUG
                logger.Debug($"SuccessStory - VerifToAddOrShow({GameAdded.Name}, {GameSourceName}) - KO");
#endif
            }
        }