/// <summary> /// Loads the UI for mod configs. /// </summary> /// <param name="config"></param> public static void OpenModConfigUI(ModConfig config) { Type interfaceType = ReflectionHelpers.GetMainAssembly() .GetType("Terraria.ModLoader.UI.Interface"); if (!Main.gameMenu) { IngameOptions.Close(); IngameFancyUI.CoverNextFrame(); Main.playerInventory = false; Main.editChest = false; Main.npcChatText = ""; Main.inFancyUI = true; } else { if (!ReflectionHelpers.Get(interfaceType, null, "modConfigID", out Main.menuMode)) { LogHelpers.Warn("Could not get Interface.modConfigID"); return; } } UIState modConfigInterfaceObj; if (!ReflectionHelpers.Get(interfaceType, null, "modConfig", out modConfigInterfaceObj) || modConfigInterfaceObj == null) { LogHelpers.Warn("Could not get Interface.modConfig"); return; } object _; if (!ReflectionHelpers.RunMethod(modConfigInterfaceObj, "SetMod", new object[] { config.mod, config }, out _)) { LogHelpers.Warn("Could not run Interface.modConfig.SetMod"); return; } Main.InGameUI.SetState(modConfigInterfaceObj); Main.PlaySound(SoundID.MenuTick); }
/// <summary> /// Switches to the list of mod configs menu. /// </summary> public static void OpenModConfigListUI() { Type interfaceType = ReflectionLibraries.GetMainAssembly() .GetType("Terraria.ModLoader.UI.Interface"); if (!Main.gameMenu) { IngameOptions.Close(); IngameFancyUI.CoverNextFrame(); Main.playerInventory = false; Main.editChest = false; Main.npcChatText = ""; Main.inFancyUI = true; } else { if (!ReflectionLibraries.Get(interfaceType, null, "modConfigID", out Main.menuMode)) { LogLibraries.Warn("Could not get Interface.modConfigID"); return; } } UIState modConfigListInterfaceObj; if (!ReflectionLibraries.Get(interfaceType, null, "modConfigList", out modConfigListInterfaceObj) || modConfigListInterfaceObj == null) { LogLibraries.Warn("Could not get Interface.modConfigList"); return; } Main.InGameUI.SetState(modConfigListInterfaceObj); Main.PlaySound(SoundID.MenuTick); }