public override IEnumerable <MainMenuItem> GetMainMenuItems(GetMainMenuItemsArgs args)
 {
     return(new List <MainMenuItem>
     {
         new MainMenuItem
         {
             Description = ResourceProvider.GetString("LOCGamePass_Catalog_Browser_MenuItemBrowseCatalogDescription"),
             MenuSection = "@Game Pass Catalog Browser",
             Action = o => {
                 InvokeViewWindow();
             }
         },
         new MainMenuItem
         {
             Description = ResourceProvider.GetString("LOCGamePass_Catalog_Browser_MenuItemAddAllCatalogDescription"),
             MenuSection = "@Game Pass Catalog Browser",
             Action = o => {
                 AddAllGamePassCatalog();
             }
         },
         new MainMenuItem
         {
             Description = ResourceProvider.GetString("LOCGamePass_Catalog_Browser_MenuItemResetCacheDescription"),
             MenuSection = "@Game Pass Catalog Browser",
             Action = o => {
                 ResetCache();
             }
         }
     });
 }
示例#2
0
 public override List <ScriptMainMenuItem> GetMainMenuItems(GetMainMenuItemsArgs args)
 {
     if (SupportedMenus.Contains(SupportedMenuMethods.MainMenu))
     {
         var res = InvokeFunction(nameof(Plugin.GetMainMenuItems), new List <object> {
             args
         });
         if (res is ScriptMainMenuItem item)
         {
             return(new List <ScriptMainMenuItem> {
                 item
             });
         }
         else if (res is List <object> items)
         {
             return(items.Cast <ScriptMainMenuItem>().ToList());
         }
         else
         {
             return(base.GetMainMenuItems(args));
         }
     }
     else
     {
         return(base.GetMainMenuItems(args));
     }
 }
 public override IEnumerable <MainMenuItem> GetMainMenuItems(GetMainMenuItemsArgs args)
 {
     return(new List <MainMenuItem>
     {
         new MainMenuItem
         {
             Description = ResourceProvider.GetString("LOCSplashScreen_MenuItemInvoke-OpenVideoManagerWindowDescription"),
             MenuSection = "@Splash Screen",
             Action = a => {
                 OpenVideoManager();
             }
         },
         new MainMenuItem
         {
             Description = ResourceProvider.GetString("LOCSplashScreen_MenuItemAdd-ImageSkipFeature"),
             MenuSection = "@Splash Screen",
             Action = a => {
                 AddImageSkipFeature();
             }
         },
         new MainMenuItem
         {
             Description = ResourceProvider.GetString("LOCSplashScreen_MenuItemRemove-ImageSkipFeature"),
             MenuSection = "@Splash Screen",
             Action = a => {
                 RemoveImageSkipFeature();
             }
         }
     });
 }
 public override IEnumerable <MainMenuItem> GetMainMenuItems(GetMainMenuItemsArgs args)
 {
     return(new List <MainMenuItem>
     {
         new MainMenuItem
         {
             Description = ResourceProvider.GetString("LOCSteam_Launcher_UtilityMenuItemLaunchSteamConfiguredActionsDescription"),
             MenuSection = "@Steam Launcher Utility",
             Action = a => {
                 LaunchSteam();
             }
         },
         new MainMenuItem
         {
             Description = ResourceProvider.GetString("LOCSteam_Launcher_UtilityMenuItemAddFilterFeatureDescription"),
             MenuSection = "@Steam Launcher Utility",
             Action = a => {
                 AddModeFeature();
             }
         },
         new MainMenuItem
         {
             Description = ResourceProvider.GetString("LOCSteam_Launcher_UtilityMenuItemRemoveModeFilterFeatureDescription"),
             MenuSection = "@Steam Launcher Utility",
             Action = a => {
                 RemoveModeFeature();
             }
         },
     });
 }
示例#5
0
 public override List <ScriptMainMenuItem> GetMainMenuItems(GetMainMenuItemsArgs args)
 {
     if (SupportedMenus.Contains(SupportedMenuMethods.MainMenu))
     {
         var res = InvokeFunction("get_mainmenu_items", new List <object> {
             args
         });
         if (res is ScriptMainMenuItem item)
         {
             return(new List <ScriptMainMenuItem> {
                 item
             });
         }
         else if (res is IEnumerable items)
         {
             return(items.Cast <ScriptMainMenuItem>().ToList());
         }
         else
         {
             return(base.GetMainMenuItems(args));
         }
     }
     else
     {
         return(base.GetMainMenuItems(args));
     }
 }
