aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rwxr-xr-xsrc/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/GuiGuiLocationConfig.java104
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/Marker.java46
-rwxr-xr-xsrc/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/PanelDefaultParameterConfig.java17
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/PanelDelegate.java283
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/config/types/GUIRectangle.java9
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/features/GuiFeature.java2
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRenderDungeonFloorStat.java7
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRenderDungeonHighestFloorStat.java7
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRendererClassLv.java7
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRendererDungeonLv.java6
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRendererSelectedClassLv.java6
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRendererSkillLv.java6
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/FeatureViewPlayerOnJoin.java27
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/FeatureMechanicBrowse.java18
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/gui/MPanel.java2
-rwxr-xr-xsrc/main/java/kr/syeyoung/dungeonsguide/gui/elements/MNavigatingPane.java1
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MTooltip.java5
-rwxr-xr-xsrc/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/RoomMatchDisplayPane.java17
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/stomp/StompPayload.java6
-rwxr-xr-xsrc/main/java/kr/syeyoung/dungeonsguide/utils/RenderUtils.java128
20 files changed, 483 insertions, 221 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/GuiGuiLocationConfig.java b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/GuiGuiLocationConfig.java
index 11dd2db2..2304378b 100755
--- a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/GuiGuiLocationConfig.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/GuiGuiLocationConfig.java
@@ -24,44 +24,110 @@ import kr.syeyoung.dungeonsguide.features.GuiFeature;
import kr.syeyoung.dungeonsguide.gui.MGui;
import kr.syeyoung.dungeonsguide.gui.MPanel;
import kr.syeyoung.dungeonsguide.gui.elements.MButton;
+import lombok.Getter;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.renderer.GlStateManager;
+import net.minecraft.util.Vec3;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;
import java.awt.*;
import java.io.IOException;
+import java.util.*;
+import java.util.List;
public class GuiGuiLocationConfig extends MGui {
private final GuiScreen before;
+ @Getter
+ private TreeMap<Integer, List<Marker>> markerTreeMapByX = new TreeMap<>();
+ @Getter
+ private TreeMap<Integer, List<Marker>> markerTreeMapByY = new TreeMap<>();
+ @Getter
+ private Set<Marker> markerSet = new HashSet<>();
+
+
+ Marker[] markers = new Marker[4];
+
+
public GuiGuiLocationConfig(final GuiScreen before, AbstractFeature featureWhitelist) {
this.before = before;
for (AbstractFeature feature : FeatureRegistry.getFeatureList()) {
if (feature instanceof GuiFeature && feature.isEnabled()) {
- getMainPanel().add(new PanelDelegate((GuiFeature) feature, featureWhitelist == null || feature == featureWhitelist));
+ getMainPanel().add(new PanelDelegate((GuiFeature) feature, featureWhitelist == null || feature == featureWhitelist, this));
}
}
- getMainPanel().setBackgroundColor(new Color(0,0,0, 60));
- {
- MButton button = new MButton() {
- @Override
- public void resize(int parentWidth, int parentHeight) {
- setBounds(new Rectangle(parentWidth-50,parentHeight-20,50,20));
+ getMainPanel().setBackgroundColor(new Color(0,0,0, 100));
+ }
+
+ public static final Vec3[] facing = new Vec3[] {
+ new Vec3(0, 0.5, 2),
+ new Vec3(0.5, 0, 1),
+ new Vec3(0.5, 1, 3),
+ new Vec3(1, 0.5, 4),
+ };
+
+ public void removeAndAddMarker(Marker prev, Marker newM) {
+ if (prev != null) {
+ markerTreeMapByX.computeIfPresent(prev.getX(),(k,v) -> {
+ v.remove(prev);
+ if (v.isEmpty()) return null;
+ else return v;
+ });
+ markerTreeMapByY.computeIfPresent(prev.getY(),(k,v) -> {
+ v.remove(prev);
+ if (v.isEmpty()) return null;
+ else return v;
+ });
+ markerSet.remove(prev);
+ }
+ if (newM != null) {
+ markerTreeMapByX.compute(newM.getX(), (k,v) -> {
+ if (v == null) {
+ return new ArrayList<>(Arrays.asList(newM));
+ } else {
+ v.add(newM);
+ return v;
}
- };
- button.setText("back");
- button.setOnActionPerformed(new Runnable() {
- @Override
- public void run() {
- Minecraft.getMinecraft().displayGuiScreen(before);
+ });
+ markerTreeMapByY.compute(newM.getY(), (k,v) -> {
+ if (v == null) {
+ return new ArrayList<>(Arrays.asList(newM));
+ } else {
+ v.add(newM);
+ return v;
}
});
- getMainPanel().add(button);
+ markerSet.add(newM);
+ }
+ }
+
+ public void setupMarkers() {
+ for (int i1 = 0; i1 < markers.length; i1++) {
+ Marker orig = markers[i1];
+ Vec3 pt = facing[i1];
+ markers[i1] = new Marker((int) (pt.xCoord * getMainPanel().getBounds().width), (int) (pt.yCoord * getMainPanel().getBounds().height), (int) pt.zCoord, this);
+
+ removeAndAddMarker(orig, markers[i1]);
+ }
+ }
+
+
+ @Override
+ public void keyTyped(char typedChar, int keyCode) throws IOException {
+ try {
+ getMainPanel().keyTyped0(typedChar, keyCode);
+
+ if (keyCode == 1) {
+ Minecraft.getMinecraft().displayGuiScreen(before);
+ }
+ } catch (Throwable e) {
+ if (!e.getMessage().contains("hack to stop"))
+ e.printStackTrace();
}
}
@@ -69,6 +135,16 @@ public class GuiGuiLocationConfig extends MGui {
public void initGui() {
super.initGui();
getMainPanel().setBounds(new Rectangle(0,0,Minecraft.getMinecraft().displayWidth,Minecraft.getMinecraft().displayHeight));
+ markerTreeMapByX.clear();
+ markerTreeMapByY.clear();
+ markerSet.clear();
+ setupMarkers();
+ for (MPanel childComponent : getMainPanel().getChildComponents()) {
+ if (childComponent instanceof PanelDelegate) {
+ ((PanelDelegate) childComponent).rebuildMarker();
+ }
+ }
+
}
}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/Marker.java b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/Marker.java
new file mode 100644
index 00000000..27ced7ee
--- /dev/null
+++ b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/Marker.java
@@ -0,0 +1,46 @@
+/*
+ * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod
+ * Copyright (C) 2021 cyoung06
+ *
+ * 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.config.guiconfig;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.Getter;
+import lombok.ToString;
+
+@Getter
+@ToString
+@AllArgsConstructor
+public class Marker {
+ private final int x;
+ private final int y;
+ /**
+ * 0xABCDEFGH
+ * A: ?
+ * B: ?
+ * C: ?
+ * D: ?
+ * EF: 0~3 (TC 0x00 CL 0x01 BC 0x10 CR 0x11)
+ */
+ private final int type;
+ private final Object parent;
+
+ public int distanceSQ(Marker m2) {
+ return (m2.x - x)*(m2.x - x) + (m2.y - y)*(m2.y - y);
+ }
+}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/PanelDefaultParameterConfig.java b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/PanelDefaultParameterConfig.java
index 0af9e2f0..a38f1a06 100755
--- a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/PanelDefaultParameterConfig.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/PanelDefaultParameterConfig.java
@@ -22,6 +22,8 @@ import kr.syeyoung.dungeonsguide.features.AbstractFeature;
import kr.syeyoung.dungeonsguide.features.FeatureParameter;
import kr.syeyoung.dungeonsguide.gui.MPanel;
import kr.syeyoung.dungeonsguide.gui.elements.MButton;
+import kr.syeyoung.dungeonsguide.gui.elements.MTooltip;
+import kr.syeyoung.dungeonsguide.gui.elements.MTooltipText;
import kr.syeyoung.dungeonsguide.utils.RenderUtils;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
@@ -68,6 +70,8 @@ public class PanelDefaultParameterConfig extends MPanel {
MPanel within;
+ MTooltip mTooltip;
+ MParameter lastWithin;
@Override
public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) {
int heights = 0;
@@ -80,9 +84,16 @@ public class PanelDefaultParameterConfig extends MPanel {
}
if (within instanceof MParameter) {
FeatureParameter feature = ((MParameter) within).getParameter();
- GL11.glDisable(GL11.GL_SCISSOR_TEST);
- RenderUtils.drawHoveringText(new ArrayList<String>(Arrays.asList(feature.getDescription().split("\n"))), relMousex0,relMousey0, Minecraft.getMinecraft().fontRendererObj);
- GL11.glEnable(GL11.GL_SCISSOR_TEST);
+ if (lastWithin != within) {
+ if (mTooltip != null) mTooltip.close();
+ mTooltip = new MTooltipText(Arrays.asList(feature.getDescription().split("\n")));
+ mTooltip.open(this);
+ }
+ } else {
+ if (mTooltip != null) {
+ mTooltip.close();
+ mTooltip = null;
+ }
}
}
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 7abb54b9..4e107766 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/PanelDelegate.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/PanelDelegate.java
@@ -23,18 +23,38 @@ import kr.syeyoung.dungeonsguide.features.GuiFeature;
import kr.syeyoung.dungeonsguide.gui.MPanel;
import kr.syeyoung.dungeonsguide.utils.RenderUtils;
import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.renderer.GlStateManager;
+import net.minecraft.client.renderer.Tessellator;
+import net.minecraft.client.renderer.WorldRenderer;
+import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
+import net.minecraft.util.EnumFacing;
+import net.minecraft.util.Tuple;
+import net.minecraft.util.Vec3;
+import org.lwjgl.opengl.GL11;
import java.awt.*;
+import java.util.*;
+import java.util.List;
+import java.util.stream.Stream;
public class PanelDelegate extends MPanel {
private final GuiFeature guiFeature;
private boolean draggable = false;
- public PanelDelegate(GuiFeature guiFeature, boolean draggable) {
+ private GuiGuiLocationConfig guiGuiLocationConfig;
+
+ private Set<Marker> markerSet = new HashSet<>();
+ public PanelDelegate(GuiFeature guiFeature, boolean draggable, GuiGuiLocationConfig guiGuiLocationConfig) {
this.guiFeature = guiFeature;
this.draggable = draggable;
+ this.guiGuiLocationConfig = guiGuiLocationConfig;
+ }
+
+ public void rebuildMarker() {
+ internallyThinking = guiFeature.getFeatureRect().getRectangleNoScale();
+ applyConstraint();
}
@Override
@@ -70,6 +90,43 @@ public class PanelDelegate extends MPanel {
GlStateManager.enableBlend();
}
+ @Override
+ public void render0(ScaledResolution resolution, Point parentPoint, Rectangle parentClip, int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks) {
+ if (selectedPart != -2) {
+ Gui.drawRect(internallyThinking.x, internallyThinking.y, internallyThinking.x + internallyThinking.width, internallyThinking.y + internallyThinking.height, 0xFF000000);
+ FontRenderer fontRenderer = Minecraft.getMinecraft().fontRendererObj;
+ fontRenderer.drawString(internallyThinking.width + "x"+internallyThinking.height, internallyThinking.x, internallyThinking.y, 0xFFFFFFFF);
+ }
+
+ GlStateManager.pushMatrix();
+ super.render0(resolution, parentPoint, parentClip, absMousex, absMousey, relMousex0, relMousey0, partialTicks);
+ GlStateManager.popMatrix();
+
+ if (snapped != null && selectedPart != -2) {
+ Tessellator tessellator = Tessellator.getInstance();
+ GlStateManager.disableTexture2D();
+ WorldRenderer worldRenderer = tessellator.getWorldRenderer();
+ worldRenderer.begin(GL11.GL_LINES, DefaultVertexFormats.POSITION_COLOR);
+ GL11.glLineWidth(1);
+ for (Tuple<Marker[], EnumFacing.Axis> markerAxisTuple : snapped) {
+// worldRenderer.pos(markerAxisTuple.getFirst()[0].getX(), markerAxisTuple.getFirst()[0].getY(), 0).color(255,255,255,255).endVertex();
+// worldRenderer.pos(markerAxisTuple.getFirst()[1].getX(), markerAxisTuple.getFirst()[1].getY(), 0).color(255,255,255,255).endVertex();
+
+ if (markerAxisTuple.getSecond() == EnumFacing.Axis.X) {
+ worldRenderer.pos(markerAxisTuple.getFirst()[0].getX(), 0, 0).color(0,255,0,255).endVertex();
+ worldRenderer.pos(markerAxisTuple.getFirst()[0].getX(), Minecraft.getMinecraft().displayHeight, 0).color(0,255,0,255).endVertex();
+ } else {
+ worldRenderer.pos(0, markerAxisTuple.getFirst()[0].getY(), 0).color(0,255,0,255).endVertex();
+ worldRenderer.pos(Minecraft.getMinecraft().displayWidth, markerAxisTuple.getFirst()[0].getY(), 0).color(0,255,0,255).endVertex();
+ }
+ }
+ tessellator.draw();
+ for (Marker marker : guiGuiLocationConfig.getMarkerSet()) {
+ Gui.drawRect(marker.getX(),marker.getY(), marker.getX()+1, marker.getY()+1, 0xFFFF0000);
+ }
+ }
+ }
+
private int selectedPart = -2;
private int lastX = 0;
@@ -78,77 +135,187 @@ public class PanelDelegate extends MPanel {
private Rectangle internallyThinking;
private Rectangle constraintApplied;
+ private Set<Tuple<Marker[], EnumFacing.Axis>> snapped = new HashSet<>();
+
public void applyConstraint() {
- Rectangle rectangle = internallyThinking.getBounds();
-
- int minWidth;
- int minHeight;
- if (guiFeature.isKeepRatio()) {
- minHeight = (int) Math.max(8, 8 / guiFeature.getDefaultRatio());
- minWidth = (int) (guiFeature.getDefaultRatio() * minHeight);
- } else {
- minWidth = 8;
- minHeight = 8;
- }
+ constraintApplied = internallyThinking.getBounds();
- if (Math.abs(rectangle.width) < minWidth) rectangle.width = rectangle.width < 0 ? -minWidth : minWidth;
- if (Math.abs(rectangle.height) < minHeight) rectangle.height = rectangle.height < 0 ? -minHeight : minHeight;
+ // SNAP Moving Point.
+ snapped.clear();
+ int scailingThreshold = 5;
+ if (selectedPart == 0){
+ Point snapPt = new Point(constraintApplied.x +constraintApplied.width, constraintApplied.y + constraintApplied.height);
+ Optional<Marker> snapX, snapY;
+ SortedMap<Integer, List<Marker>> markerSortedMap = guiGuiLocationConfig.getMarkerTreeMapByX().subMap(snapPt.x-scailingThreshold, snapPt.x +scailingThreshold);
+ snapX = markerSortedMap.values().stream()
+ .filter(Objects::nonNull)
+ .flatMap(Collection::stream)
+ .filter(a -> a.getParent() != this)
+ .min(Comparator.comparingInt(a -> (int) snapPt.distanceSq(a.getX(), a.getY())));
+ markerSortedMap = guiGuiLocationConfig.getMarkerTreeMapByY().subMap(snapPt.y-scailingThreshold, snapPt.y +scailingThreshold);
+ snapY = markerSortedMap.values().stream()
+ .filter(Objects::nonNull)
+ .flatMap(Collection::stream)
+ .filter(a -> a.getParent() != this)
+ .min(Comparator.comparingInt(a -> (int) snapPt.distanceSq(a.getX(), a.getY())));
+ snapX.ifPresent(a -> {
+ snapPt.x = a.getX();
+ });
+ snapY.ifPresent(a -> {
+ snapPt.y = a.getY();
+ });
- if (guiFeature.isKeepRatio()) {
- double ratio = guiFeature.getDefaultRatio();
+ constraintApplied = new Rectangle(constraintApplied.x, constraintApplied.y, snapPt.x - constraintApplied.x, snapPt.y - constraintApplied.y);
- if (ratio >= 1) {
- int width1 = Math.abs(rectangle.width);
- int height1 = (int) (width1 / ratio);
- rectangle.width = rectangle.width < 0 ? -width1 : width1;
- rectangle.height = rectangle.height < 0 ? -height1 : height1;
+
+
+ int minWidth;
+ int minHeight;
+ if (guiFeature.isKeepRatio()) {
+ if (guiFeature.getDefaultRatio() >= 1) {
+ minHeight = constraintApplied.height < 0 ? -8 : 8;
+ minWidth = (int) (guiFeature.getDefaultRatio() * minHeight);
+ } else {
+ minWidth = constraintApplied.width < 0 ? -8 : 8;
+ minHeight = (int) (minWidth / guiFeature.getDefaultRatio());
+ }
} else {
- int width2 = (int) Math.abs(rectangle.height * ratio);
- int height2 = Math.abs(rectangle.height);
- rectangle.width = rectangle.width < 0 ? -width2 : width2;
- rectangle.height = rectangle.height < 0 ? -height2 : height2;
+ minWidth = constraintApplied.width < 0 ? -8 : 8;
+ minHeight = constraintApplied.height < 0 ? -8 : 8;
}
- }
- if (rectangle.height < 0) {
- rectangle.height = -rectangle.height;
- rectangle.y -= rectangle.height;
- }
- if (rectangle.width < 0) {
- rectangle.width = -rectangle.width;
- rectangle.x -= rectangle.width;
+ constraintApplied.width = Math.abs(constraintApplied.width) > Math.abs(minWidth) ? constraintApplied.width :
+ Math.abs(internallyThinking.width) > Math.abs(minWidth) ? internallyThinking.width : minWidth;
+ constraintApplied.height = Math.abs(constraintApplied.height) > Math.abs(minHeight) ? constraintApplied.height :
+ Math.abs(internallyThinking.height) > Math.abs(minHeight) ? internallyThinking.height : minHeight;
+
+ if (guiFeature.isKeepRatio()) {
+ double ratio = guiFeature.getDefaultRatio();
+
+ int heightWhenWidthFix = (int) Math.abs(constraintApplied.width / ratio);
+ int widthWhenHeightFix = (int) Math.abs(ratio * constraintApplied.height);
+ if (Math.abs(heightWhenWidthFix) <= Math.abs(constraintApplied.height)) {
+ constraintApplied.height = constraintApplied.height < 0 ? -heightWhenWidthFix : heightWhenWidthFix;
+ } else if (Math.abs(widthWhenHeightFix) <= Math.abs(constraintApplied.width)) {
+ constraintApplied.width =constraintApplied.width < 0 ? - widthWhenHeightFix : widthWhenHeightFix;
+ }
+ }
+
+
+ snapX.ifPresent(a -> {
+ if (snapPt.x - constraintApplied.x == constraintApplied.width) {
+ Marker m = new Marker((int) (GuiGuiLocationConfig.facing[3].xCoord * constraintApplied.width) + constraintApplied.x, (int) (GuiGuiLocationConfig.facing[3].yCoord * constraintApplied.height) + constraintApplied.y, (int) GuiGuiLocationConfig.facing[3].zCoord, this);
+ snapped.add(new Tuple<>(new Marker[]{a, m}, EnumFacing.Axis.X));
+ }
+ });
+ snapY.ifPresent(a -> {
+ if (snapPt.y - constraintApplied.y == constraintApplied.height) {
+ Marker m = new Marker((int) (GuiGuiLocationConfig.facing[2].xCoord * constraintApplied.width) + constraintApplied.x, (int) (GuiGuiLocationConfig.facing[2].yCoord * constraintApplied.height) + constraintApplied.y, (int) GuiGuiLocationConfig.facing[2].zCoord, this);
+ snapped.add(new Tuple<>(new Marker[]{a, m}, EnumFacing.Axis.Y));
+ }
+ });
+
+ if (constraintApplied.height < 0) {
+ constraintApplied.height = -constraintApplied.height;
+ constraintApplied.y -= constraintApplied.height;
+ }
+
+ if (constraintApplied.width < 0) {
+ constraintApplied.width = -constraintApplied.width;
+ constraintApplied.x -= constraintApplied.width;
+ }
+ } else if (selectedPart == -1) {
+ for (int i : Arrays.asList(0,3,1,2)) {
+ Vec3 pt = GuiGuiLocationConfig.facing[i];
+ Marker m = new Marker((int) (pt.xCoord * constraintApplied.width) + constraintApplied.x, (int) (pt.yCoord * constraintApplied.height) + constraintApplied.y, (int) pt.zCoord, this);
+ Optional<Marker> result = guiGuiLocationConfig.getMarkerTreeMapByX().subMap(m.getX()-scailingThreshold, m.getX() +scailingThreshold).values().stream()
+ .filter(Objects::nonNull)
+ .flatMap(Collection::stream)
+ .filter(a -> a.getParent() != this)
+ .filter(a -> Math.abs(a.getX() - m.getX()) < scailingThreshold)
+ .filter(a -> ((a.getX() - pt.xCoord * constraintApplied.width) >= 0
+ && (a.getX() - pt.xCoord * constraintApplied.width + constraintApplied.width) <= Minecraft.getMinecraft().displayWidth))
+ .min(Comparator.comparingInt(a -> a.distanceSQ(m)));
+ if (result.isPresent()) {
+ int x = result.get().getX();
+ constraintApplied.x = (int) (x - pt.xCoord * constraintApplied.width);
+
+ snapped.add(new Tuple<>(new Marker[] {result.get(), m}, EnumFacing.Axis.X));
+ break;
+ }
+ }
+ for (int i : Arrays.asList(1,2,0,3)) {
+ Vec3 pt = GuiGuiLocationConfig.facing[i];
+ Marker m = new Marker((int) (pt.xCoord * constraintApplied.width) + constraintApplied.x, (int) (pt.yCoord * constraintApplied.height) + constraintApplied.y, (int) pt.zCoord, this);
+ Optional<Marker> result = guiGuiLocationConfig.getMarkerTreeMapByY().subMap(m.getY()-scailingThreshold, m.getY() +scailingThreshold).values().stream()
+ .filter(Objects::nonNull)
+ .flatMap(Collection::stream)
+ .filter(a -> a.getParent() != this)
+ .filter(a -> Math.abs(a.getY() - m.getY()) < scailingThreshold)
+ .filter(a -> ((a.getY() - pt.yCoord * constraintApplied.height) >= 0
+ && (a.getY() - pt.yCoord * constraintApplied.height+ constraintApplied.height) <= Minecraft.getMinecraft().displayHeight))
+ .min(Comparator.comparingInt(a -> a.distanceSQ(m)));
+ if (result.isPresent()) {
+ int y = result.get().getY();
+ constraintApplied.y = (int) (y - pt.yCoord * constraintApplied.height);
+ snapped.add(new Tuple<>(new Marker[] {result.get(), m}, EnumFacing.Axis.Y));
+ break;
+ }
+ }
}
- if (rectangle.x < 0) rectangle.x = 0;
- if (rectangle.y < 0) rectangle.y = 0;
- if (rectangle.x + rectangle.width + 1 >=Minecraft.getMinecraft().displayWidth) rectangle.x = Minecraft.getMinecraft().displayWidth - rectangle.width - 1;
- if (rectangle.y + rectangle.height + 1>= Minecraft.getMinecraft().displayHeight) rectangle.y = Minecraft.getMinecraft().displayHeight - rectangle.height - 1;
+ if (constraintApplied.x < 0) constraintApplied.x = 0;
+ if (constraintApplied.y < 0) constraintApplied.y = 0;
+ if (constraintApplied.x + constraintApplied.width + 1 >=Minecraft.getMinecraft().displayWidth) constraintApplied.x = Minecraft.getMinecraft().displayWidth - constraintApplied.width - 1;
+ if (constraintApplied.y + constraintApplied.height + 1>= Minecraft.getMinecraft().displayHeight) constraintApplied.y = Minecraft.getMinecraft().displayHeight - constraintApplied.height - 1;
+
+
+ setupMarkers();
+ }
+
+ Marker[] markers = new Marker[4];
+ public void setupMarkers() {
+ for (int i1 = 0; i1 < markers.length; i1++) {
+ Marker orig = markers[i1];
+ Vec3 pt = GuiGuiLocationConfig.facing[i1];
+ markers[i1] = new Marker((int) (pt.xCoord * constraintApplied.width) + constraintApplied.x, (int) (pt.yCoord * constraintApplied.height) + constraintApplied.y, (int) pt.zCoord, this);
- constraintApplied = rectangle;
+ guiGuiLocationConfig.removeAndAddMarker(orig, markers[i1]);
+ }
}
@Override
public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) {
if (!draggable) return;
if (!lastAbsClip.contains(absMouseX, absMouseY)) return;
- if (relMouseX < 4 && relMouseY < 4) {
- selectedPart = 0;
- } else if (relMouseX < 4 && relMouseY > getBounds().height - 4) {
- selectedPart = 2;
- } else if (relMouseX > getBounds().width - 4 && relMouseY > getBounds().height - 4) {
- selectedPart = 3;
- } else if (relMouseX > getBounds().width - 4 && relMouseY < 4) {
- selectedPart = 1;
- } else {
- selectedPart = -1;
- }
- lastX = absMouseX;
- lastY = absMouseY;
- internallyThinking = guiFeature.getFeatureRect().getRectangleNoScale();
- applyConstraint();
+ if (mouseButton == 0) {
+ internallyThinking = guiFeature.getFeatureRect().getRectangleNoScale();
+ if (relMouseX < 4 && relMouseY < 4) { // TL
+ selectedPart = 0;
+ internallyThinking.y += internallyThinking.height;
+ internallyThinking.height = -internallyThinking.height;
+ internallyThinking.x += internallyThinking.width;
+ internallyThinking.width = -internallyThinking.width;
+ } else if (relMouseX < 4 && relMouseY > getBounds().height - 4) { // BL
+ selectedPart = 0;
+ internallyThinking.x += internallyThinking.width;
+ internallyThinking.width = -internallyThinking.width;
+ } else if (relMouseX > getBounds().width - 4 && relMouseY > getBounds().height - 4) { // BR
+ selectedPart = 0;
+ } else if (relMouseX > getBounds().width - 4 && relMouseY < 4) { // TR
+ selectedPart = 0;
+ internallyThinking.y += internallyThinking.height;
+ internallyThinking.height = -internallyThinking.height;
+ } else {
+ selectedPart = -1;
+ }
+ lastX = absMouseX;
+ lastY = absMouseY;
+ applyConstraint();
+ }
throw new IllegalArgumentException("bruh, a hack to stop event progress");
}
@@ -170,25 +337,19 @@ public class PanelDelegate extends MPanel {
if (selectedPart >= 0) {
Rectangle rectangle = internallyThinking;
- boolean revChangeX = (selectedPart & 0x1) == 0;
- boolean revChangeY = (selectedPart & 0x2) == 0;
int prevWidth = rectangle.width;
int prevHeight= rectangle.height;
- rectangle.width = prevWidth + (revChangeX ? -1 : 1) * dx;
- rectangle.height = prevHeight + (revChangeY ? -1 : 1 ) * dy;
+ rectangle.width = prevWidth + dx;
+ rectangle.height = prevHeight + dy;
if (rectangle.height * prevHeight <= 0 && prevHeight != rectangle.height) {
- System.out.println("Flip!");
rectangle.height += prevHeight < 0 ? 4 : -4;
}
if (rectangle.width * prevWidth <= 0 && prevWidth != rectangle.width) {
- System.out.println("Flip!");
rectangle.width += prevWidth < 0 ? 4 : -4;
}
- if (revChangeX) rectangle.x -= (rectangle.width - prevWidth );
- if (revChangeY) rectangle.y -= (rectangle.height - prevHeight);
applyConstraint();
guiFeature.setFeatureRect(new GUIRectangle(constraintApplied));
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 c4fa75d2..1c129d2e 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/config/types/GUIRectangle.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/config/types/GUIRectangle.java
@@ -64,6 +64,15 @@ public class GUIRectangle {
// (int)Math.abs(width), (int)Math.abs(height));
// }
public Rectangle getRectangleNoScale() {
+ int x = this.x, y = this.y;
+ if (Math.abs(x) > Minecraft.getMinecraft().displayWidth / 2) {
+ x = x < 0 ? -Minecraft.getMinecraft().displayWidth/2 : Minecraft.getMinecraft().displayWidth/2;
+ }
+ if (Math.abs(y) > Minecraft.getMinecraft().displayHeight / 2) {
+ y = y < 0 ? -Minecraft.getMinecraft().displayHeight/2 : Minecraft.getMinecraft().displayHeight/2;
+ }
+
+
double realX = (int) (x < 0 ? Minecraft.getMinecraft().displayWidth + x : x);
double realY = (int) (y < 0 ? Minecraft.getMinecraft().displayHeight + y : y);
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/GuiFeature.java b/src/main/java/kr/syeyoung/dungeonsguide/features/GuiFeature.java
index e195a7d9..6e82add5 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/features/GuiFeature.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/features/GuiFeature.java
@@ -64,6 +64,8 @@ public abstract class GuiFeature extends AbstractFeature implements ScreenRender
GlStateManager.pushAttrib();
GlStateManager.pushMatrix();
Rectangle featureRect = this.featureRect.getRectangleNoScale();
+ ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
+ GlStateManager.translate(1.0/scaledResolution.getScaleFactor(), 1.0/scaledResolution.getScaleFactor(), 1);
clip(featureRect.x, featureRect.y, featureRect.width, featureRect.height);
GL11.glEnable(GL11.GL_SCISSOR_TEST);
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRenderDungeonFloorStat.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRenderDungeonFloorStat.java
index 2cd81c5e..8f10f146 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRenderDungeonFloorStat.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRenderDungeonFloorStat.java
@@ -24,6 +24,8 @@ import kr.syeyoung.dungeonsguide.utils.RenderUtils;
import kr.syeyoung.dungeonsguide.utils.TextUtils;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
+import net.minecraft.client.gui.ScaledResolution;
+import net.minecraftforge.fml.client.config.GuiUtils;
import java.awt.*;
import java.util.Arrays;
@@ -83,7 +85,8 @@ public class DataRenderDungeonFloorStat implements DataRenderer {
if (playedFloorFloorSpecificData == null) return;
String floorName = (dungeonType == DungeonType.CATACOMBS ? "F" : "M") + floor;
- RenderUtils.drawHoveringText(Arrays.asList(
+ ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
+ GuiUtils.drawHoveringText(Arrays.asList(
"§bFloor "+floorName,
"§bBest Score§7: §f"+playedFloorFloorSpecificData.getData().getBestScore(),
"§bTotal Completions§7: §f"+playedFloorFloorSpecificData.getData().getCompletions(),
@@ -94,6 +97,6 @@ public class DataRenderDungeonFloorStat implements DataRenderer {
"§bFastest Run§7: §f"+(playedFloorFloorSpecificData.getData().getFastestTime() != -1? TextUtils.formatTime(playedFloorFloorSpecificData.getData().getFastestTime()) : "N/A"),
"§bMost Mobs Killed§7: §f"+playedFloorFloorSpecificData.getData().getMostMobsKilled(),
"§bTotal Mobs Killed§7: §f"+playedFloorFloorSpecificData.getData().getMobsKilled()
- ), mouseX, mouseY, Minecraft.getMinecraft().fontRendererObj);
+ ), mouseX, mouseY, scaledResolution.getScaledWidth(), scaledResolution.getScaledHeight(), -1, Minecraft.getMinecraft().fontRendererObj);
}
}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRenderDungeonHighestFloorStat.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRenderDungeonHighestFloorStat.java
index 44271143..58327fcf 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRenderDungeonHighestFloorStat.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRenderDungeonHighestFloorStat.java
@@ -24,6 +24,8 @@ import kr.syeyoung.dungeonsguide.utils.RenderUtils;
import kr.syeyoung.dungeonsguide.utils.TextUtils;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
+import net.minecraft.client.gui.ScaledResolution;
+import net.minecraftforge.fml.client.config.GuiUtils;
import java.awt.*;
import java.util.Arrays;
@@ -85,7 +87,8 @@ public class DataRenderDungeonHighestFloorStat implements DataRenderer {
if (playedFloorFloorSpecificData == null) return;
String floorName = (dungeonType == DungeonType.CATACOMBS ? "F" : "M") + dungeonStatDungeonSpecificData.getData().getHighestCompleted();
- RenderUtils.drawHoveringText(Arrays.asList(
+ ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
+ GuiUtils.drawHoveringText(Arrays.asList(
"§bFloor "+floorName,
"§bBest Score§7: §f"+playedFloorFloorSpecificData.getData().getBestScore(),
"§bTotal Completions§7: §f"+playedFloorFloorSpecificData.getData().getCompletions(),
@@ -96,6 +99,6 @@ public class DataRenderDungeonHighestFloorStat implements DataRenderer {
"§bFastest Run§7: §f"+(playedFloorFloorSpecificData.getData().getFastestTime() != -1? TextUtils.formatTime(playedFloorFloorSpecificData.getData().getFastestTime()) : "N/A"),
"§bMost Mobs Killed§7: §f"+playedFloorFloorSpecificData.getData().getMostMobsKilled(),
"§bTotal Mobs Killed§7: §f"+playedFloorFloorSpecificData.getData().getMobsKilled()
- ), mouseX, mouseY, Minecraft.getMinecraft().fontRendererObj);
+ ), mouseX, mouseY, scaledResolution.getScaledWidth(), scaledResolution.getScaledHeight(), -1, Minecraft.getMinecraft().fontRendererObj);
}
}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRendererClassLv.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRendererClassLv.java
index 459e3ceb..cc6589de 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRendererClassLv.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRendererClassLv.java
@@ -25,6 +25,8 @@ import kr.syeyoung.dungeonsguide.utils.TextUtils;
import kr.syeyoung.dungeonsguide.utils.XPUtils;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
+import net.minecraft.client.gui.ScaledResolution;
+import net.minecraftforge.fml.client.config.GuiUtils;
import java.awt.*;
import java.util.Arrays;
@@ -77,6 +79,9 @@ public class DataRendererClassLv implements DataRenderer {
ClassSpecificData<PlayerProfile.PlayerClassData> dungeonStatDungeonSpecificData = playerProfile.getPlayerClassData().get(dungeonClass);
if (dungeonStatDungeonSpecificData == null) return;
XPUtils.XPCalcResult xpCalcResult = XPUtils.getCataXp(dungeonStatDungeonSpecificData.getData().getExperience());
- RenderUtils.drawHoveringText(Arrays.asList("§bCurrent Lv§7: §e"+xpCalcResult.getLevel(),"§bExp§7: §e"+ TextUtils.format((long)xpCalcResult.getRemainingXp()) + "§7/§e"+TextUtils.format((long)xpCalcResult.getNextLvXp()), "§bTotal Xp§7: §e"+ TextUtils.format((long)dungeonStatDungeonSpecificData.getData().getExperience())),mouseX, mouseY, Minecraft.getMinecraft().fontRendererObj);
+ ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
+
+ GuiUtils.drawHoveringText(Arrays.asList("§bCurrent Lv§7: §e"+xpCalcResult.getLevel(),"§bExp§7: §e"+ TextUtils.format((long)xpCalcResult.getRemainingXp()) + "§7/§e"+TextUtils.format((long)xpCalcResult.getNextLvXp()), "§bTotal Xp§7: §e"+ TextUtils.format((long)dungeonStatDungeonSpecificData.getData().getExperience())),mouseX, mouseY,
+ scaledResolution.getScaledWidth(), scaledResolution.getScaledHeight(), -1, Minecraft.getMinecraft().fontRendererObj);
}
}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRendererDungeonLv.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRendererDungeonLv.java
index 0dccb1a8..b9c16e13 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRendererDungeonLv.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRendererDungeonLv.java
@@ -28,6 +28,8 @@ import kr.syeyoung.dungeonsguide.utils.TextUtils;
import kr.syeyoung.dungeonsguide.utils.XPUtils;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
+import net.minecraft.client.gui.ScaledResolution;
+import net.minecraftforge.fml.client.config.GuiUtils;
import java.awt.*;
import java.util.Arrays;
@@ -73,6 +75,8 @@ public class DataRendererDungeonLv implements DataRenderer {
DungeonSpecificData<DungeonStat> dungeonStatDungeonSpecificData = playerProfile.getDungeonStats().get(dungeonType);
if (dungeonStatDungeonSpecificData == null) return;
XPUtils.XPCalcResult xpCalcResult = XPUtils.getCataXp(dungeonStatDungeonSpecificData.getData().getExperience());
- RenderUtils.drawHoveringText(Arrays.asList("§bCurrent Lv§7: §e"+xpCalcResult.getLevel(),"§bExp§7: §e"+TextUtils.format((long)xpCalcResult.getRemainingXp()) + "§7/§e"+TextUtils.format((long)xpCalcResult.getNextLvXp()), "§bTotal Xp§7: §e"+ TextUtils.format((long)dungeonStatDungeonSpecificData.getData().getExperience())),mouseX, mouseY, Minecraft.getMinecraft().fontRendererObj);
+ ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
+ GuiUtils.drawHoveringText(Arrays.asList("§bCurrent Lv§7: §e"+xpCalcResult.getLevel(),"§bExp§7: §e"+TextUtils.format((long)xpCalcResult.getRemainingXp()) + "§7/§e"+TextUtils.format((long)xpCalcResult.getNextLvXp()), "§bTotal Xp§7: §e"+ TextUtils.format((long)dungeonStatDungeonSpecificData.getData().getExperience())),mouseX, mouseY,
+ scaledResolution.getScaledWidth(), scaledResolution.getScaledHeight(), -1, Minecraft.getMinecraft().fontRendererObj);
}
}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRendererSelectedClassLv.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRendererSelectedClassLv.java
index 3a97f17e..8f2724aa 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRendererSelectedClassLv.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRendererSelectedClassLv.java
@@ -27,6 +27,8 @@ import kr.syeyoung.dungeonsguide.utils.TextUtils;
import kr.syeyoung.dungeonsguide.utils.XPUtils;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
+import net.minecraft.client.gui.ScaledResolution;
+import net.minecraftforge.fml.client.config.GuiUtils;
import java.awt.*;
import java.util.Arrays;
@@ -69,6 +71,8 @@ public class DataRendererSelectedClassLv implements DataRenderer {
ClassSpecificData<PlayerProfile.PlayerClassData> dungeonStatDungeonSpecificData = playerProfile.getPlayerClassData().get(playerProfile.getSelectedClass());
if (dungeonStatDungeonSpecificData == null) return;
XPUtils.XPCalcResult xpCalcResult = XPUtils.getCataXp(dungeonStatDungeonSpecificData.getData().getExperience());
- RenderUtils.drawHoveringText(Arrays.asList("§bCurrent Lv§7: §e"+xpCalcResult.getLevel(),"§bExp§7: §e"+ TextUtils.format((long)xpCalcResult.getRemainingXp()) + "§7/§e"+TextUtils.format((long)xpCalcResult.getNextLvXp()), "§bTotal Xp§7: §e"+ TextUtils.format((long)dungeonStatDungeonSpecificData.getData().getExperience())),mouseX, mouseY, Minecraft.getMinecraft().fontRendererObj);
+ ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
+ GuiUtils.drawHoveringText(Arrays.asList("§bCurrent Lv§7: §e"+xpCalcResult.getLevel(),"§bExp§7: §e"+ TextUtils.format((long)xpCalcResult.getRemainingXp()) + "§7/§e"+TextUtils.format((long)xpCalcResult.getNextLvXp()), "§bTotal Xp§7: §e"+ TextUtils.format((long)dungeonStatDungeonSpecificData.getData().getExperience())),mouseX, mouseY,
+ scaledResolution.getScaledWidth(), scaledResolution.getScaledHeight(), -1, Minecraft.getMinecraft().fontRendererObj);
}
}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRendererSkillLv.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRendererSkillLv.java
index 297db003..067226e5 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRendererSkillLv.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRendererSkillLv.java
@@ -28,6 +28,8 @@ import kr.syeyoung.dungeonsguide.utils.TextUtils;
import kr.syeyoung.dungeonsguide.utils.XPUtils;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
+import net.minecraft.client.gui.ScaledResolution;
+import net.minecraftforge.fml.client.config.GuiUtils;
import java.awt.*;
import java.util.Arrays;
@@ -73,6 +75,8 @@ public class DataRendererSkillLv implements DataRenderer {
Double xp = playerProfile.getSkillXp().get(skill);
if (xp == null) return;
XPUtils.XPCalcResult xpCalcResult = XPUtils.getSkillXp(skill, xp);
- RenderUtils.drawHoveringText(Arrays.asList("§bCurrent Lv§7: §e"+xpCalcResult.getLevel(),"§bExp§7: §e"+ TextUtils.format((long)xpCalcResult.getRemainingXp()) + "§7/§e"+TextUtils.format((long)xpCalcResult.getNextLvXp()), "§bTotal Xp§7: §e"+ TextUtils.format(xp.longValue())),mouseX, mouseY, Minecraft.getMinecraft().fontRendererObj);
+ ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
+ GuiUtils.drawHoveringText(Arrays.asList("§bCurrent Lv§7: §e"+xpCalcResult.getLevel(),"§bExp§7: §e"+ TextUtils.format((long)xpCalcResult.getRemainingXp()) + "§7/§e"+TextUtils.format((long)xpCalcResult.getNextLvXp()), "§bTotal Xp§7: §e"+ TextUtils.format(xp.longValue())),mouseX, mouseY,
+ scaledResolution.getScaledWidth(), scaledResolution.getScaledHeight(), -1, Minecraft.getMinecraft().fontRendererObj);
}
}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/FeatureViewPlayerOnJoin.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/FeatureViewPlayerOnJoin.java
index 8c152fa8..448eabe9 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/FeatureViewPlayerOnJoin.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/FeatureViewPlayerOnJoin.java
@@ -72,6 +72,7 @@ import net.minecraft.util.*;
import net.minecraft.world.World;
import net.minecraftforge.client.event.ClientChatReceivedEvent;
import net.minecraftforge.client.event.GuiScreenEvent;
+import net.minecraftforge.fml.client.config.GuiUtils;
import net.minecraftforge.fml.common.Loader;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;
@@ -183,6 +184,12 @@ public class FeatureViewPlayerOnJoin extends SimpleFeature implements GuiPostRen
}
+ public static void clip(ScaledResolution resolution, int x, int y, int width, int height) {
+ if (width < 0 || height < 0) return;
+
+ int scale = resolution.getScaleFactor();
+ GL11.glScissor((x ) * scale, Minecraft.getMinecraft().displayHeight - (y + height) * scale, (width) * scale, height * scale);
+ }
private void render(Rectangle popupRect, ScaledResolution scaledResolution, int mouseX, int mouseY, Optional<PlayerProfile> playerProfile, boolean apiKeyPlsSet) {
GlStateManager.pushMatrix();
@@ -214,7 +221,7 @@ public class FeatureViewPlayerOnJoin extends SimpleFeature implements GuiPostRen
GL11.glEnable(GL11.GL_SCISSOR_TEST);
- MPanel.clip(scaledResolution, popupRect.x, popupRect.y, popupRect.width, popupRect.height);
+ clip(scaledResolution, popupRect.x, popupRect.y, popupRect.width, popupRect.height);
Gui.drawRect(0,168, 90, 195, 0xFF23272a);
Gui.drawRect(2,170, 88, 193, new Rectangle(2,170,86,23).contains(relX, relY) ? 0xFFff7777 : 0xFFFF3333);
@@ -315,11 +322,13 @@ public class FeatureViewPlayerOnJoin extends SimpleFeature implements GuiPostRen
}
}
FontRenderer font = toHover.getItem().getFontRenderer(toHover);
+ GlStateManager.popMatrix();
GL11.glDisable(GL11.GL_SCISSOR_TEST);
FontRenderer theRenderer = (font == null ? fr : font);
- int minY = scaledResolution.getScaledHeight() - (list.size()+4) * theRenderer.FONT_HEIGHT - popupRect.y;
- RenderUtils.drawHoveringText(list,relX, Math.min(minY, relY), theRenderer);
+ GuiUtils.drawHoveringText(list,mouseX, mouseY, scaledResolution.getScaledWidth(), scaledResolution.getScaledHeight(), -1, theRenderer);
GL11.glEnable(GL11.GL_SCISSOR_TEST);
+ GlStateManager.pushMatrix();
+ GlStateManager.translate(popupRect.x, popupRect.y, 0);
}
} else {
GlStateManager.enableBlend();
@@ -328,16 +337,19 @@ public class FeatureViewPlayerOnJoin extends SimpleFeature implements GuiPostRen
fr.drawString("Loading", 5,35, 0xFFEFFF00);
}
+ GlStateManager.popMatrix();
GL11.glDisable(GL11.GL_SCISSOR_TEST);
if (dataRendererToHover != null && !drawInv) {
- dataRendererToHover.onHover(playerProfile.get(), relX, relY);
+ dataRendererToHover.onHover(playerProfile.get(), mouseX, mouseY);
}
GL11.glEnable(GL11.GL_SCISSOR_TEST);
+ GlStateManager.translate(popupRect.x, popupRect.y, 0);
+ GlStateManager.pushMatrix();
if (drawInv && playerProfile.get().getInventory() != null) {
int startX = 81;
int startY = 86;
- MPanel.clip(scaledResolution, popupRect.x+startX-1, popupRect.y+startY-1, 164, 74);
+ clip(scaledResolution, popupRect.x+startX-1, popupRect.y+startY-1, 164, 74);
GlStateManager.translate(startX,startY,1);
Gui.drawRect(-1,-1,163,73, 0xFF000000);
GlStateManager.disableLighting();
@@ -373,11 +385,12 @@ public class FeatureViewPlayerOnJoin extends SimpleFeature implements GuiPostRen
}
}
FontRenderer font = toHover.getItem().getFontRenderer(toHover);
+ GlStateManager.popMatrix();
GL11.glDisable(GL11.GL_SCISSOR_TEST);
FontRenderer theRenderer = (font == null ? fr : font);
- int minY = scaledResolution.getScaledHeight() - (list.size()+4) * theRenderer.FONT_HEIGHT - popupRect.y;
- RenderUtils.drawHoveringText(list,rx, Math.min(minY-startY, ry), theRenderer);
+ GuiUtils.drawHoveringText(list,mouseX, mouseY, scaledResolution.getScaledWidth(), scaledResolution.getScaledHeight(), -1, theRenderer);
GL11.glEnable(GL11.GL_SCISSOR_TEST);
+ GlStateManager.pushMatrix();
}
}
GL11.glDisable(GL11.GL_SCISSOR_TEST);
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 4f466cc3..f2cac046 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
@@ -152,11 +152,10 @@ public class FeatureMechanicBrowse extends GuiFeature implements GuiPreRenderLis
DungeonRoom dungeonRoom = context.getRoomMapper().get(roomPt);
if (dungeonRoom == null) return;
if (!(dungeonRoom.getRoomProcessor() instanceof GeneralRoomProcessor)) return;
- ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
- int width = scaledResolution.getScaledWidth();
- int height = scaledResolution.getScaledHeight();
- int mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth;
- int mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1;
+ int width = Minecraft.getMinecraft().displayWidth;
+ int height = Minecraft.getMinecraft().displayHeight;
+ int mouseX = Mouse.getX() ;
+ int mouseY = height - Mouse.getY() - 1;
GlStateManager.pushMatrix();
GlStateManager.enableTexture2D();
GlStateManager.disableLighting();
@@ -379,11 +378,10 @@ public class FeatureMechanicBrowse extends GuiFeature implements GuiPreRenderLis
if (dungeonRoom == null) return;
if (!(dungeonRoom.getRoomProcessor() instanceof GeneralRoomProcessor)) return;
- ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
- int width = scaledResolution.getScaledWidth();
- int height = scaledResolution.getScaledHeight();
- int mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth;
- int mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1;
+ int width = Minecraft.getMinecraft().displayWidth;
+ int height = Minecraft.getMinecraft().displayHeight;
+ int mouseX = Mouse.getX();
+ int mouseY = height - Mouse.getY() - 1;
Rectangle feature = getFeatureRect().getRectangle();
FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gui/MPanel.java b/src/main/java/kr/syeyoung/dungeonsguide/gui/MPanel.java
index 5f7ff538..aa949d16 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/gui/MPanel.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/gui/MPanel.java
@@ -21,6 +21,7 @@ package kr.syeyoung.dungeonsguide.gui;
import kr.syeyoung.dungeonsguide.gui.elements.MTooltip;
import lombok.AccessLevel;
import lombok.Getter;
+import lombok.Setter;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.ScaledResolution;
@@ -45,6 +46,7 @@ public class MPanel {
protected boolean isFocused;
@Getter
+ @Setter
protected MPanel parent;
public void setBackgroundColor(Color c) {
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MNavigatingPane.java b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MNavigatingPane.java
index d870daf2..4ad6bd45 100755
--- a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MNavigatingPane.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MNavigatingPane.java
@@ -132,6 +132,7 @@ public class MNavigatingPane extends MPanel {
panel2.setBackgroundColor(background2);
pages.put(currentPage, panel2);
panel2.setBounds(new Rectangle(1,30,getBounds().width-2, getBounds().height-31));
+ panel2.setParent(this);
}
dynamic.add(pages.get(currentPage));
dynamic.add(back);
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MTooltip.java b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MTooltip.java
index 56eb2821..561ecb0c 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MTooltip.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MTooltip.java
@@ -40,6 +40,11 @@ public class MTooltip extends MPanel {
root.removeTooltip(this);
}
+
+ public boolean isOpen() {
+ return root != null;
+ }
+
@Override
public int getTooltipsOpen() {
return super.getTooltipsOpen() - 1;
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/RoomMatchDisplayPane.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/RoomMatchDisplayPane.java
index 21ef701f..5290291f 100755
--- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/RoomMatchDisplayPane.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/RoomMatchDisplayPane.java
@@ -22,6 +22,8 @@ import kr.syeyoung.dungeonsguide.config.guiconfig.FeatureEditPane;
import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom;
import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoomInfoRegistry;
import kr.syeyoung.dungeonsguide.gui.MPanel;
+import kr.syeyoung.dungeonsguide.gui.elements.MTooltip;
+import kr.syeyoung.dungeonsguide.gui.elements.MTooltipText;
import kr.syeyoung.dungeonsguide.utils.ArrayUtils;
import kr.syeyoung.dungeonsguide.utils.RenderUtils;
import net.minecraft.block.Block;
@@ -54,6 +56,9 @@ public class RoomMatchDisplayPane extends MPanel {
targetBlocks = ArrayUtils.rotateCounterClockwise(targetBlocks);
}
+ MTooltip mTooltip;
+ int lastTooltipX = -1, lastTooltipZ = -1;
+
@Override
public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle clip) {
ScaledResolution sr = new ScaledResolution(Minecraft.getMinecraft());
@@ -80,6 +85,7 @@ public class RoomMatchDisplayPane extends MPanel {
int hoverY = (relMousey0 - offsetY - 10) / 16;
// draw Content
clip(sr, clip.x + 10, clip.y +10, clip.width - 10, clip.height - 10);
+ boolean tooltiped=false;
for (int z = 0; z < height; z++) {
for (int x = 0; x < width; x++) {
int data1;
@@ -103,10 +109,19 @@ public class RoomMatchDisplayPane extends MPanel {
fr.drawString("N", x *16 +10 + offsetX, z *16 +10 + offsetY,0xFFFF0000);
}
if (z == hoverY && x == hoverX) {
- RenderUtils.drawHoveringText(Arrays.asList("Expected "+data2 +" But found "+data1), relMousex0, relMousey0, fr);
+ tooltiped = true;
+ if (lastTooltipX != x || lastTooltipZ != z){
+ if (mTooltip != null) mTooltip.close();
+ mTooltip = new MTooltipText(Arrays.asList("Expected "+data2 +" But found "+data1));
+ mTooltip.open(this);
+ }
}
}
}
+ if (!tooltiped && mTooltip != null) {
+ mTooltip.close();
+ mTooltip = null;
+ }
}
private void drawItemStack(ItemStack stack, int x, int y)
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/stomp/StompPayload.java b/src/main/java/kr/syeyoung/dungeonsguide/stomp/StompPayload.java
index 1aeedb61..80d1ea7a 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/stomp/StompPayload.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/stomp/StompPayload.java
@@ -53,12 +53,14 @@ public class StompPayload {
if (payload != null)
sb.append(payload);
sb.append((char) 0);
- System.out.println("Probably sending "+ sb);
+ if (!sb.toString().contains("cosmetic"))
+ System.out.println("Probably sending "+ sb);
return sb.toString();
}
public static StompPayload parse(String payload) {
- System.out.println("Parsing "+payload);
+ if (!payload.contains("cosmetic"))
+ System.out.println("Parsing "+payload);
Scanner scanner = new Scanner(payload);
StompPayload stompPayload = new StompPayload();
stompPayload.method = StompHeader.valueOf(scanner.nextLine());
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/utils/RenderUtils.java b/src/main/java/kr/syeyoung/dungeonsguide/utils/RenderUtils.java
index 9a765191..c2dfdb68 100755
--- a/src/main/java/kr/syeyoung/dungeonsguide/utils/RenderUtils.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/utils/RenderUtils.java
@@ -55,125 +55,23 @@ public class RenderUtils {
public static boolean allowScrolling;
public static int scrollX = 0;
- public static void drawHoveringText(List<String> textLines, int x, int y, FontRenderer font)
- {
- if (!textLines.isEmpty())
- {
- GlStateManager.disableRescaleNormal();
- RenderHelper.disableStandardItemLighting();
- GlStateManager.disableLighting();
- GlStateManager.disableDepth();
- int i = 0;
-
- for (String s : textLines)
- {
- int j = font.getStringWidth(s);
- if (j > i)
- {
- i = j;
- }
- }
-
- int l1 = x + 12;
- int i2 = y - 12;
- int k = 8;
-
- if (textLines.size() > 1)
- {
- k += 2 + (textLines.size() - 1) * 10;
- }
+ public static int blendTwoColors(int background, int newColor) {
+ float alpha = ((newColor >> 24) & 0xFF) /255.0f;
+ int r1 = (background >> 16) & 0xFF, r2 = (newColor >> 16) & 0xFF;
+ int g1 = (background >> 8) & 0xFF, g2 = (newColor >> 8) & 0xFF;
+ int b1 = (background) & 0xFF, b2 = (newColor) & 0xFF;
- zLevel = 300.0F;
- int l = -267386864;
-
-
- if (!allowScrolling) {
- scrollX = 0;
- scrollY = 0;
- }
- allowScrolling = (i2 < 0);
- GlStateManager.pushMatrix();
- if (allowScrolling) {
- int eventDWheel = Mouse.getDWheel();
- if (Keyboard.isKeyDown(42)) {
- if (eventDWheel < 0) {
- scrollX += 10;
- } else if (eventDWheel > 0) {
- scrollX -= 10;
- }
- } else if (eventDWheel < 0) {
- scrollY -= 10;
- } else if (eventDWheel > 0) {
- scrollY += 10;
- }
- }
- GlStateManager.translate(scrollX, scrollY, 0.0F);
-
- drawGradientRect(l1 - 3, i2 - 4, l1 + i + 3, i2 - 3, l, l);
- drawGradientRect(l1 - 3, i2 + k + 3, l1 + i + 3, i2 + k + 4, l, l);
- drawGradientRect(l1 - 3, i2 - 3, l1 + i + 3, i2 + k + 3, l, l);
- drawGradientRect(l1 - 4, i2 - 3, l1 - 3, i2 + k + 3, l, l);
- drawGradientRect(l1 + i + 3, i2 - 3, l1 + i + 4, i2 + k + 3, l, l);
- int i1 = 1347420415;
- int j1 = (i1 & 16711422) >> 1 | i1 & -16777216;
- drawGradientRect(l1 - 3, i2 - 3 + 1, l1 - 3 + 1, i2 + k + 3 - 1, i1, j1);
- drawGradientRect(l1 + i + 2, i2 - 3 + 1, l1 + i + 3, i2 + k + 3 - 1, i1, j1);
- drawGradientRect(l1 - 3, i2 - 3, l1 + i + 3, i2 - 3 + 1, i1, i1);
- drawGradientRect(l1 - 3, i2 + k + 2, l1 + i + 3, i2 + k + 3, j1, j1);
-
- GlStateManager.enableBlend();
- GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA);
- GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA);
- for (int k1 = 0; k1 < textLines.size(); ++k1)
- {
- String s1 = textLines.get(k1);
- font.drawStringWithShadow(s1, (float)l1, (float)i2, -1);
-
- if (k1 == 0)
- {
- i2 += 2;
- }
-
- i2 += 10;
- }
-
- zLevel = 0.0F;
- GlStateManager.enableLighting();
- GlStateManager.enableDepth();
- RenderHelper.enableStandardItemLighting();
- GlStateManager.enableRescaleNormal();
- GlStateManager.popMatrix();
- }
+ int rr = (int) (r1 + (r2-r1) * alpha) & 0xFF;
+ int rg = (int) (g1 + (g2-g1) * alpha) & 0xFF;
+ int rb = (int) (b1 + (b2-b1) * alpha) & 0xFF;
+ return 0xFF000000 | ((rr << 16) & 0xFF0000) | ((rg << 8) & 0xFF00) | (rb & 0xFF);
}
- protected static void drawGradientRect(int left, int top, int right, int bottom, int startColor, int endColor)
- {
- float f = (float)(startColor >> 24 & 255) / 255.0F;
- float f1 = (float)(startColor >> 16 & 255) / 255.0F;
- float f2 = (float)(startColor >> 8 & 255) / 255.0F;
- float f3 = (float)(startColor & 255) / 255.0F;
- float f4 = (float)(endColor >> 24 & 255) / 255.0F;
- float f5 = (float)(endColor >> 16 & 255) / 255.0F;
- float f6 = (float)(endColor >> 8 & 255) / 255.0F;
- float f7 = (float)(endColor & 255) / 255.0F;
- GlStateManager.disableTexture2D();
- GlStateManager.enableBlend();
- GlStateManager.disableAlpha();
- GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
- GlStateManager.shadeModel(7425);
- Tessellator tessellator = Tessellator.getInstance();
- WorldRenderer worldrenderer = tessellator.getWorldRenderer();
- worldrenderer.begin(7, DefaultVertexFormats.POSITION_COLOR);
- worldrenderer.pos(right, top, zLevel).color(f1, f2, f3, f).endVertex();
- worldrenderer.pos(left, top, zLevel).color(f1, f2, f3, f).endVertex();
- worldrenderer.pos(left, bottom, zLevel).color(f5, f6, f7, f4).endVertex();
- worldrenderer.pos(right, bottom, zLevel).color(f5, f6, f7, f4).endVertex();
- tessellator.draw();
- GlStateManager.shadeModel(7424);
- GlStateManager.disableBlend();
- GlStateManager.enableAlpha();
- GlStateManager.enableTexture2D();
+
+ public static int blendAlpha(int origColor, float alphaPerc) {
+ return blendTwoColors(origColor, (int)(alphaPerc*255) << 24 | 0xFFFFFF);
}
+
public static void drawTexturedRect(float x, float y, float width, float height, float uMin, float uMax, float vMin, float vMax, int filter) {
GlStateManager.enableTexture2D();
GlStateManager.enableBlend();