diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-08-08 00:32:50 +0200 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-08-08 00:32:50 +0200 |
commit | 2ac1f3d037fee016063cd7bc499d4abcfeb765d5 (patch) | |
tree | 2bd1b280b26c082702301bf9f981c2c54eacdc12 /src/main/java | |
parent | 438913125287404a4ca7fd1564c8b2d811720adb (diff) | |
download | skyhanni-2ac1f3d037fee016063cd7bc499d4abcfeb765d5.tar.gz skyhanni-2ac1f3d037fee016063cd7bc499d4abcfeb765d5.tar.bz2 skyhanni-2ac1f3d037fee016063cd7bc499d4abcfeb765d5.zip |
code cleanup config
Diffstat (limited to 'src/main/java')
11 files changed, 196 insertions, 188 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/ConfigGuiForgeInterop.kt b/src/main/java/at/hannibal2/skyhanni/config/ConfigGuiForgeInterop.kt index 12c6d2b4a..a8190ca5b 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/ConfigGuiForgeInterop.kt +++ b/src/main/java/at/hannibal2/skyhanni/config/ConfigGuiForgeInterop.kt @@ -12,16 +12,13 @@ import java.io.IOException @Suppress("unused") class ConfigGuiForgeInterop : IModGuiFactory { override fun initialize(minecraft: Minecraft) {} - override fun mainConfigGuiClass(): Class<out GuiScreen> { - return WrappedSkyHanniConfig::class.java - } + override fun mainConfigGuiClass() = WrappedSkyHanniConfig::class.java override fun runtimeGuiCategories(): Set<RuntimeOptionCategoryElement>? = null - override fun getHandlerFor(runtimeOptionCategoryElement: RuntimeOptionCategoryElement): RuntimeOptionGuiHandler? = - null + override fun getHandlerFor(element: RuntimeOptionCategoryElement): RuntimeOptionGuiHandler? = null - class WrappedSkyHanniConfig(private val parent: GuiScreen) : GuiScreenElementWrapper(ConfigGuiManager.configEditor) { + class WrappedSkyHanniConfig(private val parent: GuiScreen) : GuiScreenElementWrapper(ConfigGuiManager.editor) { @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 index d1b84f09c..37c2920a5 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/ConfigGuiManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/config/ConfigGuiManager.kt @@ -5,13 +5,13 @@ import io.github.moulberry.moulconfig.gui.GuiScreenElementWrapper import io.github.moulberry.moulconfig.gui.MoulConfigEditor object ConfigGuiManager { - val configEditor by lazy { MoulConfigEditor(SkyHanniMod.configManager.processor) } + val editor by lazy { MoulConfigEditor(SkyHanniMod.configManager.processor) } fun openConfigGui(search: String? = null) { if (search != null) { - configEditor.search(search) + editor.search(search) } - SkyHanniMod.screenToOpen = GuiScreenElementWrapper(configEditor) + SkyHanniMod.screenToOpen = GuiScreenElementWrapper(editor) } 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 e83a14c5c..db1ebe161 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt +++ b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt @@ -8,7 +8,6 @@ import at.hannibal2.skyhanni.data.ChatManager import at.hannibal2.skyhanni.data.GuiEditManager import at.hannibal2.skyhanni.features.bingo.BingoCardDisplay import at.hannibal2.skyhanni.features.bingo.BingoNextStepHelper -import at.hannibal2.skyhanni.features.chat.ChatFilterGui import at.hannibal2.skyhanni.features.event.diana.BurrowWarpHelper import at.hannibal2.skyhanni.features.event.diana.InquisitorWaypointShare import at.hannibal2.skyhanni.features.garden.GardenAPI diff --git a/src/main/java/at/hannibal2/skyhanni/config/core/config/Position.java b/src/main/java/at/hannibal2/skyhanni/config/core/config/Position.java index 137d58138..5ce2cafce 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/core/config/Position.java +++ b/src/main/java/at/hannibal2/skyhanni/config/core/config/Position.java @@ -24,144 +24,145 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.gui.ScaledResolution; public class Position { - @Expose - private int x; - @Expose - private int y; - @Expose - private boolean centerX; - @Expose - private boolean centerY; - - private boolean clicked = false; - public String internalName = null; - - public Position(int x, int y) { - this(x, y, false, false); - } - - public Position(int x, int y, boolean centerX, boolean centerY) { - this.x = x; - this.y = y; - this.centerX = centerX; - this.centerY = centerY; - } - - public void set(Position other) { - this.x = other.x; - this.y = other.y; - this.centerX = other.centerX; - this.centerY = other.centerY; - } - - public int getRawX() { - return x; - } - - public int getRawY() { - return y; - } - - public void setClicked(boolean state) { - this.clicked = state; - } - public boolean getClicked() { - return clicked; - } - - public int getAbsX0(int objWidth) { - int width = new ScaledResolution(Minecraft.getMinecraft()).getScaledWidth(); - - int ret = x; - if (x < 0) { - ret = width + x - objWidth; - } - - if (ret < 0) ret = 0; - if (ret > width - objWidth) ret = width - objWidth; - - return ret; - } - - public int getAbsY0(int objHeight) { - int height = new ScaledResolution(Minecraft.getMinecraft()).getScaledHeight(); - - int ret = y; - if (y < 0) { - ret = height + y - objHeight; - } - - if (ret < 0) ret = 0; - if (ret > height - objHeight) ret = height - objHeight; - - return ret; - } - - public int moveX(int deltaX, int objWidth) { - int screenWidth = new ScaledResolution(Minecraft.getMinecraft()).getScaledWidth(); - boolean wasPositiveX = this.x >= 0; - this.x += deltaX; - - if (wasPositiveX) { - if (this.x < 0) { - deltaX -= this.x; - this.x = 0; - } - if (this.x > screenWidth) { - deltaX += screenWidth - this.x; - this.x = screenWidth; - } - } else { - if (this.x + 1 > 0) { - deltaX += -1 - this.x; - this.x = -1; - } - if (this.x + screenWidth < 0) { - deltaX += -screenWidth - this.x; - this.x = -screenWidth; - } - } - - if (this.x >= 0 && this.x + objWidth / 2 > screenWidth / 2) { - this.x -= screenWidth - objWidth; - } - if (this.x < 0 && this.x + objWidth / 2 <= -screenWidth / 2) { - this.x += screenWidth - objWidth; - } - return deltaX; - } - - public int moveY(int deltaY, int objHeight) { - int screenHeight = new ScaledResolution(Minecraft.getMinecraft()).getScaledHeight(); - boolean wasPositiveY = this.y >= 0; - this.y += deltaY; - - if (wasPositiveY) { - if (this.y < 0) { - deltaY -= this.y; - this.y = 0; - } - if (this.y > screenHeight) { - deltaY += screenHeight - this.y; - this.y = screenHeight; - } - } else { - if (this.y + 1 > -0) { - deltaY += -1 - this.y; - this.y = -1; - } - if (this.y + screenHeight < 0) { - deltaY += -screenHeight - this.y; - this.y = -screenHeight; - } - } - - if (this.y >= 0 && this.y - objHeight / 2 > screenHeight / 2) { - this.y -= screenHeight - objHeight; - } - if (this.y < 0 && this.y - objHeight / 2 <= -screenHeight / 2) { - this.y += screenHeight - objHeight; - } - return deltaY; - } + @Expose + private int x; + @Expose + private int y; + @Expose + private boolean centerX; + @Expose + private boolean centerY; + + private boolean clicked = false; + public String internalName = null; + + public Position(int x, int y) { + this(x, y, false, false); + } + + public Position(int x, int y, boolean centerX, boolean centerY) { + this.x = x; + this.y = y; + this.centerX = centerX; + this.centerY = centerY; + } + + public void set(Position other) { + this.x = other.x; + this.y = other.y; + this.centerX = other.centerX; + this.centerY = other.centerY; + } + + public int getRawX() { + return x; + } + + public int getRawY() { + return y; + } + + public void setClicked(boolean state) { + this.clicked = state; + } + + public boolean getClicked() { + return clicked; + } + + public int getAbsX0(int objWidth) { + int width = new ScaledResolution(Minecraft.getMinecraft()).getScaledWidth(); + + int ret = x; + if (x < 0) { + ret = width + x - objWidth; + } + + if (ret < 0) ret = 0; + if (ret > width - objWidth) ret = width - objWidth; + + return ret; + } + + public int getAbsY0(int objHeight) { + int height = new ScaledResolution(Minecraft.getMinecraft()).getScaledHeight(); + + int ret = y; + if (y < 0) { + ret = height + y - objHeight; + } + + if (ret < 0) ret = 0; + if (ret > height - objHeight) ret = height - objHeight; + + return ret; + } + + public int moveX(int deltaX, int objWidth) { + int screenWidth = new ScaledResolution(Minecraft.getMinecraft()).getScaledWidth(); + boolean wasPositiveX = this.x >= 0; + this.x += deltaX; + + if (wasPositiveX) { + if (this.x < 0) { + deltaX -= this.x; + this.x = 0; + } + if (this.x > screenWidth) { + deltaX += screenWidth - this.x; + this.x = screenWidth; + } + } else { + if (this.x + 1 > 0) { + deltaX += -1 - this.x; + this.x = -1; + } + if (this.x + screenWidth < 0) { + deltaX += -screenWidth - this.x; + this.x = -screenWidth; + } + } + + if (this.x >= 0 && this.x + objWidth / 2 > screenWidth / 2) { + this.x -= screenWidth - objWidth; + } + if (this.x < 0 && this.x + objWidth / 2 <= -screenWidth / 2) { + this.x += screenWidth - objWidth; + } + return deltaX; + } + + public int moveY(int deltaY, int objHeight) { + int screenHeight = new ScaledResolution(Minecraft.getMinecraft()).getScaledHeight(); + boolean wasPositiveY = this.y >= 0; + this.y += deltaY; + + if (wasPositiveY) { + if (this.y < 0) { + deltaY -= this.y; + this.y = 0; + } + if (this.y > screenHeight) { + deltaY += screenHeight - this.y; + this.y = screenHeight; + } + } else { + if (this.y + 1 > -0) { + deltaY += -1 - this.y; + this.y = -1; + } + if (this.y + screenHeight < 0) { + deltaY += -screenHeight - this.y; + this.y = -screenHeight; + } + } + + if (this.y >= 0 && this.y - objHeight / 2 > screenHeight / 2) { + this.y -= screenHeight - objHeight; + } + if (this.y < 0 && this.y - objHeight / 2 <= -screenHeight / 2) { + this.y += screenHeight - objHeight; + } + return deltaY; + } } diff --git a/src/main/java/at/hannibal2/skyhanni/config/core/config/gui/GuiPositionEditor.kt b/src/main/java/at/hannibal2/skyhanni/config/core/config/gui/GuiPositionEditor.kt index 1bbb948ce..e3b828407 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/core/config/gui/GuiPositionEditor.kt +++ b/src/main/java/at/hannibal2/skyhanni/config/core/config/gui/GuiPositionEditor.kt @@ -68,8 +68,20 @@ class GuiPositionEditor(private val positions: List<Position>, private val borde // When the mouse isn't currently hovering over a gui element if (displayPos == -1) { - GuiRenderUtils.drawStringCentered("§eTo edit hidden GUI elements set a key in /sh edit", getScaledWidth() / 2, 20) - GuiRenderUtils.drawStringCentered("§ethen click that key while the GUI element is visible", getScaledWidth() / 2, 32) + GuiRenderUtils.drawStringCentered( + + "§eTo edit hidden GUI elements set a key in /sh edit", + getScaledWidth() / 2, + 20 + + ) + GuiRenderUtils.drawStringCentered( + + "§ethen click that key while the GUI element is visible", + getScaledWidth() / 2, + 32 + + ) return } @@ -100,7 +112,18 @@ class GuiPositionEditor(private val positions: List<Position>, private val borde elementHeight = position.getDummySize().y drawRect(x - border, y - border, x + elementWidth + border * 2, y + elementHeight + border * 2, -0x7fbfbfc0) - if (GuiRenderUtils.isPointInRect(mouseX, mouseY, x - border, y - border, elementWidth + border * 2, elementHeight + border * 2)) { + if (GuiRenderUtils.isPointInRect( + + mouseX, + mouseY, + x - border, + y - border, + elementWidth + border * 2, + elementHeight + border * 2 + + ) + + ) { hoveredPos = index } } @@ -126,7 +149,18 @@ class GuiPositionEditor(private val positions: List<Position>, private val borde val x = position.getAbsX() val y = position.getAbsY() if (!position.clicked) { - if (GuiRenderUtils.isPointInRect(mouseX, mouseY, x - border, y - border, elementWidth + border * 2, elementHeight + border * 2)) { + if (GuiRenderUtils.isPointInRect( + + mouseX, + mouseY, + x - border, + y - border, + elementWidth + border * 2, + elementHeight + border * 2 + + ) + + ) { clickedPos = i position.clicked = true grabbedX = mouseX @@ -148,14 +182,11 @@ class GuiPositionEditor(private val positions: List<Position>, private val borde val dist = if (LorenzUtils.isShiftKeyDown()) 10 else 1 val elementWidth = position.getDummySize(true).x val elementHeight = position.getDummySize(true).y - if (keyCode == Keyboard.KEY_DOWN) { - position.moveY(dist, elementHeight) - } else if (keyCode == Keyboard.KEY_UP) { - position.moveY(-dist, elementHeight) - } else if (keyCode == Keyboard.KEY_LEFT) { - position.moveX(-dist, elementWidth) - } else if (keyCode == Keyboard.KEY_RIGHT) { - position.moveX(dist, elementWidth) + when (keyCode) { + Keyboard.KEY_DOWN -> position.moveY(dist, elementHeight) + Keyboard.KEY_UP -> position.moveY(-dist, elementHeight) + Keyboard.KEY_LEFT -> position.moveX(-dist, elementWidth) + Keyboard.KEY_RIGHT -> position.moveX(dist, elementWidth) } } diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/ChatConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/ChatConfig.java index 1723db1be..352d01589 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/ChatConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/ChatConfig.java @@ -1,13 +1,10 @@ package at.hannibal2.skyhanni.config.features; import com.google.gson.annotations.Expose; -import io.github.moulberry.moulconfig.annotations.ConfigAccordionId; -import io.github.moulberry.moulconfig.annotations.ConfigEditorAccordion; -import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean; -import io.github.moulberry.moulconfig.annotations.ConfigEditorKeybind; -import io.github.moulberry.moulconfig.annotations.ConfigOption; +import io.github.moulberry.moulconfig.annotations.*; import org.lwjgl.input.Keyboard; +@SuppressWarnings("deprecation") public class ChatConfig { @Expose diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/DamageIndicatorConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/DamageIndicatorConfig.java index e584e61df..099b2c3c4 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/DamageIndicatorConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/DamageIndicatorConfig.java @@ -88,7 +88,6 @@ public class DamageIndicatorConfig { public boolean timeToKillSlayer = true; - @Expose @ConfigOption(name = "Vampire Slayer", desc = "") @Accordion diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/DevConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/DevConfig.java index b470574bc..6492a3200 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/DevConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/DevConfig.java @@ -2,12 +2,7 @@ package at.hannibal2.skyhanni.config.features; import at.hannibal2.skyhanni.config.core.config.Position; import com.google.gson.annotations.Expose; -import io.github.moulberry.moulconfig.annotations.Accordion; -import io.github.moulberry.moulconfig.annotations.ConfigAccordionId; -import io.github.moulberry.moulconfig.annotations.ConfigEditorAccordion; -import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean; -import io.github.moulberry.moulconfig.annotations.ConfigEditorKeybind; -import io.github.moulberry.moulconfig.annotations.ConfigOption; +import io.github.moulberry.moulconfig.annotations.*; import org.lwjgl.input.Keyboard; public class DevConfig { @@ -39,7 +34,7 @@ public class DevConfig { @ConfigOption( name = "Mod Menu Log", desc = "Enables debug messages when the currently opened gui changes, with the path to the gui class. " + - "Useful for adding more mods to quick mod menu switch." + "Useful for adding more mods to quick mod menu switch." ) @ConfigEditorBoolean @ConfigAccordionId(id = 0) diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/GhostCounterConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/GhostCounterConfig.java index d69b6e833..4e41b0dbc 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/GhostCounterConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/GhostCounterConfig.java @@ -172,7 +172,6 @@ public class GhostCounterConfig { "§e%nextLevel% §7is replaced with your current bestiary level +1.\n" + "§e%value% §7is replaced with one of the text below.") @ConfigEditorText - // public String base = " &6Bestiary %currentLevel%->%nextLevel%: &b%value%"; public String base = " &6Bestiary %display%: &b%value%"; @Expose diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/RiftConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/RiftConfig.java index f2b4434ce..dec345f4c 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/RiftConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/RiftConfig.java @@ -614,7 +614,7 @@ public class RiftConfig { @Expose @ConfigOption(name = "Burger Stacks", desc = "Set your McGrubber's burger stacks.") - @ConfigEditorSlider(minStep = 1, minValue = 0, maxValue = 5) + @ConfigEditorSlider(minStep = 1, minValue = 0, maxValue = 5) public int burgerStacks = 0; @Expose diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/SlayerConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/SlayerConfig.java index d5d2b6884..9b48f0779 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/SlayerConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/SlayerConfig.java @@ -2,15 +2,7 @@ package at.hannibal2.skyhanni.config.features; import at.hannibal2.skyhanni.config.core.config.Position; import com.google.gson.annotations.Expose; -import io.github.moulberry.moulconfig.annotations.Accordion; -import io.github.moulberry.moulconfig.annotations.ConfigAccordionId; -import io.github.moulberry.moulconfig.annotations.ConfigEditorAccordion; -import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean; -import io.github.moulberry.moulconfig.annotations.ConfigEditorColour; -import io.github.moulberry.moulconfig.annotations.ConfigEditorDropdown; -import io.github.moulberry.moulconfig.annotations.ConfigEditorSlider; -import io.github.moulberry.moulconfig.annotations.ConfigEditorText; -import io.github.moulberry.moulconfig.annotations.ConfigOption; +import io.github.moulberry.moulconfig.annotations.*; public class SlayerConfig { @@ -259,8 +251,6 @@ public class SlayerConfig { public int lineWidth = 1; - - @Expose @ConfigOption(name = "Blood Ichor", desc = "") @Accordion |