示例#6
0
        // 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("LOCHowLongToBeat"),
                    Description = resources.GetString("LOCCommonGetAllDatas"),
                    Action      = (mainMenuItem) =>
                    {
                        HowLongToBeatData.GetAllDataFromMain(PlayniteApi, this.GetPluginUserDataPath(), settings);
                    }
                },
                new MainMenuItem
                {
                    MenuSection = MenuInExtensions + resources.GetString("LOCHowLongToBeat"),
                    Description = resources.GetString("LOCCommonClearAllDatas"),
                    Action      = (mainMenuItem) =>
                    {
                        HowLongToBeatData.ClearAllData(this.GetPluginUserDataPath(), PlayniteApi);
                    }
                },
                new MainMenuItem
                {
                    MenuSection = MenuInExtensions + resources.GetString("LOCHowLongToBeat"),
                    Description = resources.GetString("LOCCommonAddAllTags"),
                    Action      = (mainMenuItem) =>
                    {
                        HowLongToBeatData.AddAllTagFromMain(PlayniteApi, this.GetPluginUserDataPath());
                    }
                },
                new MainMenuItem
                {
                    MenuSection = MenuInExtensions + resources.GetString("LOCHowLongToBeat"),
                    Description = resources.GetString("LOCCommonRemoveAllTags"),
                    Action      = (mainMenuItem) =>
                    {
                        HowLongToBeatData.RemoveAllTagFromMain(PlayniteApi, this.GetPluginUserDataPath());
                    }
                }
            };

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

            return(mainMenuItems);
        }
示例#7
0
 public override IEnumerable <MainMenuItem> GetMainMenuItems(GetMainMenuItemsArgs args)
 {
     return(new List <MainMenuItem>
     {
         new MainMenuItem
         {
             Description = ResourceProvider.GetString("LOCCooperativeModesImporter_MenuItemDescriptionAddMultiplayerFeaturesAllGames"),
             MenuSection = "@Cooperative Modes Importer",
             Action = a => {
                 AddMpFeaturesToGamesProgress(PlayniteApi.Database.Games.ToList());
             }
         },
         new MainMenuItem
         {
             Description = ResourceProvider.GetString("LOCCooperativeModesImporter_MenuItemDescriptionAddMultiplayerFeaturesSelectedGames"),
             MenuSection = "@Cooperative Modes Importer",
             Action = a => {
                 AddMpFeaturesToGamesProgress(PlayniteApi.MainView.SelectedGames.ToList());
             }
         },
         new MainMenuItem
         {
             Description = ResourceProvider.GetString("LOCCooperativeModesImporter_MenuItemDescriptionAddMultiplayerFeaturesSelectedGamesManual"),
             MenuSection = "@Cooperative Modes Importer",
             Action = a => {
                 AddModesManual();
             }
         }
     });
 }
示例#8
0
 public override List <MainMenuItem> GetMainMenuItems(GetMainMenuItemsArgs menuArgs)
 {
     return(new List <MainMenuItem>
     {
         new MainMenuItem
         {
             Description = "Launch Steam with configured actions",
             MenuSection = "@Steam Launcher Utility",
             Action = args => {
                 LaunchSteam();
             }
         },
         new MainMenuItem
         {
             Description = "Add mode filter feature to selected games",
             MenuSection = "@Steam Launcher Utility",
             Action = args => {
                 AddModeFeature();
             }
         },
         new MainMenuItem
         {
             Description = "Remove mode filter feature from selected games",
             MenuSection = "@Steam Launcher Utility",
             Action = args => {
                 RemoveModeFeature();
             }
         },
     });
 }
        // 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);
        }
