From 74afe60577e3fdbc1e9dcfaa45a3316881ecc5ce Mon Sep 17 00:00:00 2001 From: GinYuH <72181395+GinYuH@users.noreply.github.com> Date: Sun, 21 Jan 2024 18:37:35 -0800 Subject: [PATCH] Added a Mod Call to register custom draedon logs --- CalamityMod.cs | 2 +- ModSupport/ModCalls.cs | 8 ++++++++ UI/PopupGUIManager.cs | 6 ++++-- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/CalamityMod.cs b/CalamityMod.cs index e74cd3ca63..55c82c3569 100644 --- a/CalamityMod.cs +++ b/CalamityMod.cs @@ -383,7 +383,7 @@ namespace CalamityMod return Color.Lerp(player.hairColor, new Color(186, 85, 211), stealthInterpolant); })); - PopupGUIManager.LoadGUIs(); + PopupGUIManager.LoadGUIs(Instance); InvasionProgressUIManager.LoadGUIs(); } #endregion diff --git a/ModSupport/ModCalls.cs b/ModSupport/ModCalls.cs index 344095e943..1bfb434bce 100644 --- a/ModSupport/ModCalls.cs +++ b/ModSupport/ModCalls.cs @@ -1995,6 +1995,14 @@ namespace CalamityMod CooldownRegistry.RegisterModCooldowns(args[1] as Mod); return null; + case "RegisterModPopupGUIs": + case "RegisterModDraedonLogs": + if (args.Length != 2 || !(args[1] is Mod)) + return new ArgumentNullException("ERROR: Must specify a Mod instance to register popup GUIs from."); + + PopupGUIManager.LoadGUIs(args[1] as Mod); + return null; + case "GetSummonerNerfDisabledByItem": if (args.Length != 2 || !isValidItemArg(args[1])) return new ArgumentException("ERROR: Must specify a valid item to check status of."); diff --git a/UI/PopupGUIManager.cs b/UI/PopupGUIManager.cs index 61c72bbf6e..d84ed01f1b 100644 --- a/UI/PopupGUIManager.cs +++ b/UI/PopupGUIManager.cs @@ -3,6 +3,8 @@ using System; using System.Collections.Generic; using System.Linq; using Terraria; +using Terraria.ModLoader; +using Terraria.ModLoader.Core; namespace CalamityMod.UI { @@ -55,10 +57,10 @@ namespace CalamityMod.UI gUIs.First(gui => gui.GetType() == type).Active = !gUIs.First(gui => gui.GetType() == type).Active; } - public static void LoadGUIs() + public static void LoadGUIs(Mod mod) { // Look through every type in the mod, and check if it's derived from PopupGUI. If it is, create a copy and save it in the static list. - foreach (Type type in typeof(CalamityMod).Assembly.GetTypes()) + foreach (Type type in AssemblyManager.GetLoadableTypes(mod.Code)) { // Don't load abstract classes since they cannot have instances. if (type.IsAbstract)