Add repeatPopup field to addon-manifest

This commit is contained in:
Nick 2023-07-03 11:26:55 -04:00
parent f92e1cf59b
commit 87372466ad
3 changed files with 10 additions and 5 deletions

View File

@ -26,5 +26,10 @@ namespace NewHorizons.External.Configs
/// A pop-up message for the first time a user runs the add-on /// A pop-up message for the first time a user runs the add-on
/// </summary> /// </summary>
public string popupMessage; public string popupMessage;
/// <summary>
/// If popupMessage is set, should it repeat every time the game starts or only once
/// </summary>
public bool repeatPopup;
} }
} }

View File

@ -701,7 +701,7 @@ namespace NewHorizons
} }
if (!string.IsNullOrEmpty(addonConfig.popupMessage)) 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);
} }
} }

View File

@ -13,7 +13,7 @@ namespace NewHorizons.OtherMods.MenuFramework
{ {
private static IMenuAPI _menuApi; 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<string> _failedFiles = new(); private static List<string> _failedFiles = new();
public static void Init() public static void Init()
@ -38,9 +38,9 @@ namespace NewHorizons.OtherMods.MenuFramework
_menuApi.RegisterStartupPopup(warning); _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)); _menuApi.RegisterStartupPopup(TranslationHandler.GetTranslation(message, TranslationHandler.TextType.UI));
NewHorizonsData.ReadOneTimePopup(mod.ModHelper.Manifest.UniqueName); 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 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));
} }
} }