From 82a849d7aee17d7e59397f0858a24b51b59a69a6 Mon Sep 17 00:00:00 2001 From: syeyoung Date: Tue, 20 Jul 2021 14:46:00 +0900 Subject: Add scaling to text hud and fix gui feature not rendering correctly --- .../dungeonsguide/config/guiconfig/PanelDelegate.java | 9 --------- .../java/kr/syeyoung/dungeonsguide/features/GuiFeature.java | 7 ++++++- .../impl/party/playerpreview/FeatureViewPlayerOnJoin.java | 2 ++ .../dungeonsguide/features/text/TextHUDFeature.java | 13 ++++++++++--- 4 files changed, 18 insertions(+), 13 deletions(-) diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/PanelDelegate.java b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/PanelDelegate.java index 4e107766..71cafd83 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/PanelDelegate.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/PanelDelegate.java @@ -92,12 +92,6 @@ public class PanelDelegate extends MPanel { @Override public void render0(ScaledResolution resolution, Point parentPoint, Rectangle parentClip, int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks) { - if (selectedPart != -2) { - Gui.drawRect(internallyThinking.x, internallyThinking.y, internallyThinking.x + internallyThinking.width, internallyThinking.y + internallyThinking.height, 0xFF000000); - FontRenderer fontRenderer = Minecraft.getMinecraft().fontRendererObj; - fontRenderer.drawString(internallyThinking.width + "x"+internallyThinking.height, internallyThinking.x, internallyThinking.y, 0xFFFFFFFF); - } - GlStateManager.pushMatrix(); super.render0(resolution, parentPoint, parentClip, absMousex, absMousey, relMousex0, relMousey0, partialTicks); GlStateManager.popMatrix(); @@ -109,9 +103,6 @@ public class PanelDelegate extends MPanel { worldRenderer.begin(GL11.GL_LINES, DefaultVertexFormats.POSITION_COLOR); GL11.glLineWidth(1); for (Tuple markerAxisTuple : snapped) { -// worldRenderer.pos(markerAxisTuple.getFirst()[0].getX(), markerAxisTuple.getFirst()[0].getY(), 0).color(255,255,255,255).endVertex(); -// worldRenderer.pos(markerAxisTuple.getFirst()[1].getX(), markerAxisTuple.getFirst()[1].getY(), 0).color(255,255,255,255).endVertex(); - if (markerAxisTuple.getSecond() == EnumFacing.Axis.X) { worldRenderer.pos(markerAxisTuple.getFirst()[0].getX(), 0, 0).color(0,255,0,255).endVertex(); worldRenderer.pos(markerAxisTuple.getFirst()[0].getX(), Minecraft.getMinecraft().displayHeight, 0).color(0,255,0,255).endVertex(); diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/GuiFeature.java b/src/main/java/kr/syeyoung/dungeonsguide/features/GuiFeature.java index 6e82add5..d878c28b 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/GuiFeature.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/GuiFeature.java @@ -22,6 +22,7 @@ import com.google.gson.JsonObject; import kr.syeyoung.dungeonsguide.config.types.GUIRectangle; import kr.syeyoung.dungeonsguide.config.types.TypeConverterRegistry; import kr.syeyoung.dungeonsguide.features.listener.ScreenRenderListener; +import kr.syeyoung.dungeonsguide.gui.elements.MTooltip; import lombok.AccessLevel; import lombok.Getter; import lombok.Setter; @@ -65,7 +66,7 @@ public abstract class GuiFeature extends AbstractFeature implements ScreenRender GlStateManager.pushMatrix(); Rectangle featureRect = this.featureRect.getRectangleNoScale(); ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); - GlStateManager.translate(1.0/scaledResolution.getScaleFactor(), 1.0/scaledResolution.getScaleFactor(), 1); + GlStateManager.scale(1.0/scaledResolution.getScaleFactor(), 1.0/scaledResolution.getScaleFactor(), 1); clip(featureRect.x, featureRect.y, featureRect.width, featureRect.height); GL11.glEnable(GL11.GL_SCISSOR_TEST); @@ -112,4 +113,8 @@ public abstract class GuiFeature extends AbstractFeature implements ScreenRender object.add("$bounds", TypeConverterRegistry.getTypeConverter("guirect", GUIRectangle.class).serialize(featureRect)); return object; } + + public MTooltip getTooltipForEditor() { + return null; + } } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/FeatureViewPlayerOnJoin.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/FeatureViewPlayerOnJoin.java index 448eabe9..517195bd 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/FeatureViewPlayerOnJoin.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/FeatureViewPlayerOnJoin.java @@ -386,11 +386,13 @@ public class FeatureViewPlayerOnJoin extends SimpleFeature implements GuiPostRen } FontRenderer font = toHover.getItem().getFontRenderer(toHover); GlStateManager.popMatrix(); + GlStateManager.popMatrix(); GL11.glDisable(GL11.GL_SCISSOR_TEST); FontRenderer theRenderer = (font == null ? fr : font); GuiUtils.drawHoveringText(list,mouseX, mouseY, scaledResolution.getScaledWidth(), scaledResolution.getScaledHeight(), -1, theRenderer); GL11.glEnable(GL11.GL_SCISSOR_TEST); GlStateManager.pushMatrix(); + GlStateManager.pushMatrix(); } } GL11.glDisable(GL11.GL_SCISSOR_TEST); diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/text/TextHUDFeature.java b/src/main/java/kr/syeyoung/dungeonsguide/features/text/TextHUDFeature.java index 470c4d77..463e1b2f 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/text/TextHUDFeature.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/text/TextHUDFeature.java @@ -45,6 +45,9 @@ public abstract class TextHUDFeature extends GuiFeature implements StyledTextPro this.parameters.put("textStylesNEW", new FeatureParameter>("textStylesNEW", "", "", new ArrayList(), "list_textStyle")); this.parameters.put("alignRight", new FeatureParameter("alignRight", "Align Right", "Align text to right", false, "boolean")); this.parameters.put("alignCenter", new FeatureParameter("alignCenter", "Align Center", "Align text to center (overrides alignright)", false, "boolean")); + if (!doesScaleWithHeight()) { + this.parameters.put("scale", new FeatureParameter("scale", "Scale", "Scale", 1.0f, "float")); + } } @Override @@ -56,8 +59,10 @@ public abstract class TextHUDFeature extends GuiFeature implements StyledTextPro if (doesScaleWithHeight()) { FontRenderer fr = getFontRenderer(); scale = getFeatureRect().getRectangle().getHeight() / (fr.FONT_HEIGHT* countLines(asd)); - GlStateManager.scale(scale, scale, 0); + } else { + scale = this.getParameter("scale").getValue(); } + GlStateManager.scale(scale, scale, 0); StyledTextRenderer.drawTextWithStylesAssociated(getText(), 0, 0, (int) (Math.abs(getFeatureRect().getWidth())/scale), getStylesMap(),this.getParameter("alignCenter").getValue() ? StyledTextRenderer.Alignment.CENTER : this.getParameter("alignRight").getValue() ? StyledTextRenderer.Alignment.RIGHT : StyledTextRenderer.Alignment.LEFT); } } @@ -72,9 +77,11 @@ public abstract class TextHUDFeature extends GuiFeature implements StyledTextPro double scale = 1; if (doesScaleWithHeight()) { FontRenderer fr = getFontRenderer(); - scale = getFeatureRect().getRectangle().getHeight() / (fr.FONT_HEIGHT * countLines(asd)); - GlStateManager.scale(scale, scale, 0); + scale = getFeatureRect().getRectangle().getHeight() / (fr.FONT_HEIGHT* countLines(asd)); + } else { + scale = this.getParameter("scale").getValue(); } + GlStateManager.scale(scale, scale, 0); StyledTextRenderer.drawTextWithStylesAssociated(getDummyText(), 0, 0, (int) (Math.abs(getFeatureRect().getWidth())/scale), getStylesMap(),this.getParameter("alignCenter").getValue() ? StyledTextRenderer.Alignment.CENTER : this.getParameter("alignRight").getValue() ? StyledTextRenderer.Alignment.RIGHT : StyledTextRenderer.Alignment.LEFT); } -- cgit