aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/kr/syeyoung/dungeonsguide/features
diff options
context:
space:
mode:
authorsyeyoung <cyong06@naver.com>2021-07-20 14:46:00 +0900
committersyeyoung <cyong06@naver.com>2021-07-20 15:34:28 +0900
commit82a849d7aee17d7e59397f0858a24b51b59a69a6 (patch)
tree4412069896da9abdd99fe77d0d140ac86a384c03 /src/main/java/kr/syeyoung/dungeonsguide/features
parenteb27fcef7ac26c71941c7911ebf6aa20254a2855 (diff)
downloadSkyblock-Dungeons-Guide-82a849d7aee17d7e59397f0858a24b51b59a69a6.tar.gz
Skyblock-Dungeons-Guide-82a849d7aee17d7e59397f0858a24b51b59a69a6.tar.bz2
Skyblock-Dungeons-Guide-82a849d7aee17d7e59397f0858a24b51b59a69a6.zip
Add scaling to text hud
and fix gui feature not rendering correctly
Diffstat (limited to 'src/main/java/kr/syeyoung/dungeonsguide/features')
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/features/GuiFeature.java7
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/FeatureViewPlayerOnJoin.java2
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/features/text/TextHUDFeature.java13
3 files changed, 18 insertions, 4 deletions
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<List<TextStyle>>("textStylesNEW", "", "", new ArrayList<TextStyle>(), "list_textStyle"));
this.parameters.put("alignRight", new FeatureParameter<Boolean>("alignRight", "Align Right", "Align text to right", false, "boolean"));
this.parameters.put("alignCenter", new FeatureParameter<Boolean>("alignCenter", "Align Center", "Align text to center (overrides alignright)", false, "boolean"));
+ if (!doesScaleWithHeight()) {
+ this.parameters.put("scale", new FeatureParameter<Float>("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.<Float>getParameter("scale").getValue();
}
+ GlStateManager.scale(scale, scale, 0);
StyledTextRenderer.drawTextWithStylesAssociated(getText(), 0, 0, (int) (Math.abs(getFeatureRect().getWidth())/scale), getStylesMap(),this.<Boolean>getParameter("alignCenter").getValue() ? StyledTextRenderer.Alignment.CENTER : this.<Boolean>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.<Float>getParameter("scale").getValue();
}
+ GlStateManager.scale(scale, scale, 0);
StyledTextRenderer.drawTextWithStylesAssociated(getDummyText(), 0, 0, (int) (Math.abs(getFeatureRect().getWidth())/scale), getStylesMap(),this.<Boolean>getParameter("alignCenter").getValue() ? StyledTextRenderer.Alignment.CENTER : this.<Boolean>getParameter("alignRight").getValue() ? StyledTextRenderer.Alignment.RIGHT : StyledTextRenderer.Alignment.LEFT);
}