Ejemplo n.º 1
0
        public SuccessStorySettingsView(IPlayniteAPI PlayniteApi, string PluginUserDataPath, SuccessStorySettings settings)
        {
            this.PlayniteApi        = PlayniteApi;
            this.PluginUserDataPath = PluginUserDataPath;
            this.settings           = settings;

            AchievementsDatabase = new AchievementsDatabase(PlayniteApi, PluginUserDataPath);

            InitializeComponent();

            SetTotal();

            SuccessStoryLoad.Visibility = Visibility.Hidden;

            switch (settings.NameSorting)
            {
            case "Name":
                cbDefaultSorting.Text = resources.GetString("LOCSucessStorylvGamesName");
                break;

            case "LastActivity":
                cbDefaultSorting.Text = resources.GetString("LOCSucessStorylvGamesLastActivity");
                break;

            case "SourceName":
                cbDefaultSorting.Text = resources.GetString("LOCSucessStorylvGamesSourceName");
                break;

            case "ProgressionValue":
                cbDefaultSorting.Text = resources.GetString("LOCSucessStorylvGamesProgression");
                break;
            }
        }
Ejemplo n.º 2
0
        public SuccessStory(IPlayniteAPI api) : base(api)
        {
            settings = new SuccessStorySettings(this);

            // Get plugin's location
            string pluginFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            // Add plugin localization in application ressource.
            PluginCommon.Localization.SetPluginLanguage(pluginFolder, api.Paths.ConfigurationPath);
            // Add common in application ressource.
            PluginCommon.Common.Load(pluginFolder);
        }
        public SuccessStory(IPlayniteAPI api) : base(api)
        {
            settings = new SuccessStorySettings(this);

            // Old database
            oldToNew = new OldToNew(this.GetPluginUserDataPath());

            // Loading plugin database
            PluginDatabase = new SuccessStoryDatabase(this, PlayniteApi, settings, this.GetPluginUserDataPath());
            PluginDatabase.InitializeDatabase();

            // Get plugin's location
            pluginFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            // Add plugin localization in application ressource.
            PluginLocalization.SetPluginLanguage(pluginFolder, api.ApplicationSettings.Language);
            // Add common in application ressource.
            Common.Load(pluginFolder);
            Common.SetEvent(PlayniteApi);

            // Check version
            if (settings.EnableCheckVersion)
            {
                CheckVersion cv = new CheckVersion();
                cv.Check("SuccessStory", pluginFolder, api);
            }

            // Init ui interagration
            successStoryUI = new SuccessStoryUI(this, api, this.GetPluginUserDataPath());

            // Custom theme button
            if (settings.EnableIntegrationInCustomTheme)
            {
                EventManager.RegisterClassHandler(typeof(Button), Button.ClickEvent, new RoutedEventHandler(successStoryUI.OnCustomThemeButtonClick));
            }

            // Add Event for WindowBase for get the "WindowSettings".
            EventManager.RegisterClassHandler(typeof(Window), Window.LoadedEvent, new RoutedEventHandler(WindowBase_LoadedEvent));

            // Add event fullScreen
            if (api.ApplicationInfo.Mode == ApplicationMode.Fullscreen)
            {
                EventManager.RegisterClassHandler(typeof(Button), Button.ClickEvent, new RoutedEventHandler(BtFullScreen_ClickEvent));
            }
        }
        public SuccessStory(IPlayniteAPI api) : base(api)
        {
            settings = new SuccessStorySettings(this);

            // Get plugin's location
            pluginFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            // Add plugin localization in application ressource.
            PluginCommon.Localization.SetPluginLanguage(pluginFolder, api.ApplicationSettings.Language);
            // Add common in application ressource.
            PluginCommon.Common.Load(pluginFolder);

            // Check version
            if (settings.EnableCheckVersion)
            {
                CheckVersion cv = new CheckVersion();

                if (cv.Check("SuccessStory", pluginFolder))
                {
                    cv.ShowNotification(api, "SuccessStory - " + resources.GetString("LOCUpdaterWindowTitle"));
                }
            }

            // Init ui interagration
            successStoryUI = new SuccessStoryUI(api, settings, this.GetPluginUserDataPath(), this);

            // Custom theme button
            if (settings.EnableIntegrationInCustomTheme)
            {
                EventManager.RegisterClassHandler(typeof(Button), Button.ClickEvent, new RoutedEventHandler(successStoryUI.OnCustomThemeButtonClick));
            }

            // Load database
            var TaskLoadDatabase = Task.Run(() =>
            {
                achievementsDatabase = new AchievementsDatabase(this, PlayniteApi, settings, this.GetPluginUserDataPath());
                achievementsDatabase.Initialize();
            });

            // Add Event for WindowBase for get the "WindowSettings".
            EventManager.RegisterClassHandler(typeof(Window), Window.LoadedEvent, new RoutedEventHandler(WindowBase_LoadedEvent));
        }