示例#10
0
        public override IEnumerable <MainMenuItem> GetMainMenuItems(GetMainMenuItemsArgs args)
        {
            yield return(new MainMenuItem
            {
                Description = "window test",
                Action = (_) =>
                {
                    var window = PlayniteApi.Dialogs.CreateWindow(new WindowCreationOptions()
                    {
                        ShowCloseButton = false,
                        ShowMaximizeButton = false
                    }
                                                                  );
                    window.Title = "window plugin test";
                    window.Content = new TestPluginSettingsView();
                    window.Owner = PlayniteApi.Dialogs.GetCurrentAppWindow();
                    window.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterOwner;
                    window.Height = 640;
                    window.Width = 480;
                    window.ShowDialog();
                }
            });

            yield return(new MainMenuItem
            {
                Description = "-"
            });

            yield return(new MainMenuItem
            {
                Description = "serialization test",
                Action = (_) =>
                {
                    var filtered = PlayniteApi.MainView.FilteredGames;
                    PlayniteApi.MainView.SelectGame(filtered[1].Id);

                    //var obj = new TestPluginSettings { Option1 = "test", Option2 = 2 };
                    //PlayniteApi.Dialogs.ShowMessage(Serialization.ToJson(obj));
                }
            });

            yield return(new MainMenuItem
            {
                Description = "filtered item test",
                Action = (_) =>
                {
                    var filtered = PlayniteApi.MainView.FilteredGames;
                    logger.Warn(filtered.Count.ToString());
                    if (filtered.Count > 2)
                    {
                        PlayniteApi.MainView.SelectGames(filtered.Select(a => a.Id).Take(2));
                    }
                }
            });
        }
示例#11
0
 public override List <MainMenuItem> GetMainMenuItems(GetMainMenuItemsArgs args)
 {
     return(new List <MainMenuItem>()
     {
         new MainMenuItem()
         {
             Action = (arags) => RemoveSuperUninstalledGames(),
             Description = "Remove Entries With Missing Source ROM...",
             MenuSection = "EmuLibrary"
         }
     });
 }
示例#12
0
 public override IEnumerable <MainMenuItem> GetMainMenuItems(GetMainMenuItemsArgs args)
 {
     return(new List <MainMenuItem>
     {
         new MainMenuItem
         {
             Description = ResourceProvider.GetString("LOCSteam_Description_Cleaner_MenuItemDescriptionCleanAllGamesDescriptions"),
             MenuSection = "@Steam Description Cleaner",
             Action = a => {
                 CleanSteamDescriptions(PlayniteApi.Database.Games);
             }
         }
     });
 }
 public override IEnumerable <MainMenuItem> GetMainMenuItems(GetMainMenuItemsArgs args)
 {
     return(new List <MainMenuItem>
     {
         new MainMenuItem
         {
             Description = ResourceProvider.GetString("LOCSteam_Game_Transfer_Utility_MenuItemLaunchWindowDescription"),
             MenuSection = "@Steam Game Transfer Utility",
             Action = a => {
                 ShowTransferWindow();
             }
         }
     });
 }
        public override IEnumerable <MainMenuItem> GetMainMenuItems(GetMainMenuItemsArgs args)
        {
            List <MainMenuItem> MainMenuItems = new List <MainMenuItem>
            {
                new MainMenuItem {
                    MenuSection = "@Simple Game Importer",
                    Icon        = Path.Combine(PluginFolder, "icon.png"),
                    Description = resources.GetString("LOC_SIMPLEGAMEIMPORTER_Import"),
                    Action      = (MainMenuItem) =>
                    {
                        DoImportGames();
                    }
                }
            };

            return(MainMenuItems);
        }
        // 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>
            {
                // Download missing data for all game in database
                new MainMenuItem
                {
                    MenuSection = MenuInExtensions + resources.GetString("LOCSystemChecker"),
                    Description = resources.GetString("LOCCommonGettingAllDatas"),
                    Action      = (mainMenuItem) =>
                    {
                        PluginDatabase.GetAllDatas();
                    }
                },

                // Delete database
                new MainMenuItem
                {
                    MenuSection = MenuInExtensions + resources.GetString("LOCSystemChecker"),
                    Description = resources.GetString("LOCCommonClearAllDatas"),
                    Action      = (mainMenuItem) =>
                    {
                        PluginDatabase.ClearDatabase();
                    }
                }
            };

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

            return(mainMenuItems);
        }
 public override IEnumerable <MainMenuItem> GetMainMenuItems(GetMainMenuItemsArgs args)
 {
     return(new List <MainMenuItem>
     {
         new MainMenuItem
         {
             Description = ResourceProvider.GetString("LOCPlayState_MenuItemAddToBlacklistDescription"),
             MenuSection = "@PlayState",
             Action = a => {
                 var featureAddedCount = AddFeatureToSelectedGames("[PlayState] Blacklist");
                 PlayniteApi.Dialogs.ShowMessage(string.Format(ResourceProvider.GetString("LOCPlayState_BlacklistAddedResultsMessage"), featureAddedCount), "PlayState");
             }
         },
         new MainMenuItem
         {
             Description = ResourceProvider.GetString("LOCPlayState_MenuItemRemoveFromBlacklistDescription"),
             MenuSection = "@PlayState",
             Action = a => {
                 var featureRemovedCount = RemoveFeatureFromSelectedGames("[PlayState] Blacklist");
                 PlayniteApi.Dialogs.ShowMessage(string.Format(ResourceProvider.GetString("LOCPlayState_BlacklistRemovedResultsMessage"), featureRemovedCount), "PlayState");
             }
         },
         new MainMenuItem
         {
             Description = ResourceProvider.GetString("LOCPlayState_MenuItemAddToPlaytimeSuspendDescription"),
             MenuSection = "@PlayState",
             Action = a => {
                 var featureAddedCount = AddFeatureToSelectedGames("[PlayState] Suspend Playtime only");
                 PlayniteApi.Dialogs.ShowMessage(string.Format(ResourceProvider.GetString("LOCPlayState_PlaytimeSuspendAddedResultsMessage"), featureAddedCount), "PlayState");
             }
         },
         new MainMenuItem
         {
             Description = ResourceProvider.GetString("LOCPlayState_MenuItemRemoveFromPlaytimeSuspendDescription"),
             MenuSection = "@PlayState",
             Action = a => {
                 var featureRemovedCount = RemoveFeatureFromSelectedGames("[PlayState] Suspend Playtime only");
                 PlayniteApi.Dialogs.ShowMessage(string.Format(ResourceProvider.GetString("LOCPlayState_PlaytimeSuspendRemovedResultsMessage"), featureRemovedCount), "PlayState");
             }
         }
     });
 }
 public override List <MainMenuItem> GetMainMenuItems(GetMainMenuItemsArgs menuArgs)
 {
     return(new List <MainMenuItem>
     {
         new MainMenuItem
         {
             Description = "Launch menu window",
             MenuSection = "@Steam Game Transfer Utility",
             Action = args => {
                 WindowMethod();
             }
         },
         new MainMenuItem
         {
             Description = "Update installation drive tag in all games",
             MenuSection = "@Steam Game Transfer Utility",
             Action = args => {
                 UpdateInstallDirTagsMenu();
             }
         }
     });
 }
