// To add new main menu items override GetMainMenuItems
        public override List <MainMenuItem> GetMainMenuItems(GetMainMenuItemsArgs args)
        {
            string MenuInExtensions = string.Empty;

            if (settings.MenuInExtensions)
            {
                MenuInExtensions = "@";
            }

            List <MainMenuItem> mainMenuItems = new List <MainMenuItem>
            {
                new MainMenuItem
                {
                    MenuSection = MenuInExtensions + resources.GetString("LOCSuccessStory"),
                    Description = resources.GetString("LOCSuccessStoryViewGames"),
                    Action      = (mainMenuItem) =>
                    {
                        var    ViewExtension   = new SuccessView(this, settings, PlayniteApi, this.GetPluginUserDataPath());
                        Window windowExtension = PlayniteUiHelper.CreateExtensionWindow(PlayniteApi, resources.GetString("LOCSuccessStory"), ViewExtension);
                        windowExtension.ShowDialog();
                    }
                }
            };

            if (settings.EnableRetroAchievementsView && settings.EnableRetroAchievements)
            {
                mainMenuItems.Add(new MainMenuItem
                {
                    MenuSection = MenuInExtensions + resources.GetString("LOCSuccessStory"),
                    Description = resources.GetString("LOCSuccessStoryViewGames") + " - RetroAchievements",
                    Action      = (mainMenuItem) =>
                    {
                        SuccessView ViewExtension = null;
                        if (settings.EnableRetroAchievementsView && PlayniteTools.IsGameEmulated(PlayniteApi, GameSelected))
                        {
                            ViewExtension = new SuccessView(this, settings, PlayniteApi, this.GetPluginUserDataPath(), true, GameSelected);
                        }
                        else
                        {
                            ViewExtension = new SuccessView(this, settings, PlayniteApi, this.GetPluginUserDataPath(), false, GameSelected);
                        }
                        Window windowExtension = PlayniteUiHelper.CreateExtensionWindow(PlayniteApi, resources.GetString("LOCSuccessStory"), ViewExtension);
                        windowExtension.ShowDialog();
                    }
                });
            }

#if DEBUG
            mainMenuItems.Add(new MainMenuItem
            {
                MenuSection = MenuInExtensions + resources.GetString("LOCSuccessStory"),
                Description = "Test",
                Action      = (mainMenuItem) => { }
            });
#endif

            return(mainMenuItems);
        }
        // To add new game menu items override GetGameMenuItems
        public override List <GameMenuItem> GetGameMenuItems(GetGameMenuItemsArgs args)
        {
            var GameMenu = args.Games.First();

            List <GameMenuItem> gameMenuItems = new List <GameMenuItem>
            {
                new GameMenuItem {
                    MenuSection = resources.GetString("LOCSuccessStory"),
                    Description = resources.GetString("LOCSuccessStoryViewGame"),
                    Action      = (gameMenuItem) =>
                    {
                        var    ViewExtension   = new SuccessView(this, settings, PlayniteApi, this.GetPluginUserDataPath(), false, GameMenu);
                        Window windowExtension = PlayniteUiHelper.CreateExtensionWindow(PlayniteApi, resources.GetString("LOCSuccessStory"), ViewExtension);
                        windowExtension.ShowDialog();
                    }
                },
                new GameMenuItem {
                    MenuSection = resources.GetString("LOCSuccessStory"),
                    Description = resources.GetString("LOCSuccessStoryRefreshData"),
                    Action      = (gameMenuItem) =>
                    {
                        if (settings.EnableIntegrationInCustomTheme || settings.EnableIntegrationInDescription)
                        {
                            PlayniteUiHelper.ResetToggle();
                        }

                        var TaskIntegrationUI = Task.Run(() =>
                        {
                            achievementsDatabase.Remove(GameMenu);
                            successStoryUI.AddElements();
                            successStoryUI.RefreshElements(GameSelected);
                        });
                    }
                }
            };

#if DEBUG
            gameMenuItems.Add(new GameMenuItem
            {
                MenuSection = resources.GetString("LOCSuccessStory"),
                Description = "Test",
                Action      = (mainMenuItem) => { }
            });
#endif

            return(gameMenuItems);
        }
        // To add new main menu items override GetMainMenuItems
        public override List <MainMenuItem> GetMainMenuItems(GetMainMenuItemsArgs args)
        {
            string MenuInExtensions = string.Empty;

            if (settings.MenuInExtensions)
            {
                MenuInExtensions = "@";
            }

            List <MainMenuItem> mainMenuItems = new List <MainMenuItem>
            {
                // Show list achievements for all games
                new MainMenuItem
                {
                    MenuSection = MenuInExtensions + resources.GetString("LOCSuccessStory"),
                    Description = resources.GetString("LOCSuccessStoryViewGames"),
                    Action      = (mainMenuItem) =>
                    {
                        PluginDatabase.IsViewOpen = true;
                        var    ViewExtension   = new SuccessView(this, PlayniteApi, this.GetPluginUserDataPath());
                        Window windowExtension = PlayniteUiHelper.CreateExtensionWindow(PlayniteApi, resources.GetString("LOCSuccessStory"), ViewExtension);
                        windowExtension.ShowDialog();
                        PluginDatabase.IsViewOpen = false;
                    }
                }
            };

            if (settings.EnableRetroAchievementsView && settings.EnableRetroAchievements)
            {
                mainMenuItems.Add(new MainMenuItem
                {
                    MenuSection = MenuInExtensions + resources.GetString("LOCSuccessStory"),
                    Description = resources.GetString("LOCSuccessStoryViewGames") + " - RetroAchievements",
                    Action      = (mainMenuItem) =>
                    {
                        PluginDatabase.IsViewOpen = true;
                        SuccessView ViewExtension = null;
                        if (settings.EnableRetroAchievementsView && PlayniteTools.IsGameEmulated(PlayniteApi, SuccessStoryDatabase.GameSelected))
                        {
                            ViewExtension = new SuccessView(this, PlayniteApi, this.GetPluginUserDataPath(), true, SuccessStoryDatabase.GameSelected);
                        }
                        else
                        {
                            ViewExtension = new SuccessView(this, PlayniteApi, this.GetPluginUserDataPath(), false, SuccessStoryDatabase.GameSelected);
                        }
                        Window windowExtension = PlayniteUiHelper.CreateExtensionWindow(PlayniteApi, resources.GetString("LOCSuccessStory"), ViewExtension);
                        windowExtension.ShowDialog();
                        PluginDatabase.IsViewOpen = false;
                    }
                });
            }

            // Download missing data for all game in database
            mainMenuItems.Add(
                new MainMenuItem
            {
                MenuSection = MenuInExtensions + resources.GetString("LOCSuccessStory"),
                Description = resources.GetString("LOCCommonGetAllDatas"),
                Action      = (mainMenuItem) =>
                {
                    PluginDatabase.GetAllDatas();
                }
            }
                );

#if DEBUG
            mainMenuItems.Add(new MainMenuItem
            {
                MenuSection = MenuInExtensions + resources.GetString("LOCSuccessStory"),
                Description = "Test",
                Action      = (mainMenuItem) => { }
            });
#endif

            return(mainMenuItems);
        }
        // To add new game menu items override GetGameMenuItems
        public override List <GameMenuItem> GetGameMenuItems(GetGameMenuItemsArgs args)
        {
            Game             GameMenu          = args.Games.First();
            string           SourceName        = PlayniteTools.GetSourceName(PlayniteApi, GameMenu);
            bool             IsAddOrShowManual = SuccessStoryDatabase.IsAddOrShowManual(GameMenu, SourceName);
            GameAchievements gameAchievements  = PluginDatabase.Get(GameMenu, true);

            List <GameMenuItem> gameMenuItems = new List <GameMenuItem>();

            if (!settings.EnableOneGameView || (settings.EnableOneGameView && gameAchievements.HasData))
            {
                // Show list achievements for the selected game
                gameMenuItems.Add(new GameMenuItem
                {
                    MenuSection = resources.GetString("LOCSuccessStory"),
                    Description = resources.GetString("LOCSuccessStoryViewGame"),
                    Action      = (gameMenuItem) =>
                    {
                        dynamic ViewExtension     = null;
                        PluginDatabase.IsViewOpen = true;
                        if (PluginDatabase.PluginSettings.EnableOneGameView)
                        {
                            ViewExtension = new SuccessStoryOneGameView(GameMenu);
                        }
                        else
                        {
                            ViewExtension = new SuccessView(this, PlayniteApi, this.GetPluginUserDataPath(), false, GameMenu);
                        }
                        Window windowExtension = PlayniteUiHelper.CreateExtensionWindow(PlayniteApi, resources.GetString("LOCSuccessStory"), ViewExtension);
                        windowExtension.ShowDialog();
                        PluginDatabase.IsViewOpen = false;
                    }
                });
            }

            if (!IsAddOrShowManual)
            {
                gameMenuItems.Add(new GameMenuItem
                {
                    MenuSection = resources.GetString("LOCSuccessStory"),
                    Description = resources.GetString("LOCCommonRefreshGameData"),
                    Action      = (gameMenuItem) =>
                    {
                        if (settings.EnableIntegrationInCustomTheme || settings.EnableIntegrationInDescription)
                        {
                            PlayniteUiHelper.ResetToggle();
                        }

                        var TaskIntegrationUI = Task.Run(() =>
                        {
                            PluginDatabase.Remove(GameMenu);
                            var dispatcherOp        = successStoryUI.AddElements();
                            dispatcherOp.Completed += (s, e) => { successStoryUI.RefreshElements(GameMenu); };
                        });
                    }
                });
            }

            if (settings.EnableManual && IsAddOrShowManual)
            {
                if (!gameAchievements.HasData)
                {
                    gameMenuItems.Add(new GameMenuItem
                    {
                        MenuSection = resources.GetString("LOCSuccessStory"),
                        Description = resources.GetString("LOCAddTitle"),
                        Action      = (mainMenuItem) =>
                        {
                            var TaskIntegrationUI = Task.Run(() =>
                            {
                                PluginDatabase.Remove(GameMenu);
                                PluginDatabase.GetManual(GameMenu);

                                var dispatcherOp        = successStoryUI.AddElements();
                                dispatcherOp.Completed += (s, e) => { successStoryUI.RefreshElements(GameMenu); };
                            });
                        }
                    });
                }
                else
                {
                    gameMenuItems.Add(new GameMenuItem
                    {
                        MenuSection = resources.GetString("LOCSuccessStory"),
                        Description = resources.GetString("LOCEditGame"),
                        Action      = (mainMenuItem) =>
                        {
                            var ViewExtension      = new SuccessStoryEditManual(GameMenu);
                            Window windowExtension = PlayniteUiHelper.CreateExtensionWindow(PlayniteApi, resources.GetString("LOCSuccessStory"), ViewExtension);
                            windowExtension.ShowDialog();
                        }
                    });

                    gameMenuItems.Add(new GameMenuItem
                    {
                        MenuSection = resources.GetString("LOCSuccessStory"),
                        Description = resources.GetString("LOCRemoveTitle"),
                        Action      = (gameMenuItem) =>
                        {
                            if (settings.EnableIntegrationInCustomTheme || settings.EnableIntegrationInDescription)
                            {
                                PlayniteUiHelper.ResetToggle();
                            }

                            var TaskIntegrationUI = Task.Run(() =>
                            {
                                PluginDatabase.Remove(GameMenu);
                                var dispatcherOp        = successStoryUI.AddElements();
                                dispatcherOp.Completed += (s, e) => { successStoryUI.RefreshElements(GameMenu); };
                            });
                        }
                    });
                }
            }

#if DEBUG
            gameMenuItems.Add(new GameMenuItem
            {
                MenuSection = resources.GetString("LOCSuccessStory"),
                Description = "Test",
                Action      = (mainMenuItem) => { }
            });
#endif
            return(gameMenuItems);
        }