Ejemplo n.º 5
0
        public SuccessStory(IPlayniteAPI api) : base(api)
        {
            settings = new SuccessStorySettings(this);

            // Get plugin's location
            string pluginFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            // Add plugin localization in application ressource.
            PluginCommon.Localization.SetPluginLanguage(pluginFolder, api.Paths.ConfigurationPath);
            // Add common in application ressource.
            PluginCommon.Common.Load(pluginFolder);

            // Check version
            if (settings.EnableCheckVersion)
            {
                CheckVersion cv = new CheckVersion();

                if (cv.Check("SuccessStory", pluginFolder))
                {
                    cv.ShowNotification(api, "SuccessStory - " + resources.GetString("LOCUpdaterWindowTitle"));
                }
            }
        }
Ejemplo n.º 6
0
        private async Task <GameAchievements> LoadData(IPlayniteAPI PlayniteApi, string PluginUserDataPath, SuccessStorySettings settings)
        {
            // Refresh database
            if (SuccessStory.isFirstLoad)
            {
                achievementsDatabase = new AchievementsDatabase(PlayniteApi, settings, this.GetPluginUserDataPath());
                achievementsDatabase.Initialize();
                SuccessStory.isFirstLoad = false;
            }

            GameAchievements SelectedGameAchievements = achievementsDatabase.Get(GameSelected.Id);

            // Download Achievements if not exist in database.
            if (SelectedGameAchievements == null)
            {
                logger.Info("SuccessStory - Download achievements for " + GameSelected.Name);
                achievementsDatabase.Add(GameSelected, settings);
                achievementsDatabase.Initialize();
                SelectedGameAchievements = achievementsDatabase.Get(GameSelected.Id);
            }

            return(SelectedGameAchievements);
        }
