private void LoadData(Game GameSelected) { Guid GameId = GameSelected.Id; GameAchievements successStories = PluginDatabase.Get(GameSelected); List <Achievements> ListAchievements = successStories.Items; List <GameStats> ListGameStats = successStories.ItemsStats; // List Achievements SuccessStoryAchievementsList successStoryAchievementsList = new SuccessStoryAchievementsList(true); successStoryAchievementsList.SetScData(successStories); PART_Achievements_List.Children.Add(successStoryAchievementsList); // Chart achievements int limit = 0; if (!PluginDatabase.PluginSettings.GraphicAllUnlockedByDay) { PART_ChartTitle.Content = resources.GetString("LOCSuccessStoryGraphicTitle"); limit = 20; } else { PART_ChartTitle.Content = resources.GetString("LOCSuccessStoryGraphicTitleDay"); limit = 16; } PluginDatabase.PluginSettings.IgnoreSettings = true; SuccessStoryAchievementsGraphics successStoryAchievementsGraphics = new SuccessStoryAchievementsGraphics(); successStoryAchievementsGraphics.SetScData(GameId, limit); PART_Achievements_Graphics.Children.Add(successStoryAchievementsGraphics); // User stats SuccessStoryUserStats successStoryUserStats = new SuccessStoryUserStats(); successStoryUserStats.SetScData(ListGameStats); PART_ScUserStats.Children.Add(successStoryUserStats); }
/// <summary> /// Show Achievements for the selected game. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ListviewGames_SelectionChanged(object sender, SelectionChangedEventArgs e) { ListViewGames GameSelected = (ListViewGames)((ListBox)sender).SelectedItem; if (GameSelected != null) { listAchievementBorder.BorderThickness = new Thickness(0); Guid GameId = Guid.Parse(GameSelected.Id); GameAchievements successStories = PluginDatabase.Get(GameId); List <Achievements> ListAchievements = successStories.Items; SuccessStory_Achievements_List.Children.Clear(); SuccessStoryAchievementsList successStoryAchievementsList = new SuccessStoryAchievementsList(true); successStoryAchievementsList.SetScData(successStories, true); SuccessStory_Achievements_List.Children.Add(successStoryAchievementsList); int limit = 0; if (!PluginDatabase.PluginSettings.GraphicAllUnlockedByDay) { GraphicTitle.Content = resources.GetString("LOCSuccessStoryGraphicTitle"); } else { GraphicTitle.Content = resources.GetString("LOCSuccessStoryGraphicTitleDay"); limit = 8; } SuccessStory_Achievements_Graphics_Game.Children.Clear(); PluginDatabase.PluginSettings.IgnoreSettings = true; SuccessStoryAchievementsGraphics successStoryAchievementsGraphics = new SuccessStoryAchievementsGraphics(); successStoryAchievementsGraphics.SetScData(GameId, limit); SuccessStory_Achievements_Graphics_Game.Children.Add(successStoryAchievementsGraphics); } }
public SuccessView(SuccessStory plugin, IPlayniteAPI PlayniteApi, string PluginUserDataPath, bool isRetroAchievements = false, Game GameSelected = null) { _plugin = plugin; _PlayniteApi = PlayniteApi; _PlayniteApiDatabase = PlayniteApi.Database; _PlayniteApiPaths = PlayniteApi.Paths; _PluginUserDataPath = PluginUserDataPath; InitializeComponent(); PART_DataLoad.Visibility = Visibility.Visible; PART_Data.Visibility = Visibility.Hidden; var TaskView = Task.Run(() => { GetListGame(); SetGraphicsAchievementsSources(); this.Dispatcher.BeginInvoke((Action) delegate { // Block hidden column. lvProgressionValue.IsEnabled = false; lvSourceName.IsEnabled = false; pbProgressionGlobalCount.Value = PluginDatabase.Progession().Unlocked; pbProgressionGlobalCount.Maximum = PluginDatabase.Progession().Total; labelProgressionGlobalCount.Content = PluginDatabase.Progession().Progression + "%"; pbProgressionLaunchedCount.Value = PluginDatabase.ProgessionLaunched().Unlocked; pbProgressionLaunchedCount.Maximum = PluginDatabase.ProgessionLaunched().Total; labelProgressionLaunchedCount.Content = PluginDatabase.ProgessionLaunched().Progression + "%"; GraphicTitle.Content = string.Empty; // lvGames options if (!PluginDatabase.PluginSettings.lvGamesIcon100Percent) { lvGameIcon100Percent.Width = 0; } if (!PluginDatabase.PluginSettings.lvGamesIcon) { lvGameIcon.Width = 0; } if (!PluginDatabase.PluginSettings.lvGamesName) { lvGameName.Width = 0; } if (!PluginDatabase.PluginSettings.lvGamesLastSession) { lvGameLastActivity.Width = 0; } if (!PluginDatabase.PluginSettings.lvGamesSource) { lvGamesSource.Width = 0; } if (!PluginDatabase.PluginSettings.lvGamesProgression) { lvGameProgression.Width = 0; } int limit = 5; GraphicTitleALL.Content = resources.GetString("LOCSuccessStoryGraphicTitleALL"); SuccessStory_Achievements_Graphics.Children.Clear(); PluginDatabase.PluginSettings.IgnoreSettings = true; SuccessStoryAchievementsGraphics successStoryAchievementsGraphics = new SuccessStoryAchievementsGraphics(); successStoryAchievementsGraphics.SetScData(null, limit, true); SuccessStory_Achievements_Graphics.Children.Add(successStoryAchievementsGraphics); SuccessStory_Achievements_Graphics.UpdateLayout(); // Set game selected if (GameSelected != null) { for (int i = 0; i < ListviewGames.Items.Count; i++) { if (((ListViewGames)ListviewGames.Items[i]).Name == GameSelected.Name) { ListviewGames.SelectedIndex = i; } } } ListviewGames.ScrollIntoView(ListviewGames.SelectedItem); string icon = string.Empty; if (PluginDatabase.PluginSettings.EnableRetroAchievementsView && PluginDatabase.PluginSettings.EnableRetroAchievements) { if (isRetroAchievements) { PART_GraphicBySource.Visibility = Visibility.Collapsed; Grid.SetColumn(PART_GraphicAllUnlocked, 0); Grid.SetColumnSpan(PART_GraphicAllUnlocked, 3); if (PluginDatabase.PluginSettings.EnableRetroAchievements) { icon = TransformIcon.Get("RetroAchievements") + " "; FilterSourceItems.Add(new ListSource { SourceName = ((icon.Length == 2) ? icon : string.Empty) + "RetroAchievements", SourceNameShort = "RetroAchievements", IsCheck = false }); } } else { if (PluginDatabase.PluginSettings.EnableLocal) { icon = TransformIcon.Get("Playnite") + " "; FilterSourceItems.Add(new ListSource { SourceName = ((icon.Length == 2) ? icon : string.Empty) + "Playnite", SourceNameShort = "Playnite", IsCheck = false }); icon = TransformIcon.Get("Hacked") + " "; FilterSourceItems.Add(new ListSource { SourceName = ((icon.Length == 2) ? icon : string.Empty) + "Hacked", SourceNameShort = "Hacked", IsCheck = false }); } if (PluginDatabase.PluginSettings.EnableSteam) { icon = TransformIcon.Get("Steam") + " "; FilterSourceItems.Add(new ListSource { SourceName = ((icon.Length == 2) ? icon : string.Empty) + "Steam", SourceNameShort = "Steam", IsCheck = false }); } if (PluginDatabase.PluginSettings.EnableGog) { icon = TransformIcon.Get("GOG") + " "; FilterSourceItems.Add(new ListSource { SourceName = ((icon.Length == 2) ? icon : string.Empty) + "GOG", SourceNameShort = "GOG", IsCheck = false }); } if (PluginDatabase.PluginSettings.EnableOrigin) { icon = TransformIcon.Get("Origin") + " "; FilterSourceItems.Add(new ListSource { SourceName = ((icon.Length == 2) ? icon : string.Empty) + "Origin", SourceNameShort = "Origin", IsCheck = false }); } if (PluginDatabase.PluginSettings.EnableXbox) { icon = TransformIcon.Get("Xbox") + " "; FilterSourceItems.Add(new ListSource { SourceName = ((icon.Length == 2) ? icon : string.Empty) + "Xbox", SourceNameShort = "Xbox", IsCheck = false }); } if (PluginDatabase.PluginSettings.EnableRpcs3Achievements) { icon = TransformIcon.Get("Rpcs3") + " "; FilterSourceItems.Add(new ListSource { SourceName = ((icon.Length == 2) ? icon : string.Empty) + "Rpcs3", SourceNameShort = "Rpcs3", IsCheck = false }); } if (PluginDatabase.PluginSettings.EnableManual) { icon = TransformIcon.Get("Manual") + " "; FilterSourceItems.Add(new ListSource { SourceName = ((icon.Length == 2) ? icon : string.Empty) + "Manual", SourceNameShort = "Manual", IsCheck = false }); } } } else { if (PluginDatabase.PluginSettings.EnableLocal) { icon = TransformIcon.Get("Playnite") + " "; FilterSourceItems.Add(new ListSource { SourceName = ((icon.Length == 2) ? icon : string.Empty) + "Playnite", SourceNameShort = "Playnite", IsCheck = false }); icon = TransformIcon.Get("Hacked") + " "; FilterSourceItems.Add(new ListSource { SourceName = ((icon.Length == 2) ? icon : string.Empty) + "Hacked", SourceNameShort = "Hacked", IsCheck = false }); } if (PluginDatabase.PluginSettings.EnableSteam) { icon = TransformIcon.Get("Steam") + " "; FilterSourceItems.Add(new ListSource { SourceName = ((icon.Length == 2) ? icon : string.Empty) + "Steam", SourceNameShort = "Steam", IsCheck = false }); } if (PluginDatabase.PluginSettings.EnableGog) { icon = TransformIcon.Get("GOG") + " "; FilterSourceItems.Add(new ListSource { SourceName = ((icon.Length == 2) ? icon : string.Empty) + "GOG", SourceNameShort = "GOG", IsCheck = false }); } if (PluginDatabase.PluginSettings.EnableOrigin) { icon = TransformIcon.Get("Origin") + " "; FilterSourceItems.Add(new ListSource { SourceName = ((icon.Length == 2) ? icon : string.Empty) + "Origin", SourceNameShort = "Origin", IsCheck = false }); } if (PluginDatabase.PluginSettings.EnableXbox) { icon = TransformIcon.Get("Xbox") + " "; FilterSourceItems.Add(new ListSource { SourceName = ((icon.Length == 2) ? icon : string.Empty) + "Xbox", SourceNameShort = "Xbox", IsCheck = false }); } if (PluginDatabase.PluginSettings.EnableRetroAchievements) { icon = TransformIcon.Get("RetroAchievements") + " "; FilterSourceItems.Add(new ListSource { SourceName = ((icon.Length == 2) ? icon : string.Empty) + "RetroAchievements", SourceNameShort = "RetroAchievements", IsCheck = false }); } if (PluginDatabase.PluginSettings.EnableRpcs3Achievements) { icon = TransformIcon.Get("RPCS3") + " "; FilterSourceItems.Add(new ListSource { SourceName = ((icon.Length == 2) ? icon : string.Empty) + "RPCS3", SourceNameShort = "Rpcs3", IsCheck = false }); } if (PluginDatabase.PluginSettings.EnableManual) { icon = TransformIcon.Get("Manual") + " "; FilterSourceItems.Add(new ListSource { SourceName = ((icon.Length == 2) ? icon : string.Empty) + "Manual", SourceNameShort = "Manual", IsCheck = false }); } } FilterSource.ItemsSource = FilterSourceItems; // Set Binding data DataContext = this; PART_DataLoad.Visibility = Visibility.Hidden; PART_Data.Visibility = Visibility.Visible; }); }); }
public override void AddCustomElements() { if (ListCustomElements.Count > 0) { #if DEBUG logger.Debug($"SuccessStory [Ignored] - CustomElements allready insert - {ListCustomElements.Count}"); #endif return; } FrameworkElement PART_ScButtonWithJustIcon = null; FrameworkElement PART_ScButtonWithTitle = null; FrameworkElement PART_ScButtonWithTitleAndDetails = null; FrameworkElement PART_Achievements_ProgressBar = null; FrameworkElement PART_Achievements_Graphics = null; FrameworkElement PART_Achievements_List = null; FrameworkElement PART_Achievements_ListComptact = null; FrameworkElement PART_Achievements_ListComptactVertical = null; FrameworkElement PART_Achievements_ListCompactUnlocked = null; FrameworkElement PART_Achievements_ListCompactLocked = null; FrameworkElement PART_Achievements_ListCompactVerticalUnlocked = null; FrameworkElement PART_Achievements_ListCompactVerticalLocked = null; FrameworkElement PART_ScUserStats = null; try { PART_ScButtonWithJustIcon = IntegrationUI.SearchElementByName("PART_ScButtonWithJustIcon", false, true); PART_ScButtonWithTitle = IntegrationUI.SearchElementByName("PART_ScButtonWithTitle", false, true); PART_ScButtonWithTitleAndDetails = IntegrationUI.SearchElementByName("PART_ScButtonWithTitleAndDetails", false, true); PART_Achievements_ProgressBar = IntegrationUI.SearchElementByName("PART_Achievements_ProgressBar", false, true); PART_Achievements_Graphics = IntegrationUI.SearchElementByName("PART_Achievements_Graphics", false, true); PART_Achievements_List = IntegrationUI.SearchElementByName("PART_Achievements_List", false, true); PART_Achievements_ListComptact = IntegrationUI.SearchElementByName("PART_Achievements_ListComptact", false, true); PART_Achievements_ListComptactVertical = IntegrationUI.SearchElementByName("PART_Achievements_ListComptactVertical", false, true); PART_Achievements_ListCompactUnlocked = IntegrationUI.SearchElementByName("PART_Achievements_ListCompactUnlocked", false, true); PART_Achievements_ListCompactLocked = IntegrationUI.SearchElementByName("PART_Achievements_ListCompactLocked", false, true); PART_Achievements_ListCompactVerticalUnlocked = IntegrationUI.SearchElementByName("PART_Achievements_ListCompactVerticalUnlocked", false, true); PART_Achievements_ListCompactVerticalLocked = IntegrationUI.SearchElementByName("PART_Achievements_ListCompactVerticalLocked", false, true); PART_ScUserStats = IntegrationUI.SearchElementByName("PART_ScUserStats", false, true); } catch (Exception ex) { Common.LogError(ex, "SuccessStory", $"Error on find custom element"); } if (PART_ScButtonWithJustIcon != null) { PART_ScButtonWithJustIcon = new SuccessStoryButton(true); ((Button)PART_ScButtonWithJustIcon).Click += OnBtActionBarClick; try { ui.AddElementInCustomTheme(PART_ScButtonWithJustIcon, "PART_ScButtonWithJustIcon"); ListCustomElements.Add(new CustomElement { ParentElementName = "PART_ScButtonWithJustIcon", Element = PART_ScButtonWithJustIcon }); } catch (Exception ex) { Common.LogError(ex, "SuccessStory", "Error on AddCustomElements()"); } } else { #if DEBUG logger.Debug($"SuccessStory [Ignored] - PART_ScButtonWithJustIcon not find"); #endif } if (PART_ScButtonWithTitle != null) { PART_ScButtonWithTitle = new SuccessStoryButton(false); ((Button)PART_ScButtonWithTitle).Click += OnBtActionBarClick; try { ui.AddElementInCustomTheme(PART_ScButtonWithTitle, "PART_ScButtonWithTitle"); ListCustomElements.Add(new CustomElement { ParentElementName = "PART_ScButtonWithTitle", Element = PART_ScButtonWithTitle }); } catch (Exception ex) { Common.LogError(ex, "SuccessStory", "Error on AddCustomElements()"); } } else { #if DEBUG logger.Debug($"SuccessStory [Ignored] - PART_ScButtonWithTitle not find"); #endif } if (PART_ScButtonWithTitleAndDetails != null) { PART_ScButtonWithTitleAndDetails = new SuccessStoryButtonDetails(); ((Button)PART_ScButtonWithTitleAndDetails).Click += OnBtActionBarClick; try { ui.AddElementInCustomTheme(PART_ScButtonWithTitleAndDetails, "PART_ScButtonWithTitleAndDetails"); ListCustomElements.Add(new CustomElement { ParentElementName = "PART_ScButtonWithTitleAndDetails", Element = PART_ScButtonWithTitleAndDetails }); } catch (Exception ex) { Common.LogError(ex, "SuccessStory", "Error on AddCustomElements()"); } } else { #if DEBUG logger.Debug($"SuccessStory [Ignored] - PART_ScButtonWithTitleAndDetails not find"); #endif } if (PART_Achievements_ProgressBar != null && PluginDatabase.PluginSettings.IntegrationShowProgressBar) { PART_Achievements_ProgressBar = new SuccessStoryAchievementsProgressBar(); PART_Achievements_ProgressBar.Name = "Achievements_ProgressBar"; try { ui.AddElementInCustomTheme(PART_Achievements_ProgressBar, "PART_Achievements_ProgressBar"); ListCustomElements.Add(new CustomElement { ParentElementName = "PART_Achievements_ProgressBar", Element = PART_Achievements_ProgressBar }); } catch (Exception ex) { Common.LogError(ex, "SuccessStory", "Error on AddCustomElements()"); } } else { #if DEBUG logger.Debug($"SuccessStory [Ignored] - PART_Achievements_ProgressBar not find"); #endif } if (PART_Achievements_Graphics != null && PluginDatabase.PluginSettings.IntegrationShowGraphic) { PART_Achievements_Graphics = new SuccessStoryAchievementsGraphics(); PART_Achievements_Graphics.Name = "Achievements_Graphics"; try { ui.AddElementInCustomTheme(PART_Achievements_Graphics, "PART_Achievements_Graphics"); ListCustomElements.Add(new CustomElement { ParentElementName = "PART_Achievements_Graphics", Element = PART_Achievements_Graphics }); } catch (Exception ex) { Common.LogError(ex, "SuccessStory", "Error on AddCustomElements()"); } } else { #if DEBUG logger.Debug($"SuccessStory [Ignored] - PART_Achievements_Graphics not find"); #endif } if (PART_Achievements_ListComptact != null && PluginDatabase.PluginSettings.IntegrationShowAchievementsCompact) { PART_Achievements_ListComptact = new ScAchievementsListCompact(); PART_Achievements_ListComptact.Name = "Achievements_ListCompact"; try { ui.AddElementInCustomTheme(PART_Achievements_ListComptact, "PART_Achievements_ListComptact"); ListCustomElements.Add(new CustomElement { ParentElementName = "PART_Achievements_ListComptact", Element = PART_Achievements_ListComptact }); } catch (Exception ex) { Common.LogError(ex, "SuccessStory", "Error on AddCustomElements()"); } } else { #if DEBUG logger.Debug($"SuccessStory [Ignored] - PART_Achievements_ListComptact not find"); #endif } if (PART_Achievements_ListComptactVertical != null)// && PluginDatabase.PluginSettings.IntegrationShowAchievementsCompact) { PART_Achievements_ListComptactVertical = new ScAchievementsListCompactVertical(); PART_Achievements_ListComptactVertical.Name = "Achievements_ListCompactVertical"; try { ui.AddElementInCustomTheme(PART_Achievements_ListComptactVertical, "PART_Achievements_ListComptactVertical"); ListCustomElements.Add(new CustomElement { ParentElementName = "PART_Achievements_ListComptactVertical", Element = PART_Achievements_ListComptactVertical }); } catch (Exception ex) { Common.LogError(ex, "SuccessStory", "Error on AddCustomElements()"); } } else { #if DEBUG logger.Debug($"SuccessStory [Ignored] - PART_Achievements_ListComptactVertical not find"); #endif } if (PART_Achievements_List != null && PluginDatabase.PluginSettings.IntegrationShowAchievements) { PART_Achievements_List = new SuccessStoryAchievementsList(); PART_Achievements_List.Name = "Achievements_List"; try { ui.AddElementInCustomTheme(PART_Achievements_List, "PART_Achievements_List"); ListCustomElements.Add(new CustomElement { ParentElementName = "PART_Achievements_List", Element = PART_Achievements_List }); } catch (Exception ex) { Common.LogError(ex, "SuccessStory", "Error on AddCustomElements()"); } } else { #if DEBUG logger.Debug($"SuccessStory [Ignored] - PART_Achievements_List not find"); #endif } if (PART_Achievements_ListCompactUnlocked != null && PluginDatabase.PluginSettings.IntegrationShowAchievements) { PART_Achievements_ListCompactUnlocked = new SuccessStoryAchievementsCompact(true); PART_Achievements_ListCompactUnlocked.Name = "Achievements_ListCompactUnlocked"; try { ui.AddElementInCustomTheme(PART_Achievements_ListCompactUnlocked, "PART_Achievements_ListCompactUnlocked"); ListCustomElements.Add(new CustomElement { ParentElementName = "PART_Achievements_ListCompactUnlocked", Element = PART_Achievements_ListCompactUnlocked }); } catch (Exception ex) { Common.LogError(ex, "SuccessStory", "Error on AddCustomElements()"); } } else { #if DEBUG logger.Debug($"SuccessStory [Ignored] - PART_Achievements_ListCompactUnlocked not find"); #endif } if (PART_Achievements_ListCompactLocked != null && PluginDatabase.PluginSettings.IntegrationShowAchievements) { PART_Achievements_ListCompactLocked = new SuccessStoryAchievementsCompact(); PART_Achievements_ListCompactLocked.Name = "Achievements_ListCompactLocked"; try { ui.AddElementInCustomTheme(PART_Achievements_ListCompactLocked, "PART_Achievements_ListCompactLocked"); ListCustomElements.Add(new CustomElement { ParentElementName = "PART_Achievements_ListCompactLocked", Element = PART_Achievements_ListCompactLocked }); } catch (Exception ex) { Common.LogError(ex, "SuccessStory", "Error on AddCustomElements()"); } } else { #if DEBUG logger.Debug($"SuccessStory [Ignored] - PART_Achievements_ListCompactLocked not find"); #endif } if (PART_Achievements_ListCompactVerticalUnlocked != null)// && PluginDatabase.PluginSettings.IntegrationShowAchievements) { PART_Achievements_ListCompactVerticalUnlocked = new SuccessStoryAchievementsCompactVertical(true); PART_Achievements_ListCompactVerticalUnlocked.Name = "Achievements_ListCompactVerticalUnlocked"; try { ui.AddElementInCustomTheme(PART_Achievements_ListCompactVerticalUnlocked, "PART_Achievements_ListCompactVerticalUnlocked"); ListCustomElements.Add(new CustomElement { ParentElementName = "PART_Achievements_ListCompactVerticalUnlocked", Element = PART_Achievements_ListCompactVerticalUnlocked }); } catch (Exception ex) { Common.LogError(ex, "SuccessStory", "Error on AddCustomElements()"); } } else { #if DEBUG logger.Debug($"SuccessStory [Ignored] - PART_Achievements_ListCompactVerticalUnlocked not find"); #endif } if (PART_Achievements_ListCompactVerticalLocked != null)// && PluginDatabase.PluginSettings.IntegrationShowAchievements) { PART_Achievements_ListCompactVerticalLocked = new SuccessStoryAchievementsCompactVertical(); PART_Achievements_ListCompactVerticalLocked.Name = "Achievements_ListCompactVerticalLocked"; try { ui.AddElementInCustomTheme(PART_Achievements_ListCompactVerticalLocked, "PART_Achievements_ListCompactVerticalLocked"); ListCustomElements.Add(new CustomElement { ParentElementName = "PART_Achievements_ListCompactVerticalLocked", Element = PART_Achievements_ListCompactVerticalLocked }); } catch (Exception ex) { Common.LogError(ex, "SuccessStory", "Error on AddCustomElements()"); } } else { #if DEBUG logger.Debug($"SuccessStory [Ignored] - PART_Achievements_ListCompactLocked not find"); #endif } if (PART_ScUserStats != null && PluginDatabase.PluginSettings.IntegrationShowUserStats) { PART_ScUserStats = new SuccessStoryUserStats(); PART_ScUserStats.Name = "UserStats_List"; try { ui.AddElementInCustomTheme(PART_ScUserStats, "PART_ScUserStats"); ListCustomElements.Add(new CustomElement { ParentElementName = "PART_ScUserStats", Element = PART_ScUserStats }); } catch (Exception ex) { Common.LogError(ex, "SuccessStory", "Error on AddCustomElements()"); } } else { #if DEBUG logger.Debug($"SuccessStory [Ignored] - PART_UserStats not find"); #endif } }