Skip to content

Commit 9f05597

Browse files
committed
feat: add ConfigGuiForgeInterop
1 parent 1bd5e50 commit 9f05597

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

src/main/kotlin/com/github/itsempa/nautilus/Nautilus.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import java.io.File
3838
clientSideOnly = true,
3939
version = Nautilus.VERSION,
4040
modLanguageAdapter = "com.github.itsempa.nautilus.utils.KotlinLanguageAdapter",
41+
guiFactory = "com.github.itsempa.nautilus.config.core.ConfigGuiForgeInterop",
4142
dependencies = "after:skyhanni",
4243
)
4344
object Nautilus {
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package com.github.itsempa.nautilus.config.core
2+
3+
import at.hannibal2.skyhanni.deps.moulconfig.gui.GuiScreenElementWrapper
4+
import com.github.itsempa.nautilus.utils.helpers.McScreen
5+
import net.minecraft.client.Minecraft
6+
import net.minecraft.client.gui.GuiScreen
7+
import net.minecraftforge.fml.client.IModGuiFactory
8+
import org.lwjgl.input.Keyboard
9+
import java.io.IOException
10+
11+
@Suppress("unused")
12+
class ConfigGuiForgeInterop : IModGuiFactory {
13+
override fun initialize(minecraft: Minecraft) { /* Empty */ }
14+
15+
override fun mainConfigGuiClass() = WrappedNautilusConfig::class.java
16+
17+
override fun runtimeGuiCategories(): Set<IModGuiFactory.RuntimeOptionCategoryElement>? = null
18+
19+
override fun getHandlerFor(element: IModGuiFactory.RuntimeOptionCategoryElement) = null
20+
21+
class WrappedNautilusConfig(
22+
private val parent: GuiScreen
23+
) : GuiScreenElementWrapper(ConfigManager.editor) {
24+
25+
@Throws(IOException::class)
26+
override fun handleKeyboardInput() {
27+
if (Keyboard.getEventKeyState() && Keyboard.getEventKey() == Keyboard.KEY_ESCAPE) {
28+
return McScreen.display(parent)
29+
} else super.handleKeyboardInput()
30+
}
31+
32+
}
33+
34+
}

0 commit comments

Comments
 (0)