aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig
diff options
context:
space:
mode:
authorsyeyoung <cyong06@naver.com>2021-07-30 11:43:38 +0900
committersyeyoung <cyong06@naver.com>2021-07-30 11:43:38 +0900
commit16a4367663f5ed2a909804de6d319c97c9854ecc (patch)
tree712c12bc6610659454fc00e4ea3f4be8fcdcc8ed /src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig
parentee96b0e9475fed7e80c4f7037ec5ad44cf07f6c2 (diff)
downloadSkyblock-Dungeons-Guide-16a4367663f5ed2a909804de6d319c97c9854ecc.tar.gz
Skyblock-Dungeons-Guide-16a4367663f5ed2a909804de6d319c97c9854ecc.tar.bz2
Skyblock-Dungeons-Guide-16a4367663f5ed2a909804de6d319c97c9854ecc.zip
Cursors in gui elements
Diffstat (limited to 'src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig')
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/nyu/GuiConfigV2.java8
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/nyu/MCategory.java7
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/nyu/MCategoryElement.java12
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/nyu/RootConfigPanel.java49
-rwxr-xr-xsrc/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/old/MFeature.java4
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/old/PanelDelegate.java34
6 files changed, 78 insertions, 36 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/nyu/GuiConfigV2.java b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/nyu/GuiConfigV2.java
index b22175a4..94dec77b 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/nyu/GuiConfigV2.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/nyu/GuiConfigV2.java
@@ -20,16 +20,22 @@ package kr.syeyoung.dungeonsguide.config.guiconfig.nyu;
import kr.syeyoung.dungeonsguide.config.guiconfig.old.ConfigPanelCreator;
import kr.syeyoung.dungeonsguide.gui.MGui;
+import kr.syeyoung.dungeonsguide.utils.cursor.EnumCursor;
+import kr.syeyoung.dungeonsguide.utils.cursor.GLCursors;
import net.minecraft.client.Minecraft;
+import org.lwjgl.LWJGLException;
+import org.lwjgl.input.Cursor;
+import org.lwjgl.input.Mouse;
import java.awt.*;
+import java.io.IOException;
public class GuiConfigV2 extends MGui {
private RootConfigPanel rootConfigPanel;
public GuiConfigV2() {
- rootConfigPanel = new RootConfigPanel();
+ rootConfigPanel = new RootConfigPanel(this);
rootConfigPanel.setPageGenerator(ConfigPanelCreator.INSTANCE);
getMainPanel().add(rootConfigPanel);
}
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
index 1f6977a0..be7dcfa6 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/nyu/MCategory.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/nyu/MCategory.java
@@ -20,6 +20,7 @@ package kr.syeyoung.dungeonsguide.config.guiconfig.nyu;
import kr.syeyoung.dungeonsguide.config.guiconfig.old.MFeature;
import kr.syeyoung.dungeonsguide.gui.MPanel;
+import kr.syeyoung.dungeonsguide.utils.cursor.EnumCursor;
import lombok.Getter;
import lombok.Setter;
import net.minecraft.client.Minecraft;
@@ -72,4 +73,10 @@ public class MCategory extends MPanel {
if (lastAbsClip.contains(absMouseX, absMouseY))
rootConfigPanel.setCurrentPage(nestedCategory.categoryFull());
}
+
+ @Override
+ public void mouseMoved(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0) {
+ if (lastAbsClip.contains(absMouseX, absMouseY))
+ setCursor(EnumCursor.POINTING_HAND);
+ }
}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/nyu/MCategoryElement.java b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/nyu/MCategoryElement.java
index 5d00d15a..3e7bba67 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/nyu/MCategoryElement.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/nyu/MCategoryElement.java
@@ -20,6 +20,7 @@ package kr.syeyoung.dungeonsguide.config.guiconfig.nyu;
import kr.syeyoung.dungeonsguide.gui.MPanel;
import kr.syeyoung.dungeonsguide.utils.RenderUtils;
+import kr.syeyoung.dungeonsguide.utils.cursor.EnumCursor;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.Gui;
@@ -30,11 +31,11 @@ import java.util.function.Consumer;
public class MCategoryElement extends MPanel {
private String category;
- private Consumer<String> onClick;
+ private Runnable onClick;
private int leftPad = 0;
private int offsetX;
private RootConfigPanel rootConfigPanel;
- public MCategoryElement(String category, Consumer<String> onClick, int leftPad, int offsetX, RootConfigPanel rooot) {
+ public MCategoryElement(String category, Runnable onClick, int leftPad, int offsetX, RootConfigPanel rooot) {
this.category = category;
this.onClick = onClick;
this.leftPad = leftPad;
@@ -70,6 +71,11 @@ public class MCategoryElement extends MPanel {
@Override
public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) {
if (!lastAbsClip.contains(absMouseX, absMouseY)) { return; }
- if (onClick != null) onClick.accept(category);
+ if (onClick != null) onClick.run();
+ }
+ @Override
+ public void mouseMoved(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0) {
+ if (lastAbsClip.contains(absMouseX, absMouseY))
+ setCursor(EnumCursor.POINTING_HAND);
}
}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/nyu/RootConfigPanel.java b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/nyu/RootConfigPanel.java
index 4d99a8bc..e156e849 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/nyu/RootConfigPanel.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/nyu/RootConfigPanel.java
@@ -19,19 +19,17 @@
package kr.syeyoung.dungeonsguide.config.guiconfig.nyu;
import com.google.common.base.Function;
-import com.google.common.base.Supplier;
+import kr.syeyoung.dungeonsguide.config.guiconfig.location.GuiGuiLocationConfig;
import kr.syeyoung.dungeonsguide.config.guiconfig.old.ConfigPanelCreator;
-import kr.syeyoung.dungeonsguide.config.guiconfig.old.FeatureEditPane;
import kr.syeyoung.dungeonsguide.config.guiconfig.old.GuiConfig;
import kr.syeyoung.dungeonsguide.features.AbstractFeature;
import kr.syeyoung.dungeonsguide.features.FeatureRegistry;
import kr.syeyoung.dungeonsguide.gui.MPanel;
import kr.syeyoung.dungeonsguide.gui.elements.*;
import kr.syeyoung.dungeonsguide.utils.RenderUtils;
-import lombok.Data;
import lombok.Getter;
import lombok.Setter;
-import lombok.experimental.Accessors;
+import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import java.awt.*;
@@ -55,7 +53,11 @@ public class RootConfigPanel extends MPanelScaledGUI {
@Getter
private String currentPage = "";
- public RootConfigPanel() {
+ private GuiConfigV2 gui;
+
+ public RootConfigPanel(GuiConfigV2 guiConfigV2) {
+ this.gui = guiConfigV2;
+
navigationScroll = new MScrollablePanel(1);
navigationScroll.setHideScrollBarWhenNotNecessary(false);
add(navigationScroll);
@@ -73,23 +75,6 @@ public class RootConfigPanel extends MPanelScaledGUI {
rePlaceElements();
}
- @Data
- @Accessors(chain = true, fluent = true)
- private static class NestedCategory {
- private final String categoryFull;
- private String categoryName;
- 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);
- return this;
- }
- }
-
private void setupNavigation() {
NestedCategory root = new NestedCategory("ROOT");
for (AbstractFeature abstractFeature : FeatureRegistry.getFeatureList()) {
@@ -98,24 +83,32 @@ public class RootConfigPanel extends MPanelScaledGUI {
NestedCategory currentRoot = root;
for (String s : category.split("\\.")) {
NestedCategory finalCurrentRoot = currentRoot;
- currentRoot = currentRoot.children().computeIfAbsent(s, k -> new NestedCategory(finalCurrentRoot.categoryFull+"."+k));
+ currentRoot = currentRoot.children().computeIfAbsent(s, k -> new NestedCategory(finalCurrentRoot.categoryFull()+"."+k));
}
}
- for (Map.Entry<String, List<AbstractFeature>> stringListEntry : FeatureRegistry.getFeaturesByCategory().entrySet()) {
- ConfigPanelCreator.map.put("ROOT."+stringListEntry.getKey(),(Supplier<MPanel>) () -> new FeatureEditPane(stringListEntry.getValue(), null));
- }
for (NestedCategory value : root.children().values()) {
setupNavigationRecursive(value, navigation, 0, 17);
}
+
+ MCategoryElement current = new MCategoryElement("GUI Relocate",() -> {
+ Minecraft.getMinecraft().displayGuiScreen(new GuiGuiLocationConfig(gui, null));
+ }, 17,17, this);
+ navigation.add(current);
}
private void setupNavigationRecursive(NestedCategory nestedCategory, MPanel parent, int depth, int offset) {
+ ConfigPanelCreator.map.put(nestedCategory.categoryFull(), () -> new MPanelCategory(nestedCategory, this));
+
if (nestedCategory.children().size() == 0) {
- MCategoryElement current = new MCategoryElement(nestedCategory.categoryFull, this::setCurrentPage, 13 * depth + 17, offset, this);
+ MCategoryElement current = new MCategoryElement(nestedCategory.categoryFull(),() -> {
+ setCurrentPage(nestedCategory.categoryFull());
+ }, 13 * depth + 17, offset, this);
parent.add(current);
} else {
- MCategoryElement current = new MCategoryElement(nestedCategory.categoryFull, this::setCurrentPage, 3,offset, this);
+ MCategoryElement current = new MCategoryElement(nestedCategory.categoryFull(),() -> {
+ setCurrentPage(nestedCategory.categoryFull());
+ }, 3,offset, this);
MCollapsable mCollapsable = new MCollapsable(current, this::rePlaceElements);
mCollapsable.setLeftPad(offset-13);
mCollapsable.getLowerElements().setDrawLine(false);
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/old/MFeature.java b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/old/MFeature.java
index 4b3b8237..922f992e 100755
--- a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/old/MFeature.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/old/MFeature.java
@@ -98,11 +98,7 @@ public class MFeature extends MPanel {
@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);
- if (hover != null && new Rectangle(new Point(0,0),getBounds().getSize()).contains(relMousex0, relMousey0)) {
- Gui.drawRect(1,18,getBounds().width -1, getBounds().height-1, hover.getRGB());
- } else {
Gui.drawRect(1,18,getBounds().width -1, getBounds().height-1, 0xFF545454);
- }
Gui.drawRect(0,17,getBounds().width, 18,0xFF444444);
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/old/PanelDelegate.java b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/old/PanelDelegate.java
index 720ae30a..3ae0b2a8 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/old/PanelDelegate.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/old/PanelDelegate.java
@@ -25,6 +25,7 @@ import kr.syeyoung.dungeonsguide.features.GuiFeature;
import kr.syeyoung.dungeonsguide.gui.MPanel;
import kr.syeyoung.dungeonsguide.gui.elements.MPopupMenu;
import kr.syeyoung.dungeonsguide.gui.elements.MTooltip;
+import kr.syeyoung.dungeonsguide.utils.cursor.EnumCursor;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.ScaledResolution;
@@ -368,4 +369,37 @@ public class PanelDelegate extends MPanel {
lastY = absMouseY;
}
}
+
+ @Override
+ public void mouseMoved(int absMouseX, int absMouseY, int relMouseX, int relMouseY) {
+ if (!draggable) return;
+ if (!guiFeature.isEnabled()) return;
+ if (getTooltipsOpen() > 0) return;
+
+ if (selectedPart == -1) {
+ setCursor(EnumCursor.CLOSED_HAND);
+ } else if (selectedPart >= 0) {
+ if (internallyThinking.width < 0 && internallyThinking.height < 0) {
+ setCursor(EnumCursor.RESIZE_TL);
+ } else if (internallyThinking.width < 0 && internallyThinking.height >= 0) {
+ setCursor(EnumCursor.RESIZE_DL);
+ } else if (internallyThinking.width >= 0 && internallyThinking.height >= 0) {
+ setCursor(EnumCursor.RESIZE_DR);
+ } else if (internallyThinking.width >= 0 && internallyThinking.height < 0) {
+ setCursor(EnumCursor.RESIZE_TR);
+ }
+ } else if (lastAbsClip.contains(absMouseX, absMouseY)) {
+ if (relMouseX < 4 && relMouseY < 4) {
+ setCursor(EnumCursor.RESIZE_TL);
+ } else if (relMouseX < 4 && relMouseY > getBounds().height - 4) {
+ setCursor(EnumCursor.RESIZE_DL);
+ } else if (relMouseX > getBounds().width - 4 && relMouseY > getBounds().height - 4) {
+ setCursor(EnumCursor.RESIZE_DR);
+ } else if (relMouseX > getBounds().width - 4 && relMouseY < 4) {
+ setCursor(EnumCursor.RESIZE_TR);
+ } else {
+ setCursor(EnumCursor.OPEN_HAND);
+ }
+ }
+ }
}