Ejemplo n.º 7
0
        public SuccessView(SuccessStorySettings settings, IPlayniteAPI PlayniteApi, string PluginUserDataPath, Game GameSelected = null)
        {
            this.PlayniteApi        = PlayniteApi;
            PlayniteApiDatabase     = PlayniteApi.Database;
            PlayniteApiPaths        = PlayniteApi.Paths;
            this.settings           = settings;
            this.PluginUserDataPath = PluginUserDataPath;


            AchievementsDatabase = new AchievementsDatabase(PlayniteApi, settings, PluginUserDataPath);
            AchievementsDatabase.Initialize();

            InitializeComponent();

            // Block hidden column.
            lvProgressionValue.IsEnabled = false;
            lvSourceName.IsEnabled       = false;


            pbProgressionGlobalCount.Value      = AchievementsDatabase.Progession().Unlocked;
            pbProgressionGlobalCount.Maximum    = AchievementsDatabase.Progession().Total;
            labelProgressionGlobalCount.Content = AchievementsDatabase.Progession().Progression + "%";

            pbProgressionLaunchedCount.Value      = AchievementsDatabase.ProgessionLaunched().Unlocked;
            pbProgressionLaunchedCount.Maximum    = AchievementsDatabase.ProgessionLaunched().Total;
            labelProgressionLaunchedCount.Content = AchievementsDatabase.ProgessionLaunched().Progression + "%";


            GetListGame();


            AchievementsGraphicsDataCount GraphicsData = null;

            if (settings.GraphicAllUnlockedByMonth)
            {
                GraphicTitleALL.Content = resources.GetString("LOCSucessStoryGraphicTitleALL");
                GraphicsData            = AchievementsDatabase.GetCountByMonth(null, 7);
            }
            else
            {
                GraphicTitleALL.Content = resources.GetString("LOCSucessStoryGraphicTitleALLDay");
                GraphicsData            = AchievementsDatabase.GetCountByDay();
            }
            string[]         StatsGraphicsAchievementsLabels = GraphicsData.Labels;
            SeriesCollection StatsGraphicAchievementsSeries  = new SeriesCollection();

            StatsGraphicAchievementsSeries.Add(new LineSeries
            {
                Title  = "",
                Values = GraphicsData.Series
            });

            SuccessStory_Achievements_Graphics.Children.Clear();
            SuccessStory_Achievements_Graphics.Children.Add(new SuccessStoryAchievementsGraphics(StatsGraphicAchievementsSeries, StatsGraphicsAchievementsLabels));
            SuccessStory_Achievements_Graphics.UpdateLayout();

            // Set game selected
            if (GameSelected != null)
            {
                for (int i = 0; i < ListviewGames.Items.Count; i++)
                {
                    if (((ListGames)ListviewGames.Items[i]).Name == GameSelected.Name)
                    {
                        ListviewGames.SelectedIndex = i;
                    }
                }
            }
            ListviewGames.ScrollIntoView(ListviewGames.SelectedItem);


            if (settings.EnableLocal)
            {
                //FilterSource.Items.Add(new { SourceName = "Playnite", IsCheck = false });
                FilterSourceItems.Add(new ListSource {
                    SourceName = "Playnite", IsCheck = false
                });
            }
            if (settings.EnableSteam)
            {
                //FilterSource.Items.Add(new { SourceName = "Steam", IsCheck = false });
                FilterSourceItems.Add(new ListSource {
                    SourceName = "Steam", IsCheck = false
                });
            }
            if (settings.EnableGog)
            {
                //FilterSource.Items.Add(new { SourceName = "GOG", IsCheck = false });
                FilterSourceItems.Add(new ListSource {
                    SourceName = "GOG", IsCheck = false
                });
            }
            if (settings.EnableOrigin)
            {
                //FilterSource.Items.Add(new { SourceName = "Origin", IsCheck = false });
                FilterSourceItems.Add(new ListSource {
                    SourceName = "Origin", IsCheck = false
                });
            }
            if (settings.EnableOrigin)
            {
                //FilterSource.Items.Add(new { SourceName = "Origin", IsCheck = false });
                FilterSourceItems.Add(new ListSource {
                    SourceName = "RetroAchievements", IsCheck = false
                });
            }
            //FilterSource.UpdateLayout();
            FilterSource.ItemsSource = FilterSourceItems;

            SetGraphicsAchievementsSources();

            // Set Binding data
            DataContext = this;
        }
