Skip to content

Commit fa67b40

Browse files
feat: have the forge config button open OptionsGui
1 parent 92ca51e commit fa67b40

File tree

3 files changed

+54
-3
lines changed

3 files changed

+54
-3
lines changed

src/main/kotlin/gg/skytils/skytilsmod/Skytils.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ import kotlin.math.abs
116116
name = Skytils.MOD_NAME,
117117
version = Skytils.VERSION,
118118
acceptedMinecraftVersions = "[1.8.9]",
119-
clientSideOnly = true
119+
clientSideOnly = true,
120+
guiFactory = "gg.skytils.skytilsmod.core.ForgeGuiFactory"
120121
)
121122
class Skytils {
122123

@@ -574,7 +575,9 @@ class Skytils {
574575
@SubscribeEvent
575576
fun onGuiChange(event: GuiOpenEvent) {
576577
val old = mc.currentScreen
577-
if (event.gui == null && config.reopenOptionsMenu) {
578+
if (event.gui == null && old is OptionsGui && old.parent != null) {
579+
displayScreen = old.parent
580+
} else if (event.gui == null && config.reopenOptionsMenu) {
578581
if (old is ReopenableGUI || (old is AccessorSettingsGui && old.config is Config)) {
579582
tickTimer(1) {
580583
if (mc.thePlayer?.openContainer == mc.thePlayer?.inventoryContainer)
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
* Skytils - Hypixel Skyblock Quality of Life Mod
3+
* Copyright (C) 2020-2024 Skytils
4+
*
5+
* This program is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU Affero General Public License as published
7+
* by the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU Affero General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU Affero General Public License
16+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
17+
*/
18+
19+
package gg.skytils.skytilsmod.core
20+
21+
import gg.skytils.skytilsmod.gui.OptionsGui
22+
import net.minecraft.client.Minecraft
23+
import net.minecraft.client.gui.Gui
24+
import net.minecraft.client.gui.GuiScreen
25+
import net.minecraftforge.fml.client.IModGuiFactory
26+
import net.minecraftforge.fml.client.IModGuiFactory.RuntimeOptionGuiHandler
27+
28+
class ForgeGuiFactory : IModGuiFactory {
29+
override fun initialize(minecraft: Minecraft) {
30+
}
31+
32+
override fun mainConfigGuiClass(): Class<out GuiScreen> = OptionsGui::class.java
33+
34+
override fun runtimeGuiCategories(): Set<IModGuiFactory.RuntimeOptionCategoryElement> = emptySet()
35+
36+
override fun getHandlerFor(runtimeOptionCategoryElement: IModGuiFactory.RuntimeOptionCategoryElement): RuntimeOptionGuiHandler =
37+
object : RuntimeOptionGuiHandler {
38+
override fun addWidgets(list: MutableList<Gui>?, i: Int, j: Int, k: Int, l: Int) {}
39+
40+
override fun paint(i: Int, j: Int, k: Int, l: Int) {}
41+
42+
override fun actionCallback(i: Int) {}
43+
44+
override fun close() {}
45+
}
46+
47+
}

src/main/kotlin/gg/skytils/skytilsmod/gui/OptionsGui.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,11 @@ import gg.skytils.skytilsmod.gui.editing.ElementaEditingGui
3434
import gg.skytils.skytilsmod.utils.Utils
3535
import gg.skytils.skytilsmod.utils.openGUI
3636
import net.minecraft.client.Minecraft
37+
import net.minecraft.client.gui.GuiScreen
3738
import java.awt.Desktop
3839
import java.net.URI
3940

40-
class OptionsGui :
41+
class OptionsGui(val parent: GuiScreen? = null) :
4142
WindowScreen(ElementaVersion.V2, newGuiScale = EssentialAPI.getGuiUtil().getGuiScale()) {
4243

4344
private val skytilsText: UIText =

0 commit comments

Comments
 (0)