aboutsummaryrefslogtreecommitdiff
path: root/mod/src/main/java
diff options
context:
space:
mode:
authorsyeyoung <cyoung06@naver.com>2023-01-25 16:44:51 +0900
committersyeyoung <cyoung06@naver.com>2023-01-25 16:44:51 +0900
commitd5229dd379372abd83edd1b3db3d1076481248e8 (patch)
tree1f397bca4b8fbaeeef298bfec598105488433d9e /mod/src/main/java
parent16e09c87114564a192c3d0a3c7e77ec18a330a11 (diff)
downloadSkyblock-Dungeons-Guide-d5229dd379372abd83edd1b3db3d1076481248e8.tar.gz
Skyblock-Dungeons-Guide-d5229dd379372abd83edd1b3db3d1076481248e8.tar.bz2
Skyblock-Dungeons-Guide-d5229dd379372abd83edd1b3db3d1076481248e8.zip
- Follow user's scaled width and height
Signed-off-by: syeyoung <cyoung06@naver.com>
Diffstat (limited to 'mod/src/main/java')
-rw-r--r--mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/AbstractHUDFeature.java5
-rw-r--r--mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/RawRenderingGuiFeature.java3
-rw-r--r--mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/discord/inviteViewer/PartyInviteViewer.java3
-rw-r--r--mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/discord/onlinealarm/PlayingDGAlarm.java3
-rw-r--r--mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/FeatureViewPlayerStatsOnJoin.java6
-rw-r--r--mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/widget/PlayerModelRenderer.java15
-rw-r--r--mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/widget/WidgetDataRendererWrapper.java11
-rw-r--r--mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/widget/WidgetPlayerInventory.java8
-rw-r--r--mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/widget/WidgetProfileViewerData.java8
-rw-r--r--mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/mechanicbrowser/FeatureMechanicBrowse.java8
-rw-r--r--mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/mechanicbrowser/WidgetSecret.java10
-rw-r--r--mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/text/TextHUDFeature.java11
-rw-r--r--mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/elements/popups/AbsLocationPopup.java (renamed from mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/elements/LocationedPopup.java)48
-rw-r--r--mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/elements/popups/MinecraftTooltip.java (renamed from mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/elements/MinecraftTooltip.java)6
-rw-r--r--mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/elements/popups/MouseTooltip.java (renamed from mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/elements/MouseTooltip.java)39
-rw-r--r--mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/elements/popups/PopupMgr.java (renamed from mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/elements/PopupMgr.java)6
-rw-r--r--mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/view/TestPopup.java2
-rw-r--r--mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/view/TestView.java2
-rw-r--r--mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/xml/DomElementRegistry.java1
-rw-r--r--mod/src/main/java/kr/syeyoung/dungeonsguide/mod/overlay/AbsPosPositioner.java42
-rw-r--r--mod/src/main/java/kr/syeyoung/dungeonsguide/mod/overlay/GUIRectanglePositioner.java63
-rw-r--r--mod/src/main/java/kr/syeyoung/dungeonsguide/mod/overlay/OverlayManager.java16
-rw-r--r--mod/src/main/java/kr/syeyoung/dungeonsguide/mod/overlay/OverlayManagerRootWidget.java18
-rw-r--r--mod/src/main/java/kr/syeyoung/dungeonsguide/mod/overlay/OverlayWidget.java2
-rw-r--r--mod/src/main/java/kr/syeyoung/dungeonsguide/mod/overlay/Positioner.java27
-rw-r--r--mod/src/main/java/kr/syeyoung/dungeonsguide/mod/overlay/WholeScreenPositioner.java37
26 files changed, 307 insertions, 93 deletions
diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/AbstractHUDFeature.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/AbstractHUDFeature.java
index 2896489f..8e841db7 100644
--- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/AbstractHUDFeature.java
+++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/AbstractHUDFeature.java
@@ -65,11 +65,6 @@ public abstract class AbstractHUDFeature extends AbstractGuiFeature {
this.featureRect = new GUIRectangle(0, 0, width, height);
}
-
- public Rect getWidgetPosition() {
- Rectangle loc = featureRect.getRectangleNoScale();
- return new Rect(loc.x, loc.y, loc.width, loc.height);
- }
public abstract void drawDemo(float partialTicks);
@Override
diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/RawRenderingGuiFeature.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/RawRenderingGuiFeature.java
index 869f6391..04ed126f 100644
--- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/RawRenderingGuiFeature.java
+++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/RawRenderingGuiFeature.java
@@ -25,6 +25,7 @@ import kr.syeyoung.dungeonsguide.mod.guiv2.primitive.ConstraintBox;
import kr.syeyoung.dungeonsguide.mod.guiv2.primitive.Size;
import kr.syeyoung.dungeonsguide.mod.guiv2.renderer.Renderer;
import kr.syeyoung.dungeonsguide.mod.guiv2.renderer.RenderingContext;
+import kr.syeyoung.dungeonsguide.mod.overlay.GUIRectanglePositioner;
import kr.syeyoung.dungeonsguide.mod.overlay.OverlayType;
import kr.syeyoung.dungeonsguide.mod.overlay.OverlayWidget;
import lombok.Getter;
@@ -64,7 +65,7 @@ public abstract class RawRenderingGuiFeature extends AbstractHUDFeature {
return new OverlayWidget(
new WidgetFeatureWrapper(),
OverlayType.UNDER_CHAT,
- this::getWidgetPosition
+ new GUIRectanglePositioner(this::getFeatureRect)
);
}
diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/discord/inviteViewer/PartyInviteViewer.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/discord/inviteViewer/PartyInviteViewer.java
index ad656753..ae3f52e8 100644
--- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/discord/inviteViewer/PartyInviteViewer.java
+++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/discord/inviteViewer/PartyInviteViewer.java
@@ -30,6 +30,7 @@ import kr.syeyoung.dungeonsguide.mod.features.FeatureParameter;
import kr.syeyoung.dungeonsguide.mod.guiv2.primitive.Rect;
import kr.syeyoung.dungeonsguide.mod.overlay.OverlayType;
import kr.syeyoung.dungeonsguide.mod.overlay.OverlayWidget;
+import kr.syeyoung.dungeonsguide.mod.overlay.WholeScreenPositioner;
import net.minecraft.client.Minecraft;
import java.util.concurrent.ExecutorService;
@@ -49,7 +50,7 @@ public class PartyInviteViewer extends AbstractGuiFeature {
return new OverlayWidget(
partyInviteViewer = new WidgetPartyInviteViewer(),
OverlayType.OVER_ANY,
- () -> new Rect(0,0,Minecraft.getMinecraft().displayWidth, Minecraft.getMinecraft().displayHeight)
+ new WholeScreenPositioner()
);
}
diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/discord/onlinealarm/PlayingDGAlarm.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/discord/onlinealarm/PlayingDGAlarm.java
index 00e1558f..85784814 100644
--- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/discord/onlinealarm/PlayingDGAlarm.java
+++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/discord/onlinealarm/PlayingDGAlarm.java
@@ -27,6 +27,7 @@ import kr.syeyoung.dungeonsguide.mod.features.AbstractGuiFeature;
import kr.syeyoung.dungeonsguide.mod.guiv2.primitive.Rect;
import kr.syeyoung.dungeonsguide.mod.overlay.OverlayType;
import kr.syeyoung.dungeonsguide.mod.overlay.OverlayWidget;
+import kr.syeyoung.dungeonsguide.mod.overlay.WholeScreenPositioner;
import net.minecraft.client.Minecraft;
public class PlayingDGAlarm extends AbstractGuiFeature {
@@ -42,7 +43,7 @@ public class PlayingDGAlarm extends AbstractGuiFeature {
return new OverlayWidget(
onlinePeopleViewer = new WidgetOnlinePeopleViewer(),
OverlayType.OVER_ANY,
- () -> new Rect(0,0,Minecraft.getMinecraft().displayWidth, Minecraft.getMinecraft().displayHeight)
+ new WholeScreenPositioner()
);
}
diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/FeatureViewPlayerStatsOnJoin.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/FeatureViewPlayerStatsOnJoin.java
index c482337e..706b5c28 100644
--- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/FeatureViewPlayerStatsOnJoin.java
+++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/FeatureViewPlayerStatsOnJoin.java
@@ -37,9 +37,7 @@ import kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.api.ApiFe
import kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.datarenders.DataRendererEditor;
import kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.widget.WidgetProfileViewer;
import kr.syeyoung.dungeonsguide.mod.guiv2.primitive.Rect;
-import kr.syeyoung.dungeonsguide.mod.overlay.OverlayManager;
-import kr.syeyoung.dungeonsguide.mod.overlay.OverlayType;
-import kr.syeyoung.dungeonsguide.mod.overlay.OverlayWidget;
+import kr.syeyoung.dungeonsguide.mod.overlay.*;
import kr.syeyoung.dungeonsguide.mod.party.PartyContext;
import kr.syeyoung.dungeonsguide.mod.party.PartyManager;
import kr.syeyoung.dungeonsguide.mod.utils.TextUtils;
@@ -150,7 +148,7 @@ public class FeatureViewPlayerStatsOnJoin extends SimpleFeature {
}
}),
OverlayType.OVER_CHAT,
- () -> new Rect(mouseX, mouseY-height, width, height)
+ new AbsPosPositioner(mouseX, mouseY-height)
);
OverlayManager.getInstance().addOverlay(widget);
}
diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/widget/PlayerModelRenderer.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/widget/PlayerModelRenderer.java
index 3834f966..0389fb32 100644
--- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/widget/PlayerModelRenderer.java
+++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/widget/PlayerModelRenderer.java
@@ -18,33 +18,26 @@
package kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.widget;
-import com.mojang.authlib.GameProfile;
import kr.syeyoung.dungeonsguide.mod.DungeonsGuide;
import kr.syeyoung.dungeonsguide.mod.cosmetics.ActiveCosmetic;
import kr.syeyoung.dungeonsguide.mod.cosmetics.CosmeticData;
import kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.FakePlayer;
-import kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.api.playerprofile.PlayerProfile;
-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.elements.MinecraftTooltip;
-import kr.syeyoung.dungeonsguide.mod.guiv2.elements.MouseTooltip;
-import kr.syeyoung.dungeonsguide.mod.guiv2.elements.PopupMgr;
+import kr.syeyoung.dungeonsguide.mod.guiv2.elements.popups.MinecraftTooltip;
+import kr.syeyoung.dungeonsguide.mod.guiv2.elements.popups.MouseTooltip;
+import kr.syeyoung.dungeonsguide.mod.guiv2.elements.popups.PopupMgr;
import kr.syeyoung.dungeonsguide.mod.guiv2.layouter.Layouter;
import kr.syeyoung.dungeonsguide.mod.guiv2.primitive.ConstraintBox;
import kr.syeyoung.dungeonsguide.mod.guiv2.primitive.Size;
import kr.syeyoung.dungeonsguide.mod.guiv2.renderer.Renderer;
import kr.syeyoung.dungeonsguide.mod.guiv2.renderer.RenderingContext;
import kr.syeyoung.dungeonsguide.mod.guiv2.xml.AnnotatedExportOnlyWidget;
-import kr.syeyoung.dungeonsguide.mod.guiv2.xml.annotations.Export;
-import kr.syeyoung.dungeonsguide.mod.utils.TextUtils;
-import lombok.AllArgsConstructor;
import lombok.Setter;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.inventory.GuiInventory;
import net.minecraft.client.renderer.GlStateManager;
-import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting;
import org.lwjgl.opengl.GL11;
@@ -153,7 +146,7 @@ public class PlayerModelRenderer extends AnnotatedExportOnlyWidget implements La
this.tooltip = null;
} else if (toHover != null && this.tooltip == null)
PopupMgr.getPopupMgr(getDomElement())
- .openPopup(this.tooltip = new MouseTooltip(absMouseX, absMouseY, actualTooltip),(a) -> {
+ .openPopup(this.tooltip = new MouseTooltip(actualTooltip),(a) -> {
this.tooltip = null;
});
return false;
diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/widget/WidgetDataRendererWrapper.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/widget/WidgetDataRendererWrapper.java
index 636a6f26..4eae8659 100644
--- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/widget/WidgetDataRendererWrapper.java
+++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/widget/WidgetDataRendererWrapper.java
@@ -22,17 +22,14 @@ import kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.api.playe
import kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.datarenders.IDataRenderer;
import kr.syeyoung.dungeonsguide.mod.guiv2.DomElement;
import kr.syeyoung.dungeonsguide.mod.guiv2.Widget;
-import kr.syeyoung.dungeonsguide.mod.guiv2.elements.MinecraftTooltip;
-import kr.syeyoung.dungeonsguide.mod.guiv2.elements.MouseTooltip;
-import kr.syeyoung.dungeonsguide.mod.guiv2.elements.PopupMgr;
+import kr.syeyoung.dungeonsguide.mod.guiv2.elements.popups.MinecraftTooltip;
+import kr.syeyoung.dungeonsguide.mod.guiv2.elements.popups.MouseTooltip;
+import kr.syeyoung.dungeonsguide.mod.guiv2.elements.popups.PopupMgr;
import kr.syeyoung.dungeonsguide.mod.guiv2.layouter.Layouter;
import kr.syeyoung.dungeonsguide.mod.guiv2.primitive.ConstraintBox;
import kr.syeyoung.dungeonsguide.mod.guiv2.primitive.Size;
import kr.syeyoung.dungeonsguide.mod.guiv2.renderer.Renderer;
import kr.syeyoung.dungeonsguide.mod.guiv2.renderer.RenderingContext;
-import net.minecraft.client.Minecraft;
-import net.minecraft.item.ItemStack;
-import net.minecraft.util.EnumChatFormatting;
import java.awt.*;
import java.util.Collections;
@@ -87,7 +84,7 @@ public class WidgetDataRendererWrapper extends Widget implements Layouter, Rende
this.tooltip = null;
} else if (toHover != null && this.tooltip == null)
PopupMgr.getPopupMgr(getDomElement())
- .openPopup(this.tooltip = new MouseTooltip(absMouseX, absMouseY, actualTooltip), (a) -> {
+ .openPopup(this.tooltip = new MouseTooltip(actualTooltip), (a) -> {
this.tooltip = null;
});
return false;
diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/widget/WidgetPlayerInventory.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/widget/WidgetPlayerInventory.java
index e32f5754..9f04cfcf 100644
--- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/widget/WidgetPlayerInventory.java
+++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/widget/WidgetPlayerInventory.java
@@ -21,9 +21,9 @@ package kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.widget;
import kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.api.playerprofile.PlayerProfile;
import kr.syeyoung.dungeonsguide.mod.guiv2.DomElement;
import kr.syeyoung.dungeonsguide.mod.guiv2.Widget;
-import kr.syeyoung.dungeonsguide.mod.guiv2.elements.MinecraftTooltip;
-import kr.syeyoung.dungeonsguide.mod.guiv2.elements.MouseTooltip;
-import kr.syeyoung.dungeonsguide.mod.guiv2.elements.PopupMgr;
+import kr.syeyoung.dungeonsguide.mod.guiv2.elements.popups.MinecraftTooltip;
+import kr.syeyoung.dungeonsguide.mod.guiv2.elements.popups.MouseTooltip;
+import kr.syeyoung.dungeonsguide.mod.guiv2.elements.popups.PopupMgr;
import kr.syeyoung.dungeonsguide.mod.guiv2.layouter.Layouter;
import kr.syeyoung.dungeonsguide.mod.guiv2.primitive.ConstraintBox;
import kr.syeyoung.dungeonsguide.mod.guiv2.primitive.Size;
@@ -124,7 +124,7 @@ public class WidgetPlayerInventory extends Widget implements Renderer, Layouter
this.tooltip = null;
} else if (toHover != null && this.tooltip == null)
PopupMgr.getPopupMgr(getDomElement())
- .openPopup(this.tooltip = new MouseTooltip(absMouseX, absMouseY, actualTooltip), (a) -> {
+ .openPopup(this.tooltip = new MouseTooltip(actualTooltip), (a) -> {
this.tooltip = null;
});
return true;
diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/widget/WidgetProfileViewerData.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/widget/WidgetProfileViewerData.java
index 3ba7cbd0..3a3ca61d 100644
--- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/widget/WidgetProfileViewerData.java
+++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/party/playerpreview/widget/WidgetProfileViewerData.java
@@ -27,8 +27,8 @@ import kr.syeyoung.dungeonsguide.mod.features.impl.party.playerpreview.datarende
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.elements.LocationedPopup;
-import kr.syeyoung.dungeonsguide.mod.guiv2.elements.PopupMgr;
+import kr.syeyoung.dungeonsguide.mod.guiv2.elements.popups.AbsLocationPopup;
+import kr.syeyoung.dungeonsguide.mod.guiv2.elements.popups.PopupMgr;
import kr.syeyoung.dungeonsguide.mod.guiv2.elements.Scaler;
import kr.syeyoung.dungeonsguide.mod.guiv2.primitive.Rect;
import kr.syeyoung.dungeonsguide.mod.guiv2.xml.AnnotatedWidget;
@@ -101,7 +101,7 @@ public class WidgetProfileViewerData extends AnnotatedWidget {
}
- private LocationedPopup popup;
+ private AbsLocationPopup popup;
@On(functionName = "openInventory")
public void openStates() {
Rect abs = inventoryButton.getValue().getAbsBounds();
@@ -115,7 +115,7 @@ public class WidgetProfileViewerData extends AnnotatedWidget {
scaler.child.setValue(new WidgetPlayerInventory(
playerSkyblockData.getPlayerProfiles()[idx]
));
- popupMgr.openPopup(popup = new LocationedPopup(x, y, scaler), (a) -> {
+ popupMgr.openPopup(popup = new AbsLocationPopup(x, y, scaler, true), (a) -> {
this.popup = null;
});
}
diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/mechanicbrowser/FeatureMechanicBrowse.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/mechanicbrowser/FeatureMechanicBrowse.java
index 87f28a3c..b5e67a5d 100644
--- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/mechanicbrowser/FeatureMechanicBrowse.java
+++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/mechanicbrowser/FeatureMechanicBrowse.java
@@ -33,7 +33,7 @@ import kr.syeyoung.dungeonsguide.mod.features.RawRenderingGuiFeature;
import kr.syeyoung.dungeonsguide.mod.gui.MPanel;
import kr.syeyoung.dungeonsguide.mod.gui.elements.MFloatSelectionButton;
import kr.syeyoung.dungeonsguide.mod.gui.elements.MPassiveLabelAndElement;
-import kr.syeyoung.dungeonsguide.mod.guiv2.primitive.Rect;
+import kr.syeyoung.dungeonsguide.mod.overlay.GUIRectanglePositioner;
import kr.syeyoung.dungeonsguide.mod.overlay.OverlayManager;
import kr.syeyoung.dungeonsguide.mod.overlay.OverlayType;
import kr.syeyoung.dungeonsguide.mod.overlay.OverlayWidget;
@@ -199,11 +199,7 @@ public class FeatureMechanicBrowse extends RawRenderingGuiFeature {
OverlayManager.getInstance().removeOverlay(lastOpen);
widget = new OverlayWidget(
mechanicBrowser = new WidgetMechanicBrowser(dungeonRoomOpt.get()),
- OverlayType.OVER_CHAT,
- () -> {
- Rectangle loc = getFeatureRect().getRectangleNoScale();
- return new Rect(loc.x, loc.y, loc.width, loc.height);
- });
+ OverlayType.OVER_CHAT, new GUIRectanglePositioner(this::getFeatureRect));
}
}
if (mechanicBrowser != null)
diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/mechanicbrowser/WidgetSecret.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/mechanicbrowser/WidgetSecret.java
index 899f07f9..0642da1b 100644
--- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/mechanicbrowser/WidgetSecret.java
+++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/secret/mechanicbrowser/WidgetSecret.java
@@ -21,8 +21,8 @@ package kr.syeyoung.dungeonsguide.mod.features.impl.secret.mechanicbrowser;
import kr.syeyoung.dungeonsguide.dungeon.mechanics.dunegonmechanic.DungeonMechanic;
import kr.syeyoung.dungeonsguide.mod.dungeon.roomfinder.DungeonRoom;
import kr.syeyoung.dungeonsguide.mod.guiv2.BindableAttribute;
-import kr.syeyoung.dungeonsguide.mod.guiv2.elements.LocationedPopup;
-import kr.syeyoung.dungeonsguide.mod.guiv2.elements.PopupMgr;
+import kr.syeyoung.dungeonsguide.mod.guiv2.elements.popups.AbsLocationPopup;
+import kr.syeyoung.dungeonsguide.mod.guiv2.elements.popups.PopupMgr;
import kr.syeyoung.dungeonsguide.mod.guiv2.primitive.Rect;
import kr.syeyoung.dungeonsguide.mod.guiv2.xml.AnnotatedWidget;
import kr.syeyoung.dungeonsguide.mod.guiv2.xml.annotations.Bind;
@@ -54,14 +54,14 @@ public class WidgetSecret extends AnnotatedWidget {
this.onSelect = selectedId;
}
- private LocationedPopup popup;
+ private AbsLocationPopup popup;
@On(functionName = "toggleStates")
public void openStates() {
Rect abs = getDomElement().getAbsBounds();
double x = abs.getX() + abs.getWidth();
double y = abs.getY();
- if (x + 120 > Minecraft.getMinecraft().displayWidth)
+ if (!PopupMgr.getPopupMgr(getDomElement()).getDomElement().getAbsBounds().contains(x + 120 , y))
x = abs.getX() - 120;
@@ -69,7 +69,7 @@ public class WidgetSecret extends AnnotatedWidget {
if (popup == null) {
PopupMgr popupMgr = PopupMgr.getPopupMgr(getDomElement());
- popupMgr.openPopup(popup = new LocationedPopup(x, y, new WidgetStateTooltip(room, mechanic, id)), (val) -> {
+ popupMgr.openPopup(popup = new AbsLocationPopup(x, y, new WidgetStateTooltip(room, mechanic, id), true), (val) -> {
if (val == null)
onSelect.accept(null);
popup = null;
diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/text/TextHUDFeature.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/text/TextHUDFeature.java
index 34f76728..7debd1f0 100644
--- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/text/TextHUDFeature.java
+++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/text/TextHUDFeature.java
@@ -38,6 +38,7 @@ import kr.syeyoung.dungeonsguide.mod.guiv2.elements.richtext.BreakWord;
import kr.syeyoung.dungeonsguide.mod.guiv2.elements.richtext.RichText;
import kr.syeyoung.dungeonsguide.mod.guiv2.elements.richtext.TextSpan;
import kr.syeyoung.dungeonsguide.mod.guiv2.elements.richtext.styles.ParentDelegatingTextStyle;
+import kr.syeyoung.dungeonsguide.mod.overlay.GUIRectanglePositioner;
import kr.syeyoung.dungeonsguide.mod.overlay.OverlayType;
import kr.syeyoung.dungeonsguide.mod.overlay.OverlayWidget;
import net.minecraft.client.Minecraft;
@@ -50,7 +51,13 @@ public abstract class TextHUDFeature extends AbstractHUDFeature implements Style
protected TextHUDFeature(String category, String name, String description, String key, boolean keepRatio, int width, int height) {
super(category, name, description, key, keepRatio, width, height);
addParameter("textStylesNEW", new FeatureParameter<List<TextStyle>>("textStylesNEW", "", "", new ArrayList<TextStyle>(), "list_textStyle"));
- addParameter("alignment", new FeatureParameter<String>("alignment", "Alignment", "Alignment", "LEFT", "string"));
+ addParameter("alignment", new FeatureParameter<String>("alignment", "Alignment", "Alignment", "LEFT", "string", (change) -> {
+ richText.setAlign(
+ change.equals("LEFT") ? RichText.TextAlign.LEFT :
+ change.equals("CENTER") ? RichText.TextAlign.CENTER :
+ change.equals("RIGHT") ? RichText.TextAlign.RIGHT : RichText.TextAlign.LEFT
+ );
+ }));
addParameter("scale", new FeatureParameter<Float>("scale", "Scale", "Scale", 1.0f, "float"));
}
@@ -66,7 +73,7 @@ public abstract class TextHUDFeature extends AbstractHUDFeature implements Style
@Override
public OverlayWidget instantiateWidget() {
- return new OverlayWidget(richText, OverlayType.UNDER_CHAT, this::getWidgetPosition);
+ return new OverlayWidget(richText, OverlayType.UNDER_CHAT, new GUIRectanglePositioner(this::getFeatureRect));
}
private Map<String, ParentDelegatingTextStyle> builtTextStyles = new HashMap<>();
diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/elements/LocationedPopup.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/elements/popups/AbsLocationPopup.java
index 2ed260ab..06db01e2 100644
--- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/elements/LocationedPopup.java
+++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/elements/popups/AbsLocationPopup.java
@@ -16,16 +16,19 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
-package kr.syeyoung.dungeonsguide.mod.guiv2.elements;
+package kr.syeyoung.dungeonsguide.mod.guiv2.elements.popups;
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.xml.AnnotatedImportOnlyWidget;
import kr.syeyoung.dungeonsguide.mod.guiv2.xml.AnnotatedWidget;
import kr.syeyoung.dungeonsguide.mod.guiv2.xml.annotations.Bind;
+import kr.syeyoung.dungeonsguide.mod.guiv2.xml.annotations.Export;
import net.minecraft.util.ResourceLocation;
-public class LocationedPopup extends AnnotatedWidget {
+public class AbsLocationPopup extends AnnotatedImportOnlyWidget {
@Bind(variableName = "x")
public final BindableAttribute<Double> x = new BindableAttribute<>(Double.class);
@Bind(variableName = "y")
@@ -34,16 +37,49 @@ public class LocationedPopup extends AnnotatedWidget {
public final BindableAttribute<DomElement> ref = new BindableAttribute<>(DomElement.class);
@Bind(variableName = "child")
public final BindableAttribute<Widget> child = new BindableAttribute<>(Widget.class);
- public LocationedPopup(double x, double y, Widget child) {
+
+ public final BindableAttribute<Double> absX = new BindableAttribute<>(Double.class);
+ public final BindableAttribute<Double> absY = new BindableAttribute<>(Double.class);
+ public boolean autoclose = false;
+ public AbsLocationPopup(double x, double y, Widget child, boolean autoclose) {
super(new ResourceLocation("dungeonsguide:gui/elements/locationedPopup.gui"));
- this.x.setValue(x);
- this.y.setValue(y);
+ absX.setValue(x);
+ absY.setValue(y);
+ absX.addOnUpdate(this::updatePos);
+ absY.addOnUpdate(this::updatePos);
this.child.setValue(child);
+ this.autoclose = autoclose;
+ }
+ public AbsLocationPopup(BindableAttribute<Double> x, BindableAttribute<Double> y, Widget child, boolean autoclose) {
+ super(new ResourceLocation("dungeonsguide:gui/elements/locationedPopup.gui"));
+ x.exportTo(this.absX);
+ y.exportTo(this.absY);
+ absX.addOnUpdate(this::updatePos);
+ absY.addOnUpdate(this::updatePos);
+ this.child.setValue(child);
+ this.autoclose = autoclose;
+ }
+
+ @Override
+ public void onMount() {
+ updatePos(0,0);
+ }
+
+ public void updatePos(double old, double neu) {
+ PopupMgr popupMgr = PopupMgr.getPopupMgr(getDomElement());
+ Rect rect = popupMgr.getDomElement().getAbsBounds();
+ Rect rel = popupMgr.getDomElement().getRelativeBound();
+ this.x.setValue(
+ (absX.getValue() - rect.getX()) * rel.getWidth() / rect.getWidth()
+ );
+ this.y.setValue(
+ (absY.getValue() - rect.getY()) * rel.getHeight() / rect.getHeight()
+ );
}
@Override
public boolean mouseClicked(int absMouseX, int absMouseY, double relMouseX, double relMouseY, int mouseButton) {
- if (!ref.getValue().getAbsBounds().contains(absMouseX, absMouseY)) {
+ if (!ref.getValue().getAbsBounds().contains(absMouseX, absMouseY) && autoclose) {
PopupMgr.getPopupMgr(getDomElement()).closePopup(this,null);
}
return false;
diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/elements/MinecraftTooltip.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/elements/popups/MinecraftTooltip.java
index f445c52f..3206478a 100644
--- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/elements/MinecraftTooltip.java
+++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/elements/popups/MinecraftTooltip.java
@@ -16,7 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
-package kr.syeyoung.dungeonsguide.mod.guiv2.elements;
+package kr.syeyoung.dungeonsguide.mod.guiv2.elements.popups;
import kr.syeyoung.dungeonsguide.mod.guiv2.DomElement;
import kr.syeyoung.dungeonsguide.mod.guiv2.Widget;
@@ -52,7 +52,7 @@ public class MinecraftTooltip extends Widget implements Renderer, Layouter {
@Override
public void doRender(int absMouseX, int absMouseY, double relMouseX, double relMouseY, float partialTicks, RenderingContext context, DomElement buildContext) {
GuiUtils.drawHoveringText(tooltip,0,0,
- Minecraft.getMinecraft().displayWidth,
- Minecraft.getMinecraft().displayHeight, -1, Minecraft.getMinecraft().fontRendererObj);
+ (int) buildContext.getRelativeBound().getWidth(),
+ (int) buildContext.getRelativeBound().getHeight(), -1, Minecraft.getMinecraft().fontRendererObj);
}
}
diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/elements/MouseTooltip.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/elements/popups/MouseTooltip.java
index e065774e..7a9c2f37 100644
--- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/elements/MouseTooltip.java
+++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/elements/popups/MouseTooltip.java
@@ -16,7 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
-package kr.syeyoung.dungeonsguide.mod.guiv2.elements;
+package kr.syeyoung.dungeonsguide.mod.guiv2.elements.popups;
import kr.syeyoung.dungeonsguide.mod.guiv2.BindableAttribute;
import kr.syeyoung.dungeonsguide.mod.guiv2.DomElement;
@@ -24,21 +24,30 @@ import kr.syeyoung.dungeonsguide.mod.guiv2.Widget;
import kr.syeyoung.dungeonsguide.mod.guiv2.xml.AnnotatedWidget;
import kr.syeyoung.dungeonsguide.mod.guiv2.xml.annotations.Bind;
import net.minecraft.util.ResourceLocation;
+import org.lwjgl.input.Mouse;
-public class MouseTooltip extends AnnotatedWidget {
- @Bind(variableName = "x")
- public final BindableAttribute<Double> x = new BindableAttribute<>(Double.class);
- @Bind(variableName = "y")
- public final BindableAttribute<Double> y = new BindableAttribute<>(Double.class);;
- @Bind(variableName = "ref")
- public final BindableAttribute<DomElement> ref = new BindableAttribute<>(DomElement.class);
- @Bind(variableName = "child")
- public final BindableAttribute<Widget> child = new BindableAttribute<>(Widget.class);
- public MouseTooltip(double mouseX, double mouseY, Widget child) {
- super(new ResourceLocation("dungeonsguide:gui/elements/locationedPopup.gui"));
- this.x.setValue(mouseX);
- this.y.setValue(mouseY);
- this.child.setValue(child);
+import java.util.Collections;
+import java.util.List;
+
+public class MouseTooltip extends Widget {
+ private final AbsLocationPopup absLocationPopup;
+
+ private final BindableAttribute<Double> x = new BindableAttribute<>(Double.class, (double)Mouse.getX());
+ private final BindableAttribute<Double> y = new BindableAttribute<>(Double.class, (double)Mouse.getY());
+
+ public MouseTooltip(Widget content) {
+ absLocationPopup = new AbsLocationPopup(x,y, content, false);
+ }
+ @Override
+ public List<Widget> build(DomElement buildContext) {
+ return Collections.singletonList(absLocationPopup);
+ }
+
+ @Override
+ public void onUnmount() {
+ super.onUnmount();
+ x.unexportAll();
+ y.unexportAll();
}
@Override
diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/elements/PopupMgr.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/elements/popups/PopupMgr.java
index 7bfcffea..b67d2df3 100644
--- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/elements/PopupMgr.java
+++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/elements/popups/PopupMgr.java
@@ -1,6 +1,6 @@
/*
* Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod
- * Copyright (C) 2022 cyoung06 (syeyoung)
+ * Copyright (C) 2023 cyoung06 (syeyoung)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
@@ -16,7 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
-package kr.syeyoung.dungeonsguide.mod.guiv2.elements;
+package kr.syeyoung.dungeonsguide.mod.guiv2.elements.popups;
import kr.syeyoung.dungeonsguide.mod.guiv2.BindableAttribute;
import kr.syeyoung.dungeonsguide.mod.guiv2.DomElement;
@@ -49,6 +49,8 @@ public class PopupMgr extends AnnotatedWidget {
public void onMount() {
super.onMount();
getDomElement().getContext().CONTEXT.put("popup", this);
+ getDomElement().getContext().CONTEXT.put("popupWidth", this.getDomElement().getRelativeBound().getWidth());
+ getDomElement().getContext().CONTEXT.put("popupHeight", this.getDomElement().getRelativeBound().getHeight());
}
@Override
diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/view/TestPopup.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/view/TestPopup.java
index 4e420ad0..3a4a047f 100644
--- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/view/TestPopup.java
+++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/view/TestPopup.java
@@ -18,7 +18,7 @@
package kr.syeyoung.dungeonsguide.mod.guiv2.view;
-import kr.syeyoung.dungeonsguide.mod.guiv2.elements.PopupMgr;
+import kr.syeyoung.dungeonsguide.mod.guiv2.elements.popups.PopupMgr;
import kr.syeyoung.dungeonsguide.mod.guiv2.xml.AnnotatedImportOnlyWidget;
import kr.syeyoung.dungeonsguide.mod.guiv2.xml.annotations.On;
import net.minecraft.util.ResourceLocation;
diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/view/TestView.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/view/TestView.java
index 1a54a37f..d391f2dd 100644
--- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/view/TestView.java
+++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/view/TestView.java
@@ -19,7 +19,7 @@
package kr.syeyoung.dungeonsguide.mod.guiv2.view;
import kr.syeyoung.dungeonsguide.mod.guiv2.BindableAttribute;
-import kr.syeyoung.dungeonsguide.mod.guiv2.elements.PopupMgr;
+import kr.syeyoung.dungeonsguide.mod.guiv2.elements.popups.PopupMgr;
import kr.syeyoung.dungeonsguide.mod.guiv2.xml.AnnotatedImportOnlyWidget;
import kr.syeyoung.dungeonsguide.mod.guiv2.xml.annotations.Bind;
import kr.syeyoung.dungeonsguide.mod.guiv2.xml.annotations.On;
diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/xml/DomElementRegistry.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/xml/DomElementRegistry.java
index 8bc9b5a2..5cc22476 100644
--- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/xml/DomElementRegistry.java
+++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/xml/DomElementRegistry.java
@@ -22,6 +22,7 @@ import kr.syeyoung.dungeonsguide.mod.guiv2.Widget;
import kr.syeyoung.dungeonsguide.mod.guiv2.elements.*;
import kr.syeyoung.dungeonsguide.mod.guiv2.elements.image.ResourceImage;
import kr.syeyoung.dungeonsguide.mod.guiv2.elements.image.URLImage;
+import kr.syeyoung.dungeonsguide.mod.guiv2.elements.popups.PopupMgr;
import kr.syeyoung.dungeonsguide.mod.guiv2.view.TestView;
import kr.syeyoung.dungeonsguide.mod.guiv2.xml.data.Parser;
import kr.syeyoung.dungeonsguide.mod.guiv2.xml.data.ParserException;
diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/overlay/AbsPosPositioner.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/overlay/AbsPosPositioner.java
new file mode 100644
index 00000000..e82488be
--- /dev/null
+++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/overlay/AbsPosPositioner.java
@@ -0,0 +1,42 @@
+/*
+ * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod
+ * Copyright (C) 2023 cyoung06 (syeyoung)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published
+ * by the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+package kr.syeyoung.dungeonsguide.mod.overlay;
+
+import kr.syeyoung.dungeonsguide.mod.guiv2.DomElement;
+import kr.syeyoung.dungeonsguide.mod.guiv2.primitive.ConstraintBox;
+import kr.syeyoung.dungeonsguide.mod.guiv2.primitive.Rect;
+import kr.syeyoung.dungeonsguide.mod.guiv2.primitive.Size;
+import lombok.RequiredArgsConstructor;
+import net.minecraft.client.Minecraft;
+
+import java.util.function.Supplier;
+
+@RequiredArgsConstructor
+public class AbsPosPositioner implements Positioner {
+ public final double x, y;
+
+ @Override
+ public Rect position(DomElement domElement, double screenWidth, double screenHeight) {
+ double xScale = Minecraft.getMinecraft().displayWidth/screenWidth;
+ double yScale = Minecraft.getMinecraft().displayHeight /screenHeight;
+ Size size = domElement.getLayouter().layout(domElement,
+ new ConstraintBox(0, screenWidth-x, 0, screenHeight - y));
+ return new Rect(x / xScale, y/ yScale, size.getWidth(), size.getHeight());
+ }
+}
diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/overlay/GUIRectanglePositioner.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/overlay/GUIRectanglePositioner.java
new file mode 100644
index 00000000..55920c81
--- /dev/null
+++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/overlay/GUIRectanglePositioner.java
@@ -0,0 +1,63 @@
+/*
+ * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod
+ * Copyright (C) 2023 cyoung06 (syeyoung)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published
+ * by the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+package kr.syeyoung.dungeonsguide.mod.overlay;
+
+import kr.syeyoung.dungeonsguide.mod.config.types.GUIRectangle;
+import kr.syeyoung.dungeonsguide.mod.guiv2.DomElement;
+import kr.syeyoung.dungeonsguide.mod.guiv2.primitive.ConstraintBox;
+import kr.syeyoung.dungeonsguide.mod.guiv2.primitive.Rect;
+import kr.syeyoung.dungeonsguide.mod.guiv2.primitive.Size;
+import lombok.RequiredArgsConstructor;
+import net.minecraft.client.Minecraft;
+
+import java.awt.*;
+import java.util.function.Supplier;
+
+@RequiredArgsConstructor
+public class GUIRectanglePositioner implements Positioner {
+ public final Supplier<GUIRectangle> rectSupplier;
+
+ @Override
+ public Rect position(DomElement domElement, double screenWidth, double screenHeight) {
+ GUIRectangle posSize = rectSupplier.get();
+
+ double x = posSize.getX(), y = posSize.getY();
+ x = x * screenWidth / Minecraft.getMinecraft().displayWidth;
+ y = y * screenHeight / Minecraft.getMinecraft().displayHeight;
+ if (Math.abs(x) > screenWidth / 2) {
+ x = x < 0 ? -screenWidth/2 : screenWidth/2;
+ }
+ if (Math.abs(y) > screenHeight/ 2) {
+ y = y < 0 ? -screenHeight/2 : screenHeight/2;
+ }
+
+
+
+ double realX = (int) (x < 0 ? screenWidth + x : x);
+ double realY = (int) (y < 0 ? screenHeight + y : y);
+
+ Size size = domElement.getLayouter().layout(domElement,
+ new ConstraintBox(Math.abs(posSize.getWidth()),
+ Math.abs(posSize.getWidth()),
+ Math.abs(posSize.getHeight()),
+ Math.abs(posSize.getHeight())));
+ return new Rect(Math.min(realX + posSize.getWidth(), realX), Math.min(realY + posSize.getHeight(), realY),
+ Math.abs(posSize.getWidth()), Math.abs(posSize.getHeight()));
+ }
+}
diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/overlay/OverlayManager.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/overlay/OverlayManager.java
index 111a24bc..a7f6cd19 100644
--- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/overlay/OverlayManager.java
+++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/overlay/OverlayManager.java
@@ -19,7 +19,8 @@
package kr.syeyoung.dungeonsguide.mod.overlay;
import kr.syeyoung.dungeonsguide.mod.guiv2.RootDom;
-import kr.syeyoung.dungeonsguide.mod.guiv2.elements.PopupMgr;
+import kr.syeyoung.dungeonsguide.mod.guiv2.elements.Scaler;
+import kr.syeyoung.dungeonsguide.mod.guiv2.elements.popups.PopupMgr;
import kr.syeyoung.dungeonsguide.mod.guiv2.primitive.ConstraintBox;
import kr.syeyoung.dungeonsguide.mod.guiv2.primitive.Rect;
import kr.syeyoung.dungeonsguide.mod.guiv2.primitive.Size;
@@ -62,11 +63,19 @@ public class OverlayManager {
public static final String OVERLAY_TYPE_KEY = "OVERLAY_TYPE";
+ private Scaler scaler;
private OverlayManager() {
this.mc = Minecraft.getMinecraft();
+
PopupMgr popupMgr = new PopupMgr();
popupMgr.child.setValue(root);
- view = new RootDom(popupMgr);
+
+
+ scaler = new Scaler();
+ scaler.child.setValue(popupMgr);
+ scaler.scale.setValue((double) new ScaledResolution(Minecraft.getMinecraft()).getScaleFactor());
+
+ view = new RootDom(scaler);
guiResize(null);
view.setMounted(true);
}
@@ -74,6 +83,7 @@ public class OverlayManager {
@SubscribeEvent()
public void guiResize(GuiScreenEvent.InitGuiEvent.Post post){
try {
+ scaler.scale.setValue((double) new ScaledResolution(Minecraft.getMinecraft()).getScaleFactor());
view.setRelativeBound(new Rect(0,0, Minecraft.getMinecraft().displayWidth, Minecraft.getMinecraft().displayHeight));
view.setAbsBounds(new Rect(0,0, Minecraft.getMinecraft().displayWidth, Minecraft.getMinecraft().displayHeight));
view.setSize(new Size(Minecraft.getMinecraft().displayWidth, Minecraft.getMinecraft().displayHeight));
@@ -82,7 +92,7 @@ public class OverlayManager {
Minecraft.getMinecraft().displayWidth,
Minecraft.getMinecraft().displayHeight,
Minecraft.getMinecraft().displayHeight
- ));
+ ));
} catch (Exception e) {
e.printStackTrace();
}
diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/overlay/OverlayManagerRootWidget.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/overlay/OverlayManagerRootWidget.java
index ed5a259c..ae64f0aa 100644
--- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/overlay/OverlayManagerRootWidget.java
+++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/overlay/OverlayManagerRootWidget.java
@@ -44,9 +44,7 @@ public class OverlayManagerRootWidget extends Widget implements Layouter {
DomElement domElement = overlayWidget.createDomElement(getDomElement());
getDomElement().addElement(domElement);
- Rect posSize = overlayWidget.positionSize.get();
- Size size = domElement.getLayouter().layout(domElement, new ConstraintBox(posSize.getWidth(), posSize.getWidth(), posSize.getHeight(), posSize.getHeight()));
- domElement.setRelativeBound(new Rect(posSize.getX(), posSize.getY(), size.getWidth(), size.getHeight()));
+ updateOverlayPosition(overlayWidget);
}
public void removeOverlay(OverlayWidget widget) {
@@ -55,19 +53,19 @@ public class OverlayManagerRootWidget extends Widget implements Layouter {
public void updateOverlayPosition(OverlayWidget overlayWidget) {
DomElement domElement = overlayWidget.getDomElement();
- Rect posSize = overlayWidget.positionSize.get();
- Size size = domElement.getLayouter().layout(domElement, new ConstraintBox(posSize.getWidth(), posSize.getWidth(), posSize.getHeight(), posSize.getHeight()));
- domElement.setRelativeBound(new Rect(posSize.getX(), posSize.getY(), size.getWidth(), size.getHeight()));
+ Positioner positioner = overlayWidget.positionSize;
+ domElement.setRelativeBound(positioner.position(domElement, lastWidth, lastHeight));
}
+ private double lastWidth, lastHeight;
+
@Override
public Size layout(DomElement buildContext, ConstraintBox constraintBox) {
+ lastWidth = constraintBox.getMaxWidth();
+ lastHeight = constraintBox.getMaxHeight();
for (DomElement child : buildContext.getChildren()) {
if (!(child.getWidget() instanceof OverlayWidget)) continue;
-
- Rect posSize = ((OverlayWidget) child.getWidget()).positionSize.get();
- Size size = child.getLayouter().layout(child, new ConstraintBox(posSize.getWidth(), posSize.getWidth(), posSize.getHeight(), posSize.getHeight()));
- child.setRelativeBound(new Rect(posSize.getX(), posSize.getY(), size.getWidth(), size.getHeight()));
+ updateOverlayPosition((OverlayWidget) child.getWidget());
}
return new Size(constraintBox.getMaxWidth(), constraintBox.getMaxHeight());
diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/overlay/OverlayWidget.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/overlay/OverlayWidget.java
index 10a9b6de..920a9317 100644
--- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/overlay/OverlayWidget.java
+++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/overlay/OverlayWidget.java
@@ -38,7 +38,7 @@ import java.util.function.Supplier;
public class OverlayWidget extends Widget implements Renderer, Layouter {
public Widget wrappingWidget;
public OverlayType overlayType;
- public Supplier<Rect> positionSize;
+ public Positioner positionSize;
@Override
public List<Widget> build(DomElement buildContext) {
diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/overlay/Positioner.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/overlay/Positioner.java
new file mode 100644
index 00000000..6ee60388
--- /dev/null
+++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/overlay/Positioner.java
@@ -0,0 +1,27 @@
+/*
+ * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod
+ * Copyright (C) 2023 cyoung06 (syeyoung)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published
+ * by the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+package kr.syeyoung.dungeonsguide.mod.overlay;
+
+import kr.syeyoung.dungeonsguide.mod.guiv2.DomElement;
+import kr.syeyoung.dungeonsguide.mod.guiv2.primitive.Rect;
+import kr.syeyoung.dungeonsguide.mod.guiv2.primitive.Size;
+
+public interface Positioner {
+ Rect position(DomElement domElement, double screenWidth, double screenHeight);
+}
diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/overlay/WholeScreenPositioner.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/overlay/WholeScreenPositioner.java
new file mode 100644
index 00000000..5520748a
--- /dev/null
+++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/overlay/WholeScreenPositioner.java
@@ -0,0 +1,37 @@
+/*
+ * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod
+ * Copyright (C) 2023 cyoung06 (syeyoung)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published
+ * by the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+package kr.syeyoung.dungeonsguide.mod.overlay;
+
+import kr.syeyoung.dungeonsguide.mod.guiv2.DomElement;
+import kr.syeyoung.dungeonsguide.mod.guiv2.primitive.ConstraintBox;
+import kr.syeyoung.dungeonsguide.mod.guiv2.primitive.Rect;
+import kr.syeyoung.dungeonsguide.mod.guiv2.primitive.Size;
+import lombok.RequiredArgsConstructor;
+
+import java.util.function.Supplier;
+
+@RequiredArgsConstructor
+public class WholeScreenPositioner implements Positioner {
+ @Override
+ public Rect position(DomElement domElement, double screenWidth, double screenHeight) {
+ Size size = domElement.getLayouter().layout(domElement,
+ new ConstraintBox(screenWidth, screenWidth, screenHeight, screenHeight));
+ return new Rect(0,0, size.getWidth(), size.getHeight());
+ }
+}