Ejemplo n.º 8
0
        public SuccessView(SuccessStory plugin, SuccessStorySettings settings, IPlayniteAPI PlayniteApi, string PluginUserDataPath, bool isRetroAchievements = false, Game GameSelected = null)
        {
            this.plugin             = plugin;
            this._PlayniteApi       = PlayniteApi;
            _PlayniteApiDatabase    = PlayniteApi.Database;
            _PlayniteApiPaths       = PlayniteApi.Paths;
            this.settings           = settings;
            this.PluginUserDataPath = PluginUserDataPath;


            InitializeComponent();


            PART_DataLoad.Visibility = Visibility.Visible;
            PART_Data.Visibility     = Visibility.Hidden;

            var TaskView = Task.Run(() =>
            {
                AchievementsDb = new AchievementsDatabase(plugin, PlayniteApi, settings, PluginUserDataPath, isRetroAchievements);
                AchievementsDb.Initialize(false);

                GetListGame();
                SetGraphicsAchievementsSources();

                AchievementsGraphicsDataCount GraphicsData = null;
                if (settings.GraphicAllUnlockedByMonth)
                {
                    GraphicsData = AchievementsDb.GetCountByMonth(null, 6);
                }
                else
                {
                    GraphicsData = AchievementsDb.GetCountByDay(null, 5);
                }

                Application.Current.Dispatcher.BeginInvoke((Action) delegate
                {
                    // Block hidden column.
                    lvProgressionValue.IsEnabled = false;
                    lvSourceName.IsEnabled       = false;


                    pbProgressionGlobalCount.Value      = AchievementsDb.Progession().Unlocked;
                    pbProgressionGlobalCount.Maximum    = AchievementsDb.Progession().Total;
                    labelProgressionGlobalCount.Content = AchievementsDb.Progession().Progression + "%";

                    pbProgressionLaunchedCount.Value      = AchievementsDb.ProgessionLaunched().Unlocked;
                    pbProgressionLaunchedCount.Maximum    = AchievementsDb.ProgessionLaunched().Total;
                    labelProgressionLaunchedCount.Content = AchievementsDb.ProgessionLaunched().Progression + "%";


                    GraphicTitle.Content = string.Empty;


                    // lvGames options
                    if (!settings.lvGamesIcon100Percent)
                    {
                        lvGameIcon100Percent.Width = 0;
                    }
                    if (!settings.lvGamesIcon)
                    {
                        lvGameIcon.Width = 0;
                    }
                    if (!settings.lvGamesName)
                    {
                        lvGameName.Width = 0;
                    }
                    if (!settings.lvGamesLastSession)
                    {
                        lvGameLastActivity.Width = 0;
                    }
                    if (!settings.lvGamesSource)
                    {
                        lvGamesSource.Width = 0;
                    }
                    if (!settings.lvGamesProgression)
                    {
                        lvGameProgression.Width = 0;
                    }


                    if (settings.GraphicAllUnlockedByMonth)
                    {
                        GraphicTitleALL.Content = resources.GetString("LOCSuccessStoryGraphicTitleALL");
                    }
                    else
                    {
                        GraphicTitleALL.Content = resources.GetString("LOCSuccessStoryGraphicTitleALLDay");
                    }
                    string[] StatsGraphicsAchievementsLabels        = GraphicsData.Labels;
                    SeriesCollection StatsGraphicAchievementsSeries = new SeriesCollection();
                    StatsGraphicAchievementsSeries.Add(new LineSeries
                    {
                        Title  = string.Empty,
                        Values = GraphicsData.Series
                    });

                    SuccessStory_Achievements_Graphics.Children.Clear();
                    settings.IgnoreSettings = true;
                    SuccessStory_Achievements_Graphics.Children.Add(new SuccessStoryAchievementsGraphics(StatsGraphicAchievementsSeries, StatsGraphicsAchievementsLabels, settings));
                    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 (settings.EnableRetroAchievementsView && settings.EnableRetroAchievements)
                    {
                        if (isRetroAchievements)
                        {
                            PART_GraphicBySource.Visibility = Visibility.Collapsed;
                            Grid.SetColumn(PART_GraphicAllUnlocked, 0);
                            Grid.SetColumnSpan(PART_GraphicAllUnlocked, 3);

                            if (settings.EnableRetroAchievements)
                            {
                                icon = TransformIcon.Get("RetroAchievements") + " ";
                                FilterSourceItems.Add(new ListSource {
                                    SourceName = ((icon.Length == 2) ? icon : string.Empty) + "RetroAchievements", SourceNameShort = "RetroAchievements", IsCheck = false
                                });
                            }
                        }
                        else
                        {
                            if (settings.EnableLocal)
                            {
                                icon = TransformIcon.Get("Playnite") + " ";
                                FilterSourceItems.Add(new ListSource {
                                    SourceName = ((icon.Length == 2) ? icon : string.Empty) + "Playnite", SourceNameShort = "Playnite", IsCheck = false
                                });
                            }
                            if (settings.EnableSteam)
                            {
                                icon = TransformIcon.Get("Steam") + " ";
                                FilterSourceItems.Add(new ListSource {
                                    SourceName = ((icon.Length == 2) ? icon : string.Empty) + "Steam", SourceNameShort = "Steam", IsCheck = false
                                });
                            }
                            if (settings.EnableGog)
                            {
                                icon = TransformIcon.Get("GOG") + " ";
                                FilterSourceItems.Add(new ListSource {
                                    SourceName = ((icon.Length == 2) ? icon : string.Empty) + "GOG", SourceNameShort = "GOG", IsCheck = false
                                });
                            }
                            if (settings.EnableOrigin)
                            {
                                icon = TransformIcon.Get("Origin") + " ";
                                FilterSourceItems.Add(new ListSource {
                                    SourceName = ((icon.Length == 2) ? icon : string.Empty) + "Origin", SourceNameShort = "Origin", IsCheck = false
                                });
                            }
                            if (settings.EnableXbox)
                            {
                                icon = TransformIcon.Get("Xbox") + " ";
                                FilterSourceItems.Add(new ListSource {
                                    SourceName = ((icon.Length == 2) ? icon : string.Empty) + "Xbox", SourceNameShort = "Xbox", IsCheck = false
                                });
                            }
                        }
                    }
                    else
                    {
                        if (settings.EnableLocal)
                        {
                            icon = TransformIcon.Get("Playnite") + " ";
                            FilterSourceItems.Add(new ListSource {
                                SourceName = ((icon.Length == 2) ? icon : string.Empty) + "Playnite", SourceNameShort = "Playnite", IsCheck = false
                            });
                        }
                        if (settings.EnableSteam)
                        {
                            icon = TransformIcon.Get("Steam") + " ";
                            FilterSourceItems.Add(new ListSource {
                                SourceName = ((icon.Length == 2) ? icon : string.Empty) + "Steam", SourceNameShort = "Steam", IsCheck = false
                            });
                        }
                        if (settings.EnableGog)
                        {
                            icon = TransformIcon.Get("GOG") + " ";
                            FilterSourceItems.Add(new ListSource {
                                SourceName = ((icon.Length == 2) ? icon : string.Empty) + "GOG", SourceNameShort = "GOG", IsCheck = false
                            });
                        }
                        if (settings.EnableOrigin)
                        {
                            icon = TransformIcon.Get("Origin") + " ";
                            FilterSourceItems.Add(new ListSource {
                                SourceName = ((icon.Length == 2) ? icon : string.Empty) + "Origin", SourceNameShort = "Origin", IsCheck = false
                            });
                        }
                        if (settings.EnableXbox)
                        {
                            icon = TransformIcon.Get("Xbox") + " ";
                            FilterSourceItems.Add(new ListSource {
                                SourceName = ((icon.Length == 2) ? icon : string.Empty) + "Xbox", SourceNameShort = "Xbox", IsCheck = false
                            });
                        }
                        if (settings.EnableRetroAchievements)
                        {
                            icon = TransformIcon.Get("RetroAchievements") + " ";
                            FilterSourceItems.Add(new ListSource {
                                SourceName = ((icon.Length == 2) ? icon : string.Empty) + "RetroAchievements", SourceNameShort = "RetroAchievements", IsCheck = false
                            });
                        }
                    }

                    FilterSource.ItemsSource = FilterSourceItems;


                    // Set Binding data
                    DataContext = this;

                    PART_DataLoad.Visibility = Visibility.Hidden;
                    PART_Data.Visibility     = Visibility.Visible;
                });
            });
        }