示例#18
0
        // 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 plugin view with all activities for all game in database
                new MainMenuItem
                {
                    MenuSection = MenuInExtensions + resources.GetString("LOCGameActivity"),
                    Description = resources.GetString("LOCGameActivityViewGamesActivities"),
                    Action      = (mainMenuItem) =>
                    {
                        DatabaseReference = PlayniteApi.Database;
                        var    ViewExtension   = new GameActivityView(settings, PlayniteApi, this.GetPluginUserDataPath());
                        Window windowExtension = PlayniteUiHelper.CreateExtensionWindow(PlayniteApi, resources.GetString("LOCGameActivity"), ViewExtension);
                        windowExtension.ShowDialog();
                    }
                }
            };

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

            return(mainMenuItems);
        }
示例#19
0
 public override List <MainMenuItem> GetMainMenuItems(GetMainMenuItemsArgs menuArgs)
 {
     return(new List <MainMenuItem>
     {
         new MainMenuItem
         {
             Description = "Update enabled status of games",
             MenuSection = "@NVIDIA GeForce NOW Enabler",
             Action = args => {
                 MainMethod(true);
             }
         },
         new MainMenuItem
         {
             Description = "Remove Play Action from all games",
             MenuSection = "@NVIDIA GeForce NOW Enabler",
             Action = args => {
                 LibraryRemoveAllPlayActions();
             }
         },
     });
 }
 public override IEnumerable <MainMenuItem> GetMainMenuItems(GetMainMenuItemsArgs args)
 {
     return(new List <MainMenuItem>
     {
         new MainMenuItem
         {
             Description = ResourceProvider.GetString("LOCInstallation_Status_Updater_MenuItemStatusUpdaterDescription"),
             MenuSection = "@Installation Status Updater",
             Action = a => {
                 DetectInstallationStatus(true);
             }
         },
         new MainMenuItem
         {
             Description = ResourceProvider.GetString("LOCInstallation_Status_Updater_MenuAddIgnoreFeatureDescription"),
             MenuSection = "@Installation Status Updater",
             Action = a => {
                 AddIgnoreFeature();
             }
         },
         new MainMenuItem
         {
             Description = ResourceProvider.GetString("LOCInstallation_Status_Updater_MenuRemoveIgnoreFeatureDescription"),
             MenuSection = "@Installation Status Updater",
             Action = a => {
                 RemoveIgnoreFeature();
             }
         },
         new MainMenuItem
         {
             Description = ResourceProvider.GetString("LOCInstallation_Status_Updater_MenuUpdateDriveInstallTagDescription"),
             MenuSection = "@Installation Status Updater",
             Action = a => {
                 UpdateInstallDirTags();
                 PlayniteApi.Dialogs.ShowMessage(ResourceProvider.GetString("LOCInstallation_Status_Updater_StatusUpdaterUpdatingTagsFinishMessage"), "Installation Status Updater");
             }
         }
     });
 }
