public void InitializeMultipleAdd(string GameSourceName = "all") { switch (GameSourceName.ToLower()) { case "all": InitializeMultipleAdd("Steam"); InitializeMultipleAdd("GOG"); InitializeMultipleAdd("Origin"); break; case "steam": break; case "gog": if (!PlayniteTools.IsDisabledPlaynitePlugins("GogLibrary", _PlayniteApi.Paths.ConfigurationPath) && PluginSettings.EnableGog && gogAPI == null) { gogAPI = new GogAchievements(_PlayniteApi, PluginSettings, PluginUserDataPath); } break; case "origin": if (!PlayniteTools.IsDisabledPlaynitePlugins("OriginLibrary", _PlayniteApi.Paths.ConfigurationPath) && originAPI == null) { originAPI = new OriginAchievements(_PlayniteApi, PluginSettings, PluginUserDataPath); } break; case "Xbox": if (!PlayniteTools.IsDisabledPlaynitePlugins("XboxLibrary", _PlayniteApi.Paths.ConfigurationPath) && xboxAPI == null) { xboxAPI = new XboxAchievements(_PlayniteApi, PluginSettings, PluginUserDataPath); } break; case "playnite": break; } }
/// <summary> /// /// </summary> /// <param name="GameSourceName"></param> /// <param name="settings"></param> /// <returns></returns> public static bool VerifToAddOrShow(SuccessStory plugin, IPlayniteAPI PlayniteApi, SuccessStorySettings settings, string PluginUserDataPath, string GameSourceName) { if (settings.EnableSteam && GameSourceName.ToLower() == "steam") { if (PlayniteTools.IsDisabledPlaynitePlugins("SteamLibrary", PlayniteApi.Paths.ConfigurationPath)) { logger.Warn("SuccessStory - Steam is enable then disabled"); PlayniteApi.Notifications.Add(new NotificationMessage( "SuccessStory-Steam-disabled", $"SuccessStory\r\n{resources.GetString("LOCSuccessStoryNotificationsSteamDisabled")}", NotificationType.Error, () => plugin.OpenSettingsView() )); return(false); } else { SteamAchievements steamAchievements = new SteamAchievements(PlayniteApi, settings, PluginUserDataPath); if (!steamAchievements.IsConfigured()) { logger.Warn("SuccessStory - Bad Steam configuration"); PlayniteApi.Notifications.Add(new NotificationMessage( "SuccessStory-Steam-NoConfig", $"SuccessStory\r\n{resources.GetString("LOCSuccessStoryNotificationsSteamBadConfig")}", NotificationType.Error, () => plugin.OpenSettingsView() )); return(false); } } return(true); } if (settings.EnableGog && GameSourceName.ToLower() == "gog") { if (PlayniteTools.IsDisabledPlaynitePlugins("GogLibrary", PlayniteApi.Paths.ConfigurationPath)) { logger.Warn("SuccessStory - GOG is enable then disabled"); PlayniteApi.Notifications.Add(new NotificationMessage( "SuccessStory-GOG-disabled", $"SuccessStory\r\n{resources.GetString("LOCSuccessStoryNotificationsGogDisabled")}", NotificationType.Error, () => plugin.OpenSettingsView() )); return(false); } else { GogAchievements gogAchievements = new GogAchievements(PlayniteApi, settings, PluginUserDataPath); if (VerifToAddOrShowGog == null) { VerifToAddOrShowGog = gogAchievements.IsConnected(); } if (!(bool)VerifToAddOrShowGog) { logger.Warn("SuccessStory - Gog user is not authenticate"); PlayniteApi.Notifications.Add(new NotificationMessage( "SuccessStory-Gog-NoAuthenticated", $"SuccessStory\r\n{resources.GetString("LOCSuccessStoryNotificationsGogNoAuthenticate")}", NotificationType.Error, () => plugin.OpenSettingsView() )); return(false); } } return(true); } if (settings.EnableOrigin && GameSourceName.ToLower() == "origin") { if (PlayniteTools.IsDisabledPlaynitePlugins("OriginLibrary", PlayniteApi.Paths.ConfigurationPath)) { logger.Warn("SuccessStory - Origin is enable then disabled"); PlayniteApi.Notifications.Add(new NotificationMessage( "SuccessStory-Origin-disabled", $"SuccessStory\r\n{resources.GetString("LOCSuccessStoryNotificationsOriginDisabled")}", NotificationType.Error, () => plugin.OpenSettingsView() )); return(false); } else { OriginAchievements originAchievements = new OriginAchievements(PlayniteApi, settings, PluginUserDataPath); if (VerifToAddOrShowOrigin == null) { VerifToAddOrShowOrigin = originAchievements.IsConnected(); } if (!(bool)VerifToAddOrShowOrigin) { logger.Warn("SuccessStory - Origin user is not authenticated"); PlayniteApi.Notifications.Add(new NotificationMessage( "SuccessStory-Origin-NoAuthenticate", $"SuccessStory\r\n{resources.GetString("LOCSuccessStoryNotificationsOriginNoAuthenticate")}", NotificationType.Error, () => plugin.OpenSettingsView() )); return(false); } } return(true); } if (settings.EnableXbox && GameSourceName.ToLower() == "xbox") { if (PlayniteTools.IsDisabledPlaynitePlugins("XboxLibrary", PlayniteApi.Paths.ConfigurationPath)) { logger.Warn("SuccessStory - Xbox is enable then disabled"); PlayniteApi.Notifications.Add(new NotificationMessage( "SuccessStory-Xbox-disabled", $"SuccessStory\r\n{resources.GetString("LOCSuccessStoryNotificationsXboxDisabled")}", NotificationType.Error, () => plugin.OpenSettingsView() )); return(false); } else { XboxAchievements xboxAchievements = new XboxAchievements(PlayniteApi, settings, PluginUserDataPath); #if DEBUG logger.Debug($"SuccessStory [Ignored] - VerifToAddOrShowXbox: {VerifToAddOrShowXbox}"); #endif if (VerifToAddOrShowXbox == null) { VerifToAddOrShowXbox = xboxAchievements.IsConnected(); } #if DEBUG logger.Debug($"SuccessStory [Ignored] - VerifToAddOrShowXbox: {VerifToAddOrShowXbox}"); #endif if (!(bool)VerifToAddOrShowXbox) { logger.Warn("SuccessStory - Xbox user is not authenticated"); PlayniteApi.Notifications.Add(new NotificationMessage( "SuccessStory-Xbox-NoAuthenticate", $"SuccessStory\r\n{resources.GetString("LOCSuccessStoryNotificationsXboxNotAuthenticate")}", NotificationType.Error, () => plugin.OpenSettingsView() )); return(false); } } return(true); } if (settings.EnableLocal && (GameSourceName.ToLower() == "playnite" || GameSourceName.ToLower() == "hacked")) { return(true); } if (settings.EnableRetroAchievements && GameSourceName.ToLower() == "retroachievements") { RetroAchievements retroAchievements = new RetroAchievements(PlayniteApi, settings, PluginUserDataPath); if (!retroAchievements.IsConfigured()) { logger.Warn("SuccessStory - Bad RetroAchievements configuration"); PlayniteApi.Notifications.Add(new NotificationMessage( "SuccessStory-RetroAchievements-NoConfig", $"SuccessStory\r\n{resources.GetString("LOCSuccessStoryNotificationsRetroAchievementsBadConfig")}", NotificationType.Error, () => plugin.OpenSettingsView() )); return(false); } return(true); } if (settings.EnableRpcs3Achievements && GameSourceName.ToLower() == "rpcs3") { Rpcs3Achievements rpcs3Achievements = new Rpcs3Achievements(PlayniteApi, settings, PluginUserDataPath); if (!rpcs3Achievements.IsConfigured()) { logger.Warn("SuccessStory - Bad RPCS3 configuration"); PlayniteApi.Notifications.Add(new NotificationMessage( "SuccessStory-Rpcs3-NoConfig", $"SuccessStory\r\n{resources.GetString("LOCSuccessStoryNotificationsRpcs3BadConfig")}", NotificationType.Error, () => plugin.OpenSettingsView() )); return(false); } return(true); } logger.Warn($"SuccessStory - VerifToAddOrShow() find no action for {GameSourceName}"); return(false); }
// Override additional methods based on supported metadata fields. public override string GetDescription() { // Get type source, data and description string Data; string Description = string.Empty; if (AvailableFields.Contains(MetadataField.Description)) { // Get Playnite language PlayniteLanguage = _plugin.PlayniteApi.ApplicationSettings.Language; string GameId = string.Empty; string GameName = string.Empty; string StoreName = string.Empty; try { GameId = _options.GameData.GameId; GameName = _options.GameData.Name; if (_options.GameData.SourceId != Guid.Parse("00000000-0000-0000-0000-000000000000")) { StoreName = _options.GameData.Source.Name; } else { logger.Warn("No source name"); } // Selectable Store metadata if (!_options.IsBackgroundDownload && _settings.EnableSelectStore) { MetadataLocalStoreSelection ViewExtension = null; Application.Current.Dispatcher.Invoke(new Action(() => { ViewExtension = new MetadataLocalStoreSelection(_plugin.PlayniteApi, StoreName, GameName, _plugin.GetPluginUserDataPath()); Window windowExtension = PlayniteUiHelper.CreateExtensionWindow(_plugin.PlayniteApi, resources.GetString("LOCMetadataLocalStoreSelection"), ViewExtension); windowExtension.ShowDialog(); })); if (!ViewExtension.StoreResult.StoreName.IsNullOrEmpty()) { GameId = ViewExtension.StoreResult.StoreId; GameName = ViewExtension.StoreResult.Name; StoreName = ViewExtension.StoreResult.StoreName; } else { GameId = string.Empty; GameName = string.Empty; StoreName = string.Empty; } } switch (StoreName.ToLower()) { case "steam": uint appId = uint.Parse(GameId); Data = GetSteamData(appId, PlayniteLanguage); var parsedData = JsonConvert.DeserializeObject <Dictionary <string, StoreAppDetailsResult> >(Data); Description = parsedData[appId.ToString()].data.detailed_description; break; case "origin": Description = GetOriginData(GameId, PlayniteLanguage); break; case "epic": Description = GetEpicData(GameName); break; case "xbox": if (!PlayniteTools.IsDisabledPlaynitePlugins("XboxLibrary", _PlayniteConfigurationPath)) { Description = GetXboxData(GameId, PlayniteLanguage, _plugin.GetPluginUserDataPath(), _plugin).GetAwaiter().GetResult(); } else { logger.Warn("XboxLibrary is used then disabled"); _plugin.PlayniteApi.Notifications.Add(new NotificationMessage( $"metadataLocal-xbox-disabled", "XboxLibrary is used then disabled", NotificationType.Error, () => _plugin.OpenSettingsView() )); } break; case "ubisoft": case "uplay": case "ubisoft connect": Description = GetUbisoftData(GameName, PlayniteLanguage, GameId); break; } } catch (Exception ex) { Common.LogError(ex, false, $"Error with {GameName} - {GameId} - {StoreName}"); } } if (Description.IsNullOrEmpty()) { return(base.GetDescription()); } else { return(Description); } }