diff --git a/.gitignore b/.gitignore index 75c41f65..38d39a46 100644 --- a/.gitignore +++ b/.gitignore @@ -29,3 +29,4 @@ src/main/resources/mixins.*.json *.bat *.DS_Store !gradlew.bat +layout.json diff --git a/dependencies.gradle b/dependencies.gradle index 3b04bd12..d043dac9 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -6,8 +6,8 @@ dependencies { devOnlyNonPublishable('com.github.GTNewHorizons:TCNodeTracker:1.3.0:dev') - compileOnly(deobfCurse('xaeros-minimap-263420:4905582')) - compileOnly(deobfCurse('xaeros-world-map-317780:4905612')) + compileOnly(deobfCurse('xaeros-minimap-263420:5060684')) + compileOnly(deobfCurse('xaeros-world-map-317780:5060733')) compileOnly(deobf('https://media.forgecdn.net/files/2462/146/mod_voxelMap_1.7.0b_for_1.7.10.litemod', 'mod_voxelMap_1.7.0b_for_1.7.10.jar')) // For debugging diff --git a/src/main/java/com/sinthoras/visualprospecting/integration/DrawUtils.java b/src/main/java/com/sinthoras/visualprospecting/integration/DrawUtils.java index 731936c8..0ad18488 100644 --- a/src/main/java/com/sinthoras/visualprospecting/integration/DrawUtils.java +++ b/src/main/java/com/sinthoras/visualprospecting/integration/DrawUtils.java @@ -3,6 +3,7 @@ import java.util.List; import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.renderer.OpenGlHelper; import net.minecraft.client.renderer.Tessellator; @@ -139,6 +140,39 @@ public static void drawSimpleLabel(GuiScreen gui, String text, double textX, dou GL11.glPopMatrix(); } + public static void drawLabel(String text, double textX, double textY, int fontColor, int bgColor, boolean centered, + double fontScale) { + final FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer; + + GL11.glPushMatrix(); + + if (fontScale != 1.0) { + textX /= fontScale; + textY /= fontScale; + GL11.glScaled(fontScale, fontScale, 0); + } + double dTextX = textX - (double) (int) textX; + double dTextY = textY - (double) (int) textY; + double textWidth = fontRenderer.getStringWidth(text); + double xOffsetL = centered ? -textWidth / 2.0 - 2 : -2; + double xOffsetR = centered ? textWidth / 2.0 + 2 : textWidth + 2; + GL11.glTranslated(dTextX, dTextY, 0.0); + drawGradientRect( + (int) textX + xOffsetL, + (int) textY - 2, + (int) textX + xOffsetR, + (int) textY + fontRenderer.FONT_HEIGHT + 2, + 0, + bgColor, + bgColor); + fontRenderer.drawStringWithShadow( + text, + (centered ? (int) (textX - textWidth / 2.0) : (int) textX), + (int) textY, + fontColor); + GL11.glPopMatrix(); + } + public static void drawSimpleTooltip(GuiScreen gui, List text, double x, double y, int fontColor, int bgColor) { if (text.isEmpty()) return; diff --git a/src/main/java/com/sinthoras/visualprospecting/integration/xaeroworldmap/rendersteps/OreVeinRenderStep.java b/src/main/java/com/sinthoras/visualprospecting/integration/xaeroworldmap/rendersteps/OreVeinRenderStep.java index 3350a073..c31b0918 100644 --- a/src/main/java/com/sinthoras/visualprospecting/integration/xaeroworldmap/rendersteps/OreVeinRenderStep.java +++ b/src/main/java/com/sinthoras/visualprospecting/integration/xaeroworldmap/rendersteps/OreVeinRenderStep.java @@ -5,6 +5,7 @@ import javax.annotation.Nullable; +import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.resources.I18n; import net.minecraft.init.Blocks; @@ -25,7 +26,7 @@ public class OreVeinRenderStep implements InteractableRenderStep { private final OreVeinLocation oreVeinLocation; private final ResourceLocation depletedTextureLocation = new ResourceLocation(Tags.MODID, "textures/depleted.png"); private final IIcon blockStoneIcon = Blocks.stone.getIcon(0, 0); - private final double iconSize = 32; + private double iconSize; private double iconX; private double iconY; @@ -35,6 +36,7 @@ public OreVeinRenderStep(OreVeinLocation veinPosition) { @Override public void draw(@Nullable GuiScreen gui, double cameraX, double cameraZ, double scale) { + iconSize = 10 * scale; final double iconSizeHalf = iconSize / 2; final double scaleForGui = Math.max(1, scale); iconX = (oreVeinLocation.getBlockX() - 0.5 - cameraX) * scaleForGui - iconSizeHalf; @@ -75,18 +77,17 @@ public void draw(@Nullable GuiScreen gui, double cameraX, double cameraZ, double } } - if (gui != null && scale >= Utils.journeyMapScaleToLinear(Config.minZoomLevelForOreLabel) - && !oreVeinLocation.isDepleted()) { + if (scale >= Utils.journeyMapScaleToLinear(Config.minZoomLevelForOreLabel) && !oreVeinLocation.isDepleted()) { final int fontColor = oreVeinLocation.drawSearchHighlight() ? 0xFFFFFFFF : 0xFF7F7F7F; String text = I18n.format(oreVeinLocation.getName()); - DrawUtils.drawSimpleLabel( - gui, + DrawUtils.drawLabel( text, 0, - -iconSizeHalf - gui.mc.fontRenderer.FONT_HEIGHT - 5, + -iconSizeHalf - Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT - 5, fontColor, 0xB4000000, - true); + true, + 1.6); } if (oreVeinLocation.isActiveAsWaypoint()) { diff --git a/src/main/java/com/sinthoras/visualprospecting/mixins/late/xaerosminimap/MinimapRendererMixin.java b/src/main/java/com/sinthoras/visualprospecting/mixins/late/xaerosminimap/MinimapRendererMixin.java index 8ffbe9c2..448a9a6b 100644 --- a/src/main/java/com/sinthoras/visualprospecting/mixins/late/xaerosminimap/MinimapRendererMixin.java +++ b/src/main/java/com/sinthoras/visualprospecting/mixins/late/xaerosminimap/MinimapRendererMixin.java @@ -67,15 +67,16 @@ public class MinimapRendererMixin { } if (stencilEnabled) { + double mapZoom = zoom * (double) minimapScale / 2.0; GL11.glPushMatrix(); GL11.glEnable(GL11.GL_STENCIL_TEST); GL11.glRotated(Math.toDegrees(angle) - 90, 0.0, 0.0, 1.0); - GL11.glScaled(zoom, zoom, 0); + GL11.glScaled(mapZoom, mapZoom, 0); GL11.glStencilFunc(GL11.GL_EQUAL, 1, 1); for (LayerRenderer renderer : XaeroWorldMapState.instance.renderers) { if (renderer.isLayerActive()) { for (RenderStep renderStep : renderer.getRenderSteps()) { - renderStep.draw(null, playerX, playerZ, scale); + renderStep.draw(null, playerX, playerZ, mapZoom); } } }