diff options
7 files changed, 97 insertions, 48 deletions
diff --git a/src/main/java/de/hysky/skyblocker/config/SkyblockerConfig.java b/src/main/java/de/hysky/skyblocker/config/SkyblockerConfig.java index e07a7588..ffd6aa4d 100644 --- a/src/main/java/de/hysky/skyblocker/config/SkyblockerConfig.java +++ b/src/main/java/de/hysky/skyblocker/config/SkyblockerConfig.java @@ -624,6 +624,18 @@ public class SkyblockerConfig { public int mapY = 2; @SerialEntry + public boolean enableScore = true; + + @SerialEntry + public int scoreX = 29; + + @SerialEntry + public int scoreY = 134; + + @SerialEntry + public float scoreScaling = 1f; + + @SerialEntry public boolean playerSecretsTracker = false; @SerialEntry diff --git a/src/main/java/de/hysky/skyblocker/config/categories/DungeonsCategory.java b/src/main/java/de/hysky/skyblocker/config/categories/DungeonsCategory.java index 06133afc..8cd697e5 100644 --- a/src/main/java/de/hysky/skyblocker/config/categories/DungeonsCategory.java +++ b/src/main/java/de/hysky/skyblocker/config/categories/DungeonsCategory.java @@ -315,6 +315,13 @@ public class DungeonsCategory { newValue -> config.locations.dungeons.enableMap = newValue) .controller(ConfigUtils::createBooleanController) .build()) + .option(Option.<Boolean>createBuilder() + .name(Text.translatable("text.autoconfig.skyblocker.option.locations.dungeons.enableScore")) + .binding(defaults.locations.dungeons.enableScore, + () -> config.locations.dungeons.enableScore, + newValue -> config.locations.dungeons.enableScore = newValue) + .controller(ConfigUtils::createBooleanController) + .build()) .option(ButtonOption.createBuilder() .name(Text.translatable("text.autoconfig.skyblocker.option.locations.dungeons.mapScreen")) .text(Text.translatable("text.skyblocker.open")) @@ -327,6 +334,17 @@ public class DungeonsCategory { newValue -> config.locations.dungeons.mapScaling = newValue) .controller(FloatFieldControllerBuilder::create) .build()) + .option(Option.<Float>createBuilder() + .name(Text.translatable("text.autoconfig.skyblocker.option.locations.dungeons.scoreScaling")) + .binding(defaults.locations.dungeons.scoreScaling, + () -> config.locations.dungeons.scoreScaling, + newValue -> { + config.locations.dungeons.scoreX = config.locations.dungeons.scoreX + (int) ((config.locations.dungeons.scoreScaling - newValue) * 38.0); + config.locations.dungeons.scoreY = config.locations.dungeons.scoreY + (int) ((config.locations.dungeons.scoreScaling - newValue) * MinecraftClient.getInstance().textRenderer.fontHeight / 2.0); + config.locations.dungeons.scoreScaling = newValue; + }) + .controller(FloatFieldControllerBuilder::create) + .build()) .option(Option.<Boolean>createBuilder() .name(Text.translatable("text.autoconfig.skyblocker.option.locations.dungeons.playerSecretsTracker")) .description(OptionDescription.of(Text.translatable("text.autoconfig.skyblocker.option.locations.dungeons.playerSecretsTracker.@Tooltip"))) diff --git a/src/main/java/de/hysky/skyblocker/mixin/InGameHudMixin.java b/src/main/java/de/hysky/skyblocker/mixin/InGameHudMixin.java index 0ee7b528..396bf893 100644 --- a/src/main/java/de/hysky/skyblocker/mixin/InGameHudMixin.java +++ b/src/main/java/de/hysky/skyblocker/mixin/InGameHudMixin.java @@ -5,9 +5,11 @@ import com.llamalad7.mixinextras.sugar.Local; import de.hysky.skyblocker.SkyblockerMod; import de.hysky.skyblocker.config.SkyblockerConfigManager; import de.hysky.skyblocker.skyblock.FancyStatusBars; +import de.hysky.skyblocker.skyblock.dungeon.DungeonMap; +import de.hysky.skyblocker.skyblock.dungeon.DungeonScore; +import de.hysky.skyblocker.skyblock.dungeon.DungeonScoreHUD; import de.hysky.skyblocker.skyblock.item.HotbarSlotLock; import de.hysky.skyblocker.skyblock.item.ItemCooldowns; -import de.hysky.skyblocker.skyblock.dungeon.DungeonMap; import de.hysky.skyblocker.skyblock.item.ItemRarityBackgrounds; import de.hysky.skyblocker.utils.Utils; import net.fabricmc.api.EnvType; @@ -64,8 +66,10 @@ public abstract class InGameHudMixin { if (statusBars.render(context, scaledWidth, scaledHeight)) ci.cancel(); - if (Utils.isInDungeons() && SkyblockerConfigManager.get().locations.dungeons.enableMap) - DungeonMap.render(context.getMatrices()); + if (Utils.isInDungeons() && DungeonScore.isDungeonStarted()) { + if (SkyblockerConfigManager.get().locations.dungeons.enableMap) DungeonMap.render(context.getMatrices()); + if (SkyblockerConfigManager.get().locations.dungeons.enableScore) DungeonScoreHUD.render(context); + } } @Inject(method = "renderMountHealth", at = @At("HEAD"), cancellable = true) diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dungeon/DungeonMap.java b/src/main/java/de/hysky/skyblocker/skyblock/dungeon/DungeonMap.java index e1af85ea..293d301f 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dungeon/DungeonMap.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dungeon/DungeonMap.java @@ -5,7 +5,6 @@ import de.hysky.skyblocker.utils.scheduler.Scheduler; import net.fabricmc.fabric.api.client.command.v2.ClientCommandManager; import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback; import net.minecraft.client.MinecraftClient; -import net.minecraft.client.gui.DrawContext; import net.minecraft.client.render.MapRenderer; import net.minecraft.client.render.VertexConsumerProvider; import net.minecraft.client.util.math.MatrixStack; @@ -13,12 +12,9 @@ import net.minecraft.item.FilledMapItem; import net.minecraft.item.ItemStack; import net.minecraft.item.map.MapState; import net.minecraft.nbt.NbtCompound; -import net.minecraft.util.Identifier; import org.apache.commons.lang3.StringUtils; public class DungeonMap { - private static final Identifier MAP_BACKGROUND = new Identifier("textures/map/map_background.png"); - public static void render(MatrixStack matrices) { MinecraftClient client = MinecraftClient.getInstance(); if (client.player == null || client.world == null) return; @@ -46,13 +42,7 @@ public class DungeonMap { } } - public static void renderHUDMap(DrawContext context, int x, int y) { - float scaling = SkyblockerConfigManager.get().locations.dungeons.mapScaling; - int size = (int) (128 * scaling); - context.drawTexture(MAP_BACKGROUND, x, y, 0, 0, size, size, size, size); - } - - public static void init() { + public static void init() { //Todo: consider renaming the command to a more general name since it'll also have dungeon score and maybe other stuff in the future ClientCommandRegistrationCallback.EVENT.register((dispatcher, registryAccess) -> dispatcher.register(ClientCommandManager.literal("skyblocker") .then(ClientCommandManager.literal("hud") .then(ClientCommandManager.literal("dungeonmap") diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dungeon/DungeonMapConfigScreen.java b/src/main/java/de/hysky/skyblocker/skyblock/dungeon/DungeonMapConfigScreen.java index 02b08254..00a956e1 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dungeon/DungeonMapConfigScreen.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dungeon/DungeonMapConfigScreen.java @@ -5,13 +5,17 @@ import de.hysky.skyblocker.utils.render.RenderHelper; import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.screen.Screen; import net.minecraft.text.Text; +import net.minecraft.util.Identifier; import java.awt.*; public class DungeonMapConfigScreen extends Screen { - private int hudX = SkyblockerConfigManager.get().locations.dungeons.mapX; - private int hudY = SkyblockerConfigManager.get().locations.dungeons.mapY; + private int mapX = SkyblockerConfigManager.get().locations.dungeons.mapX; + private int mapY = SkyblockerConfigManager.get().locations.dungeons.mapY; + private int scoreX = SkyblockerConfigManager.get().locations.dungeons.scoreX; + private int scoreY = SkyblockerConfigManager.get().locations.dungeons.scoreY; + private static final Identifier MAP_BACKGROUND = new Identifier("textures/map/map_background.png"); private final Screen parent; protected DungeonMapConfigScreen() { @@ -27,17 +31,23 @@ public class DungeonMapConfigScreen extends Screen { public void render(DrawContext context, int mouseX, int mouseY, float delta) { super.render(context, mouseX, mouseY, delta); renderBackground(context, mouseX, mouseY, delta); - DungeonMap.renderHUDMap(context, hudX, hudY); + renderHUDMap(context, mapX, mapY); + renderHUDScore(context, scoreX, scoreY); context.drawCenteredTextWithShadow(textRenderer, "Right Click To Reset Position", width >> 1, height >> 1, Color.GRAY.getRGB()); } @Override public boolean mouseDragged(double mouseX, double mouseY, int button, double deltaX, double deltaY) { - float scaling = SkyblockerConfigManager.get().locations.dungeons.mapScaling; - int size = (int) (128 * scaling); - if (RenderHelper.pointIsInArea(mouseX, mouseY, hudX, hudY, hudX + size, hudY + size) && button == 0) { - hudX = (int) Math.max(Math.min(mouseX - (size >> 1), this.width - size), 0); - hudY = (int) Math.max(Math.min(mouseY - (size >> 1), this.height - size), 0); + int mapSize = (int) (128 * SkyblockerConfigManager.get().locations.dungeons.mapScaling); + float scoreScaling = SkyblockerConfigManager.get().locations.dungeons.scoreScaling; + int scoreWidth = (int) (textRenderer.getWidth("Score: 300 (S+)") * scoreScaling); + int scoreHeight = (int) (textRenderer.fontHeight * scoreScaling); + if (RenderHelper.pointIsInArea(mouseX, mouseY, mapX, mapY, mapX + mapSize, mapY + mapSize) && button == 0) { + mapX = (int) Math.max(Math.min(mouseX - (mapSize >> 1), this.width - mapSize), 0); + mapY = (int) Math.max(Math.min(mouseY - (mapSize >> 1), this.height - mapSize), 0); + } else if (RenderHelper.pointIsInArea(mouseX, mouseY, scoreX, scoreY, scoreX + scoreWidth, scoreY + scoreHeight) && button == 0) { + scoreX = (int) Math.max(Math.min(mouseX - (scoreWidth >> 1), this.width - scoreWidth), 0); + scoreY = (int) Math.max(Math.min(mouseY - (scoreHeight >> 1), this.height - scoreHeight), 0); } return super.mouseDragged(mouseX, mouseY, button, deltaX, deltaY); } @@ -45,8 +55,10 @@ public class DungeonMapConfigScreen extends Screen { @Override public boolean mouseClicked(double mouseX, double mouseY, int button) { if (button == 1) { - hudX = 2; - hudY = 2; + mapX = 2; + mapY = 2; + scoreX = Math.max((int) ((mapX + (64 * SkyblockerConfigManager.get().locations.dungeons.mapScaling)) - textRenderer.getWidth("Score: 300 (S+)") * SkyblockerConfigManager.get().locations.dungeons.scoreScaling / 2), 0); + scoreY = (int) (mapY + (128 * SkyblockerConfigManager.get().locations.dungeons.mapScaling) + 4); } return super.mouseClicked(mouseX, mouseY, button); @@ -54,10 +66,22 @@ public class DungeonMapConfigScreen extends Screen { @Override public void close() { - SkyblockerConfigManager.get().locations.dungeons.mapX = hudX; - SkyblockerConfigManager.get().locations.dungeons.mapY = hudY; + SkyblockerConfigManager.get().locations.dungeons.mapX = mapX; + SkyblockerConfigManager.get().locations.dungeons.mapY = mapY; + SkyblockerConfigManager.get().locations.dungeons.scoreX = scoreX; + SkyblockerConfigManager.get().locations.dungeons.scoreY = scoreY; SkyblockerConfigManager.save(); this.client.setScreen(parent); } + + public void renderHUDMap(DrawContext context, int x, int y) { + float scaling = SkyblockerConfigManager.get().locations.dungeons.mapScaling; + int size = (int) (128 * scaling); + context.drawTexture(MAP_BACKGROUND, x, y, 0, 0, size, size, size, size); + } + + public void renderHUDScore(DrawContext context, int x, int y) { + DungeonScoreHUD.render(context, x, y); + } } diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dungeon/DungeonScoreHUD.java b/src/main/java/de/hysky/skyblocker/skyblock/dungeon/DungeonScoreHUD.java index 9da12426..18038ccd 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dungeon/DungeonScoreHUD.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dungeon/DungeonScoreHUD.java @@ -1,38 +1,37 @@ package de.hysky.skyblocker.skyblock.dungeon; import de.hysky.skyblocker.config.SkyblockerConfigManager; -import de.hysky.skyblocker.utils.Utils; -import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback; import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.DrawContext; +import net.minecraft.client.util.math.MatrixStack; import net.minecraft.text.Text; import net.minecraft.util.Formatting; public class DungeonScoreHUD { - - public static void init() { - HudRenderCallback.EVENT.register(DungeonScoreHUD::onHudRender); + private DungeonScoreHUD() { } - private static void onHudRender(DrawContext context, float tickDelta) { - if (!Utils.isInDungeons() || !DungeonScore.isDungeonStarted()) return; + public static void render(DrawContext context) { + int x = SkyblockerConfigManager.get().locations.dungeons.scoreX; + int y = SkyblockerConfigManager.get().locations.dungeons.scoreY; + render(context, x, y); + } - int x = SkyblockerConfigManager.get().locations.dungeons.mapX; - int y = SkyblockerConfigManager.get().locations.dungeons.mapY; - int size = (int) (128 * SkyblockerConfigManager.get().locations.dungeons.mapScaling); - context.drawCenteredTextWithShadow(MinecraftClient.getInstance().textRenderer, - Text.literal("Score: ").append(formatScore(DungeonScore.getScore())), - x + (size >> 1), - y + size + 5, - 0x00FFFFFF); + public static void render(DrawContext context, int x, int y) { + float scale = SkyblockerConfigManager.get().locations.dungeons.scoreScaling; + MatrixStack matrixStack = context.getMatrices(); + matrixStack.push(); + matrixStack.scale(scale, scale, 0); + context.drawTextWithShadow(MinecraftClient.getInstance().textRenderer, Text.literal("Score: ").append(formatScore(DungeonScore.getScore())), (int) (x / scale), (int) (y / scale), 0xFFFFFFFF); + matrixStack.pop(); } private static Text formatScore(int score) { - if (score < 100) return Text.literal(String.valueOf(score)).withColor(0xDC1A1A).append(Text.literal(" (D)").formatted(Formatting.GRAY)); - if (score < 160) return Text.literal(String.valueOf(score)).withColor(0x4141FF).append(Text.literal(" (C)").formatted(Formatting.GRAY)); - if (score < 230) return Text.literal(String.valueOf(score)).withColor(0x7FCC19).append(Text.literal(" (B)").formatted(Formatting.GRAY)); - if (score < 270) return Text.literal(String.valueOf(score)).withColor(0x7F3FB2).append(Text.literal(" (A)").formatted(Formatting.GRAY)); - if (score < 300) return Text.literal(String.valueOf(score)).withColor(0xF1E252).append(Text.literal(" (S)").formatted(Formatting.GRAY)); - return Text.literal(String.valueOf(score)).withColor(0xF1E252).formatted(Formatting.BOLD).append(Text.literal(" (S+)").formatted(Formatting.GRAY)); + if (score < 100) return Text.literal(String.format("%03d", score)).withColor(0xDC1A1A).append(Text.literal(" (D) ").formatted(Formatting.GRAY)); + if (score < 160) return Text.literal(String.format("%03d", score)).withColor(0x4141FF).append(Text.literal(" (C) ").formatted(Formatting.GRAY)); + if (score < 230) return Text.literal(String.format("%03d", score)).withColor(0x7FCC19).append(Text.literal(" (B) ").formatted(Formatting.GRAY)); + if (score < 270) return Text.literal(String.format("%03d", score)).withColor(0x7F3FB2).append(Text.literal(" (A) ").formatted(Formatting.GRAY)); + if (score < 300) return Text.literal(String.format("%03d", score)).withColor(0xF1E252).append(Text.literal(" (S) ").formatted(Formatting.GRAY)); + return Text.literal(String.format("%03d", score)).withColor(0xF1E252).formatted(Formatting.BOLD).append(Text.literal(" (S+)").formatted(Formatting.GRAY)); } } diff --git a/src/main/resources/assets/skyblocker/lang/en_us.json b/src/main/resources/assets/skyblocker/lang/en_us.json index cd1d9673..e66fbfcd 100644 --- a/src/main/resources/assets/skyblocker/lang/en_us.json +++ b/src/main/resources/assets/skyblocker/lang/en_us.json @@ -215,8 +215,10 @@ "text.autoconfig.skyblocker.option.locations.dungeons.croesusHelper": "Croesus Helper", "text.autoconfig.skyblocker.option.locations.dungeons.croesusHelper.@Tooltip": "Gray out chests that have already been opened.", "text.autoconfig.skyblocker.option.locations.dungeons.enableMap": "Enable Map", - "text.autoconfig.skyblocker.option.locations.dungeons.mapScreen": "Dungeon Map Placement Config...", + "text.autoconfig.skyblocker.option.locations.dungeons.enableScore": "Enable Score HUD", + "text.autoconfig.skyblocker.option.locations.dungeons.mapScreen": "Dungeon Map & Score Placement Config...", "text.autoconfig.skyblocker.option.locations.dungeons.mapScaling": "Map Scaling", + "text.autoconfig.skyblocker.option.locations.dungeons.scoreScaling": "Score Scaling", "text.autoconfig.skyblocker.option.locations.dungeons.playerSecretsTracker": "Player Secrets Tracker", "text.autoconfig.skyblocker.option.locations.dungeons.playerSecretsTracker.@Tooltip": "Tracks the amount of secrets people in your dungeon run are doing.", "text.autoconfig.skyblocker.option.locations.dungeons.starredMobGlow": "Starred Mob Glow", |