aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/kr/syeyoung/dungeonsguide/config
diff options
context:
space:
mode:
authorsyeyoung <cyong06@naver.com>2021-02-27 02:49:34 +0900
committersyeyoung <cyong06@naver.com>2021-02-27 02:49:34 +0900
commit01f5b97bd5e0f9369f883982752852c0fbb09bc1 (patch)
tree8021ee6bd4c03878dc98b4ecea13dd8365541cbb /src/main/java/kr/syeyoung/dungeonsguide/config
parentb0524098c6e6ae399fff7b94f8423e2f0d1b9567 (diff)
downloadSkyblock-Dungeons-Guide-01f5b97bd5e0f9369f883982752852c0fbb09bc1.tar.gz
Skyblock-Dungeons-Guide-01f5b97bd5e0f9369f883982752852c0fbb09bc1.tar.bz2
Skyblock-Dungeons-Guide-01f5b97bd5e0f9369f883982752852c0fbb09bc1.zip
gui resize
Diffstat (limited to 'src/main/java/kr/syeyoung/dungeonsguide/config')
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/PanelDelegate.java44
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/config/types/GUIRectangle.java34
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/config/types/TCGUIRectangle.java8
3 files changed, 51 insertions, 35 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 c9a1922c..14661871 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/PanelDelegate.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/PanelDelegate.java
@@ -94,18 +94,12 @@ public class PanelDelegate extends MPanel {
rectangle.width = minWidth;
rectangle.height= minHeight;
}
-
+ ScaledResolution sr = new ScaledResolution(Minecraft.getMinecraft());
if (rectangle.x < 0) rectangle.x = 0;
if (rectangle.y < 0) rectangle.y = 0;
-
- 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);
+ if (rectangle.x + rectangle.width + 1 >= sr.getScaledWidth()) rectangle.x = sr.getScaledWidth() - rectangle.width - 1;
+ if (rectangle.y + rectangle.height + 1>= sr.getScaledHeight()) rectangle.y = sr.getScaledHeight() - rectangle.height - 1;
+ guiFeature.setFeatureRect(new GUIRectangle(rectangle));
}
selectedPart = -2;
@@ -166,26 +160,24 @@ public class PanelDelegate extends MPanel {
lastX += revChangeX ? 3 : 3;
}
- 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);
+ ScaledResolution sr = new ScaledResolution(Minecraft.getMinecraft());
+ if (rectangle.x < 0) rectangle.x = 0;
+ if (rectangle.y < 0) rectangle.y = 0;
+ if (rectangle.x + rectangle.width + 1 >= sr.getScaledWidth()) rectangle.x = sr.getScaledWidth() - rectangle.width - 1;
+ if (rectangle.y + rectangle.height + 1>= sr.getScaledHeight()) rectangle.y = sr.getScaledHeight() - rectangle.height - 1;
+
+ guiFeature.setFeatureRect(new GUIRectangle(rectangle));
throw new IllegalArgumentException("bruh, a hack to stop event progress");
} else if (selectedPart == -1){
Rectangle rectangle = guiFeature.getFeatureRect().getRectangle().getBounds();
rectangle.translate(dx, dy);
- 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);
+
+ ScaledResolution sr = new ScaledResolution(Minecraft.getMinecraft());
+ if (rectangle.x < 0) rectangle.x = 0;
+ if (rectangle.y < 0) rectangle.y = 0;
+ if (rectangle.x + rectangle.width + 1 >= sr.getScaledWidth()) rectangle.x = sr.getScaledWidth() - rectangle.width - 1;
+ if (rectangle.y + rectangle.height + 1>= sr.getScaledHeight()) rectangle.y = sr.getScaledHeight() - rectangle.height - 1;
+ guiFeature.setFeatureRect(new GUIRectangle(rectangle));
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 085a568c..ceabe366 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/config/types/GUIRectangle.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/config/types/GUIRectangle.java
@@ -12,15 +12,39 @@ import java.awt.*;
@AllArgsConstructor
@NoArgsConstructor
public class GUIRectangle {
- private double x;
- private double y;
- private double width;
- private double height;
+ public GUIRectangle(Rectangle rectangle) {
+
+ ScaledResolution sr = new ScaledResolution(Minecraft.getMinecraft());
+ if (rectangle.x < sr.getScaledWidth() / 2) {
+ this.x = rectangle.x;
+ this.width = rectangle.width;
+ } else {
+ this.x = rectangle.x + rectangle.width - sr.getScaledWidth();
+ this.width = -rectangle.width;
+ }
+
+ if (rectangle.y < sr.getScaledHeight() / 2) {
+ this.y = rectangle.y;
+ this.height = rectangle.height;
+ } else {
+ this.y = rectangle.y +rectangle.height - sr.getScaledHeight();
+ this.height = -rectangle.height;
+ }
+ }
+
+ private int x;
+ private int y;
+ private int width;
+ private int height;
public Rectangle getRectangle() {
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()));
+ int realX = x < 0 ? scaledResolution.getScaledWidth() + x : x;
+ int realY = y < 0 ? scaledResolution.getScaledHeight() + y : y;
+
+ return new Rectangle(Math.min(realX + width, realX), Math.min(realY + height, realY),
+ Math.abs(width), Math.abs(height));
}
}
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 746ce555..b4ca931d 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/config/types/TCGUIRectangle.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/config/types/TCGUIRectangle.java
@@ -15,10 +15,10 @@ public class TCGUIRectangle implements TypeConverter<GUIRectangle> {
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());
- rectangle.setWidth(((JsonObject)element).get("width").getAsDouble());
- rectangle.setHeight(((JsonObject)element).get("height").getAsDouble());
+ rectangle.setX(((JsonObject)element).get("x").getAsInt());
+ rectangle.setY(((JsonObject)element).get("y").getAsInt());
+ rectangle.setWidth(((JsonObject)element).get("width").getAsInt());
+ rectangle.setHeight(((JsonObject)element).get("height").getAsInt());
return rectangle;
}