diff options
Diffstat (limited to 'src/main/java/kr/syeyoung/dungeonsguide')
10 files changed, 75 insertions, 34 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 6ce54077..c9a1922c 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/PanelDelegate.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/PanelDelegate.java @@ -1,8 +1,11 @@ package kr.syeyoung.dungeonsguide.config.guiconfig; +import kr.syeyoung.dungeonsguide.config.types.GUIRectangle; import kr.syeyoung.dungeonsguide.features.GuiFeature; import kr.syeyoung.dungeonsguide.gui.MPanel; +import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Gui; +import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.renderer.GlStateManager; import java.awt.*; @@ -17,7 +20,7 @@ public class PanelDelegate extends MPanel { @Override public Rectangle getBounds() { - return guiFeature.getFeatureRect(); + return guiFeature.getFeatureRect().getRectangle(); } @Override @@ -86,7 +89,7 @@ public class PanelDelegate extends MPanel { minWidth = 8; minHeight = 8; } - Rectangle rectangle = guiFeature.getFeatureRect().getBounds(); + Rectangle rectangle = guiFeature.getFeatureRect().getRectangle().getBounds(); if (rectangle.width < minWidth || rectangle.height < minHeight) { rectangle.width = minWidth; rectangle.height= minHeight; @@ -95,7 +98,14 @@ public class PanelDelegate extends MPanel { if (rectangle.x < 0) rectangle.x = 0; if (rectangle.y < 0) rectangle.y = 0; - guiFeature.setFeatureRect(rectangle); + ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); + GUIRectangle guiRectangle = new GUIRectangle( + rectangle.x / scaledResolution.getScaledWidth_double(), + rectangle.y / scaledResolution.getScaledHeight_double(), + rectangle.width / scaledResolution.getScaledWidth_double(), + rectangle.height / scaledResolution.getScaledHeight_double() + ); + guiFeature.setFeatureRect(guiRectangle); } selectedPart = -2; @@ -111,7 +121,7 @@ public class PanelDelegate extends MPanel { if (selectedPart >= 0) { boolean revChangeX = (selectedPart & 0x1) == 0; boolean revChangeY = (selectedPart & 0x2) == 0; - Rectangle rectangle = guiFeature.getFeatureRect().getBounds(); + Rectangle rectangle = guiFeature.getFeatureRect().getRectangle().getBounds(); int prevWidth = rectangle.width; int prevHeight= rectangle.height; @@ -156,12 +166,26 @@ public class PanelDelegate extends MPanel { lastX += revChangeX ? 3 : 3; } - guiFeature.setFeatureRect(rectangle); + ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); + GUIRectangle guiRectangle = new GUIRectangle( + rectangle.x / scaledResolution.getScaledWidth_double(), + rectangle.y / scaledResolution.getScaledHeight_double(), + rectangle.width / scaledResolution.getScaledWidth_double(), + rectangle.height / scaledResolution.getScaledHeight_double() + ); + guiFeature.setFeatureRect(guiRectangle); throw new IllegalArgumentException("bruh, a hack to stop event progress"); } else if (selectedPart == -1){ - Rectangle rectangle = guiFeature.getFeatureRect().getBounds(); + Rectangle rectangle = guiFeature.getFeatureRect().getRectangle().getBounds(); rectangle.translate(dx, dy); - guiFeature.setFeatureRect(rectangle); + ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); + GUIRectangle guiRectangle = new GUIRectangle( + rectangle.x / scaledResolution.getScaledWidth_double(), + rectangle.y / scaledResolution.getScaledHeight_double(), + rectangle.width / scaledResolution.getScaledWidth_double(), + rectangle.height / scaledResolution.getScaledHeight_double() + ); + guiFeature.setFeatureRect(guiRectangle); lastX = absMouseX; lastY = absMouseY; } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/types/GUIRectangle.java b/src/main/java/kr/syeyoung/dungeonsguide/config/types/GUIRectangle.java index f45cbb99..085a568c 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/config/types/GUIRectangle.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/config/types/GUIRectangle.java @@ -1,12 +1,16 @@ package kr.syeyoung.dungeonsguide.config.types; +import lombok.AllArgsConstructor; import lombok.Data; +import lombok.NoArgsConstructor; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.ScaledResolution; import java.awt.*; @Data +@AllArgsConstructor +@NoArgsConstructor public class GUIRectangle { private double x; private double y; @@ -17,6 +21,6 @@ public class GUIRectangle { return getRectangle(new ScaledResolution(Minecraft.getMinecraft())); } public Rectangle getRectangle(ScaledResolution scaledResolution) { - return new Rectangle((int) x * scaledResolution.getScaledWidth(), (int) y * scaledResolution.getScaledHeight(), (int) width * scaledResolution.getScaledWidth(), (int) height * scaledResolution.getScaledHeight()); + return new Rectangle((int) (x * scaledResolution.getScaledWidth()), (int) (y * scaledResolution.getScaledHeight()), (int) (width * scaledResolution.getScaledWidth()), (int) (height * scaledResolution.getScaledHeight())); } } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/types/TCGUIRectangle.java b/src/main/java/kr/syeyoung/dungeonsguide/config/types/TCGUIRectangle.java index 473c1970..746ce555 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/config/types/TCGUIRectangle.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/config/types/TCGUIRectangle.java @@ -13,6 +13,7 @@ public class TCGUIRectangle implements TypeConverter<GUIRectangle> { @Override public GUIRectangle deserialize(JsonElement element) { + if (element == null) return null; GUIRectangle rectangle = new GUIRectangle(); rectangle.setX(((JsonObject)element).get("x").getAsDouble()); rectangle.setY(((JsonObject)element).get("y").getAsDouble()); diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/GuiFeature.java b/src/main/java/kr/syeyoung/dungeonsguide/features/GuiFeature.java index f15b10b5..36ae4c78 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/GuiFeature.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/GuiFeature.java @@ -1,6 +1,7 @@ package kr.syeyoung.dungeonsguide.features; 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 lombok.AccessLevel; @@ -12,6 +13,7 @@ import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.OpenGlHelper; import org.lwjgl.opengl.GL11; +import org.w3c.dom.css.Rect; import javax.sound.midi.MidiEvent; import java.awt.*; @@ -19,22 +21,24 @@ import java.awt.*; @Getter public abstract class GuiFeature extends AbstractFeature implements ScreenRenderListener { @Setter - private Rectangle featureRect; + private GUIRectangle featureRect; @Setter(value = AccessLevel.PROTECTED) private boolean keepRatio; @Setter(value = AccessLevel.PROTECTED) - private int defaultWidth; + private double defaultWidth; @Setter(value = AccessLevel.PROTECTED) - private int defaultHeight; + private double defaultHeight; private double defaultRatio; - protected GuiFeature(String category, String name, String description, String key, boolean keepRatio, int width, int height) { + protected GuiFeature(String category, String name, String description, String key, boolean keepRatio, double width, double height) { super(category, name, description, key); this.keepRatio = keepRatio; this.defaultWidth = width; this.defaultHeight = height; this.defaultRatio = defaultWidth / (double)defaultHeight; - this.featureRect = new Rectangle(0, 0, width, height); + if (width > 1) width = width / 720; + if (height > 1) height = height / 480; + this.featureRect = new GUIRectangle(0, 0, width, height); } @Override @@ -44,7 +48,9 @@ public abstract class GuiFeature extends AbstractFeature implements ScreenRender GlStateManager.color(1,1,1,1); GlStateManager.disableFog();GL11.glDisable(GL11.GL_FOG); GlStateManager.disableLighting(); - clip(new ScaledResolution(Minecraft.getMinecraft()), featureRect.x, featureRect.y, featureRect.width, featureRect.height); + ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); + Rectangle featureRect = this.featureRect.getRectangle(scaledResolution); + clip(scaledResolution, featureRect.x, featureRect.y, featureRect.width, featureRect.height); GL11.glEnable(GL11.GL_SCISSOR_TEST); GlStateManager.translate(featureRect.x, featureRect.y, 0); @@ -74,13 +80,14 @@ public abstract class GuiFeature extends AbstractFeature implements ScreenRender @Override public void loadConfig(JsonObject jsonObject) { super.loadConfig(jsonObject); - featureRect = TypeConverterRegistry.getTypeConverter("rect", Rectangle.class).deserialize(jsonObject.get("$bounds")); + GUIRectangle featureRect = TypeConverterRegistry.getTypeConverter("guirect",GUIRectangle.class).deserialize(jsonObject.get("$bounds2")); + if (featureRect != null && featureRect.getWidth() <= 1 && featureRect.getHeight() <= 1) this.featureRect = featureRect; } @Override public JsonObject saveConfig() { JsonObject object = super.saveConfig(); - object.add("$bounds", TypeConverterRegistry.getTypeConverter("rect", Rectangle.class).serialize(featureRect)); + object.add("$bounds2", TypeConverterRegistry.getTypeConverter("guirect", GUIRectangle.class).serialize(featureRect)); return object; } } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/advanced/FeatureDebuggableMap.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/advanced/FeatureDebuggableMap.java index 97c3f7db..79dcaef9 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/advanced/FeatureDebuggableMap.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/advanced/FeatureDebuggableMap.java @@ -54,8 +54,8 @@ public class FeatureDebuggableMap extends GuiFeature { @Override public void drawDemo(float partialTicks) { FontRenderer fr = getFontRenderer(); - fr.drawString("Please join a dungeon to see preview", getFeatureRect().width / 2 - fr.getStringWidth("Please join a dungeon to see preview") / 2, getFeatureRect().height / 2 - fr.FONT_HEIGHT / 2, 0xFFFFFFFF); + Rectangle featureRect = getFeatureRect().getRectangle(); GL11.glLineWidth(2); - RenderUtils.drawUnfilledBox(0,0,getFeatureRect().width, getFeatureRect().height, 0xff000000, false); + RenderUtils.drawUnfilledBox(0,0,featureRect.width, featureRect.height, 0xff000000, false); } } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/advanced/FeatureRoomCoordDisplay.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/advanced/FeatureRoomCoordDisplay.java index ada1e3ef..abb5bebe 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/advanced/FeatureRoomCoordDisplay.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/advanced/FeatureRoomCoordDisplay.java @@ -48,7 +48,7 @@ public class FeatureRoomCoordDisplay extends GuiFeature { FontRenderer fontRenderer = Minecraft.getMinecraft().fontRendererObj; - double scale = getFeatureRect().getHeight() / fontRenderer.FONT_HEIGHT; + double scale = getFeatureRect().getRectangle().getHeight() / fontRenderer.FONT_HEIGHT; GlStateManager.scale(scale, scale, 0); int color = this.<Color>getParameter("color").getValue().getRGB(); @@ -60,6 +60,8 @@ public class FeatureRoomCoordDisplay extends GuiFeature { FontRenderer fr = getFontRenderer(); int facing = (int) (Minecraft.getMinecraft().thePlayer.rotationYaw + 45) % 360; if (facing < 0) facing += 360; + double scale = getFeatureRect().getRectangle().getHeight() / fr.FONT_HEIGHT; + GlStateManager.scale(scale, scale, 0); fr.drawString("X: 0 Y: 3 Z: 5 Facing: "+FeatureRoomCoordDisplay.facing[(facing / 90) % 4], 0,0, this.<Color>getParameter("color").getValue().getRGB()); } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonMap.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonMap.java index 2f958169..a14b9c99 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonMap.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonMap.java @@ -110,17 +110,18 @@ public class FeatureDungeonMap extends GuiFeature implements DungeonEndListener, DungeonContext context = skyblockStatus.getContext(); MapProcessor mapProcessor = context.getMapProcessor(); MapData mapData = mapProcessor.getLastMapData2(); - Gui.drawRect(0,0,getFeatureRect().width, getFeatureRect().height, RenderUtils.getColorAt(getFeatureRect().x, getFeatureRect().y, this.<AColor>getParameter("background_color").getValue())); + Rectangle featureRect =getFeatureRect().getRectangle(); + Gui.drawRect(0,0,featureRect.width, featureRect.height, RenderUtils.getColorAt(featureRect.x, featureRect.y, this.<AColor>getParameter("background_color").getValue())); GlStateManager.color(1,1,1,1); GlStateManager.pushMatrix();; if (mapData == null) { - Gui.drawRect(0,0,getFeatureRect().width, getFeatureRect().height, 0xFFFF0000); + Gui.drawRect(0,0,featureRect.width, featureRect.height, 0xFFFF0000); } else { renderMap(partialTicks,mapProcessor,mapData,context); } GlStateManager.popMatrix(); GL11.glLineWidth(2); - RenderUtils.drawUnfilledBox(0,0,getFeatureRect().width, getFeatureRect().height, this.<AColor>getParameter("border_color").getValue()); + RenderUtils.drawUnfilledBox(0,0,featureRect.width, featureRect.height, this.<AColor>getParameter("border_color").getValue()); } @Override @@ -129,16 +130,18 @@ public class FeatureDungeonMap extends GuiFeature implements DungeonEndListener, drawHUD(partialTicks); return; } - Gui.drawRect(0,0,getFeatureRect().width, getFeatureRect().height, RenderUtils.getColorAt(getFeatureRect().x, getFeatureRect().y, this.<AColor>getParameter("background_color").getValue())); + Rectangle featureRect =getFeatureRect().getRectangle(); + Gui.drawRect(0,0,featureRect.width, featureRect.height, RenderUtils.getColorAt(featureRect.x, featureRect.y, this.<AColor>getParameter("background_color").getValue())); FontRenderer fr = getFontRenderer(); - fr.drawString("Please join a dungeon to see preview", getFeatureRect().width / 2 - fr.getStringWidth("Please join a dungeon to see preview") / 2, getFeatureRect().height / 2 - fr.FONT_HEIGHT / 2, 0xFFFFFFFF); + fr.drawString("Please join a dungeon to see preview", featureRect.width / 2 - fr.getStringWidth("Please join a dungeon to see preview") / 2, featureRect.height / 2 - fr.FONT_HEIGHT / 2, 0xFFFFFFFF); GL11.glLineWidth(2); - RenderUtils.drawUnfilledBox(0,0,getFeatureRect().width, getFeatureRect().height, this.<AColor>getParameter("border_color").getValue()); + RenderUtils.drawUnfilledBox(0,0,featureRect.width, featureRect.height, this.<AColor>getParameter("border_color").getValue()); } public void renderMap(float partialTicks, MapProcessor mapProcessor, MapData mapData, DungeonContext context){ float postScale = this.<Boolean>getParameter("playerCenter").getValue() ? this.<Float>getParameter("postScale").getValue() : 1; - int width = getFeatureRect().width; + Rectangle featureRect =getFeatureRect().getRectangle(); + int width = featureRect.width; float scale = (this.<Boolean>getParameter("scale").getValue() ? width / 128.0f : 1); GlStateManager.translate(width / 2, width / 2, 0); GlStateManager.scale(scale, scale, 0); diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/etc/FeatureCooldownCounter.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/etc/FeatureCooldownCounter.java index 6af93c63..9534f68f 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/etc/FeatureCooldownCounter.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/etc/FeatureCooldownCounter.java @@ -29,7 +29,7 @@ public class FeatureCooldownCounter extends GuiFeature implements DungeonQuitLis public void drawHUD(float partialTicks) { if (System.currentTimeMillis() - leftDungeonTime > 20000) return; FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - double scale = getFeatureRect().getHeight() / fr.FONT_HEIGHT; + double scale = getFeatureRect().getRectangle().getHeight() / fr.FONT_HEIGHT; GlStateManager.scale(scale, scale, 0); fr.drawString("Cooldown: "+(20 - (System.currentTimeMillis() - leftDungeonTime) / 1000)+"s", 0,0,this.<Color>getParameter("color").getValue().getRGB()); } @@ -37,7 +37,7 @@ public class FeatureCooldownCounter extends GuiFeature implements DungeonQuitLis @Override public void drawDemo(float partialTicks) { FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - double scale = getFeatureRect().getHeight() / fr.FONT_HEIGHT; + double scale = getFeatureRect().getRectangle().getHeight() / fr.FONT_HEIGHT; GlStateManager.scale(scale, scale, 0); fr.drawString("Cooldown: 20s", 0,0,this.<Color>getParameter("color").getValue().getRGB()); } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/FeatureMechanicBrowse.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/FeatureMechanicBrowse.java index 0727c36c..e6164fa4 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/FeatureMechanicBrowse.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/FeatureMechanicBrowse.java @@ -71,7 +71,7 @@ public class FeatureMechanicBrowse extends GuiFeature implements GuiPreRenderLis GeneralRoomProcessor grp = (GeneralRoomProcessor) dungeonRoom.getRoomProcessor(); - Rectangle feature = getFeatureRect(); + Rectangle feature = getFeatureRect().getRectangle(); FontRenderer fr = getFontRenderer(); Gui.drawRect(0, 0, feature.width, fr.FONT_HEIGHT + 4, 0xFF444444); @@ -88,7 +88,7 @@ public class FeatureMechanicBrowse extends GuiFeature implements GuiPreRenderLis @Override public void drawDemo(float partialTicks) { - Rectangle feature = getFeatureRect(); + Rectangle feature = getFeatureRect().getRectangle(); FontRenderer fr = getFontRenderer(); Gui.drawRect(0, 0, feature.width, fr.FONT_HEIGHT + 4, 0xFF444444); @@ -128,7 +128,7 @@ public class FeatureMechanicBrowse extends GuiFeature implements GuiPreRenderLis GeneralRoomProcessor grp = (GeneralRoomProcessor) dungeonRoom.getRoomProcessor(); - Rectangle feature = getFeatureRect(); + Rectangle feature = getFeatureRect().getRectangle(); FontRenderer fr = getFontRenderer(); GlStateManager.translate(feature.x, feature.y, 0); Gui.drawRect(0, 0, feature.width, fr.FONT_HEIGHT + 4, 0xFF444444); @@ -337,7 +337,7 @@ public class FeatureMechanicBrowse extends GuiFeature implements GuiPreRenderLis int mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth; int mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1; - Rectangle feature = getFeatureRect(); + Rectangle feature = getFeatureRect().getRectangle(); FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; Point popupStart = new Point(feature.x + feature.width, (selected + 1) * fr.FONT_HEIGHT +6 + feature.y - dy); if (feature.contains(mouseX, mouseY)) { 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 edfe99ff..7df67515 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/text/TextHUDFeature.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/text/TextHUDFeature.java @@ -34,7 +34,7 @@ public abstract class TextHUDFeature extends GuiFeature implements StyledTextPro if (doesScaleWithHeight()) { FontRenderer fr = getFontRenderer(); - double scale = getFeatureRect().getHeight() / (fr.FONT_HEIGHT* countLines(asd)); + double scale = getFeatureRect().getRectangle().getHeight() / (fr.FONT_HEIGHT* countLines(asd)); GlStateManager.scale(scale, scale, 0); } StyledTextRenderer.drawTextWithStylesAssociated(getText(), 0, 0, getStylesMap()); @@ -50,7 +50,7 @@ public abstract class TextHUDFeature extends GuiFeature implements StyledTextPro List<StyledText> asd = getDummyText(); if (doesScaleWithHeight()) { FontRenderer fr = getFontRenderer(); - double scale = getFeatureRect().getHeight() / (fr.FONT_HEIGHT * countLines(asd)); + double scale = getFeatureRect().getRectangle().getHeight() / (fr.FONT_HEIGHT * countLines(asd)); GlStateManager.scale(scale, scale, 0); } StyledTextRenderer.drawTextWithStylesAssociated(getDummyText(), 0, 0, getStylesMap()); |