From 87372466adae695721467b05b459a42631e2e73c Mon Sep 17 00:00:00 2001 From: Nick Date: Mon, 3 Jul 2023 11:26:55 -0400 Subject: [PATCH] Add repeatPopup field to addon-manifest --- NewHorizons/External/Configs/AddonConfig.cs | 5 +++++ NewHorizons/Main.cs | 2 +- NewHorizons/OtherMods/MenuFramework/MenuHandler.cs | 8 ++++---- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/NewHorizons/External/Configs/AddonConfig.cs b/NewHorizons/External/Configs/AddonConfig.cs index a43f3910..54d8cf0e 100644 --- a/NewHorizons/External/Configs/AddonConfig.cs +++ b/NewHorizons/External/Configs/AddonConfig.cs @@ -26,5 +26,10 @@ namespace NewHorizons.External.Configs /// A pop-up message for the first time a user runs the add-on /// public string popupMessage; + + /// + /// If popupMessage is set, should it repeat every time the game starts or only once + /// + public bool repeatPopup; } } diff --git a/NewHorizons/Main.cs b/NewHorizons/Main.cs index 1b431a0e..b8f9dce2 100644 --- a/NewHorizons/Main.cs +++ b/NewHorizons/Main.cs @@ -701,7 +701,7 @@ namespace NewHorizons } if (!string.IsNullOrEmpty(addonConfig.popupMessage)) { - MenuHandler.RegisterOneTimePopup(mod, TranslationHandler.GetTranslation(addonConfig.popupMessage, TranslationHandler.TextType.UI)); + MenuHandler.RegisterOneTimePopup(mod, TranslationHandler.GetTranslation(addonConfig.popupMessage, TranslationHandler.TextType.UI), addonConfig.repeatPopup); } } diff --git a/NewHorizons/OtherMods/MenuFramework/MenuHandler.cs b/NewHorizons/OtherMods/MenuFramework/MenuHandler.cs index 4181c2d5..101a0789 100644 --- a/NewHorizons/OtherMods/MenuFramework/MenuHandler.cs +++ b/NewHorizons/OtherMods/MenuFramework/MenuHandler.cs @@ -13,7 +13,7 @@ namespace NewHorizons.OtherMods.MenuFramework { private static IMenuAPI _menuApi; - private static List<(IModBehaviour mod, string message)> _registeredPopups = new(); + private static List<(IModBehaviour mod, string message, bool repeat)> _registeredPopups = new(); private static List _failedFiles = new(); public static void Init() @@ -38,9 +38,9 @@ namespace NewHorizons.OtherMods.MenuFramework _menuApi.RegisterStartupPopup(warning); } - foreach(var (mod, message) in _registeredPopups) + foreach(var (mod, message, repeat) in _registeredPopups) { - if (!NewHorizonsData.HasReadOneTimePopup(mod.ModHelper.Manifest.UniqueName)) + if (repeat || !NewHorizonsData.HasReadOneTimePopup(mod.ModHelper.Manifest.UniqueName)) { _menuApi.RegisterStartupPopup(TranslationHandler.GetTranslation(message, TranslationHandler.TextType.UI)); NewHorizonsData.ReadOneTimePopup(mod.ModHelper.Manifest.UniqueName); @@ -64,6 +64,6 @@ namespace NewHorizons.OtherMods.MenuFramework public static void RegisterFailedConfig(string filename) => _failedFiles.Add(filename); - public static void RegisterOneTimePopup(IModBehaviour mod, string message) => _registeredPopups.Add((mod, message)); + public static void RegisterOneTimePopup(IModBehaviour mod, string message, bool repeat) => _registeredPopups.Add((mod, message, repeat)); } }