aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsyeyoung <cyong06@naver.com>2021-07-29 12:25:21 +0900
committersyeyoung <cyong06@naver.com>2021-07-29 21:41:22 +0900
commitee96b0e9475fed7e80c4f7037ec5ad44cf07f6c2 (patch)
tree49d818ff38cb7f3e73113a5f563ce856df736f9e
parentb95c84eece5cfbb1dd25a7e5d4b022863f643044 (diff)
downloadSkyblock-Dungeons-Guide-ee96b0e9475fed7e80c4f7037ec5ad44cf07f6c2.tar.gz
Skyblock-Dungeons-Guide-ee96b0e9475fed7e80c4f7037ec5ad44cf07f6c2.tar.bz2
Skyblock-Dungeons-Guide-ee96b0e9475fed7e80c4f7037ec5ad44cf07f6c2.zip
Cursors complete
-rwxr-xr-xbuild.gradle3
-rwxr-xr-xsrc/main/java/kr/syeyoung/dungeonsguide/Main.java16
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/nyu/MCategory.java75
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/nyu/MPanelCategory.java83
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/nyu/NestedCategory.java46
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/utils/cursor/CursorReader.java98
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/utils/cursor/EnumCursor.java32
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/utils/cursor/Foundation.java4
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/utils/cursor/GLCursors.java100
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/utils/cursor/User32.java3
-rwxr-xr-xsrc/main/resources/assets/dg/cursors/IBeamCursor.curbin0 -> 8774 bytes
-rwxr-xr-xsrc/main/resources/assets/dg/cursors/arrowCursor.curbin0 -> 136606 bytes
-rw-r--r--src/main/resources/assets/dg/cursors/closedHandCursor.curbin0 -> 136606 bytes
-rwxr-xr-xsrc/main/resources/assets/dg/cursors/crosshairCursor.curbin0 -> 8774 bytes
-rw-r--r--src/main/resources/assets/dg/cursors/openHandCursor.curbin0 -> 136606 bytes
-rwxr-xr-xsrc/main/resources/assets/dg/cursors/operationNotAllowedCursor.curbin0 -> 136606 bytes
-rwxr-xr-xsrc/main/resources/assets/dg/cursors/pointingHandCursor.curbin0 -> 136606 bytes
-rwxr-xr-xsrc/main/resources/assets/dg/cursors/resizeDownCursor.curbin0 -> 136606 bytes
-rwxr-xr-xsrc/main/resources/assets/dg/cursors/resizeLeftCursor.curbin0 -> 136606 bytes
-rwxr-xr-xsrc/main/resources/assets/dg/cursors/resizeLeftRightCursor.curbin0 -> 136606 bytes
-rwxr-xr-xsrc/main/resources/assets/dg/cursors/resizeNE.curbin0 -> 136606 bytes
-rwxr-xr-xsrc/main/resources/assets/dg/cursors/resizeNESW.curbin0 -> 136606 bytes
-rwxr-xr-xsrc/main/resources/assets/dg/cursors/resizeNW.curbin0 -> 136606 bytes
-rwxr-xr-xsrc/main/resources/assets/dg/cursors/resizeNWSE.curbin0 -> 136606 bytes
-rwxr-xr-xsrc/main/resources/assets/dg/cursors/resizeRightCursor.curbin0 -> 136606 bytes
-rwxr-xr-xsrc/main/resources/assets/dg/cursors/resizeSE.curbin0 -> 136606 bytes
-rwxr-xr-xsrc/main/resources/assets/dg/cursors/resizeSW.curbin0 -> 136606 bytes
-rwxr-xr-xsrc/main/resources/assets/dg/cursors/resizeUpCursor.curbin0 -> 136606 bytes
-rwxr-xr-xsrc/main/resources/assets/dg/cursors/resizeUpDownCursor.curbin0 -> 136606 bytes
29 files changed, 407 insertions, 53 deletions
diff --git a/build.gradle b/build.gradle
index 3012eaa2..37267a02 100755
--- a/build.gradle
+++ b/build.gradle
@@ -60,6 +60,8 @@ dependencies {
implementation "org.jetbrains:annotations-java5:19.0.0"
implementation "org.java-websocket:Java-WebSocket:1.5.1"
implementation "org.json:json:20171018"
+ implementation "com.twelvemonkeys.imageio:imageio-bmp:3.7.0"
+
compileOnly "org.projectlombok:lombok:1.18.20"
compileOnly files("mods/Hychat-1.12.1-BETA.jar")
@@ -79,6 +81,7 @@ shadowJar {
include(dependency("org.java-websocket:Java-WebSocket:1.5.1"))
include(dependency("org.slf4j:slf4j-api:1.7.25"))
include(dependency("org.json:json:20171018"))
+ include(dependency("com.twelvemonkeys.imageio:imageio-bmp:3.7.0"))
}
}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/Main.java b/src/main/java/kr/syeyoung/dungeonsguide/Main.java
index bd6a34bb..29ac0599 100755
--- a/src/main/java/kr/syeyoung/dungeonsguide/Main.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/Main.java
@@ -19,15 +19,13 @@
package kr.syeyoung.dungeonsguide;
import com.mojang.authlib.exceptions.AuthenticationException;
-import kr.syeyoung.dungeonsguide.eventlistener.DungeonListener;
import kr.syeyoung.dungeonsguide.url.DGStreamHandlerFactory;
-import net.minecraft.client.Minecraft;
+import kr.syeyoung.dungeonsguide.utils.cursor.EnumCursor;
+import kr.syeyoung.dungeonsguide.utils.cursor.GLCursors;
import net.minecraft.client.gui.*;
import net.minecraft.launchwrapper.LaunchClassLoader;
import net.minecraftforge.client.event.GuiOpenEvent;
import net.minecraftforge.common.MinecraftForge;
-import net.minecraftforge.fml.client.CustomModLoadingErrorDisplayException;
-import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.ProgressManager;
@@ -35,14 +33,9 @@ import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.eventhandler.EventPriority;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
-import scala.tools.nsc.Global;
-import javax.crypto.BadPaddingException;
-import javax.crypto.IllegalBlockSizeException;
-import javax.crypto.NoSuchPaddingException;
import java.io.*;
import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
import java.net.URL;
import java.security.*;
import java.security.cert.CertificateException;
@@ -83,11 +76,6 @@ public class Main
e.printStackTrace();
}
}
-
-
-
-
-
}
@SubscribeEvent(priority = EventPriority.HIGHEST)
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/nyu/MCategory.java b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/nyu/MCategory.java
new file mode 100644
index 00000000..1f6977a0
--- /dev/null
+++ b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/nyu/MCategory.java
@@ -0,0 +1,75 @@
+/*
+ * 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.nyu;
+
+import kr.syeyoung.dungeonsguide.config.guiconfig.old.MFeature;
+import kr.syeyoung.dungeonsguide.gui.MPanel;
+import lombok.Getter;
+import lombok.Setter;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.FontRenderer;
+import net.minecraft.client.gui.Gui;
+import net.minecraft.client.renderer.GlStateManager;
+import org.lwjgl.opengl.GL11;
+import org.lwjgl.opengl.GL14;
+
+import java.awt.*;
+
+public class MCategory extends MPanel {
+
+ private NestedCategory nestedCategory;
+ private RootConfigPanel rootConfigPanel;
+ @Getter
+ @Setter
+ private Color hover = new Color(94, 94, 94, 255);
+ public MCategory(NestedCategory nestedCategory, RootConfigPanel rootConfigPanel) {
+ this.nestedCategory = nestedCategory;
+ this.rootConfigPanel = rootConfigPanel;
+ }
+
+ @Override
+ public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) {
+ Gui.drawRect(0,0,getBounds().width, getBounds().height,0xFF444444);
+
+
+ FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
+ GlStateManager.pushMatrix();
+ GlStateManager.translate(5,5,0);
+ GlStateManager.scale(1.0,1.0,0);
+ 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);
+
+ fr.drawString((lastAbsClip.contains(absMousex, absMousey) ? "§n" : "") + nestedCategory.categoryName(), 0,0, 0xFFFFFFFF);
+ GlStateManager.popMatrix();
+
+ fr.drawSplitString("NO DESC", 5, 23, getBounds().width -10, 0xFFBFBFBF);
+ }
+
+
+ @Override
+ public Dimension getPreferredSize() {
+ return new Dimension(100, 17);
+ }
+ @Override
+ public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) {
+ if (lastAbsClip.contains(absMouseX, absMouseY))
+ rootConfigPanel.setCurrentPage(nestedCategory.categoryFull());
+ }
+}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/nyu/MPanelCategory.java b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/nyu/MPanelCategory.java
new file mode 100644
index 00000000..5b6d9bbd
--- /dev/null
+++ b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/nyu/MPanelCategory.java
@@ -0,0 +1,83 @@
+/*
+ * 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.nyu;
+
+import kr.syeyoung.dungeonsguide.config.guiconfig.old.MFeature;
+import kr.syeyoung.dungeonsguide.features.AbstractFeature;
+import kr.syeyoung.dungeonsguide.features.FeatureRegistry;
+import kr.syeyoung.dungeonsguide.gui.MPanel;
+import kr.syeyoung.dungeonsguide.gui.elements.MLabel;
+import kr.syeyoung.dungeonsguide.gui.elements.MList;
+
+import java.awt.*;
+
+public class MPanelCategory extends MPanel {
+
+ private NestedCategory key;
+ private RootConfigPanel rootConfigPanel;
+
+ private MList list;
+
+ public MPanelCategory(NestedCategory nestedCategory, RootConfigPanel rootConfigPanel) {
+ this.key = nestedCategory;
+ this.rootConfigPanel = rootConfigPanel;
+
+ list = new MList();
+ list.setDrawLine(false);
+ list.setGap(5);
+ add(list);
+
+ for (NestedCategory value : nestedCategory.children().values()) {
+ list.add(new MCategory(value, rootConfigPanel));
+ }
+ String actualCategory = nestedCategory.categoryFull().substring(5);
+ if (FeatureRegistry.getFeaturesByCategory().containsKey(actualCategory))
+ for (AbstractFeature abstractFeature : FeatureRegistry.getFeaturesByCategory().get(actualCategory)) {
+ MFeature mFeature = new MFeature(abstractFeature, null);
+ list.add(mFeature);
+ mFeature.setHover(new Color(94, 94, 94, 255));
+ }
+ list.realignChildren();
+
+ }
+
+ @Override
+ public void resize(int parentWidth, int parentHeight) {
+ super.resize(parentWidth, parentHeight);
+ Dimension prefSize = list.getPreferredSize();
+ int wid = Math.max(prefSize.width + 10, parentWidth);
+ int hei = prefSize.height + 10;
+ setBounds(new Rectangle(0,0,wid,hei));
+ }
+
+ @Override
+ public void setBounds(Rectangle bounds) {
+ super.setBounds(bounds);
+ list.setBounds(new Rectangle(5,5,bounds.width- 10, bounds.height - 10));
+ list.realignChildren();
+ }
+
+ @Override
+ public Dimension getPreferredSize() {
+ Dimension prefSize = list.getPreferredSize();
+ int wid = prefSize.width + 10;
+ int hei = prefSize.height + 10;
+ return new Dimension(wid, hei);
+ }
+}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/nyu/NestedCategory.java b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/nyu/NestedCategory.java
new file mode 100644
index 00000000..ac3b8f49
--- /dev/null
+++ b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/nyu/NestedCategory.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.nyu;
+
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.util.HashMap;
+import java.util.Map;
+
+@Data
+@Accessors(chain = true, fluent = true)
+class NestedCategory {
+ private final String categoryFull;
+ private String categoryName;
+ private NestedCategory parent;
+
+ public NestedCategory(String categoryFull) {
+ this.categoryFull = categoryFull;
+ this.categoryName = categoryFull.substring(categoryFull.lastIndexOf(".") + 1);
+ }
+
+ private Map<String, NestedCategory> children = new HashMap<>();
+
+ public NestedCategory child(NestedCategory child) {
+ this.children.put(child.categoryName, child);
+ child.parent = this;
+ return this;
+ }
+}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/utils/cursor/CursorReader.java b/src/main/java/kr/syeyoung/dungeonsguide/utils/cursor/CursorReader.java
new file mode 100644
index 00000000..8a1a7950
--- /dev/null
+++ b/src/main/java/kr/syeyoung/dungeonsguide/utils/cursor/CursorReader.java
@@ -0,0 +1,98 @@
+/*
+ * 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.utils.cursor;
+
+import com.google.common.io.LittleEndianDataInputStream;
+import com.google.common.io.LittleEndianDataOutputStream;
+import com.twelvemonkeys.imageio.plugins.bmp.CURImageReader;
+import com.twelvemonkeys.imageio.plugins.bmp.ICOImageReader;
+import lombok.Data;
+
+import javax.imageio.ImageIO;
+import javax.imageio.ImageReader;
+import javax.imageio.stream.ImageInputStream;
+import java.awt.image.BufferedImage;
+import java.io.*;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+public class CursorReader {
+ public static List<CursorData> readFromInputStream(InputStream inputStream) throws IOException {
+ LittleEndianDataInputStream dataInputStream = new LittleEndianDataInputStream(new BufferedInputStream(inputStream));
+ dataInputStream.mark(Integer.MAX_VALUE);
+
+
+ int magicValue = dataInputStream.readUnsignedShort();
+ if (magicValue != 0) throw new RuntimeException("Invalid Cursor file");
+ int type = dataInputStream.readUnsignedShort();
+ if (type != 2) throw new RuntimeException("not cursor");
+ int size = dataInputStream.readShort();
+
+ List<CursorData> directoryList = new ArrayList<>();
+ for (int i = 0; i < size; i++) {
+
+ CursorData directory = new CursorData();
+ directory.setWidth((short) dataInputStream.readUnsignedByte());
+ directory.setHeight((short) dataInputStream.readUnsignedByte());
+ directory.setColorCnt((short) dataInputStream.readUnsignedByte());
+ directory.setMagicValue(dataInputStream.readByte());
+ directory.setXHotSpot(dataInputStream.readShort());
+ directory.setYHotSpot(dataInputStream.readShort());
+ directory.setSizeBitmap(dataInputStream.readInt() & 0x00000000ffffffffL);
+ directory.setOffset(dataInputStream.readInt() & 0x00000000ffffffffL);
+
+ directoryList.add(directory);
+ }
+ dataInputStream.reset();
+
+ try (ImageInputStream imageInputStream = ImageIO.createImageInputStream(dataInputStream)) {
+ Iterator<ImageReader> imageReaderIterator = ImageIO.getImageReaders(imageInputStream);
+ CURImageReader imageReader = (CURImageReader) imageReaderIterator.next();
+ imageReader.setInput(imageInputStream);
+
+ for (int i = 0; i < directoryList.size(); i++) {
+ directoryList.get(i).setBufferedImage(imageReader.read(i));
+ }
+ }
+ inputStream.close();
+
+ return directoryList;
+ }
+
+ private static void setIntLittleEndian(byte[] bytes, int index, int value) {
+ byte[] ins = new byte[] {
+ (byte) ((value >> 24)& 0xFF), (byte) ((value >> 16)& 0xFF), (byte) ((value >> 8)& 0xFF), (byte) (value & 0xFF)
+ };
+ bytes[index+3] = ins[0];
+ bytes[index+2] = ins[1];
+ bytes[index+1] = ins[2];
+ bytes[index] = ins[3];
+ }
+
+
+ @Data
+ public static class CursorData {
+ private short width, height, colorCnt, magicValue;
+ private int xHotSpot, yHotSpot;
+ private long sizeBitmap;
+ private long offset;
+ private BufferedImage bufferedImage;
+ }
+}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/utils/cursor/EnumCursor.java b/src/main/java/kr/syeyoung/dungeonsguide/utils/cursor/EnumCursor.java
index caea4d61..20cccef7 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/utils/cursor/EnumCursor.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/utils/cursor/EnumCursor.java
@@ -25,18 +25,26 @@ import lombok.Getter;
@AllArgsConstructor
@Getter
public enum EnumCursor {
- DEFAULT(32512,68,"arrowCursor","arrowCursor"),
- POINTING_HAND(32649,60,"pointingHandCursor", "pointingHandCursor"),
- OPEN_HAND(32649,60,"openHandCursor","openHandCursor"),
- CLOSED_HAND(32646,52,"closedHandCursor","closedHandCursor"),
- BEAM_CURSOR(32513, 152, "IBeamCursor", "IBeamCursor"),
- RESIZE_LEFT(32644, 70,"resizeLeftCursor", "resizeLeftCursor"),
- RESIZE_RIGHT(32644, 96,"resizeRightCursor", "resizeRightCursor"),
- RESIZE_LEFT_RIGHT(32644, 108, "resizeLeftRightCursor", "resizeLeftRightCursor"),
- RESIZE_UP(32645,138,"resizeUpCursor", "resizeUpCursor"),
- RESIZE_DOWN(32645,16,"resizeDownCursor", "resizeDownCursor"),
- RESIZE_UP_DOWN(32645,116,"resizeUpDownCursor", "resizeUpDownCursor"),
- CROSS(32515, 34,"crosshairCursor", "crosshairCursor");
+ DEFAULT(32512,68,"arrowCursor","arrowCursor.cur"),
+ POINTING_HAND(32649,60,"pointingHandCursor", "pointingHandCursor.cur"),
+ OPEN_HAND(32646,58,"openHandCursor","openHandCursor.cur"),
+ CLOSED_HAND(32646,52,"closedHandCursor","closedHandCursor.cur"),
+ BEAM_CURSOR(32513, 152, "IBeamCursor", "IBeamCursor.cur"),
+ RESIZE_LEFT(32644, 70,"resizeLeftCursor", "resizeLeftCursor.cur"),
+ RESIZE_RIGHT(32644, 96,"resizeRightCursor", "resizeRightCursor.cur"),
+ RESIZE_LEFT_RIGHT(32644, 108, "resizeLeftRightCursor", "resizeLeftRightCursor.cur"),
+ RESIZE_UP(32645,138,"resizeUpCursor", "resizeUpCursor.cur"),
+ RESIZE_DOWN(32645,16,"resizeDownCursor", "resizeDownCursor.cur"),
+ RESIZE_UP_DOWN(32645,116,"resizeUpDownCursor", "resizeUpDownCursor.cur"),
+ RESIZE_TL(32642, 134, null, "resizeNW.cur"),
+ RESIZE_DR(32642, 14, null, "resizeSE.cur"),
+ RESIZE_TLDR(32642, 14, null, "resizeNWSE.cur"),
+ RESIZE_TR(32643, 136, null, "resizeNE.cur"),
+ RESIZE_DL(32643, 12, null, "resizeSW.cur"),
+ RESIZE_TRDL(32643, 12, null, "resizeNESW.cur"),
+ CROSS(32515, 34,"crosshairCursor", "crosshairCursor.cur"),
+ NOT_ALLOWED(32648, -1,"operationNotAllowedCursor", "operationNotAllowedCursor.cur"),
+ TEST(-1, -1, null, "testnonexistant.cur");
private int windows;
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/utils/cursor/Foundation.java b/src/main/java/kr/syeyoung/dungeonsguide/utils/cursor/Foundation.java
index 995ee101..b08ad378 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/utils/cursor/Foundation.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/utils/cursor/Foundation.java
@@ -23,12 +23,12 @@ import com.sun.jna.Native;
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
+
public interface Foundation extends Library {
Foundation INSTANCE = (Foundation) Native.loadLibrary("Foundation",
Foundation.class);
Pointer objc_getClass(String className);
Pointer sel_registerName(String selectorName);
- void objc_msgSend(Pointer receiver, Pointer selector, Object... args);
- Structure objc_msgSend_stret(Pointer receiver, Pointer selector, Object... args);
+ Pointer objc_msgSend(Pointer receiver, Pointer selector, Object... args);
}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/utils/cursor/GLCursors.java b/src/main/java/kr/syeyoung/dungeonsguide/utils/cursor/GLCursors.java
index 415e82bf..185edec1 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/utils/cursor/GLCursors.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/utils/cursor/GLCursors.java
@@ -18,8 +18,10 @@
package kr.syeyoung.dungeonsguide.utils.cursor;
+import com.sun.jna.Memory;
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
+import kr.syeyoung.dungeonsguide.utils.RenderUtils;
import net.minecraft.client.Minecraft;
import net.minecraft.util.MathHelper;
import net.minecraft.util.ResourceLocation;
@@ -36,9 +38,15 @@ import java.lang.reflect.Array;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
+import java.nio.Buffer;
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
import java.nio.IntBuffer;
+import java.util.Comparator;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
+import java.util.stream.Collectors;
public class GLCursors {
@@ -74,20 +82,21 @@ public class GLCursors {
if (enumCursorCursorMap.size() != 0) return;
int platform = LWJGLUtil.getPlatform();
for (EnumCursor value : EnumCursor.values()) {
+ System.out.println("Loading "+value);
Cursor c = null;
try {
switch(platform) {
case LWJGLUtil.PLATFORM_WINDOWS:
- if (value.getWindows() == -1) continue;
- c = createCursorWindows(value.getWindows());
+ if (value.getWindows() != -1)
+ c = createCursorWindows(value.getWindows());
break;
case LWJGLUtil.PLATFORM_LINUX:
- if (value.getLinux() == -1) continue;
- c = createCursorLinux(value.getLinux());
+ if (value.getLinux() != -1)
+ c = createCursorLinux(value.getLinux());
break;
case LWJGLUtil.PLATFORM_MACOSX:
- if (value.getMacos() == null) continue;
- c = createCursorMac(value.getMacos());
+ if (value.getMacos() != null)
+ c = createCursorMac(value.getMacos());
break;
}
} catch (Throwable e) {
@@ -96,21 +105,29 @@ public class GLCursors {
}
try {
if (c == null) {
+ System.out.println("Loading image cursor "+value);
int hotspotX = 0, hotspotY = 0;
+ BufferedImage bufferedImage = null;
+ int minC = Cursor.getMinCursorSize(), maxC = Cursor.getMaxCursorSize();
try {
- ResourceLocation cursorinfo = new ResourceLocation("dungeonsguide:cursors/"+value.getAltFileName()+".curinfo");
- String cursorinfoStr = IOUtils.toString(Minecraft.getMinecraft().getResourceManager().getResource(cursorinfo).getInputStream());
- hotspotX = Integer.parseInt(cursorinfoStr.split(":")[0]);
- hotspotY = Integer.parseInt(cursorinfoStr.split(":")[1]);
+ ResourceLocation cursorinfo = new ResourceLocation("dungeonsguide:cursors/"+value.getAltFileName());
+ List<CursorReader.CursorData> cursorDataList = CursorReader.readFromInputStream(Minecraft.getMinecraft().getResourceManager().getResource(cursorinfo).getInputStream());
+ List<CursorReader.CursorData> cursorDataList2 = cursorDataList.stream()
+ .filter(cdata -> cdata.getBufferedImage() != null)
+ .filter(cdata -> minC <= cdata.getHeight() && cdata.getHeight() <= maxC && minC <= cdata.getWidth() && cdata.getWidth() <= maxC)
+ .sorted(Comparator.comparingInt(CursorReader.CursorData::getWidth)).collect(Collectors.toList());
+
+ CursorReader.CursorData cursorData =
+ cursorDataList2.size() == 0 ? cursorDataList.get(0) : cursorDataList2.get(0);
+ System.out.println(cursorData);
+ bufferedImage = cursorData.getBufferedImage();
+ hotspotX = cursorData.getXHotSpot();
+ hotspotY = cursorData.getYHotSpot();
} catch (Throwable t) {t.printStackTrace();}
- ResourceLocation cursor = new ResourceLocation("dungeonsguide:cursors/"+value.getAltFileName()+".png");
- BufferedImage bufferedImage = ImageIO.read(Minecraft.getMinecraft().getResourceManager().getResource(cursor).getInputStream());
-
-
- int width = bufferedImage.getWidth();
- int height = bufferedImage.getHeight();
+ int width = bufferedImage == null ? 16 : bufferedImage.getWidth();
+ int height = bufferedImage == null ? 16 : bufferedImage.getHeight();
int effWidth = MathHelper.clamp_int(width, Cursor.getMinCursorSize(), Cursor.getMaxCursorSize());
int effHeight = MathHelper.clamp_int(height, Cursor.getMinCursorSize(), Cursor.getMaxCursorSize());
int length = effHeight * effWidth;
@@ -118,20 +135,44 @@ public class GLCursors {
for (int i = 0; i < length; i++) {
int x = i % effWidth;
int y = i / effWidth;
- if (x >= width || y >= height) {
+ if (bufferedImage == null) {
+ intBuffer.put(RenderUtils.getChromaColorAt(x,y,1.0f, 1.0f, 1.0f, 1.0f));
+ } else if (x >= width || y >= height) {
intBuffer.put(0);
} else {
intBuffer.put(bufferedImage.getRGB(x, height - y - 1));
}
}
intBuffer.flip();
- c = new Cursor(effWidth, effHeight, hotspotX, hotspotY,1,intBuffer, null);
+ c = new Cursor(effWidth, effHeight, hotspotX, height - hotspotY - 1,1,intBuffer, null);
}
} catch (Throwable e) {
System.out.println("Error occured while loading cursor from resource: "+value);
e.printStackTrace();
}
- if (c != null) enumCursorCursorMap.put(value, c);
+ if (c != null) {
+ try {
+ Object arr = cursorField.get(c);
+ Object cursor = Array.get(arr, 0);
+ for (Field declaredField : cursor.getClass().getDeclaredFields()) {
+ declaredField.setAccessible(true);
+ Object obj = declaredField.get(cursor);
+ System.out.println(declaredField.getName()+": "+obj+" - "+(obj instanceof ByteBuffer));
+ if (obj instanceof ByteBuffer) {
+ ByteBuffer b = (ByteBuffer) declaredField.get(cursor);
+ StringBuilder sb = new StringBuilder("Contents: ");
+ for (int i = 0; i < b.limit(); i++) {
+ sb.append(Integer.toHexString(b.get(i) & 0xFF)).append(" ");
+ }
+ System.out.println(sb.toString());
+ }
+ }
+ } catch (IllegalAccessException e) {
+ e.printStackTrace();
+ }
+
+ enumCursorCursorMap.put(value, c);
+ }
}
}
@@ -143,9 +184,21 @@ public class GLCursors {
User32 user32 = User32.INSTANCE;
Pointer hIcon = user32
.LoadCursorW(Pointer.NULL, cursor);
- long iconPtr = Pointer.nativeValue(hIcon);
-
- return createCursor(iconPtr);
+ long ptrVal = Pointer.nativeValue(hIcon);
+ ByteBuffer handle = BufferUtils.createByteBuffer(Pointer.SIZE); // Why does it have to be direct? well it crashes without it.
+ if (handle.order() == ByteOrder.LITTLE_ENDIAN) {
+ for (int i = 0; i < Pointer.SIZE; i++) {
+ byte value = (byte) ((ptrVal >> i * 8) & 0xFF);
+ handle.put(value);
+ }
+ } else {
+ for (int i = Pointer.SIZE; i >= 0; i++) {
+ byte value = (byte) ((ptrVal >> i * 8) & 0xFF);
+ handle.put(value);
+ }
+ }
+ handle.position(0);
+ return createCursor(handle);
}
private static Cursor createCursorLinux(int cursor) throws LWJGLException, InstantiationException, InvocationTargetException, IllegalAccessException {
X11.Display display = X11.INSTANCE.XOpenDisplay(null);
@@ -159,8 +212,7 @@ public class GLCursors {
Foundation foundation = Foundation.INSTANCE;
Pointer nsCursor = foundation.objc_getClass("NSCursor");
Pointer selector = foundation.sel_registerName(cursor);
- Structure structure = foundation.objc_msgSend_stret(nsCursor, selector);
- Pointer thePointer = structure.getPointer();
+ Pointer thePointer = foundation.objc_msgSend(nsCursor, selector);
long iconPtr = Pointer.nativeValue(thePointer);
return createCursor(iconPtr);
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/utils/cursor/User32.java b/src/main/java/kr/syeyoung/dungeonsguide/utils/cursor/User32.java
index a5e594ba..5bcd2599 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/utils/cursor/User32.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/utils/cursor/User32.java
@@ -21,6 +21,7 @@ package kr.syeyoung.dungeonsguide.utils.cursor;
import com.sun.jna.Library;
import com.sun.jna.Native;
import com.sun.jna.Pointer;
+import com.sun.jna.Structure;
public interface User32 extends Library {
@@ -62,6 +63,6 @@ public interface User32 extends Library {
/** http://msdn.microsoft.com/en-us/library/ms648391(VS.85).aspx */
public Pointer LoadCursorW(Pointer hInstance,
- int lpCursorName);
+ int lpCursorName);
}
diff --git a/src/main/resources/assets/dg/cursors/IBeamCursor.cur b/src/main/resources/assets/dg/cursors/IBeamCursor.cur
new file mode 100755
index 00000000..19f162df
--- /dev/null
+++ b/src/main/resources/assets/dg/cursors/IBeamCursor.cur
Binary files differ
diff --git a/src/main/resources/assets/dg/cursors/arrowCursor.cur b/src/main/resources/assets/dg/cursors/arrowCursor.cur
new file mode 100755
index 00000000..7d58eec1
--- /dev/null
+++ b/src/main/resources/assets/dg/cursors/arrowCursor.cur
Binary files differ
diff --git a/src/main/resources/assets/dg/cursors/closedHandCursor.cur b/src/main/resources/assets/dg/cursors/closedHandCursor.cur
new file mode 100644
index 00000000..26d6ba9f
--- /dev/null
+++ b/src/main/resources/assets/dg/cursors/closedHandCursor.cur
Binary files differ
diff --git a/src/main/resources/assets/dg/cursors/crosshairCursor.cur b/src/main/resources/assets/dg/cursors/crosshairCursor.cur
new file mode 100755
index 00000000..7d4589af
--- /dev/null
+++ b/src/main/resources/assets/dg/cursors/crosshairCursor.cur
Binary files differ
diff --git a/src/main/resources/assets/dg/cursors/openHandCursor.cur b/src/main/resources/assets/dg/cursors/openHandCursor.cur
new file mode 100644
index 00000000..26d6ba9f
--- /dev/null
+++ b/src/main/resources/assets/dg/cursors/openHandCursor.cur
Binary files differ
diff --git a/src/main/resources/assets/dg/cursors/operationNotAllowedCursor.cur b/src/main/resources/assets/dg/cursors/operationNotAllowedCursor.cur
new file mode 100755
index 00000000..1bb62ed5
--- /dev/null
+++ b/src/main/resources/assets/dg/cursors/operationNotAllowedCursor.cur
Binary files differ
diff --git a/src/main/resources/assets/dg/cursors/pointingHandCursor.cur b/src/main/resources/assets/dg/cursors/pointingHandCursor.cur
new file mode 100755
index 00000000..77313176
--- /dev/null
+++ b/src/main/resources/assets/dg/cursors/pointingHandCursor.cur
Binary files differ
diff --git a/src/main/resources/assets/dg/cursors/resizeDownCursor.cur b/src/main/resources/assets/dg/cursors/resizeDownCursor.cur
new file mode 100755
index 00000000..bae2c237
--- /dev/null
+++ b/src/main/resources/assets/dg/cursors/resizeDownCursor.cur
Binary files differ
diff --git a/src/main/resources/assets/dg/cursors/resizeLeftCursor.cur b/src/main/resources/assets/dg/cursors/resizeLeftCursor.cur
new file mode 100755
index 00000000..b904bc5c
--- /dev/null
+++ b/src/main/resources/assets/dg/cursors/resizeLeftCursor.cur
Binary files differ
diff --git a/src/main/resources/assets/dg/cursors/resizeLeftRightCursor.cur b/src/main/resources/assets/dg/cursors/resizeLeftRightCursor.cur
new file mode 100755
index 00000000..b904bc5c
--- /dev/null
+++ b/src/main/resources/assets/dg/cursors/resizeLeftRightCursor.cur
Binary files differ
diff --git a/src/main/resources/assets/dg/cursors/resizeNE.cur b/src/main/resources/assets/dg/cursors/resizeNE.cur
new file mode 100755
index 00000000..ccaac220
--- /dev/null
+++ b/src/main/resources/assets/dg/cursors/resizeNE.cur
Binary files differ
diff --git a/src/main/resources/assets/dg/cursors/resizeNESW.cur b/src/main/resources/assets/dg/cursors/resizeNESW.cur
new file mode 100755
index 00000000..ccaac220
--- /dev/null
+++ b/src/main/resources/assets/dg/cursors/resizeNESW.cur
Binary files differ
diff --git a/src/main/resources/assets/dg/cursors/resizeNW.cur b/src/main/resources/assets/dg/cursors/resizeNW.cur
new file mode 100755
index 00000000..f67aa78d
--- /dev/null
+++ b/src/main/resources/assets/dg/cursors/resizeNW.cur
Binary files differ
diff --git a/src/main/resources/assets/dg/cursors/resizeNWSE.cur b/src/main/resources/assets/dg/cursors/resizeNWSE.cur
new file mode 100755
index 00000000..f67aa78d
--- /dev/null
+++ b/src/main/resources/assets/dg/cursors/resizeNWSE.cur
Binary files differ
diff --git a/src/main/resources/assets/dg/cursors/resizeRightCursor.cur b/src/main/resources/assets/dg/cursors/resizeRightCursor.cur
new file mode 100755
index 00000000..b904bc5c
--- /dev/null
+++ b/src/main/resources/assets/dg/cursors/resizeRightCursor.cur
Binary files differ
diff --git a/src/main/resources/assets/dg/cursors/resizeSE.cur b/src/main/resources/assets/dg/cursors/resizeSE.cur
new file mode 100755
index 00000000..f67aa78d
--- /dev/null
+++ b/src/main/resources/assets/dg/cursors/resizeSE.cur
Binary files differ
diff --git a/src/main/resources/assets/dg/cursors/resizeSW.cur b/src/main/resources/assets/dg/cursors/resizeSW.cur
new file mode 100755
index 00000000..ccaac220
--- /dev/null
+++ b/src/main/resources/assets/dg/cursors/resizeSW.cur
Binary files differ
diff --git a/src/main/resources/assets/dg/cursors/resizeUpCursor.cur b/src/main/resources/assets/dg/cursors/resizeUpCursor.cur
new file mode 100755
index 00000000..bae2c237
--- /dev/null
+++ b/src/main/resources/assets/dg/cursors/resizeUpCursor.cur
Binary files differ
diff --git a/src/main/resources/assets/dg/cursors/resizeUpDownCursor.cur b/src/main/resources/assets/dg/cursors/resizeUpDownCursor.cur
new file mode 100755
index 00000000..bae2c237
--- /dev/null
+++ b/src/main/resources/assets/dg/cursors/resizeUpDownCursor.cur
Binary files differ