aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/kr/syeyoung/dungeonsguide/gui
diff options
context:
space:
mode:
authorsyeyoung <cyong06@naver.com>2021-08-03 17:23:41 +0900
committersyeyoung <cyong06@naver.com>2021-08-03 17:23:41 +0900
commit982e460c861579f49959c08e25505a27e9c6b3f0 (patch)
tree4cccbe086fd69f5f5be138a3eb24237e0211b76e /src/main/java/kr/syeyoung/dungeonsguide/gui
parentd1c36c2412b98350f8336e38361e49b3655982d5 (diff)
downloadSkyblock-Dungeons-Guide-982e460c861579f49959c08e25505a27e9c6b3f0.tar.gz
Skyblock-Dungeons-Guide-982e460c861579f49959c08e25505a27e9c6b3f0.tar.bz2
Skyblock-Dungeons-Guide-982e460c861579f49959c08e25505a27e9c6b3f0.zip
Too many changes to describe
Config gui overhaul. v2
Diffstat (limited to 'src/main/java/kr/syeyoung/dungeonsguide/gui')
-rwxr-xr-xsrc/main/java/kr/syeyoung/dungeonsguide/gui/elements/MButton.java8
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MModal.java87
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MModalConfirmation.java88
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MRootPanel.java1
-rwxr-xr-xsrc/main/java/kr/syeyoung/dungeonsguide/gui/elements/MTextField.java2
-rwxr-xr-xsrc/main/java/kr/syeyoung/dungeonsguide/gui/elements/MToggleButton.java5
6 files changed, 187 insertions, 4 deletions
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 ff8061e7..6f147472 100755
--- a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MButton.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MButton.java
@@ -24,9 +24,11 @@ import kr.syeyoung.dungeonsguide.utils.cursor.EnumCursor;
import lombok.Getter;
import lombok.Setter;
import net.minecraft.client.Minecraft;
+import net.minecraft.client.audio.PositionedSoundRecord;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.renderer.GlStateManager;
+import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL14;
@@ -53,7 +55,8 @@ public class MButton extends MPanel {
Dimension bounds = getSize();
int bg = background;
- if (!enabled) {
+ if (getTooltipsOpen() > 0) {
+ } else if (!enabled) {
bg = disabled;
} else if (isclicked) {
bg = clicked;
@@ -80,10 +83,11 @@ public class MButton extends MPanel {
boolean isclicked = false;
@Override
public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) {
- if (lastAbsClip.contains(absMouseX, absMouseY)) {
+ if (lastAbsClip.contains(absMouseX, absMouseY) && getTooltipsOpen() == 0) {
isclicked = true;
if (onActionPerformed != null)
onActionPerformed.run();
+ Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.create(new ResourceLocation("gui.button.press"), 1.0F));
}
}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MModal.java b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MModal.java
new file mode 100644
index 00000000..71a13c93
--- /dev/null
+++ b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MModal.java
@@ -0,0 +1,87 @@
+/*
+ * 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.gui.elements;
+
+import kr.syeyoung.dungeonsguide.gui.MPanel;
+import kr.syeyoung.dungeonsguide.utils.RenderUtils;
+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 java.awt.*;
+
+public class MModal extends MTooltip {
+ private MPanel modalContent = new MPanel();
+
+ @Getter @Setter
+ private String title = "Default Title";
+
+ public MModal() {
+ super.add(modalContent);
+ }
+
+ @Override
+ public void resize(int parentWidth, int parentHeight) {
+ super.resize(parentWidth, parentHeight);
+ setBounds(new Rectangle(0,0, parentWidth, parentHeight));
+ }
+
+ @Getter @Setter
+ private Dimension modalSize = new Dimension(300,200);
+
+
+ @Override
+ public void setBounds(Rectangle bounds) {
+ super.setBounds(bounds);
+ Dimension effDim = getEffectiveDimension();
+
+ modalContent.setBounds(new Rectangle((effDim.width - modalSize.width)/2, (effDim.height - modalSize.height)/2 + 16, modalSize.width, modalSize.height-16));
+ }
+
+ @Override
+ public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) {
+ RenderUtils.drawGradientRect(0, 0, bounds.width, bounds.height, -1072689136, -804253680);
+ Dimension effDim = getEffectiveDimension();
+ int x = (effDim.width-modalSize.width)/2;
+ int y = (effDim.height - modalSize.height)/2;
+ GlStateManager.translate(x,y, 0);
+ RenderUtils.drawRoundedRectangle(0,0,modalSize.width, modalSize.height, 10, Math.PI/8, RenderUtils.blendAlpha(0x141414, 0.20f));
+ Gui.drawRect(0,15, modalSize.width, 16, 0xFF02EE67);
+ Gui.drawRect(0,16,modalSize.width, 26, RenderUtils.blendAlpha(0x141414, 0.1f));
+ RenderUtils.drawRoundedRectangle(0,16,modalSize.width, modalSize.height-16, 10, Math.PI/8, RenderUtils.blendAlpha(0x141414, 0.1f));
+
+ GlStateManager.enableTexture2D();
+
+ FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
+ fr.drawString(title, 10,(16-fr.FONT_HEIGHT)/2, -1);
+ }
+
+ @Override
+ public void add(MPanel child) {
+ modalContent.add(child);
+ }
+
+ @Override
+ public void remove(MPanel panel) {
+ modalContent.remove(panel);
+ }
+}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MModalConfirmation.java b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MModalConfirmation.java
new file mode 100644
index 00000000..238392ed
--- /dev/null
+++ b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MModalConfirmation.java
@@ -0,0 +1,88 @@
+/*
+ * 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.gui.elements;
+
+import kr.syeyoung.dungeonsguide.gui.MPanel;
+import kr.syeyoung.dungeonsguide.utils.RenderUtils;
+import lombok.Getter;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.FontRenderer;
+import net.minecraft.client.renderer.GlStateManager;
+import org.lwjgl.opengl.GL11;
+
+import java.awt.*;
+
+public class MModalConfirmation extends MModal {
+ private String content;
+ private Runnable callBackYes;
+ private Runnable callBackNo;
+ @Getter
+ private MButton yes, no;
+ public MModalConfirmation(String title, String content, Runnable callBackYes, Runnable callBackNo) {
+ super();
+ setTitle(title);
+ this.content = content;
+ this.callBackYes = callBackYes;
+ this.callBackNo = callBackNo;
+ this.yes = new MButton();
+ this.no = new MButton();
+ yes.setText("Yes"); no.setText("No");
+ no.setBackground(RenderUtils.blendAlpha(0x141414, 0.15f));
+ no.setHover(RenderUtils.blendAlpha(0x141414, 0.17f));
+ yes.setOnActionPerformed(() -> {
+ close();
+ if (callBackYes != null) callBackYes.run();
+ });
+ no.setOnActionPerformed(() -> {
+ close();
+ if (callBackNo != null) callBackNo.run();
+ });
+ yes.setBackground(RenderUtils.blendAlpha(0x141414, 0.15f));
+ yes.setHover(RenderUtils.blendAlpha(0x141414, 0.17f));
+
+ add(new ConfirmationContent());
+ }
+
+ public class ConfirmationContent extends MPanel {
+ public ConfirmationContent() {
+ add(yes); add(no);
+ }
+
+ @Override
+ public void resize(int parentWidth, int parentHeight) {
+ setBounds(new Rectangle(0,0,parentWidth, parentHeight));
+ System.out.println("Resized to "+parentWidth+"-"+parentHeight);
+ }
+
+ @Override
+ public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) {
+ GlStateManager.translate(5,5,0);
+ FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
+ GL11.glDisable(GL11.GL_SCISSOR_TEST);
+ fr.drawSplitString(content, 0,0, ConfirmationContent.this.bounds.width-10, -1);
+ }
+
+ @Override
+ public void setBounds(Rectangle bounds) {
+ super.setBounds(bounds);
+ yes.setBounds(new Rectangle(10,bounds.height-25,(bounds.width-30)/2, 15));
+ no.setBounds(new Rectangle(yes.getBounds().x + yes.getBounds().width + 10,bounds.height-25,(bounds.width-30)/2, 15));
+ }
+ }
+}
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 d1d96a35..4172acb8 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MRootPanel.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MRootPanel.java
@@ -36,6 +36,7 @@ public class MRootPanel extends MPanel {
public void openTooltip(MTooltip mPanel) {
mPanel.setRoot(this);
tooltips.add(mPanel);
+ mPanel.resize(getBounds().width, getBounds().height);
add(mPanel);
}
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 b61837a4..827dc3e8 100755
--- a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MTextField.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MTextField.java
@@ -125,7 +125,7 @@ public class MTextField extends MPanel {
Rectangle actualField = new Rectangle(1, 3,getBounds().width - 2, getBounds().height - 6);
if (!actualField.contains(relMouseX, relMouseY)) return;
if (!lastAbsClip.contains(absMouseX, absMouseY)) return;
-
+ if (getTooltipsOpen() > 0) return;
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 5709906f..3c223d84 100755
--- a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MToggleButton.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MToggleButton.java
@@ -24,9 +24,11 @@ import kr.syeyoung.dungeonsguide.utils.cursor.EnumCursor;
import lombok.Getter;
import lombok.Setter;
import net.minecraft.client.Minecraft;
+import net.minecraft.client.audio.PositionedSoundRecord;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.renderer.GlStateManager;
+import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL14;
@@ -74,8 +76,9 @@ public class MToggleButton extends MPanel {
@Override
public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) {
- if (onToggle != null && lastAbsClip.contains(absMouseX, absMouseY)) {
+ if (onToggle != null && lastAbsClip.contains(absMouseX, absMouseY) && getTooltipsOpen() == 0) {
enabled = !enabled;
+ Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.create(new ResourceLocation("gui.button.press"), 1.0F));
onToggle.run();
}
}