Exemplo n.º 5
0
        // To add new game menu items override GetGameMenuItems
        public override List <GameMenuItem> GetGameMenuItems(GetGameMenuItemsArgs args)
        {
            var GameMenu = args.Games.First();

            List <GameMenuItem> gameMenuItems = new List <GameMenuItem>();

            if (!PluginDatabase.PluginSettings.EnableOneGameView ||
                (PluginDatabase.PluginSettings.EnableOneGameView && PluginDatabase.Get(GameMenu, true).HasData))
            {
                // Show list achievements for the selected game
                gameMenuItems.Add(new GameMenuItem
                {
                    MenuSection = resources.GetString("LOCSuccessStory"),
                    Description = resources.GetString("LOCSuccessStoryViewGame"),
                    Action      = (gameMenuItem) =>
                    {
                        dynamic ViewExtension     = null;
                        PluginDatabase.IsViewOpen = true;
                        if (PluginDatabase.PluginSettings.EnableOneGameView)
                        {
                            ViewExtension = new SuccessStoryOneGameView(GameMenu);
                        }
                        else
                        {
                            ViewExtension = new SuccessView(this, PlayniteApi, this.GetPluginUserDataPath(), false, GameMenu);
                        }
                        Window windowExtension = PlayniteUiHelper.CreateExtensionWindow(PlayniteApi, resources.GetString("LOCSuccessStory"), ViewExtension);
                        windowExtension.ShowDialog();
                        PluginDatabase.IsViewOpen = false;
                    }
                });
            }

            gameMenuItems.Add(new GameMenuItem
            {
                // Delete & download localizations data for the selected game
                MenuSection = resources.GetString("LOCSuccessStory"),
                Description = resources.GetString("LOCCommonRefreshGameData"),
                Action      = (gameMenuItem) =>
                {
                    if (settings.EnableIntegrationInCustomTheme || settings.EnableIntegrationInDescription)
                    {
                        PlayniteUiHelper.ResetToggle();
                    }

                    var TaskIntegrationUI = Task.Run(() =>
                    {
                        PluginDatabase.Remove(GameMenu);
                        var dispatcherOp        = successStoryUI.AddElements();
                        dispatcherOp.Completed += (s, e) => { successStoryUI.RefreshElements(GameMenu); };
                    });
                }
            });

#if DEBUG
            gameMenuItems.Add(new GameMenuItem
            {
                MenuSection = resources.GetString("LOCSuccessStory"),
                Description = "Test",
                Action      = (mainMenuItem) => { }
            });
#endif

            return(gameMenuItems);
        }