public override void AddBtActionBar() { if (PART_BtActionBar != null) { #if DEBUG logger.Debug($"SuccessStory - PART_BtActionBar allready insert"); #endif return; } FrameworkElement BtActionBar; if (_Settings.EnableIntegrationInDescriptionWithToggle) { if (_Settings.EnableIntegrationButtonDetails) { BtActionBar = new SuccessStoryToggleButtonDetails(); } else { BtActionBar = new SuccessStoryToggleButton(_Settings); } ((ToggleButton)BtActionBar).Click += OnBtActionBarToggleButtonClick; } else { if (_Settings.EnableIntegrationButtonDetails) { BtActionBar = new SuccessStoryButtonDetails(); } else { BtActionBar = new SuccessStoryButton(_Settings.EnableIntegrationInDescriptionOnlyIcon); } ((Button)BtActionBar).Click += OnBtActionBarClick; } if (!_Settings.EnableIntegrationInDescriptionOnlyIcon) { BtActionBar.Width = 150; } BtActionBar.Name = BtActionBarName; BtActionBar.Margin = new Thickness(10, 0, 0, 0); try { ui.AddButtonInGameSelectedActionBarButtonOrToggleButton(BtActionBar); PART_BtActionBar = IntegrationUI.SearchElementByName(BtActionBarName); } catch (Exception ex) { Common.LogError(ex, "SuccessStory", "Error on AddBtActionBar()"); } }
private void Integration() { try { // Search game description if (PART_ElemDescription == null) { foreach (StackPanel sp in Tools.FindVisualChildren <StackPanel>(Application.Current.MainWindow)) { if (sp.Name == "PART_ElemDescription") { PART_ElemDescription = sp; break; } } } // Delete logger.Info("SuccessStory - Delete"); ui.RemoveButtonInGameSelectedActionBarButtonOrToggleButton("PART_ScButton"); ui.RemoveButtonInGameSelectedActionBarButtonOrToggleButton("PART_ScToggleButton"); ui.RemoveElementInGameSelectedDescription("PART_Achievements"); ui.ClearElementInCustomTheme("PART_Achievements_Graphics"); ui.ClearElementInCustomTheme("PART_Achievements_List"); ui.ClearElementInCustomTheme("PART_Achievements_ProgressBar"); // Reset resources List <ResourcesList> resourcesLists = new List <ResourcesList>(); resourcesLists.Add(new ResourcesList { Key = "Sc_Total", Value = "0" }); resourcesLists.Add(new ResourcesList { Key = "Sc_Unlocked", Value = "0" }); resourcesLists.Add(new ResourcesList { Key = "Sc_Locked", Value = "0" }); ui.AddResources(resourcesLists); var taskIntegration = Task.Run(() => LoadData(PlayniteApi, this.GetPluginUserDataPath(), settings)) .ContinueWith(antecedent => { GameAchievements SelectedGameAchievements = antecedent.Result; Application.Current.Dispatcher.Invoke(new Action(() => { // No achievements if (SelectedGameAchievements == null || !SelectedGameAchievements.HaveAchivements) { //logger.Debug(JsonConvert.SerializeObject(SelectedGameAchievements)); logger.Info("SuccessStory - No achievement for " + GameSelected.Name); return; } // Add resources resourcesLists.Add(new ResourcesList { Key = "Sc_Total", Value = SelectedGameAchievements.Total.ToString() }); resourcesLists.Add(new ResourcesList { Key = "Sc_Unlocked", Value = SelectedGameAchievements.Unlocked.ToString() }); resourcesLists.Add(new ResourcesList { Key = "Sc_Locked", Value = SelectedGameAchievements.Locked.ToString() }); ui.AddResources(resourcesLists); // Auto integration if (settings.EnableIntegrationInDescription || settings.EnableIntegrationInDescriptionWithToggle) { if (settings.EnableIntegrationInDescriptionWithToggle) { ToggleButton tb = new ToggleButton(); if (settings.IntegrationToggleDetails) { tb = new SuccessStoryToggleButtonDetails(SelectedGameAchievements.Unlocked, SelectedGameAchievements.Total); } else { tb = new SuccessStoryToggleButton(); tb.Content = resources.GetString("LOCSucessStoryAchievements"); } tb.IsChecked = false; tb.Name = "PART_ScToggleButton"; tb.Width = 150; tb.HorizontalAlignment = HorizontalAlignment.Right; tb.VerticalAlignment = VerticalAlignment.Stretch; tb.Margin = new Thickness(10, 0, 0, 0); tb.Click += OnGameSelectedToggleButtonClick; ui.AddButtonInGameSelectedActionBarButtonOrToggleButton(tb); } // Add Achievements elements StackPanel ScA = CreateSc(achievementsDatabase, SelectedGameAchievements, settings.IntegrationShowTitle, settings.IntegrationShowGraphic, settings.IntegrationShowAchievements, settings.IntegrationShowProgressBar, false); if (settings.EnableIntegrationInDescriptionWithToggle) { ScA.Visibility = Visibility.Collapsed; } ui.AddElementInGameSelectedDescription(ScA, settings.IntegrationTopGameDetails); } // Auto adding button if (settings.EnableIntegrationButton || settings.EnableIntegrationButtonDetails) { Button bt = new Button(); if (settings.EnableIntegrationButton) { bt.Content = resources.GetString("LOCSucessStoryAchievements"); } if (settings.EnableIntegrationButtonDetails) { bt = new SuccessStoryButtonDetails(SelectedGameAchievements.Unlocked, SelectedGameAchievements.Total); } bt.Name = "PART_ScButton"; bt.Width = 150; bt.HorizontalAlignment = HorizontalAlignment.Right; bt.VerticalAlignment = VerticalAlignment.Stretch; bt.Margin = new Thickness(10, 0, 0, 0); bt.Click += OnBtGameSelectedActionBarClick; ui.AddButtonInGameSelectedActionBarButtonOrToggleButton(bt); } // Custom theme if (settings.EnableIntegrationInCustomTheme) { if (settings.IntegrationShowGraphic) { StackPanel scAG = CreateSc(achievementsDatabase, SelectedGameAchievements, false, true, false, false, true); ui.AddElementInCustomTheme(scAG, "PART_Achievements_Graphics"); } if (settings.IntegrationShowAchievements) { StackPanel scAL = CreateSc(achievementsDatabase, SelectedGameAchievements, false, false, true, false, true); ui.AddElementInCustomTheme(scAL, "PART_Achievements_List"); } if (settings.IntegrationShowProgressBar) { StackPanel scPB = CreateSc(achievementsDatabase, SelectedGameAchievements, false, false, false, true, true); ui.AddElementInCustomTheme(scPB, "PART_Achievements_ProgressBar"); } } })); }); } catch (Exception ex) { Common.LogError(ex, "SucessStory", $"Impossible integration"); } }
private void Integration() { bool noAchievements = false; try { AchievementsDatabase achievementsDatabase = new AchievementsDatabase(PlayniteApi, this.GetPluginUserDataPath()); achievementsDatabase.Initialize(); GameAchievements SelectedGameAchievements = achievementsDatabase.Get(GameSelected.Id); // Download Achievements if not exist in database. if (SelectedGameAchievements == null) { logger.Info("SuccesStory - Download achievements for " + GameSelected.Name); achievementsDatabase.Add(GameSelected, settings); achievementsDatabase.Initialize(); SelectedGameAchievements = achievementsDatabase.Get(GameSelected.Id); } if (SelectedGameAchievements == null || !SelectedGameAchievements.HaveAchivements) { logger.Info("SuccessStory - No achievement for " + GameSelected.Name); if (settings.EnableIntegrationInDescription || settings.EnableIntegrationInDescriptionWithToggle) { Button PART_ScButton = (Button)LogicalTreeHelper.FindLogicalNode(PART_ActionButtons, "PART_ScButton"); // Delete old ButtonDetails if (settings.EnableIntegrationButtonDetails) { PART_ActionButtons.Children.Remove(PART_ScButton); PART_ScButton = null; } ToggleButton PART_ScToggleButton = (ToggleButton)LogicalTreeHelper.FindLogicalNode(PART_ActionButtons, "PART_ScToggleButton"); // Delete old ToggleDetails if (settings.IntegrationToggleDetails) { PART_ActionButtons.Children.Remove(PART_ScToggleButton); PART_ScToggleButton = null; } // Delete old string NameControl = "PART_Achievements"; StackPanel PART_Achievements = (StackPanel)LogicalTreeHelper.FindLogicalNode(PART_ElemDescription, NameControl); if (PART_Achievements != null) { PART_ElemDescription.Children.Remove(PART_Achievements); } } noAchievements = true; } // Auto integration if (settings.EnableIntegrationInDescription || settings.EnableIntegrationInDescriptionWithToggle) { // Search parent action buttons if (PART_ActionButtons == null) { foreach (Button bt in Tools.FindVisualChildren <Button>(Application.Current.MainWindow)) { if (bt.Name == "PART_ButtonEditGame") { PART_ActionButtons = (StackPanel)bt.Parent; break; } } } //Adding togglebutton if (settings.EnableIntegrationInDescriptionWithToggle && PART_ActionButtons != null) { ToggleButton PART_ScToggleButton = (ToggleButton)LogicalTreeHelper.FindLogicalNode(PART_ActionButtons, "PART_ScToggleButton"); // Delete old ToggleDetails if (settings.IntegrationToggleDetails) { PART_ActionButtons.Children.Remove(PART_ScToggleButton); PART_ScToggleButton = null; } if (PART_ScToggleButton == null && !noAchievements) { ToggleButton tb = new ToggleButton(); if (settings.IntegrationToggleDetails) { tb = new SuccessStoryToggleButtonDetails(SelectedGameAchievements.Unlocked, SelectedGameAchievements.Total); } else { tb.Content = resources.GetString("LOCSucessStoryAchievements"); } tb.IsChecked = false; tb.Name = "PART_ScToggleButton"; tb.Width = 150; tb.Height = 40; tb.HorizontalAlignment = HorizontalAlignment.Right; tb.VerticalAlignment = VerticalAlignment.Stretch; tb.Margin = new Thickness(10, 0, 0, 0); tb.Click += ScToggleButton_Click; PART_ActionButtons.Children.Add(tb); PART_ActionButtons.UpdateLayout(); } } // Search game description if (PART_ElemDescription == null) { foreach (StackPanel sp in Tools.FindVisualChildren <StackPanel>(Application.Current.MainWindow)) { if (sp.Name == "PART_ElemDescription") { PART_ElemDescription = sp; break; } } } // Adding control if (PART_ElemDescription != null) { // Delete old string NameControl = "PART_Achievements"; StackPanel PART_Achievements = (StackPanel)LogicalTreeHelper.FindLogicalNode(PART_ElemDescription, NameControl); if (PART_Achievements != null) { if (settings.EnableIntegrationInDescription) { PART_ElemDescription.Children.Remove(PART_Achievements); } if (settings.EnableIntegrationInDescriptionWithToggle) { PART_ElemDescription.Children.Remove(PART_Achievements); } } else { logger.Error($"SuccessStory - {NameControl} not found in Integration()"); } if (SelectedGameAchievements != null && SelectedGameAchievements.HaveAchivements) { StackPanel ScA = CreateSc(achievementsDatabase, SelectedGameAchievements, settings.IntegrationShowTitle, settings.IntegrationShowGraphic, settings.IntegrationShowAchievements, false); if (settings.EnableIntegrationInDescription) { // Add if (settings.IntegrationTopGameDetails) { PART_ElemDescription.Children.Insert(0, ScA); } else { PART_ElemDescription.Children.Add(ScA); } PART_ElemDescription.UpdateLayout(); } if (settings.EnableIntegrationInDescriptionWithToggle) { ScA.Visibility = Visibility.Collapsed; PART_ElemDescription.Children.Add(ScA); PART_ElemDescription.UpdateLayout(); } } } else { logger.Error($"SuccessStory - PART_ElemDescription not found in Integration()"); } } // Auto adding button if (settings.EnableIntegrationButton || settings.EnableIntegrationButtonDetails) { // Search parent action buttons if (PART_ActionButtons == null) { foreach (Button bt in Tools.FindVisualChildren <Button>(Application.Current.MainWindow)) { if (bt.Name == "PART_ButtonEditGame") { PART_ActionButtons = (StackPanel)bt.Parent; break; } } } // Adding button if (PART_ActionButtons != null) { Button PART_ScButton = (Button)LogicalTreeHelper.FindLogicalNode(PART_ActionButtons, "PART_ScButton"); // Delete old ButtonDetails if (settings.EnableIntegrationButtonDetails) { PART_ActionButtons.Children.Remove(PART_ScButton); PART_ScButton = null; } if (PART_ScButton == null) { Button bt = new Button(); if (settings.EnableIntegrationButton) { bt.Content = resources.GetString("LOCSucessStoryAchievements"); } if (settings.EnableIntegrationButtonDetails) { bt = new SuccessStoryButtonDetails(SelectedGameAchievements.Unlocked, SelectedGameAchievements.Total); } bt.Name = "PART_ScButton"; bt.Width = 150; bt.Height = 40; bt.HorizontalAlignment = HorizontalAlignment.Right; bt.VerticalAlignment = VerticalAlignment.Stretch; bt.Margin = new Thickness(10, 0, 0, 0); bt.Click += ScButton_Click; PART_ActionButtons.Children.Add(bt); PART_ActionButtons.UpdateLayout(); } } } // Custom theme if (settings.EnableIntegrationInCustomTheme) { // Search custom element foreach (StackPanel sp in Tools.FindVisualChildren <StackPanel>(Application.Current.MainWindow)) { if (sp.Name == "PART_Achievements_Graphics") { if (SelectedGameAchievements != null && SelectedGameAchievements.HaveAchivements) { // Create StackPanel scAG = CreateSc(achievementsDatabase, SelectedGameAchievements, false, true, false, true); // Clear & add sp.Children.Clear(); sp.Children.Add(scAG); sp.UpdateLayout(); } else { sp.Children.Clear(); sp.UpdateLayout(); } } if (sp.Name == "PART_Achievements_List") { if (SelectedGameAchievements != null && SelectedGameAchievements.HaveAchivements) { // Create StackPanel scAL = CreateSc(achievementsDatabase, SelectedGameAchievements, false, false, true, true); // Clear & add sp.Children.Clear(); sp.Children.Add(scAL); sp.UpdateLayout(); } else { sp.Children.Clear(); sp.UpdateLayout(); } } } } } catch (Exception ex) { var LineNumber = new StackTrace(ex, true).GetFrame(0).GetFileLineNumber(); string FileName = new StackTrace(ex, true).GetFrame(0).GetFileName(); logger.Error(ex, $"SuccessStory [{FileName} {LineNumber}] - Impossible integration "); } }
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 } }
public override void AddCustomElements() { if (ListCustomElements.Count > 0) { #if DEBUG logger.Debug($"SuccessStory - 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_ListCompactUnlocked = null; FrameworkElement PART_Achievements_ListCompactLocked = 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_ListCompactUnlocked = IntegrationUI.SearchElementByName("PART_Achievements_ListCompactUnlocked", false, true); PART_Achievements_ListCompactLocked = IntegrationUI.SearchElementByName("PART_Achievements_ListCompactLocked", 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 - 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 - 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 - PART_ScButtonWithTitleAndDetails not find"); #endif } if (PART_Achievements_ProgressBar != null && _Settings.IntegrationShowProgressBar) { PART_Achievements_ProgressBar = new ScDescriptionIntegration(_Settings, SuccessStory.achievementsDatabase, SuccessStory.SelectedGameAchievements, true, false, false, false, false, true); 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 - PART_Achievements_ProgressBar not find"); #endif } if (PART_Achievements_Graphics != null && _Settings.IntegrationShowGraphic) { PART_Achievements_Graphics = new ScDescriptionIntegration(_Settings, SuccessStory.achievementsDatabase, SuccessStory.SelectedGameAchievements, true, true, false, false, false, false); 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 - PART_Achievements_Graphics not find"); #endif } if (PART_Achievements_List != null && _Settings.IntegrationShowAchievements) { PART_Achievements_List = new ScDescriptionIntegration(_Settings, SuccessStory.achievementsDatabase, SuccessStory.SelectedGameAchievements, true, false, true, false, false, false); 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 - PART_Achievements_List not find"); #endif } if (PART_Achievements_ListCompactUnlocked != null && _Settings.IntegrationShowAchievements) { PART_Achievements_ListCompactUnlocked = new ScDescriptionIntegration(_Settings, SuccessStory.achievementsDatabase, SuccessStory.SelectedGameAchievements, true, false, false, false, true, false); 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 - PART_Achievements_ListCompactUnlocked not find"); #endif } if (PART_Achievements_ListCompactLocked != null && _Settings.IntegrationShowAchievements) { PART_Achievements_ListCompactLocked = new ScDescriptionIntegration(_Settings, SuccessStory.achievementsDatabase, SuccessStory.SelectedGameAchievements, true, false, false, true, false, false); 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 - PART_Achievements_ListCompactLocked not find"); #endif } }