aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/lorenz/mod/misc
diff options
context:
space:
mode:
authorLorenz <ESs95s3P5z8Pheb>2022-07-09 00:37:17 +0200
committerLorenz <ESs95s3P5z8Pheb>2022-07-09 00:37:17 +0200
commitb6e4599d4454bc227886fafd0deab5ced882b97c (patch)
treebecfa9afb79190031c159f5d5d302d9599e451d6 /src/main/java/at/lorenz/mod/misc
parent0d3c6f6c95fe3574d1da5d75f344dac459a3b241 (diff)
downloadskyhanni-b6e4599d4454bc227886fafd0deab5ced882b97c.tar.gz
skyhanni-b6e4599d4454bc227886fafd0deab5ced882b97c.tar.bz2
skyhanni-b6e4599d4454bc227886fafd0deab5ced882b97c.zip
adding a button on pause menu
Diffstat (limited to 'src/main/java/at/lorenz/mod/misc')
-rw-r--r--src/main/java/at/lorenz/mod/misc/ButtonOnPause.kt42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/main/java/at/lorenz/mod/misc/ButtonOnPause.kt b/src/main/java/at/lorenz/mod/misc/ButtonOnPause.kt
new file mode 100644
index 000000000..9fe540ae9
--- /dev/null
+++ b/src/main/java/at/lorenz/mod/misc/ButtonOnPause.kt
@@ -0,0 +1,42 @@
+package at.lorenz.mod.misc
+
+import at.lorenz.mod.LorenzMod
+import com.thatgravyboat.skyblockhud_2.config.SBHConfigEditor
+import com.thatgravyboat.skyblockhud_2.core.GuiScreenElementWrapper
+import net.minecraft.client.gui.GuiButton
+import net.minecraft.client.gui.GuiIngameMenu
+import net.minecraftforge.client.event.GuiScreenEvent
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+
+class ButtonOnPause {
+ private val buttonId = System.nanoTime().toInt()
+
+ @SubscribeEvent
+ fun onGuiAction(event: GuiScreenEvent.ActionPerformedEvent.Post) {
+ if (LorenzMod.feature.misc.configButtonOnPause && event.gui is GuiIngameMenu && event.button.id == buttonId) {
+ LorenzMod.screenToOpen = GuiScreenElementWrapper(SBHConfigEditor(LorenzMod.feature))
+ }
+ }
+
+ @SubscribeEvent
+ fun onGuiInitPost(event: GuiScreenEvent.InitGuiEvent.Post) {
+ if (LorenzMod.feature.misc.configButtonOnPause && event.gui is GuiIngameMenu) {
+ val x = event.gui.width - 105
+ val x2 = x + 100
+ var y = event.gui.height - 22
+ var y2 = y + 20
+ val sorted = event.buttonList.sortedWith { a, b -> b.yPosition + b.height - a.yPosition + a.height }
+ for (button in sorted) {
+ val otherX = button.xPosition
+ val otherX2 = button.xPosition + button.width
+ val otherY = button.yPosition
+ val otherY2 = button.yPosition + button.height
+ if (otherX2 > x && otherX < x2 && otherY2 > y && otherY < y2) {
+ y = otherY - 20 - 2
+ y2 = y + 20
+ }
+ }
+ event.buttonList.add(GuiButton(buttonId, x, 0.coerceAtLeast(y), 100, 20, "Lorenz Mod"))
+ }
+ }
+} \ No newline at end of file