diff options
author | olim <bobq4582@gmail.com> | 2024-01-31 10:52:37 +0000 |
---|---|---|
committer | olim <bobq4582@gmail.com> | 2024-01-31 10:52:37 +0000 |
commit | 86035f311b28094daf1ab7dbda7c888259e56723 (patch) | |
tree | 1c53e15c03780135f783d88bc00e4ed62bda0482 /src/main/java/de/hysky/skyblocker/skyblock/dwarven/DwarvenHudConfigScreen.java | |
parent | bc5cf9a37e4241096bd5ec1b2491ad71281593ff (diff) | |
download | Skyblocker-86035f311b28094daf1ab7dbda7c888259e56723.tar.gz Skyblocker-86035f311b28094daf1ab7dbda7c888259e56723.tar.bz2 Skyblocker-86035f311b28094daf1ab7dbda7c888259e56723.zip |
added powder hud
added powder to the dwarven hud
Diffstat (limited to 'src/main/java/de/hysky/skyblocker/skyblock/dwarven/DwarvenHudConfigScreen.java')
-rw-r--r-- | src/main/java/de/hysky/skyblocker/skyblock/dwarven/DwarvenHudConfigScreen.java | 38 |
1 files changed, 26 insertions, 12 deletions
diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/DwarvenHudConfigScreen.java b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/DwarvenHudConfigScreen.java index 6f281ba9..5efa9c03 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/DwarvenHudConfigScreen.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/DwarvenHudConfigScreen.java @@ -3,7 +3,9 @@ package de.hysky.skyblocker.skyblock.dwarven; import de.hysky.skyblocker.config.SkyblockerConfigManager; import de.hysky.skyblocker.skyblock.dwarven.DwarvenHud.Commission; import de.hysky.skyblocker.skyblock.tabhud.widget.hud.HudCommsWidget; +import de.hysky.skyblocker.skyblock.tabhud.widget.hud.HudPowderWidget; import de.hysky.skyblocker.utils.render.RenderHelper; +import it.unimi.dsi.fastutil.Pair; import it.unimi.dsi.fastutil.ints.IntIntPair; import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.screen.Screen; @@ -15,9 +17,13 @@ import java.util.List; public class DwarvenHudConfigScreen extends Screen { private static final List<DwarvenHud.Commission> CFG_COMMS = List.of(new Commission("Test Commission 1", "1%"), new DwarvenHud.Commission("Test Commission 2", "2%")); + private static final int CFG_MITHRIL = 100; + private static final int CFG_GEMSTONE = 1010; + private int commissionsHudX = SkyblockerConfigManager.get().locations.dwarvenMines.dwarvenHud.commissionsX; + private int commissionsHudY = SkyblockerConfigManager.get().locations.dwarvenMines.dwarvenHud.commissionsY; - private int hudX = SkyblockerConfigManager.get().locations.dwarvenMines.dwarvenHud.x; - private int hudY = SkyblockerConfigManager.get().locations.dwarvenMines.dwarvenHud.y; + private int powderHudX = SkyblockerConfigManager.get().locations.dwarvenMines.dwarvenHud.powderX; + private int powderHudY = SkyblockerConfigManager.get().locations.dwarvenMines.dwarvenHud.powderY; private final Screen parent; protected DwarvenHudConfigScreen() { @@ -33,16 +39,20 @@ public class DwarvenHudConfigScreen extends Screen { public void render(DrawContext context, int mouseX, int mouseY, float delta) { super.render(context, mouseX, mouseY, delta); renderBackground(context, mouseX, mouseY, delta); - DwarvenHud.render(HudCommsWidget.INSTANCE_CFG, context, hudX, hudY, List.of(new DwarvenHud.Commission("Test Commission 1", "1%"), new DwarvenHud.Commission("Test Commission 2", "2%"))); + DwarvenHud.render(HudCommsWidget.INSTANCE_CFG, HudPowderWidget.INSTANCE_CFG, context, commissionsHudX, commissionsHudY,powderHudX,powderHudY,CFG_COMMS,CFG_MITHRIL,CFG_GEMSTONE); context.drawCenteredTextWithShadow(textRenderer, "Right Click To Reset Position", width / 2, height / 2, Color.GRAY.getRGB()); } @Override public boolean mouseDragged(double mouseX, double mouseY, int button, double deltaX, double deltaY) { - IntIntPair dims = DwarvenHud.getDimForConfig(CFG_COMMS); - if (RenderHelper.pointIsInArea(mouseX, mouseY, hudX, hudY, hudX + 200, hudY + 40) && button == 0) { - hudX = (int) Math.max(Math.min(mouseX - (double) dims.leftInt() / 2, this.width - dims.leftInt()), 0); - hudY = (int) Math.max(Math.min(mouseY - (double) dims.rightInt() / 2, this.height - dims.rightInt()), 0); + Pair<IntIntPair,IntIntPair> dims = DwarvenHud.getDimForConfig(CFG_COMMS); + if (RenderHelper.pointIsInArea(mouseX, mouseY, commissionsHudX, commissionsHudY, commissionsHudX + 200, commissionsHudY + 40) && button == 0) { + commissionsHudX = (int) Math.max(Math.min(mouseX - (double) dims.first().leftInt() / 2, this.width - dims.first().leftInt()), 0); + commissionsHudY = (int) Math.max(Math.min(mouseY - (double) dims.first().rightInt() / 2, this.height - dims.first().rightInt()), 0); + } + if (RenderHelper.pointIsInArea(mouseX, mouseY, powderHudX, powderHudY, powderHudX + 200, powderHudY + 40) && button == 0) { + powderHudX = (int) Math.max(Math.min(mouseX - (double) dims.second().leftInt() / 2, this.width - dims.second().leftInt()), 0); + powderHudY = (int) Math.max(Math.min(mouseY - (double) dims.second().rightInt() / 2, this.height - dims.second().rightInt()), 0); } return super.mouseDragged(mouseX, mouseY, button, deltaX, deltaY); } @@ -50,17 +60,21 @@ public class DwarvenHudConfigScreen extends Screen { @Override public boolean mouseClicked(double mouseX, double mouseY, int button) { if (button == 1) { - IntIntPair dims = DwarvenHud.getDimForConfig(CFG_COMMS); - hudX = this.width / 2 - dims.leftInt(); - hudY = this.height / 2 - dims.rightInt(); + Pair<IntIntPair,IntIntPair> dims = DwarvenHud.getDimForConfig(CFG_COMMS); + commissionsHudX = this.width / 2 - dims.left().leftInt(); + commissionsHudY = this.height / 2 - dims.left().rightInt(); + powderHudX = this.width / 2 - dims.right().leftInt(); + powderHudY = this.height / 2 - dims.right().rightInt() + dims.left().rightInt(); //add this to make it bellow the other widget } return super.mouseClicked(mouseX, mouseY, button); } @Override public void close() { - SkyblockerConfigManager.get().locations.dwarvenMines.dwarvenHud.x = hudX; - SkyblockerConfigManager.get().locations.dwarvenMines.dwarvenHud.y = hudY; + SkyblockerConfigManager.get().locations.dwarvenMines.dwarvenHud.commissionsX = commissionsHudX; + SkyblockerConfigManager.get().locations.dwarvenMines.dwarvenHud.commissionsY = commissionsHudY; + SkyblockerConfigManager.get().locations.dwarvenMines.dwarvenHud.powderX = powderHudX; + SkyblockerConfigManager.get().locations.dwarvenMines.dwarvenHud.powderY = powderHudY; SkyblockerConfigManager.save(); client.setScreen(parent); |