示例#21
0
 public override IEnumerable <MainMenuItem> GetMainMenuItems(GetMainMenuItemsArgs args)
 {
     return(new List <MainMenuItem>
     {
         new MainMenuItem
         {
             Description = ResourceProvider.GetString("LOCNgfn_Enabler_MenuItemUpdateStatusDescription"),
             MenuSection = "@NVIDIA GeForce NOW Enabler",
             Action = o => {
                 MainMethod(true);
             }
         },
         new MainMenuItem
         {
             Description = ResourceProvider.GetString("LOCNgfn_Enabler_MenuItemRemoveGameActionDescription"),
             MenuSection = "@NVIDIA GeForce NOW Enabler",
             Action = o => {
                 LibraryRemoveAllPlayActions();
             }
         },
     });
 }
示例#22
0
 public override List <MainMenuItem> GetMainMenuItems(GetMainMenuItemsArgs args)
 {
     return(new List <MainMenuItem>
     {
         new MainMenuItem
         {
             Description = "window test",
             Action = (_) =>
             {
                 var window = PlayniteApi.Dialogs.CreateWindow(new WindowCreationOptions()
                 {
                     ShowCloseButton = false,
                     ShowMaximizeButton = false
                 }
                                                               );
                 window.Title = "window plugin test";
                 window.Content = new TestPluginSettingsView();
                 window.Owner = PlayniteApi.Dialogs.GetCurrentAppWindow();
                 window.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterOwner;
                 window.Height = 640;
                 window.Width = 480;
                 window.ShowDialog();
             }
         },
         new MainMenuItem
         {
             Description = "serialization test",
             Action = (_) =>
             {
                 var obj = new TestPluginSettings {
                     Option1 = "test", Option2 = 2
                 };
                 PlayniteApi.Dialogs.ShowMessage(Serialization.ToJson(obj));
             }
         }
     });
 }
示例#23
0
        // 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>
            {
            };

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

            return(mainMenuItems);
        }
        // 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);
        }
