public SuccessStorySettingsView(SuccessStory plugin, IPlayniteAPI PlayniteApi, string PluginUserDataPath, SuccessStorySettings settings) { this.PlayniteApi = PlayniteApi; this.PluginUserDataPath = PluginUserDataPath; this.settings = settings; achievementsDatabase = new AchievementsDatabase(plugin, PlayniteApi, settings, PluginUserDataPath); InitializeComponent(); DataLoad.Visibility = Visibility.Collapsed; SetTotal(); switch (settings.NameSorting) { case "Name": cbDefaultSorting.Text = resources.GetString("LOCGameNameTitle"); break; case "LastActivity": cbDefaultSorting.Text = resources.GetString("LOCLastPlayed"); break; case "SourceName": cbDefaultSorting.Text = resources.GetString("LOCSourceLabel"); break; case "ProgressionValue": cbDefaultSorting.Text = resources.GetString("LOCSuccessStorylvGamesProgression"); break; } }
public XboxAchievements(IPlayniteAPI PlayniteApi, SuccessStorySettings settings, string PluginUserDataPath) : base(PlayniteApi, settings, PluginUserDataPath) { LocalLang = CodeLang.GetXboxLang(_PlayniteApi.ApplicationSettings.Language); liveTokensPath = Path.Combine(_PluginUserDataPath + "\\..\\7e4fbb5e-2ae3-48d4-8ba0-6b30e7a4e287", "login.json"); xstsLoginTokesPath = Path.Combine(_PluginUserDataPath + "\\..\\7e4fbb5e-2ae3-48d4-8ba0-6b30e7a4e287", "xsts.json"); }
public void InitializeMultipleAdd(SuccessStorySettings settings, string GameSourceName = "all") { switch (GameSourceName.ToLower()) { case "all": InitializeMultipleAdd(settings, "Steam"); InitializeMultipleAdd(settings, "GOG"); InitializeMultipleAdd(settings, "Origin"); break; case "steam": break; case "gog": if (settings.EnableGog && gogAPI == null) { gogAPI = new GogAchievements(PlayniteApi); } break; case "origin": if (settings.EnableOrigin && originAPI == null) { originAPI = new OriginAchievements(PlayniteApi); } break; case "playnite": break; } }
public SuccessStoryUI(IPlayniteAPI PlayniteApi, SuccessStorySettings Settings, string PluginUserDataPath, SuccessStory Plugin) : base(PlayniteApi, PluginUserDataPath) { _Settings = Settings; _Plugin = Plugin; _PluginUserDataPath = PluginUserDataPath; BtActionBarName = "PART_ScButton"; SpDescriptionName = "PART_ScDescriptionIntegration"; }
public AchievementsDatabase(IPlayniteAPI PlayniteApi, SuccessStorySettings Settings, string PluginUserDataPath) { this.PlayniteApi = PlayniteApi; this.Settings = Settings; this.PluginUserDataPath = PluginUserDataPath; PluginDatabasePath = PluginUserDataPath + "\\achievements\\"; if (!Directory.Exists(PluginDatabasePath)) { Directory.CreateDirectory(PluginDatabasePath); } }
public AchievementsDatabase(SuccessStory plugin, IPlayniteAPI PlayniteApi, SuccessStorySettings Settings, string PluginUserDataPath, bool isRetroachievements = false) { _plugin = plugin; _PlayniteApi = PlayniteApi; _settings = Settings; _PluginUserDataPath = PluginUserDataPath; _isRetroachievements = isRetroachievements; PluginDatabasePath = PluginUserDataPath + "\\achievements\\"; if (!Directory.Exists(PluginDatabasePath)) { Directory.CreateDirectory(PluginDatabasePath); } }
public SuccessStoryToggleButton(SuccessStorySettings settings) { InitializeComponent(); if (settings.EnableIntegrationInDescriptionOnlyIcon) { PART_ButtonIcon.Visibility = Visibility.Visible; PART_ButtonText.Visibility = Visibility.Collapsed; } else { PART_ButtonIcon.Visibility = Visibility.Collapsed; PART_ButtonText.Visibility = Visibility.Visible; } }
public ScDescriptionIntegration(SuccessStorySettings settings, AchievementsDatabase achievementsDatabase, GameAchievements SelectedGameAchievements, bool IsCustom = false, bool ShowAchievementsGraphic = false, bool ShowAchievementsList = false, bool ShowAchievementsCompactLocked = false, bool ShowAchievementsCompactUnlocked = false, bool ShowProgressBar = false) { InitializeComponent(); _IsCustom = IsCustom; _ShowAchievementsGraphic = ShowAchievementsGraphic; _ShowAchievementsList = ShowAchievementsList; _ShowAchievementsCompactLocked = ShowAchievementsCompactLocked; _ShowAchievementsCompactUnlocked = ShowAchievementsCompactUnlocked; _ShowProgressBar = ShowProgressBar; #if DEBUG logger.Debug($"SuccessStory - ScDescriptionIntegration() - _IsCustom: {_IsCustom}"); #endif SetScData(settings, achievementsDatabase, SelectedGameAchievements); }
public void InitializeMultipleAdd(SuccessStorySettings settings, string GameSourceName = "all") { switch (GameSourceName.ToLower()) { case "all": InitializeMultipleAdd(settings, "Steam"); InitializeMultipleAdd(settings, "GOG"); InitializeMultipleAdd(settings, "Origin"); break; case "steam": break; case "gog": if (!PlayniteTools.IsDisabledPlaynitePlugins("GogLibrary", _PlayniteApi.Paths.ConfigurationPath) && settings.EnableGog && gogAPI == null) { gogAPI = new GogAchievements(_PlayniteApi, settings, _PluginUserDataPath); } break; case "origin": if (!PlayniteTools.IsDisabledPlaynitePlugins("OriginLibrary", _PlayniteApi.Paths.ConfigurationPath) && originAPI == null) { originAPI = new OriginAchievements(_PlayniteApi, settings, _PluginUserDataPath); } break; case "Xbox": if (!PlayniteTools.IsDisabledPlaynitePlugins("XboxLibrary", _PlayniteApi.Paths.ConfigurationPath) && xboxAPI == null) { xboxAPI = new XboxAchievements(_PlayniteApi, settings, _PluginUserDataPath); } break; case "playnite": break; } }
/// <summary> /// /// </summary> /// <param name="GameSourceName"></param> /// <param name="settings"></param> /// <returns></returns> public static bool VerifToAddOrShow(string GameSourceName, SuccessStorySettings settings) { bool Result = false; if (settings.EnableSteam && GameSourceName.ToLower() == "steam") { return(true); } if (settings.EnableGog && GameSourceName.ToLower() == "gog") { return(true); } if (settings.EnableOrigin && GameSourceName.ToLower() == "origin") { return(true); } if (settings.EnableLocal && GameSourceName.ToLower() == "playnite") { return(true); } return(Result); }
/// <summary> /// /// </summary> /// <param name="GameSourceName"></param> /// <param name="settings"></param> /// <returns></returns> public static bool VerifToAddOrShow(SuccessStory plugin, IPlayniteAPI PlayniteApi, string GameSourceName, SuccessStorySettings settings, string PluginUserDataPath) { 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 - VerifToAddOrShowXbox: {VerifToAddOrShowXbox}"); //#endif if (VerifToAddOrShowXbox == null) { VerifToAddOrShowXbox = xboxAchievements.IsConnected(); } //#if DEBUG logger.Debug($"SuccessStory - 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") { 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); } logger.Warn($"SuccessStory - VerifToAddOrShow() find no action"); return(false); }
public RetroAchievements(SuccessStorySettings settings) { User = settings.RetroAchievementsUser; Key = settings.RetroAchievementsKey; }
public GenericAchievements(IPlayniteAPI PlayniteApi, SuccessStorySettings settings, string PluginUserDataPath) { _PlayniteApi = PlayniteApi; _settings = settings; _PluginUserDataPath = PluginUserDataPath; }
/// <summary> /// /// </summary> /// <param name="GameSourceName"></param> /// <param name="settings"></param> /// <returns></returns> public static bool VerifToAddOrShow(string GameSourceName, SuccessStorySettings settings, string PluginUserDataPath) { bool Result = false; JArray DisabledPlugins = new JArray(); JObject PlayniteConfig = new JObject(); try { PlayniteConfig = JObject.Parse(File.ReadAllText(PluginUserDataPath + "\\..\\..\\config.json")); DisabledPlugins = (JArray)PlayniteConfig["DisabledPlugins"]; } catch { } if (settings.EnableSteam && GameSourceName.ToLower() == "steam") { if (DisabledPlugins != null) { foreach (string name in DisabledPlugins) { if (name == "SteamLibrary") { logger.Warn("SuccessStory - Steam is enable then disabled"); return(false); } } } return(true); } if (settings.EnableGog && GameSourceName.ToLower() == "gog") { if (DisabledPlugins != null) { foreach (string name in DisabledPlugins) { if (name == "GogLibrary") { logger.Warn("SuccessStory - GOG is enable then disabled"); return(false); } } } return(true); } if (settings.EnableOrigin && GameSourceName.ToLower() == "origin") { if (DisabledPlugins != null) { foreach (string name in DisabledPlugins) { if (name == "OriginLibrary") { logger.Warn("SuccessStory - Origin is enable then disabled"); return(false); } } } return(true); } if (settings.EnableLocal && GameSourceName.ToLower() == "playnite") { return(true); } if (settings.EnableRetroAchievements && GameSourceName.ToLower() == "retroachievements") { return(true); } return(Result); }
public void SetScData(SuccessStorySettings settings, AchievementsDatabase achievementsDatabase, GameAchievements SelectedGameAchievements) { if (!settings.IntegrationShowTitle || _IsCustom) { PART_Title.Visibility = Visibility.Collapsed; PART_Separator.Visibility = Visibility.Collapsed; } #if DEBUG logger.Debug($"SuccessStory - _IsCustom: {_IsCustom} - _ShowAchievementsGraphic: {_ShowAchievementsGraphic} - _ShowAchievementsList: {_ShowAchievementsList} - _ShowAchievementsCompactLocked: {_ShowAchievementsCompactLocked} - _ShowAchievementsCompactUnlocked: {_ShowAchievementsCompactUnlocked} - _ShowProgressBar: {_ShowProgressBar}"); #endif bool Show = true; if (SelectedGameAchievements == null || !SelectedGameAchievements.HaveAchivements) { return; } PART_SuccessStory_ProgressBar.Visibility = Visibility.Collapsed; if (settings.IntegrationShowProgressBar) { Show = true; if (_IsCustom && !_ShowProgressBar) { Show = false; } #if DEBUG logger.Debug($"SuccessStory - PART_SuccessStory_ProgressBar - Show: {Show} - SelectedGameAchievements: {JsonConvert.SerializeObject(SelectedGameAchievements)}"); #endif if (Show) { PART_SuccessStory_ProgressBar.Visibility = Visibility.Visible; if (successStoryAchievementsProgressBar == null) { successStoryAchievementsProgressBar = new SuccessStoryAchievementsProgressBar(); if (!_IsCustom) { PART_SuccessStory_ProgressBar.Height = 40; PART_SuccessStory_ProgressBar.Margin = new Thickness(0, 5, 0, 5); } PART_SuccessStory_ProgressBar.Children.Add(successStoryAchievementsProgressBar); } successStoryAchievementsProgressBar.SetScData(SelectedGameAchievements.Unlocked, SelectedGameAchievements.Total, settings.IntegrationShowProgressBarPercent, settings.IntegrationShowProgressBarIndicator, _IsCustom); } } PART_SuccessStory_Graphic.Visibility = Visibility.Collapsed; if (settings.IntegrationShowGraphic) { Show = true; if (_IsCustom && !_ShowAchievementsGraphic) { Show = false; } #if DEBUG logger.Debug($"SuccessStory - PART_SuccessStory_Graphic - Show: {Show} - SelectedGameAchievements: {JsonConvert.SerializeObject(SelectedGameAchievements)}"); #endif if (Show) { PART_SuccessStory_Graphic.Visibility = Visibility.Visible; AchievementsGraphicsDataCount GraphicsData = null; if (!settings.GraphicAllUnlockedByDay) { GraphicsData = achievementsDatabase.GetCountByMonth(SuccessStory.GameSelected.Id, (settings.IntegrationGraphicOptionsCountAbscissa - 1)); } else { GraphicsData = achievementsDatabase.GetCountByDay(SuccessStory.GameSelected.Id, (settings.IntegrationGraphicOptionsCountAbscissa - 1)); } string[] StatsGraphicsAchievementsLabels = GraphicsData.Labels; SeriesCollection StatsGraphicAchievementsSeries = new SeriesCollection(); StatsGraphicAchievementsSeries.Add(new LineSeries { Title = string.Empty, Values = GraphicsData.Series }); if (successStoryAchievementsGraphics == null) { successStoryAchievementsGraphics = new SuccessStoryAchievementsGraphics(StatsGraphicAchievementsSeries, StatsGraphicsAchievementsLabels, settings); if (!_IsCustom) { PART_SuccessStory_Graphic.Height = settings.IntegrationShowGraphicHeight; PART_SuccessStory_Graphic.Margin = new Thickness(0, 5, 0, 5); } PART_SuccessStory_Graphic.Children.Add(successStoryAchievementsGraphics); } successStoryAchievementsGraphics.SetScData(StatsGraphicAchievementsSeries, StatsGraphicsAchievementsLabels, settings); } } PART_SuccessStory_List.Visibility = Visibility.Collapsed; if (settings.IntegrationShowAchievements) { Show = true; if (_IsCustom && !_ShowAchievementsList) { Show = false; } #if DEBUG logger.Debug($"SuccessStory - PART_SuccessStory_List - Show: {Show} - SelectedGameAchievements: {JsonConvert.SerializeObject(SelectedGameAchievements)}"); #endif if (Show) { PART_SuccessStory_List.Visibility = Visibility.Visible; if (successStoryAchievementsList == null) { successStoryAchievementsList = new SuccessStoryAchievementsList(); if (!_IsCustom) { PART_SuccessStory_List.Height = settings.IntegrationShowAchievementsHeight; PART_SuccessStory_List.Margin = new Thickness(0, 5, 0, 5); } PART_SuccessStory_List.Children.Add(successStoryAchievementsList); } successStoryAchievementsList.SetScData(SelectedGameAchievements.Achievements, _IsCustom, settings.EnableRaretyIndicator); } } PART_SuccessStory_Compact_Locked.Visibility = Visibility.Collapsed; if (settings.IntegrationShowAchievementsCompactLocked) { Show = true; if (_IsCustom && !_ShowAchievementsCompactLocked) { Show = false; } #if DEBUG logger.Debug($"SuccessStory - PART_SuccessStory_Compact_Locked - Show: {Show} - SelectedGameAchievements: {JsonConvert.SerializeObject(SelectedGameAchievements)}"); #endif if (Show) { PART_SuccessStory_Compact_Locked.Visibility = Visibility.Visible; if (successStoryAchievementsCompact_Locked == null) { successStoryAchievementsCompact_Locked = new SuccessStoryAchievementsCompact(SelectedGameAchievements.Achievements, false, settings.EnableRaretyIndicator); if (!_IsCustom) { PART_SuccessStory_Compact_Locked.Margin = new Thickness(0, 5, 0, 5); PART_SuccessStory_Compact_Locked.Height = successStoryAchievementsCompact_Locked.Height; } PART_SuccessStory_Compact_Locked.Children.Add(successStoryAchievementsCompact_Locked); } successStoryAchievementsCompact_Locked.SetScData(SelectedGameAchievements.Achievements, false, settings.EnableRaretyIndicator); } } PART_SuccessStory_Compact_Unlocked.Visibility = Visibility.Collapsed; if (settings.IntegrationShowAchievementsCompactUnlocked) { Show = true; if (_IsCustom && !_ShowAchievementsCompactUnlocked) { Show = false; } #if DEBUG logger.Debug($"SuccessStory - PART_SuccessStory_Compact_Unlocked - Show: {Show} - SelectedGameAchievements: {JsonConvert.SerializeObject(SelectedGameAchievements)}"); #endif if (Show) { PART_SuccessStory_Compact_Unlocked.Visibility = Visibility.Visible; if (successStoryAchievementsCompact_Unlocked == null) { successStoryAchievementsCompact_Unlocked = new SuccessStoryAchievementsCompact(SelectedGameAchievements.Achievements, true, settings.EnableRaretyIndicator); if (!_IsCustom) { PART_SuccessStory_Compact_Unlocked.Margin = new Thickness(0, 5, 0, 5); PART_SuccessStory_Compact_Unlocked.Height = successStoryAchievementsCompact_Unlocked.Height; } PART_SuccessStory_Compact_Unlocked.Children.Add(successStoryAchievementsCompact_Unlocked); } successStoryAchievementsCompact_Unlocked.SetScData(SelectedGameAchievements.Achievements, true, settings.EnableRaretyIndicator); } } }
/// <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 = ""; if (GameSourceId != Guid.Parse("00000000-0000-0000-0000-000000000000")) { GameSourceName = GameAdded.Source.Name; } else { GameSourceName = "Playnite"; } string PluginDatabaseGamePath = PluginDatabasePath + GameId.ToString() + ".json"; List <Achievements> Achievements = new List <Achievements>(); // Generate database only this source if (VerifToAddOrShow(GameSourceName, settings)) { // Generate only not exist if (!File.Exists(PluginDatabaseGamePath)) { // TODO one func if (GameSourceName.ToLower() == "gog") { if (gogAPI == null) { gogAPI = new GogAchievements(PlayniteApi); } GameAchievements = gogAPI.GetAchievements(PlayniteApi, GameId); } if (GameSourceName.ToLower() == "steam") { SteamAchievements steamAPI = new SteamAchievements(); GameAchievements = steamAPI.GetAchievements(PlayniteApi, GameId, PluginUserDataPath); } if (GameSourceName.ToLower() == "origin") { if (originAPI == null) { originAPI = new OriginAchievements(PlayniteApi); } GameAchievements = originAPI.GetAchievements(PlayniteApi, GameId); } if (GameSourceName.ToLower() == "playnite") { SteamAchievements steamAPI = new SteamAchievements(); GameAchievements = steamAPI.GetAchievements(PlayniteApi, GameId, PluginUserDataPath, settings.EnableLocal); } File.WriteAllText(PluginDatabaseGamePath, JsonConvert.SerializeObject(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 } }
/// <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 = ""; List <Guid> ListEmulators = new List <Guid>(); foreach (var item in PlayniteApi.Database.Emulators) { ListEmulators.Add(item.Id); } if (GameSourceId != Guid.Parse("00000000-0000-0000-0000-000000000000")) { GameSourceName = GameAdded.Source.Name; if (GameAdded.PlayAction != null && GameAdded.PlayAction.EmulatorId != null && ListEmulators.Contains(GameAdded.PlayAction.EmulatorId)) { GameSourceName = "RetroAchievements"; } } else { if (GameAdded.PlayAction != null && GameAdded.PlayAction.EmulatorId != null && ListEmulators.Contains(GameAdded.PlayAction.EmulatorId)) { GameSourceName = "RetroAchievements"; } else { GameSourceName = "Playnite"; } } string PluginDatabaseGamePath = PluginDatabasePath + GameId.ToString() + ".json"; List <Achievements> Achievements = new List <Achievements>(); // Generate database only this source if (VerifToAddOrShow(GameSourceName, settings, PluginUserDataPath)) { // Generate only not exist if (!File.Exists(PluginDatabaseGamePath)) { // TODO one func if (GameSourceName.ToLower() == "gog") { if (gogAPI == null) { gogAPI = new GogAchievements(PlayniteApi); } GameAchievements = gogAPI.GetAchievements(PlayniteApi, GameId); } if (GameSourceName.ToLower() == "steam") { SteamAchievements steamAPI = new SteamAchievements(); GameAchievements = steamAPI.GetAchievements(PlayniteApi, GameId, PluginUserDataPath); } if (GameSourceName.ToLower() == "origin") { if (originAPI == null) { originAPI = new OriginAchievements(PlayniteApi); } GameAchievements = originAPI.GetAchievements(PlayniteApi, GameId); } if (GameSourceName.ToLower() == "playnite") { SteamAchievements steamAPI = new SteamAchievements(); GameAchievements = steamAPI.GetAchievements(PlayniteApi, GameId, PluginUserDataPath, settings.EnableLocal); } if (GameSourceName.ToLower() == "retroachievements") { RetroAchievements retroAchievementsAPI = new RetroAchievements(settings); GameAchievements = retroAchievementsAPI.GetAchievements(PlayniteApi, GameId, PluginUserDataPath); } if (GameAchievements != null) { File.WriteAllText(PluginDatabaseGamePath, JsonConvert.SerializeObject(GameAchievements)); } } } }
public RetroAchievements(IPlayniteAPI PlayniteApi, SuccessStorySettings settings, string PluginUserDataPath) : base(PlayniteApi, settings, PluginUserDataPath) { User = settings.RetroAchievementsUser; Key = settings.RetroAchievementsKey; }
public SuccessStoryAchievementsGraphics(SeriesCollection StatsGraphicAchievementsSeries, IList <string> StatsGraphicsAchievementsLabels, SuccessStorySettings settings, bool withContener = false) { InitializeComponent(); //let create a mapper so LiveCharts know how to plot our CustomerViewModel class var customerVmMapper = Mappers.Xy <CustomerForSingle>() .X((value, index) => index) .Y(value => value.Values); //lets save the mapper globally Charting.For <CustomerForSingle>(customerVmMapper); SetScData(StatsGraphicAchievementsSeries, StatsGraphicsAchievementsLabels, settings, withContener); }
public Rpcs3Achievements(IPlayniteAPI PlayniteApi, SuccessStorySettings settings, string PluginUserDataPath) : base(PlayniteApi, settings, PluginUserDataPath) { }
public void SetScData(SeriesCollection StatsGraphicAchievementsSeries, IList <string> StatsGraphicsAchievementsLabels, SuccessStorySettings settings, bool withContener = false) { _withContener = withContener; StatsGraphicAchievements.Series = StatsGraphicAchievementsSeries; StatsGraphicAchievementsX.Labels = StatsGraphicsAchievementsLabels; if (!settings.IgnoreSettings) { StatsGraphicAchievementsX.ShowLabels = settings.EnableIntegrationAxisGraphic; StatsGraphicAchievementsY.ShowLabels = settings.EnableIntegrationOrdinatesGraphic; } }
public SteamAchievements(IPlayniteAPI PlayniteApi, SuccessStorySettings settings, string PluginUserDataPath) : base(PlayniteApi, settings, PluginUserDataPath) { LocalLang = CodeLang.GetSteamLang(_PlayniteApi.ApplicationSettings.Language); }
public GogAchievements(IPlayniteAPI PlayniteApi, SuccessStorySettings settings, string PluginUserDataPath) : base(PlayniteApi, settings, PluginUserDataPath) { var view = PlayniteApi.WebViews.CreateOffscreenView(); gogAPI = new GogAccountClient(view); }