diff options
Diffstat (limited to 'src/main')
4 files changed, 24 insertions, 12 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/ConfigGuiForgeInterop.kt b/src/main/java/at/hannibal2/skyhanni/config/ConfigGuiForgeInterop.kt index 0d094dad6..f0da4febb 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/ConfigGuiForgeInterop.kt +++ b/src/main/java/at/hannibal2/skyhanni/config/ConfigGuiForgeInterop.kt @@ -22,7 +22,7 @@ class ConfigGuiForgeInterop : IModGuiFactory { override fun getHandlerFor(runtimeOptionCategoryElement: RuntimeOptionCategoryElement): RuntimeOptionGuiHandler? = null - class WrappedSkyHanniConfig(private val parent: GuiScreen) : GuiScreenElementWrapper(MoulConfigEditor(SkyHanniMod.configManager.processor)) { + class WrappedSkyHanniConfig(private val parent: GuiScreen) : GuiScreenElementWrapper(ConfigGuiManager.configEditor) { @Throws(IOException::class) override fun handleKeyboardInput() { if (Keyboard.getEventKeyState() && Keyboard.getEventKey() == Keyboard.KEY_ESCAPE) { diff --git a/src/main/java/at/hannibal2/skyhanni/config/ConfigGuiManager.kt b/src/main/java/at/hannibal2/skyhanni/config/ConfigGuiManager.kt new file mode 100644 index 000000000..d1b84f09c --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/config/ConfigGuiManager.kt @@ -0,0 +1,18 @@ +package at.hannibal2.skyhanni.config + +import at.hannibal2.skyhanni.SkyHanniMod +import io.github.moulberry.moulconfig.gui.GuiScreenElementWrapper +import io.github.moulberry.moulconfig.gui.MoulConfigEditor + +object ConfigGuiManager { + val configEditor by lazy { MoulConfigEditor(SkyHanniMod.configManager.processor) } + + fun openConfigGui(search: String? = null) { + if (search != null) { + configEditor.search(search) + } + SkyHanniMod.screenToOpen = GuiScreenElementWrapper(configEditor) + } + + +}
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt index 01bc17d9c..2ef9f169b 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt +++ b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt @@ -1,6 +1,7 @@ package at.hannibal2.skyhanni.config.commands import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.config.ConfigGuiManager import at.hannibal2.skyhanni.config.commands.SimpleCommand.ProcessCommandRunnable import at.hannibal2.skyhanni.data.ApiDataLoader import at.hannibal2.skyhanni.data.GuiEditManager @@ -13,8 +14,6 @@ import at.hannibal2.skyhanni.test.LorenzTest import at.hannibal2.skyhanni.test.PacketTest import at.hannibal2.skyhanni.test.command.CopyItemCommand import at.hannibal2.skyhanni.test.command.CopyNearbyEntitiesCommand -import io.github.moulberry.moulconfig.gui.GuiScreenElementWrapper -import io.github.moulberry.moulconfig.gui.MoulConfigEditor import net.minecraft.command.ICommandSender import net.minecraftforge.client.ClientCommandHandler @@ -25,12 +24,10 @@ object Commands { if (it[0].lowercase() == "gui") { GuiEditManager.openGuiEditor() } else { - val editor = MoulConfigEditor(SkyHanniMod.configManager.processor) - editor.search(it.joinToString(" ")) - SkyHanniMod.screenToOpen = GuiScreenElementWrapper(editor) + ConfigGuiManager.openConfigGui(it.joinToString(" ")) } } else { - SkyHanniMod.screenToOpen = GuiScreenElementWrapper(MoulConfigEditor(SkyHanniMod.configManager.processor)) + ConfigGuiManager.openConfigGui() } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/ButtonOnPause.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/ButtonOnPause.kt index d81f9e242..c28119857 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/ButtonOnPause.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/ButtonOnPause.kt @@ -1,9 +1,8 @@ package at.hannibal2.skyhanni.features.misc import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.config.ConfigGuiManager import at.hannibal2.skyhanni.utils.LorenzUtils -import io.github.moulberry.moulconfig.gui.GuiScreenElementWrapper -import io.github.moulberry.moulconfig.gui.MoulConfigEditor import net.minecraft.client.gui.GuiButton import net.minecraft.client.gui.GuiIngameMenu import net.minecraftforge.client.event.GuiScreenEvent @@ -17,9 +16,7 @@ class ButtonOnPause { if (!LorenzUtils.isHyPixel) return if (SkyHanniMod.feature.misc.configButtonOnPause && event.gui is GuiIngameMenu && event.button.id == buttonId) { - SkyHanniMod.screenToOpen = GuiScreenElementWrapper( - MoulConfigEditor(SkyHanniMod.configManager.processor) - ) + ConfigGuiManager.openConfigGui() } } |