示例#25
0
        private void AddExtensionItems()
        {
            extensionsItem.Items.Clear();
            AddMenuChild(extensionsItem.Items, "LOCReloadScripts", mainModel.ReloadScriptsCommand);
            extensionsItem.Items.Add(new Separator());
            foreach (var function in mainModel.Extensions.ExportedFunctions)
            {
                var item = new MenuItem
                {
                    Header           = function.Name,
                    Command          = mainModel.InvokeExtensionFunctionCommand,
                    CommandParameter = function
                };

                extensionsItem.Items.Add(item);
            }

            var args  = new GetMainMenuItemsArgs();
            var toAdd = new List <MainMenuItem>();

            foreach (var plugin in mainModel.Extensions.Plugins.Values)
            {
                try
                {
                    var items = plugin.Plugin.GetMainMenuItems(args);
                    if (items.HasItems())
                    {
                        toAdd.AddRange(items);
                    }
                }
                catch (Exception e) when(!PlayniteEnvironment.ThrowAllErrors)
                {
                    logger.Error(e, $"Failed to get menu items from plugin {plugin.Description.Name}");
                }
            }

            foreach (var script in mainModel.Extensions.Scripts)
            {
                if (script.SupportedMenus.Contains(Scripting.SupportedMenuMethods.MainMenu))
                {
                    try
                    {
                        var items = script.GetMainMenuItems(args);
                        if (items.HasItems())
                        {
                            foreach (var item in items)
                            {
                                var newItem = MainMenuItem.FromScriptMainMenuItem(item);
                                newItem.Action = (a) =>
                                {
                                    script.InvokeFunction(item.FunctionName, new List <object>
                                    {
                                        new ScriptMainMenuItemActionArgs()
                                    });
                                };

                                toAdd.Add(newItem);
                            }
                        }
                    }
                    catch (Exception e) when(!PlayniteEnvironment.ThrowAllErrors)
                    {
                        logger.Error(e, $"Failed to get menu items from script {script.Name}");
                    }
                }
            }

            if (toAdd.Count > 0)
            {
                var menuItems          = new Dictionary <string, MenuItem>();
                var menuExtensionItems = new Dictionary <string, MenuItem>();
                foreach (var item in toAdd)
                {
                    var newItem = new MenuItem()
                    {
                        Header = item.Description,
                        Icon   = MenuHelpers.GetIcon(item.Icon)
                    };

                    if (item.Action != null)
                    {
                        newItem.Click += (_, __) =>
                        {
                            try
                            {
                                item.Action(new MainMenuItemActionArgs());
                            }
                            catch (Exception e) when(!PlayniteEnvironment.ThrowAllErrors)
                            {
                                logger.Error(e, "Main menu extension action failed.");
                                Dialogs.ShowErrorMessage(
                                    ResourceProvider.GetString("LOCMenuActionExecError") +
                                    Environment.NewLine + Environment.NewLine +
                                    e.Message, "");
                            }
                        };
                    }

                    var startIndex = Items.IndexOf(extensionsItem) + 1;
                    if (item.MenuSection.IsNullOrEmpty())
                    {
                        Items.Insert(startIndex, newItem);
                    }
                    else
                    {
                        if (item.MenuSection == "@")
                        {
                            extensionsItem.Items.Add(newItem);
                        }
                        else if (item.MenuSection.StartsWith("@"))
                        {
                            var parent = MenuHelpers.GenerateMenuParents(menuExtensionItems, item.MenuSection.Substring(1), extensionsItem.Items);
                            parent?.Items.Add(newItem);
                        }
                        else
                        {
                            var parent = MenuHelpers.GenerateMenuParents(menuItems, item.MenuSection, Items, startIndex);
                            parent?.Items.Add(newItem);
                        }
                    }
                }
            }
        }
 public override List <MainMenuItem> GetMainMenuItems(GetMainMenuItemsArgs menuArgs)
 {
     return(new List <MainMenuItem>
     {
         new MainMenuItem
         {
             Description = translator.Launch_Label(),
             MenuSection = "@" + translator.Ludusavi(),
             Action = args => {
                 LaunchLudusavi();
             }
         },
         new MainMenuItem
         {
             Description = translator.BackUpLastGame_Label(),
             MenuSection = "@" + translator.Ludusavi(),
             Action = async args => {
                 if (!CanPerformOperationOnLastGamePlayed())
                 {
                     return;
                 }
                 if (UserConsents(translator.BackUpOneGame_Confirm(GetGameName(lastGamePlayed), RequiresCustomEntry(lastGamePlayed))))
                 {
                     await Task.Run(() => BackUpOneGame(lastGamePlayed));
                 }
             }
         },
         new MainMenuItem
         {
             Description = translator.BackUpAllGames_Label(),
             MenuSection = "@" + translator.Ludusavi(),
             Action = async args => {
                 if (!CanPerformOperation())
                 {
                     return;
                 }
                 if (UserConsents(translator.BackUpAllGames_Confirm()))
                 {
                     await Task.Run(() => BackUpAllGames());
                 }
             }
         },
         new MainMenuItem
         {
             Description = translator.RestoreLastGame_Label(),
             MenuSection = "@" + translator.Ludusavi(),
             Action = async args => {
                 if (!CanPerformOperationOnLastGamePlayed())
                 {
                     return;
                 }
                 if (UserConsents(translator.RestoreOneGame_Confirm(GetGameName(lastGamePlayed), RequiresCustomEntry(lastGamePlayed))))
                 {
                     await Task.Run(() => RestoreOneGame(lastGamePlayed));
                 }
             }
         },
         new MainMenuItem
         {
             Description = translator.RestoreAllGames_Label(),
             MenuSection = "@" + translator.Ludusavi(),
             Action = async args => {
                 if (!CanPerformOperation())
                 {
                     return;
                 }
                 if (UserConsents(translator.RestoreAllGames_Confirm()))
                 {
                     await Task.Run(() => RestoreAllGames());
                 }
             }
         },
     });
 }
