diff options
author | syeyoung <cyong06@naver.com> | 2021-07-30 11:43:38 +0900 |
---|---|---|
committer | syeyoung <cyong06@naver.com> | 2021-07-30 11:43:38 +0900 |
commit | 16a4367663f5ed2a909804de6d319c97c9854ecc (patch) | |
tree | 712c12bc6610659454fc00e4ea3f4be8fcdcc8ed /src | |
parent | ee96b0e9475fed7e80c4f7037ec5ad44cf07f6c2 (diff) | |
download | Skyblock-Dungeons-Guide-16a4367663f5ed2a909804de6d319c97c9854ecc.tar.gz Skyblock-Dungeons-Guide-16a4367663f5ed2a909804de6d319c97c9854ecc.tar.bz2 Skyblock-Dungeons-Guide-16a4367663f5ed2a909804de6d319c97c9854ecc.zip |
Cursors in gui elements
Diffstat (limited to 'src')
16 files changed, 208 insertions, 39 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/DungeonsGuide.java b/src/main/java/kr/syeyoung/dungeonsguide/DungeonsGuide.java index f2bdad43..0a744e11 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/DungeonsGuide.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/DungeonsGuide.java @@ -35,6 +35,7 @@ import kr.syeyoung.dungeonsguide.stomp.CloseListener; import kr.syeyoung.dungeonsguide.stomp.StompClient; import kr.syeyoung.dungeonsguide.stomp.StompInterface; import kr.syeyoung.dungeonsguide.utils.AhUtils; +import kr.syeyoung.dungeonsguide.utils.cursor.GLCursors; import kr.syeyoung.dungeonsguide.wsresource.StaticResourceCache; import lombok.Getter; import net.minecraft.client.Minecraft; @@ -157,8 +158,6 @@ public class DungeonsGuide implements DGInterface, CloseListener { } catch (IOException e) { e.printStackTrace(); } - - ProgressManager.pop(progressbar); } @Getter 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); + } + } + } } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gui/MGui.java b/src/main/java/kr/syeyoung/dungeonsguide/gui/MGui.java index c5428c14..d523c923 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/gui/MGui.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/gui/MGui.java @@ -19,11 +19,14 @@ package kr.syeyoung.dungeonsguide.gui; import kr.syeyoung.dungeonsguide.gui.elements.MRootPanel; +import kr.syeyoung.dungeonsguide.utils.cursor.EnumCursor; +import kr.syeyoung.dungeonsguide.utils.cursor.GLCursors; 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 org.lwjgl.LWJGLException; import org.lwjgl.input.Mouse; import org.lwjgl.opengl.GL11; @@ -33,8 +36,15 @@ import java.io.IOException; public class MGui extends GuiScreen { @Getter - private final MPanel mainPanel = new MRootPanel(); + private final MRootPanel mainPanel = new MRootPanel(); + public MGui(){ + try { + Mouse.setNativeCursor(GLCursors.getCursor(EnumCursor.DEFAULT)); + } catch (Throwable e) { + e.printStackTrace(); + } + } @Override public void initGui() { @@ -98,6 +108,12 @@ public class MGui extends GuiScreen { @Override public void onGuiClosed() { super.onGuiClosed(); + + try { + Mouse.setNativeCursor(null); + } catch (LWJGLException e) { + e.printStackTrace(); + } } @Override @@ -122,10 +138,23 @@ public class MGui extends GuiScreen { } } + public void mouseMove(int mouseX, int mouseY) { + try { + mainPanel.mouseMoved0(mouseX, mouseY + ,mouseX ,mouseY); + } catch (Throwable e) { + if (e.getMessage() == null || !e.getMessage().contains("hack to stop")) + e.printStackTrace(); + } + } + + private int touchValue; private int eventButton; private long lastMouseEvent; + + private int lastX, lastY; @Override public void handleMouseInput() throws IOException { try { @@ -159,14 +188,30 @@ public class MGui extends GuiScreen { long l = Minecraft.getSystemTime() - this.lastMouseEvent; this.mouseClickMove(i, j, this.eventButton, l); } + if (lastX != i || lastY != j) { + try { + EnumCursor prevCursor = mainPanel.getCurrentCursor(); + mainPanel.setCursor(EnumCursor.DEFAULT); + this.mouseMove(i, j); + EnumCursor newCursor = mainPanel.getCurrentCursor(); + if (prevCursor != newCursor) Mouse.setNativeCursor(GLCursors.getCursor(newCursor)); + } catch (Throwable e) { + if (e.getMessage() == null || !e.getMessage().contains("hack to stop")) + e.printStackTrace(); + } + } int wheel = Mouse.getDWheel(); if (wheel != 0) { mainPanel.mouseScrolled0(i, j,i,j, wheel); } + lastX = i; + lastY = j; } catch (Throwable e) { e.printStackTrace(); } } + + } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gui/MPanel.java b/src/main/java/kr/syeyoung/dungeonsguide/gui/MPanel.java index 84cccdf5..126d69b6 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/gui/MPanel.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/gui/MPanel.java @@ -19,6 +19,7 @@ package kr.syeyoung.dungeonsguide.gui; import kr.syeyoung.dungeonsguide.gui.elements.MTooltip; +import kr.syeyoung.dungeonsguide.utils.cursor.EnumCursor; import lombok.AccessLevel; import lombok.Getter; import lombok.Setter; @@ -264,4 +265,19 @@ public class MPanel { mouseScrolled(absMouseX, absMouseY, relMousex, relMousey, scrollAmount); } public void mouseScrolled(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0, int scrollAmount) {} + + public void mouseMoved0(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0) { + int relMousex = relMouseX0 - getBounds().x; + int relMousey = relMouseY0 - getBounds().y; + + mouseMoved(absMouseX, absMouseY, relMousex, relMousey); + for (MPanel childComponent : getChildComponents()) { + childComponent.mouseMoved0(absMouseX, absMouseY, relMousex, relMousey); + } + } + public void mouseMoved(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0) {} + + public void setCursor(EnumCursor enumCursor) { + parent.setCursor(enumCursor); + } } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MButton.java b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MButton.java index da2ff78c..1a1f30d4 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MButton.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MButton.java @@ -20,6 +20,7 @@ package kr.syeyoung.dungeonsguide.gui.elements; import kr.syeyoung.dungeonsguide.gui.MPanel; import kr.syeyoung.dungeonsguide.utils.RenderUtils; +import kr.syeyoung.dungeonsguide.utils.cursor.EnumCursor; import lombok.Getter; import lombok.Setter; import net.minecraft.client.Minecraft; @@ -85,4 +86,12 @@ public class MButton extends MPanel { public void mouseReleased(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int state) { isclicked = false; } + + + @Override + public void mouseMoved(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0) { + if (lastAbsClip.contains(absMouseX, absMouseY) && enabled) + setCursor(EnumCursor.POINTING_HAND); + } + } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MCollapsable.java b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MCollapsable.java index ef10377e..20fa2c93 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MCollapsable.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MCollapsable.java @@ -19,6 +19,7 @@ package kr.syeyoung.dungeonsguide.gui.elements; import kr.syeyoung.dungeonsguide.gui.MPanel; +import kr.syeyoung.dungeonsguide.utils.cursor.EnumCursor; import lombok.Getter; import lombok.Setter; import net.minecraft.client.Minecraft; @@ -128,4 +129,10 @@ public class MCollapsable extends MPanel { if (onPreferedSizeChange != null) onPreferedSizeChange.run(); } } + + @Override + public void mouseMoved(int absMouseX, int absMouseY, int relMouseX, int relMouseY) { + if (relMouseX >= leftPad && relMouseY >= 0 && relMouseX <= leftPad + 10 && relMouseY <= representing.getPreferredSize().height) + setCursor(EnumCursor.POINTING_HAND); + } } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MPanelScaledGUI.java b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MPanelScaledGUI.java index 64599058..4a1d30ee 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MPanelScaledGUI.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MPanelScaledGUI.java @@ -196,4 +196,17 @@ public class MPanelScaledGUI extends MPanel { } mouseScrolled(absMouseX, absMouseY, relMousex, relMousey, scrollAmount); } + + @Override + public void mouseMoved0(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0) { + int relMousex = (int) ((relMouseX0 - getBounds().x) / scale); + int relMousey = (int) ((relMouseY0 - getBounds().y) / scale); + absMouseX = (int) (absMouseX / scale); + absMouseY = (int) (absMouseY / scale); + + mouseMoved(absMouseX, absMouseY, relMousex, relMousey); + for (MPanel childComponent : getChildComponents()) { + childComponent.mouseMoved0(absMouseX, absMouseY, relMousex, relMousey); + } + } } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MRootPanel.java b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MRootPanel.java index a6987241..d1d96a35 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MRootPanel.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MRootPanel.java @@ -19,7 +19,9 @@ package kr.syeyoung.dungeonsguide.gui.elements; import kr.syeyoung.dungeonsguide.gui.MPanel; +import kr.syeyoung.dungeonsguide.utils.cursor.EnumCursor; import lombok.Getter; +import lombok.Setter; import java.util.List; import java.util.concurrent.CopyOnWriteArrayList; @@ -47,4 +49,11 @@ public class MRootPanel extends MPanel { tooltips.remove(mTooltip); remove(mTooltip); } + + @Getter @Setter + private EnumCursor currentCursor = EnumCursor.DEFAULT; + @Override + public void setCursor(EnumCursor enumCursor) { + currentCursor = enumCursor; + } } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MScrollBar.java b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MScrollBar.java index 215c7c6d..1797297a 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MScrollBar.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MScrollBar.java @@ -21,6 +21,7 @@ package kr.syeyoung.dungeonsguide.gui.elements; import kr.syeyoung.dungeonsguide.config.types.AColor; import kr.syeyoung.dungeonsguide.gui.MPanel; import kr.syeyoung.dungeonsguide.utils.RenderUtils; +import kr.syeyoung.dungeonsguide.utils.cursor.EnumCursor; import lombok.Getter; import lombok.Setter; import net.minecraft.client.gui.Gui; @@ -71,6 +72,7 @@ public class MScrollBar extends MPanel { this.onUpdate = onUpdate; } + private Rectangle lastThumbRect = new Rectangle(); @Override public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { // RENDER SUPER NICE SCROLL BAR @@ -93,12 +95,14 @@ public class MScrollBar extends MPanel { endX = Math.max(endX, startX + 20); Gui.drawRect(startX,0,endX,getBounds().height, color); + lastThumbRect.x = startX; lastThumbRect.y = 0; lastThumbRect.width = endX - startX; lastThumbRect.height = getBounds().height; } else if (axis == Axis.Y) { int startY = (int) (startPerc * getBounds().height); int endY = (int) (endPerc * getBounds().height); endY = Math.max(endY, startY + 20); Gui.drawRect(0,startY,getBounds().width,endY, color); + lastThumbRect.x = 0; lastThumbRect.y = startY; lastThumbRect.width = getBounds().width; lastThumbRect.height = endY - startY; } } @@ -146,4 +150,13 @@ public class MScrollBar extends MPanel { public static enum Axis { X, Y } + + + @Override + public void mouseMoved(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0) { + if (grabbed) + setCursor(EnumCursor.CLOSED_HAND); + else if (lastThumbRect.contains(relMouseX0, relMouseY0)) + setCursor(EnumCursor.OPEN_HAND); + } } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MTextField.java b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MTextField.java index 6d8b3f51..6054a68f 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MTextField.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MTextField.java @@ -20,6 +20,7 @@ package kr.syeyoung.dungeonsguide.gui.elements; import kr.syeyoung.dungeonsguide.gui.MPanel; import kr.syeyoung.dungeonsguide.utils.RenderUtils; +import kr.syeyoung.dungeonsguide.utils.cursor.EnumCursor; import lombok.Getter; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; @@ -371,4 +372,11 @@ public class MTextField extends MPanel { block != Character.UnicodeBlock.SPECIALS; } + + @Override + public void mouseMoved(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0) { + if (lastAbsClip.contains(absMouseX, absMouseY)) + setCursor(EnumCursor.BEAM_CURSOR); + } + } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MToggleButton.java b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MToggleButton.java index 5b99959f..d3a3fe06 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MToggleButton.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MToggleButton.java @@ -20,6 +20,7 @@ package kr.syeyoung.dungeonsguide.gui.elements; import kr.syeyoung.dungeonsguide.gui.MPanel; import kr.syeyoung.dungeonsguide.utils.RenderUtils; +import kr.syeyoung.dungeonsguide.utils.cursor.EnumCursor; import lombok.Getter; import lombok.Setter; import net.minecraft.client.Minecraft; @@ -76,4 +77,11 @@ public class MToggleButton extends MPanel { onToggle.run(); } } + + + @Override + public void mouseMoved(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0) { + if (lastAbsClip.contains(absMouseX, absMouseY)) + setCursor(EnumCursor.POINTING_HAND); + } } |