aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/kr/syeyoung/dungeonsguide/config
diff options
context:
space:
mode:
authorsyeyoung <cyong06@naver.com>2021-02-27 02:02:38 +0900
committersyeyoung <cyong06@naver.com>2021-02-27 02:02:38 +0900
commitb0524098c6e6ae399fff7b94f8423e2f0d1b9567 (patch)
tree865efe368a3c0b65f83b36c991ad4d6401aa0392 /src/main/java/kr/syeyoung/dungeonsguide/config
parenta67de30acd54d4781dded0e86e5980bbb5402809 (diff)
downloadSkyblock-Dungeons-Guide-b0524098c6e6ae399fff7b94f8423e2f0d1b9567.tar.gz
Skyblock-Dungeons-Guide-b0524098c6e6ae399fff7b94f8423e2f0d1b9567.tar.bz2
Skyblock-Dungeons-Guide-b0524098c6e6ae399fff7b94f8423e2f0d1b9567.zip
bruh
Diffstat (limited to 'src/main/java/kr/syeyoung/dungeonsguide/config')
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/PanelDelegate.java38
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/config/types/GUIRectangle.java6
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/config/types/TCGUIRectangle.java1
3 files changed, 37 insertions, 8 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());