示例#27
0
        // 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("LOCHowLongToBeat"),
                    Description = resources.GetString("LOCHowLongToBeatPluginUserView"),
                    Action      = (mainMenuItem) =>
                    {
                        var    ViewExtension   = new HowLongToBeatUserView();
                        Window windowExtension = PlayniteUiHelper.CreateExtensionWindow(PlayniteApi, "HowLongToBeat", ViewExtension);
                        windowExtension.ShowDialog();
                    }
                },

                new MainMenuItem
                {
                    MenuSection = MenuInExtensions + resources.GetString("LOCHowLongToBeat"),
                    Description = resources.GetString("LOCCommonGetAllDatas"),
                    Action      = (mainMenuItem) =>
                    {
                        PluginDatabase.GetAllDatas();
                    }
                },
                new MainMenuItem
                {
                    MenuSection = MenuInExtensions + resources.GetString("LOCHowLongToBeat"),
                    Description = resources.GetString("LOCCommonClearAllDatas"),
                    Action      = (mainMenuItem) =>
                    {
                        if (PluginDatabase.ClearDatabase())
                        {
                            PlayniteApi.Dialogs.ShowMessage(resources.GetString("LOCCommonDataRemove"), "HowLongToBeat");
                        }
                        else
                        {
                            PlayniteApi.Dialogs.ShowErrorMessage(resources.GetString("LOCCommonDataErrorRemove"), "HowLongToBeat");
                        }
                    }
                },

                new MainMenuItem
                {
                    MenuSection = MenuInExtensions + resources.GetString("LOCHowLongToBeat"),
                    Description = resources.GetString("LOCHowLongToBeatActualiseUserData"),
                    Action      = (mainMenuItem) =>
                    {
                        PluginDatabase.RefreshUserData();
                    }
                },

                new MainMenuItem
                {
                    MenuSection = MenuInExtensions + resources.GetString("LOCHowLongToBeat"),
                    Description = resources.GetString("LOCCommonAddAllTags"),
                    Action      = (mainMenuItem) =>
                    {
                        PluginDatabase.AddTagAllGame();
                    }
                },
                new MainMenuItem
                {
                    MenuSection = MenuInExtensions + resources.GetString("LOCHowLongToBeat"),
                    Description = resources.GetString("LOCCommonRemoveAllTags"),
                    Action      = (mainMenuItem) =>
                    {
                        PluginDatabase.RemoveTagAllGame();
                    }
                }
            };

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

            return(mainMenuItems);
        }
示例#28
0
 /// <summary>
 /// Gets list of items to be displayed in Playnite's main menu.
 /// </summary>
 /// <param name="args">Contextual arguments.</param>
 /// <returns>List of menu items to be displayed in Playnite's main menu.</returns>
 public virtual IEnumerable <MainMenuItem> GetMainMenuItems(GetMainMenuItemsArgs args)
 {
     return(null);
 }
