diff options
author | Aaron <51387595+AzureAaron@users.noreply.github.com> | 2024-02-02 01:05:14 -0500 |
---|---|---|
committer | Aaron <51387595+AzureAaron@users.noreply.github.com> | 2024-02-02 01:05:14 -0500 |
commit | e5017cf3b6bf1d072033ed79e7b73291d5584650 (patch) | |
tree | 70f010665fdabe63a19c972a10ac4cfd01ade870 /src/main | |
parent | 26301c0032c96cc96993420e8c7011cea18fc4a2 (diff) | |
download | Skyblocker-e5017cf3b6bf1d072033ed79e7b73291d5584650.tar.gz Skyblocker-e5017cf3b6bf1d072033ed79e7b73291d5584650.tar.bz2 Skyblocker-e5017cf3b6bf1d072033ed79e7b73291d5584650.zip |
Add map scaling option
Also fixed the last few formatting issues I saw
Diffstat (limited to 'src/main')
7 files changed, 44 insertions, 16 deletions
diff --git a/src/main/java/de/hysky/skyblocker/config/SkyblockerConfig.java b/src/main/java/de/hysky/skyblocker/config/SkyblockerConfig.java index 5ca9604c..4acb8064 100644 --- a/src/main/java/de/hysky/skyblocker/config/SkyblockerConfig.java +++ b/src/main/java/de/hysky/skyblocker/config/SkyblockerConfig.java @@ -1,7 +1,6 @@ package de.hysky.skyblocker.config; import de.hysky.skyblocker.SkyblockerMod; -import de.hysky.skyblocker.skyblock.dwarven.CrystalsWaypoint; import de.hysky.skyblocker.skyblock.item.CustomArmorTrims; import de.hysky.skyblocker.utils.chat.ChatFilterResult; import de.hysky.skyblocker.utils.waypoint.Waypoint; @@ -15,9 +14,7 @@ import net.minecraft.util.Formatting; import net.minecraft.util.Identifier; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; -import java.util.Map; public class SkyblockerConfig { @SerialEntry @@ -925,6 +922,9 @@ public class SkyblockerConfig { @SerialEntry public int y = 130; + + @SerialEntry + public float mapScaling = 1f; } public static class CrystalsWaypoints { diff --git a/src/main/java/de/hysky/skyblocker/config/categories/DwarvenMinesCategory.java b/src/main/java/de/hysky/skyblocker/config/categories/DwarvenMinesCategory.java index 62b0ebf9..97b48bc4 100644 --- a/src/main/java/de/hysky/skyblocker/config/categories/DwarvenMinesCategory.java +++ b/src/main/java/de/hysky/skyblocker/config/categories/DwarvenMinesCategory.java @@ -9,6 +9,7 @@ import dev.isxander.yacl3.api.Option; import dev.isxander.yacl3.api.OptionDescription; import dev.isxander.yacl3.api.OptionGroup; import de.hysky.skyblocker.skyblock.dwarven.DwarvenHudConfigScreen; +import dev.isxander.yacl3.api.controller.FloatFieldControllerBuilder; import dev.isxander.yacl3.api.controller.IntegerSliderControllerBuilder; import net.minecraft.client.MinecraftClient; import net.minecraft.text.Text; @@ -99,6 +100,13 @@ public class DwarvenMinesCategory { .text(Text.translatable("text.skyblocker.open")) .action((screen, opt) -> MinecraftClient.getInstance().setScreen(new CrystalsHudConfigScreen(screen))) .build()) + .option(Option.<Float>createBuilder() + .name(Text.translatable("text.autoconfig.skyblocker.option.locations.dwarvenMines.crystalsHud.mapScaling")) + .binding(defaults.locations.dwarvenMines.crystalsHud.mapScaling, + () -> config.locations.dwarvenMines.crystalsHud.mapScaling, + newValue -> config.locations.dwarvenMines.crystalsHud.mapScaling = newValue) + .controller(FloatFieldControllerBuilder::create) + .build()) .option(Option.<Boolean>createBuilder() .name(Text.translatable("text.autoconfig.skyblocker.option.locations.dwarvenMines.crystalsHud.showLocations")) .description(OptionDescription.of(Text.translatable("text.autoconfig.skyblocker.option.locations.dwarvenMines.crystalsHud.showLocations.@Tooltip"))) diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsHud.java b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsHud.java index 171f13ea..2a1ce63a 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsHud.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsHud.java @@ -11,6 +11,7 @@ import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallba 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.util.Identifier; import net.minecraft.util.math.MathHelper; @@ -20,7 +21,7 @@ import java.util.Map; public class CrystalsHud { private static final MinecraftClient CLIENT = MinecraftClient.getInstance(); - private static final Identifier MAP_TEXTURE = new Identifier(SkyblockerMod.NAMESPACE, "textures/gui/crystals_map.png"); + protected static final Identifier MAP_TEXTURE = new Identifier(SkyblockerMod.NAMESPACE, "textures/gui/crystals_map.png"); private static final Identifier MAP_ICON = new Identifier("textures/map/map_icons.png"); private static final String[] SMALL_LOCATIONS = { "Fairy Grotto", "King", "Corleone" }; @@ -43,8 +44,9 @@ public class CrystalsHud { }); } - protected static IntIntPair getDimForConfig() { - return IntIntPair.of(62, 62); + protected static IntIntPair getDimensionsForConfig() { + int size = (int) (62 * SkyblockerConfigManager.get().locations.dwarvenMines.crystalsHud.mapScaling); + return IntIntPair.of(size, size); } @@ -55,9 +57,20 @@ public class CrystalsHud { * @param hudX Top left X coordinate of the map * @param hudY Top left Y coordinate of the map */ - protected static void render(DrawContext context, int hudX, int hudY) { + private static void render(DrawContext context, int hudX, int hudY) { + float scale = SkyblockerConfigManager.get().locations.dwarvenMines.crystalsHud.mapScaling; + int size = (int) (62 * scale); + + //make sure the map renders infront of some stuff - improve this in the future with better layering (1.20.5?) + MatrixStack matrices = context.getMatrices(); + matrices.push(); + matrices.translate(0f, 0f, 200f); + //draw map texture - context.drawTexture(MAP_TEXTURE, hudX, hudY, 0, 0, 62, 62, 62, 62); + context.drawTexture(MAP_TEXTURE, hudX, hudY, 0, 0, size, size, size, size); + + //scale the rest of the stuff - this isn't applied to the map texture because doing so causes it to render with an "offset" + matrices.scale(scale, scale, 0f); //if enabled add waypoint locations to map if (SkyblockerConfigManager.get().locations.dwarvenMines.crystalsHud.showLocations) { @@ -89,7 +102,8 @@ public class CrystalsHud { //draw marker on map context.drawTexture(MAP_ICON, hudX + renderPos.first() - 2, hudY + renderPos.second() - 2, 58, 2, 4, 4, 128, 128); - //todo add direction and scale (can not work out how to rotate) + //todo add direction (can not work out how to rotate) + matrices.pop(); } /** diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsHudConfigScreen.java b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsHudConfigScreen.java index e30d6390..b4e423e9 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsHudConfigScreen.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsHudConfigScreen.java @@ -28,14 +28,14 @@ public class CrystalsHudConfigScreen extends Screen { public void render(DrawContext context, int mouseX, int mouseY, float delta) { super.render(context, mouseX, mouseY, delta); renderBackground(context, mouseX, mouseY, delta); - CrystalsHud.render( context, hudX, hudY); + renderHUDMap(context, hudX, hudY); 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 = CrystalsHud.getDimForConfig(); - if (RenderHelper.pointIsInArea(mouseX, mouseY, hudX, hudY, hudX + 200, hudY + 40) && button == 0) { + IntIntPair dims = CrystalsHud.getDimensionsForConfig(); + if (RenderHelper.pointIsInArea(mouseX, mouseY, hudX, hudY, hudX + dims.leftInt(), hudY + dims.rightInt()) && 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); } @@ -45,13 +45,19 @@ public class CrystalsHudConfigScreen extends Screen { @Override public boolean mouseClicked(double mouseX, double mouseY, int button) { if (button == 1) { - IntIntPair dims = CrystalsHud.getDimForConfig(); + IntIntPair dims = CrystalsHud.getDimensionsForConfig(); hudX = this.width / 2 - dims.leftInt(); hudY = this.height / 2 - dims.rightInt(); } return super.mouseClicked(mouseX, mouseY, button); } + private void renderHUDMap(DrawContext context, int x, int y) { + float scaling = SkyblockerConfigManager.get().locations.dwarvenMines.crystalsHud.mapScaling; + int size = (int) (62 * scaling); + context.drawTexture(CrystalsHud.MAP_TEXTURE, x, y, 0, 0, size, size, size, size); + } + @Override public void close() { SkyblockerConfigManager.get().locations.dwarvenMines.crystalsHud.x = hudX; diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsLocationsManager.java b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsLocationsManager.java index 5b196f8e..1cbbb32e 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsLocationsManager.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsLocationsManager.java @@ -169,7 +169,7 @@ public class CrystalsLocationsManager { private static void addCustomWaypoint( Text waypointName, BlockPos pos) { CrystalsWaypoint.Category category = WAYPOINT_LOCATIONS.get(waypointName.getString()); CrystalsWaypoint waypoint = new CrystalsWaypoint(category, waypointName, pos); - activeWaypoints.put(waypointName.getString(),waypoint); + activeWaypoints.put(waypointName.getString(), waypoint); } public static void render(WorldRenderContext context) { @@ -183,7 +183,7 @@ public class CrystalsLocationsManager { } private static void reset() { - activeWaypoints.clear(); + activeWaypoints.clear(); } public static void update() { diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsWaypoint.java b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsWaypoint.java index ad85e763..423a8cbd 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsWaypoint.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsWaypoint.java @@ -25,7 +25,6 @@ import java.util.function.ToDoubleFunction; public class CrystalsWaypoint extends Waypoint { private static final Logger LOGGER = LoggerFactory.getLogger(CrystalsWaypoint.class); - private static final Supplier<SkyblockerConfig.Waypoints> CONFIG = () -> SkyblockerConfigManager.get().general.waypoints; private static final Supplier<Type> TYPE_SUPPLIER = () -> CONFIG.get().waypointType; final Category category; diff --git a/src/main/resources/assets/skyblocker/lang/en_us.json b/src/main/resources/assets/skyblocker/lang/en_us.json index 936ac1fa..f17f109e 100644 --- a/src/main/resources/assets/skyblocker/lang/en_us.json +++ b/src/main/resources/assets/skyblocker/lang/en_us.json @@ -279,6 +279,7 @@ "text.autoconfig.skyblocker.option.locations.dwarvenMines.crystalsHud": "Crystal Hollows Map", "text.autoconfig.skyblocker.option.locations.dwarvenMines.crystalsHud.enabled": "Enabled", "text.autoconfig.skyblocker.option.locations.dwarvenMines.crystalsHud.screen": "Crystal Hollows Map Placement Config...", + "text.autoconfig.skyblocker.option.locations.dwarvenMines.crystalsHud.mapScaling": "Map Scaling", "text.autoconfig.skyblocker.option.locations.dwarvenMines.crystalsHud.showLocations": "Show Waypoints", "text.autoconfig.skyblocker.option.locations.dwarvenMines.crystalsHud.showLocations.@Tooltip": "Show boxes on important areas in the crystal hollows e.g. Jungle Temple and Fairy Grotto.", "text.autoconfig.skyblocker.option.locations.dwarvenMines.crystalsHud.showLocations.locationSize": "Location Size", |