From 2c9e03a56995baba5953b5361eaca7c077ddcfca Mon Sep 17 00:00:00 2001 From: syeyoung Date: Wed, 25 Jan 2023 18:39:55 +0900 Subject: - Fix ABSXY trying to set locaiton when size is not set - Fix AbsLocationPopup using relativebound to determine scale Signed-off-by: syeyoung --- .../main/java/kr/syeyoung/dungeonsguide/mod/guiv2/elements/AbsXY.java | 3 ++- .../dungeonsguide/mod/guiv2/elements/popups/AbsLocationPopup.java | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'mod/src') diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/elements/AbsXY.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/elements/AbsXY.java index 75db0973..0f5a97d1 100644 --- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/elements/AbsXY.java +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/elements/AbsXY.java @@ -47,8 +47,9 @@ public class AbsXY extends AnnotatedExportOnlyWidget implements Layouter { } private void setLocations(double old, double neu) { - if (getDomElement().getChildren().size() <= 0) return; + if (getDomElement().getChildren().size() == 0) return; DomElement child = getDomElement().getChildren().get(0); + if (child.getSize() == null) return; child.setRelativeBound(new Rect(x.getValue(), y.getValue(), child.getSize().getWidth(), child.getSize().getHeight())); } diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/elements/popups/AbsLocationPopup.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/elements/popups/AbsLocationPopup.java index 06db01e2..e9331b33 100644 --- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/elements/popups/AbsLocationPopup.java +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/elements/popups/AbsLocationPopup.java @@ -22,6 +22,7 @@ import kr.syeyoung.dungeonsguide.mod.guiv2.BindableAttribute; import kr.syeyoung.dungeonsguide.mod.guiv2.DomElement; import kr.syeyoung.dungeonsguide.mod.guiv2.Widget; import kr.syeyoung.dungeonsguide.mod.guiv2.primitive.Rect; +import kr.syeyoung.dungeonsguide.mod.guiv2.primitive.Size; import kr.syeyoung.dungeonsguide.mod.guiv2.xml.AnnotatedImportOnlyWidget; import kr.syeyoung.dungeonsguide.mod.guiv2.xml.AnnotatedWidget; import kr.syeyoung.dungeonsguide.mod.guiv2.xml.annotations.Bind; @@ -68,7 +69,7 @@ public class AbsLocationPopup extends AnnotatedImportOnlyWidget { public void updatePos(double old, double neu) { PopupMgr popupMgr = PopupMgr.getPopupMgr(getDomElement()); Rect rect = popupMgr.getDomElement().getAbsBounds(); - Rect rel = popupMgr.getDomElement().getRelativeBound(); + Size rel = popupMgr.getDomElement().getSize(); this.x.setValue( (absX.getValue() - rect.getX()) * rel.getWidth() / rect.getWidth() ); -- cgit