示例#29
0
        // To add new main menu items override GetMainMenuItems
        public override IEnumerable <MainMenuItem> GetMainMenuItems(GetMainMenuItemsArgs args)
        {
            string MenuInExtensions = string.Empty;

            if (PluginSettings.Settings.MenuInExtensions)
            {
                MenuInExtensions = "@";
            }

            List <MainMenuItem> mainMenuItems = new List <MainMenuItem>();

            mainMenuItems.Add(new MainMenuItem
            {
                MenuSection = MenuInExtensions + resources.GetString("LOCLm"),
                Description = resources.GetString("LOCLmSetCompanies"),
                Action      = (mainMenuItem) =>
                {
                    LibraryManagementTools libraryManagementTools = new LibraryManagementTools(this, PlayniteApi, PluginSettings.Settings);
                    libraryManagementTools.SetCompanies();
                }
            });
            mainMenuItems.Add(new MainMenuItem
            {
                MenuSection = MenuInExtensions + resources.GetString("LOCLm"),
                Description = resources.GetString("LOCLmSetFeatures"),
                Action      = (mainMenuItem) =>
                {
                    LibraryManagementTools libraryManagementTools = new LibraryManagementTools(this, PlayniteApi, PluginSettings.Settings);
                    libraryManagementTools.SetFeatures();
                }
            });
            mainMenuItems.Add(new MainMenuItem
            {
                MenuSection = MenuInExtensions + resources.GetString("LOCLm"),
                Description = resources.GetString("LOCLmSetGenres"),
                Action      = (mainMenuItem) =>
                {
                    LibraryManagementTools libraryManagementTools = new LibraryManagementTools(this, PlayniteApi, PluginSettings.Settings);
                    libraryManagementTools.SetGenres();
                }
            });
            mainMenuItems.Add(new MainMenuItem
            {
                MenuSection = MenuInExtensions + resources.GetString("LOCLm"),
                Description = resources.GetString("LOCLmSetTags"),
                Action      = (mainMenuItem) =>
                {
                    LibraryManagementTools libraryManagementTools = new LibraryManagementTools(this, PlayniteApi, PluginSettings.Settings);
                    libraryManagementTools.SetTags();
                }
            });
            mainMenuItems.Add(new MainMenuItem
            {
                MenuSection = MenuInExtensions + resources.GetString("LOCLm"),
                Description = resources.GetString("LOCLmSetTagsToFeatures"),
                Action      = (mainMenuItem) =>
                {
                    LibraryManagementTools libraryManagementTools = new LibraryManagementTools(this, PlayniteApi, PluginSettings.Settings);
                    libraryManagementTools.SetTagsToFeatures();
                }
            });
            mainMenuItems.Add(new MainMenuItem
            {
                MenuSection = MenuInExtensions + resources.GetString("LOCLm"),
                Description = resources.GetString("LOCLmSetTagsToGenres"),
                Action      = (mainMenuItem) =>
                {
                    LibraryManagementTools libraryManagementTools = new LibraryManagementTools(this, PlayniteApi, PluginSettings.Settings);
                    libraryManagementTools.SetTagsToGenres();
                }
            });

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

            return(mainMenuItems);
        }
        // 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>
            {
                // Download missing localizations data for all game in database
                new MainMenuItem
                {
                    MenuSection = MenuInExtensions + resources.GetString("LOCCheckLocalizations"),
                    Description = resources.GetString("LOCCommonGetAllDatas"),
                    Action      = (mainMenuItem) =>
                    {
                        PluginDatabase.GetAllDatas();
                    }
                },

                // Delete all data of plugin
                new MainMenuItem
                {
                    MenuSection = MenuInExtensions + resources.GetString("LOCCheckLocalizations"),
                    Description = resources.GetString("LOCCommonClearAllDatas"),
                    Action      = (mainMenuItem) =>
                    {
                        if (PluginDatabase.ClearDatabase())
                        {
                            PlayniteApi.Dialogs.ShowMessage(resources.GetString("LOCCommonDataRemove"), "CheckLocalizations");
                        }
                        else
                        {
                            PlayniteApi.Dialogs.ShowErrorMessage(resources.GetString("LOCCommonDataErrorRemove"), "CheckLocalizations");
                        }
                    }
                },

                // Add tag for all game in database if data exists
                new MainMenuItem
                {
                    MenuSection = MenuInExtensions + resources.GetString("LOCCheckLocalizations"),
                    Description = resources.GetString("LOCCommonAddAllTags"),
                    Action      = (mainMenuItem) =>
                    {
                        PluginDatabase.AddTagAllGame();
                    }
                },

                // Remove tag for all game in database
                new MainMenuItem
                {
                    MenuSection = MenuInExtensions + resources.GetString("LOCCheckLocalizations"),
                    Description = resources.GetString("LOCCommonRemoveAllTags"),
                    Action      = (mainMenuItem) =>
                    {
                        PluginDatabase.RemoveTagAllGame();
                    }
                }
            };

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

            return(mainMenuItems);
        }