aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rwxr-xr-xsrc/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/GuiConfig.java69
-rwxr-xr-xsrc/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/GuiGuiLocationConfig.java78
-rwxr-xr-xsrc/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/GuiParameterValueEdit.java102
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/PanelDelegate.java182
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/config/types/GUIRectangle.java29
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/features/GuiFeature.java10
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/features/text/PanelTextParameterConfig.java2
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/gui/MGui.java172
-rw-r--r--[-rwxr-xr-x]src/main/java/kr/syeyoung/dungeonsguide/gui/MPanel.java31
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MRootPanel.java50
-rwxr-xr-xsrc/main/java/kr/syeyoung/dungeonsguide/gui/elements/MToggleButton.java2
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MTooltip.java86
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MTooltipText.java44
-rwxr-xr-xsrc/main/java/kr/syeyoung/dungeonsguide/roomedit/gui/GuiDungeonAddSet.java75
-rwxr-xr-xsrc/main/java/kr/syeyoung/dungeonsguide/roomedit/gui/GuiDungeonParameterEdit.java76
-rwxr-xr-xsrc/main/java/kr/syeyoung/dungeonsguide/roomedit/gui/GuiDungeonRoomEdit.java66
-rwxr-xr-xsrc/main/java/kr/syeyoung/dungeonsguide/roomedit/gui/GuiDungeonValueEdit.java106
17 files changed, 541 insertions, 639 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/GuiConfig.java b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/GuiConfig.java
index 18828abd..24b98e00 100755
--- a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/GuiConfig.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/GuiConfig.java
@@ -21,6 +21,7 @@ package kr.syeyoung.dungeonsguide.config.guiconfig;
import com.google.common.base.Supplier;
import kr.syeyoung.dungeonsguide.features.AbstractFeature;
import kr.syeyoung.dungeonsguide.features.FeatureRegistry;
+import kr.syeyoung.dungeonsguide.gui.MGui;
import kr.syeyoung.dungeonsguide.gui.MPanel;
import kr.syeyoung.dungeonsguide.gui.elements.MNavigatingPane;
import kr.syeyoung.dungeonsguide.gui.elements.MTabbedPane;
@@ -42,9 +43,8 @@ import java.util.Map;
import java.util.Stack;
import java.util.stream.Collectors;
-public class GuiConfig extends GuiScreen {
+public class GuiConfig extends MGui {
- private final MPanel mainPanel = new MPanel();
@Getter
private final MNavigatingPane tabbedPane;
@@ -53,7 +53,7 @@ public class GuiConfig extends GuiScreen {
public GuiConfig() {
MNavigatingPane tabbedPane = new MNavigatingPane();
- mainPanel.add(tabbedPane);
+ getMainPanel().add(tabbedPane);
tabbedPane.setBackground2(new Color(38, 38, 38, 255));
tabbedPane.setPageGenerator(ConfigPanelCreator.INSTANCE);
@@ -90,67 +90,6 @@ public class GuiConfig extends GuiScreen {
@Override
public void initGui() {
super.initGui();
- ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
- mainPanel.setBounds(new Rectangle(Math.min((scaledResolution.getScaledWidth() - 500) / 2, scaledResolution.getScaledWidth()), Math.min((scaledResolution.getScaledHeight() - 300) / 2, scaledResolution.getScaledHeight()),500,300));
- }
- FloatBuffer floatBuffer = BufferUtils.createFloatBuffer(16);
-
- @Override
- public void drawScreen(int mouseX, int mouseY, float partialTicks) {
- try {
- ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
- GlStateManager.pushMatrix();
- GlStateManager.pushAttrib();
- GlStateManager.disableLighting();
- GlStateManager.disableFog();
- GL11.glDisable(GL11.GL_FOG);
- GlStateManager.color(1, 1, 1, 1);
- GlStateManager.disableDepth();
- GlStateManager.depthMask(false);
- mainPanel.render0(scaledResolution, new Point(0,0), new Rectangle(0,0,scaledResolution.getScaledWidth(),scaledResolution.getScaledHeight()), mouseX, mouseY, mouseX, mouseY, partialTicks);
- GlStateManager.enableDepth();
- GlStateManager.depthMask(true);
- GlStateManager.popAttrib();
- GlStateManager.popMatrix();
- GlStateManager.enableBlend();
- GlStateManager.enableLighting();
- } catch (Throwable e) {
- e.printStackTrace();
- }
- }
-
- @Override
- public void keyTyped(char typedChar, int keyCode) throws IOException {
- super.keyTyped(typedChar, keyCode);
- mainPanel.keyTyped0(typedChar, keyCode);
- }
-
- @Override
- public void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
- super.mouseClicked(mouseX, mouseY, mouseButton);
- mainPanel.mouseClicked0(mouseX, mouseY,mouseX,mouseY, mouseButton);
- }
-
- @Override
- public void mouseReleased(int mouseX, int mouseY, int state) {
- mainPanel.mouseReleased0(mouseX, mouseY,mouseX,mouseY, state);
- }
-
- @Override
- public void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) {
- mainPanel.mouseClickMove0(mouseX,mouseY,mouseX,mouseY,clickedMouseButton,timeSinceLastClick);
- }
-
- @Override
- public void handleMouseInput() throws IOException {
- super.handleMouseInput();
-
- int i = Mouse.getEventX() * this.width / this.mc.displayWidth;
- int j = this.height - Mouse.getEventY() * this.height / this.mc.displayHeight - 1;
-
- int wheel = Mouse.getDWheel();
- if (wheel != 0) {
- mainPanel.mouseScrolled0(i, j,i,j, wheel);
- }
+ getMainPanel().setBounds(new Rectangle(Math.min((Minecraft.getMinecraft().displayWidth - 500) / 2, Minecraft.getMinecraft().displayWidth), Math.min((Minecraft.getMinecraft().displayHeight - 300) / 2, Minecraft.getMinecraft().displayHeight),500,300));
}
}
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 8e186e6b..11dd2db2 100755
--- a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/GuiGuiLocationConfig.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/GuiGuiLocationConfig.java
@@ -21,6 +21,7 @@ package kr.syeyoung.dungeonsguide.config.guiconfig;
import kr.syeyoung.dungeonsguide.features.AbstractFeature;
import kr.syeyoung.dungeonsguide.features.FeatureRegistry;
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 net.minecraft.client.Minecraft;
@@ -33,20 +34,19 @@ import org.lwjgl.opengl.GL11;
import java.awt.*;
import java.io.IOException;
-public class GuiGuiLocationConfig extends GuiScreen {
+public class GuiGuiLocationConfig extends MGui {
- private final MPanel mainPanel = new MPanel();
private final GuiScreen before;
public GuiGuiLocationConfig(final GuiScreen before, AbstractFeature featureWhitelist) {
this.before = before;
for (AbstractFeature feature : FeatureRegistry.getFeatureList()) {
if (feature instanceof GuiFeature && feature.isEnabled()) {
- mainPanel.add(new PanelDelegate((GuiFeature) feature, featureWhitelist == null || feature == featureWhitelist));
+ getMainPanel().add(new PanelDelegate((GuiFeature) feature, featureWhitelist == null || feature == featureWhitelist));
}
}
- mainPanel.setBackgroundColor(new Color(0,0,0, 60));
+ getMainPanel().setBackgroundColor(new Color(0,0,0, 60));
{
MButton button = new MButton() {
@Override
@@ -61,80 +61,14 @@ public class GuiGuiLocationConfig extends GuiScreen {
Minecraft.getMinecraft().displayGuiScreen(before);
}
});
- mainPanel.add(button);
+ getMainPanel().add(button);
}
}
@Override
public void initGui() {
super.initGui();
- ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
- mainPanel.setBounds(new Rectangle(0,0,scaledResolution.getScaledWidth(),scaledResolution.getScaledHeight()));
+ getMainPanel().setBounds(new Rectangle(0,0,Minecraft.getMinecraft().displayWidth,Minecraft.getMinecraft().displayHeight));
}
- @Override
- public void drawScreen(int mouseX, int mouseY, float partialTicks) {
-
- ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
- GlStateManager.pushMatrix();
- GlStateManager.pushAttrib();
- GlStateManager.disableLighting();
- GlStateManager.disableFog();
- GL11.glDisable(GL11.GL_FOG);
- GlStateManager.color(1, 1, 1, 1);
- GlStateManager.disableDepth();
- GlStateManager.depthMask(false);
- mainPanel.render0(scaledResolution, new Point(0,0), new Rectangle(0,0,scaledResolution.getScaledWidth(),scaledResolution.getScaledHeight()), mouseX, mouseY, mouseX, mouseY, partialTicks);
- GlStateManager.enableDepth();
- GlStateManager.depthMask(true);
- GlStateManager.popAttrib();
- GlStateManager.popMatrix();
- GlStateManager.enableBlend();
- GlStateManager.enableLighting();
- }
-
- @Override
- public void keyTyped(char typedChar, int keyCode) throws IOException {
- super.keyTyped(typedChar, keyCode);
- mainPanel.keyTyped0(typedChar, keyCode);
- }
-
- @Override
- public void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
- super.mouseClicked(mouseX, mouseY, mouseButton);
- try {
- mainPanel.mouseClicked0(mouseX, mouseY, mouseX, mouseY, mouseButton);
- } catch (IllegalArgumentException ignored) {
- } catch (Throwable t) {
- t.printStackTrace();
- }
- }
-
- @Override
- public void mouseReleased(int mouseX, int mouseY, int state) {
- mainPanel.mouseReleased0(mouseX, mouseY,mouseX,mouseY, state);
- }
-
- @Override
- public void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) {
- try {
- mainPanel.mouseClickMove0(mouseX,mouseY,mouseX,mouseY,clickedMouseButton,timeSinceLastClick);
- } catch (IllegalArgumentException ignored) {
- } catch (Throwable t) {
- t.printStackTrace();
- }
- }
-
- @Override
- public void handleMouseInput() throws IOException {
- super.handleMouseInput();
-
- int i = Mouse.getEventX() * this.width / this.mc.displayWidth;
- int j = this.height - Mouse.getEventY() * this.height / this.mc.displayHeight - 1;
-
- int wheel = Mouse.getDWheel();
- if (wheel != 0) {
- mainPanel.mouseScrolled0(i, j,i,j, wheel);
- }
- }
}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/GuiParameterValueEdit.java b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/GuiParameterValueEdit.java
index ce106433..0d7b819c 100755
--- a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/GuiParameterValueEdit.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/GuiParameterValueEdit.java
@@ -18,6 +18,7 @@
package kr.syeyoung.dungeonsguide.config.guiconfig;
+import kr.syeyoung.dungeonsguide.gui.MGui;
import kr.syeyoung.dungeonsguide.gui.MPanel;
import kr.syeyoung.dungeonsguide.roomedit.Parameter;
import kr.syeyoung.dungeonsguide.gui.elements.MButton;
@@ -37,14 +38,7 @@ import org.lwjgl.opengl.GL11;
import java.awt.*;
import java.io.IOException;
-public class GuiParameterValueEdit extends GuiScreen {
-
- private final MPanel mainPanel = new MPanel() {
- @Override
- public void onBoundsUpdate() {
- save.setBounds(new Rectangle(0 ,getBounds().height - 20, getBounds().width, 20));
- }
- };
+public class GuiParameterValueEdit extends MGui {
private MPanel currentValueEdit;
@@ -65,7 +59,7 @@ public class GuiParameterValueEdit extends GuiScreen {
public GuiParameterValueEdit(final Object object, final GuiConfig prev) {
try {
this.editingObj = object;
- mainPanel.setBackgroundColor(new Color(17, 17, 17, 179));
+ getMainPanel().setBackgroundColor(new Color(17, 17, 17, 179));
{
currentValueEdit = new MPanel() {
@Override
@@ -73,7 +67,7 @@ public class GuiParameterValueEdit extends GuiScreen {
setBounds(new Rectangle(5, 5, parentWidth-10, parentHeight - 25));
}
};
- mainPanel.add(currentValueEdit);
+ getMainPanel().add(currentValueEdit);
}
{
save = new MButton() {
@@ -91,7 +85,7 @@ public class GuiParameterValueEdit extends GuiScreen {
Minecraft.getMinecraft().displayGuiScreen(prev);
}
});
- mainPanel.add(save);
+ getMainPanel().add(save);
}
updateClassSelection();
} catch (Exception e){}
@@ -123,89 +117,7 @@ public class GuiParameterValueEdit extends GuiScreen {
public void initGui() {
super.initGui();
// update bounds
- ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
- mainPanel.setBounds(new Rectangle(10, Math.min((scaledResolution.getScaledHeight() - 300) / 2, scaledResolution.getScaledHeight()),200,300));
- }
-
- @Override
- public void drawScreen(int mouseX, int mouseY, float partialTicks) {
- try {
-
- ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
- GlStateManager.pushMatrix();
- GlStateManager.pushAttrib();
- GlStateManager.disableLighting();
- GlStateManager.disableFog();
- GL11.glDisable(GL11.GL_FOG);
- GlStateManager.color(1, 1, 1, 1);
- GlStateManager.disableDepth();
- GlStateManager.depthMask(false);
- mainPanel.render0(scaledResolution, new Point(0,0), new Rectangle(0,0,scaledResolution.getScaledWidth(),scaledResolution.getScaledHeight()), mouseX, mouseY, mouseX, mouseY, partialTicks);
- GlStateManager.enableDepth();
- GlStateManager.depthMask(true);
- GlStateManager.popAttrib();
- GlStateManager.popMatrix();
- GlStateManager.enableBlend();
- GlStateManager.enableLighting();
- } catch (Throwable e) {
- e.printStackTrace();
- }
- }
-
- @Override
- public void keyTyped(char typedChar, int keyCode) throws IOException {
-
- try {
- super.keyTyped(typedChar, keyCode);
- mainPanel.keyTyped0(typedChar, keyCode);
- } catch (Throwable t) {
- t.printStackTrace();
- }
- }
-
- @Override
- public void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
- try {
- super.mouseClicked(mouseX, mouseY, mouseButton);
- mainPanel.mouseClicked0(mouseX, mouseY,mouseX,mouseY, mouseButton);
- } catch (Throwable t) {
- t.printStackTrace();
- }
- }
-
- @Override
- public void mouseReleased(int mouseX, int mouseY, int state) {
- try {
- mainPanel.mouseReleased0(mouseX, mouseY,mouseX,mouseY, state);
- } catch (Throwable t) {
- t.printStackTrace();
- }
- }
-
- @Override
- public void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) {
- try {
- mainPanel.mouseClickMove0(mouseX,mouseY,mouseX,mouseY,clickedMouseButton,timeSinceLastClick);
-
- } catch (Throwable t) {
- t.printStackTrace();
- }
- }
-
- @Override
- public void handleMouseInput() throws IOException {
- super.handleMouseInput();
-
- int i = Mouse.getEventX() * this.width / this.mc.displayWidth;
- int j = this.height - Mouse.getEventY() * this.height / this.mc.displayHeight - 1;
-
- int wheel = Mouse.getDWheel();
- if (wheel != 0) {
- try {
- mainPanel.mouseScrolled0(i, j,i,j, wheel);
- } catch (Throwable t) {
- t.printStackTrace();
- }
- }
+ getMainPanel().setBounds(new Rectangle(10, Math.min((Minecraft.getMinecraft().displayHeight - 300) / 2, Minecraft.getMinecraft().displayHeight),200,300));
+ save.setBounds(new Rectangle(0 ,getMainPanel().getBounds().height - 20, getMainPanel().getBounds().width, 20));
}
}
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 09614313..7abb54b9 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/PanelDelegate.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/PanelDelegate.java
@@ -39,29 +39,30 @@ public class PanelDelegate extends MPanel {
@Override
public Rectangle getBounds() {
- return guiFeature.getFeatureRect().getRectangle();
+ Rectangle rectangle = guiFeature.getFeatureRect().getRectangle();
+ return new Rectangle(rectangle.x, rectangle.y, rectangle.width, rectangle.height);
}
@Override
public void render(int absMousex, int absMousey, int relMouseX, int relMouseY, float partialTicks, Rectangle scissor) {
+
GlStateManager.pushMatrix();
guiFeature.drawDemo(partialTicks);
GlStateManager.popMatrix();
-
if (!draggable) return;
- Gui.drawRect(0,0, 3, 3, 0xFFBBBBBB);
- Gui.drawRect(0, getBounds().height - 3, 3, getBounds().height, 0xFFBBBBBB);
- Gui.drawRect(getBounds().width - 3,0, getBounds().width, 3, 0xFFBBBBBB);
- Gui.drawRect(getBounds().width - 3,getBounds().height - 3, getBounds().width, getBounds().height, 0xFFBBBBBB);
+ Gui.drawRect(0,0, 4, 4, 0xFFBBBBBB);
+ Gui.drawRect(0, getBounds().height - 4, 4, getBounds().height, 0xFFBBBBBB);
+ Gui.drawRect(getBounds().width - 4,0, getBounds().width, 4, 0xFFBBBBBB);
+ Gui.drawRect(getBounds().width - 4,getBounds().height - 4, getBounds().width, getBounds().height, 0xFFBBBBBB);
if (lastAbsClip.contains(absMousex, absMousey)) {
- if (relMouseX < 3 && relMouseY < 3) {
- Gui.drawRect(0,0, 3, 3, 0x55FFFFFF);
- } else if (relMouseX < 3 && relMouseY > getBounds().height - 3) {
- Gui.drawRect(0, getBounds().height - 3, 3, getBounds().height, 0x55FFFFFF);
- } else if (relMouseX > getBounds().width - 3 && relMouseY > getBounds().height - 3) {
- Gui.drawRect(getBounds().width - 3,getBounds().height - 3, getBounds().width, getBounds().height, 0x55FFFFFF);
- } else if (relMouseX > getBounds().width - 3 && relMouseY < 3) {
- Gui.drawRect(getBounds().width - 3,0, getBounds().width, 3, 0x55FFFFFF);
+ if (relMouseX < 4 && relMouseY < 4) {
+ Gui.drawRect(0,0, 4, 4, 0x55FFFFFF);
+ } else if (relMouseX < 4 && relMouseY > getBounds().height - 4) {
+ Gui.drawRect(0, getBounds().height - 4, 4, getBounds().height, 0x55FFFFFF);
+ } else if (relMouseX > getBounds().width - 4 && relMouseY > getBounds().height - 4) {
+ Gui.drawRect(getBounds().width - 4,getBounds().height - 4, getBounds().width, getBounds().height, 0x55FFFFFF);
+ } else if (relMouseX > getBounds().width - 4 && relMouseY < 4) {
+ Gui.drawRect(getBounds().width - 4,0, getBounds().width, 4, 0x55FFFFFF);
} else if (selectedPart == -2){
Gui.drawRect(0,0, getBounds().width, getBounds().height, 0x55FFFFFF);
}
@@ -74,24 +75,79 @@ public class PanelDelegate extends MPanel {
private int lastX = 0;
private int lastY = 0;
+ private Rectangle internallyThinking;
+ private Rectangle constraintApplied;
+
+ 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;
+ }
+
+ 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;
+
+ if (guiFeature.isKeepRatio()) {
+ double ratio = guiFeature.getDefaultRatio();
+
+ 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;
+ } 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;
+ }
+ }
+
+ if (rectangle.height < 0) {
+ rectangle.height = -rectangle.height;
+ rectangle.y -= rectangle.height;
+ }
+
+ if (rectangle.width < 0) {
+ rectangle.width = -rectangle.width;
+ rectangle.x -= rectangle.width;
+ }
+
+ 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;
+
+
+ constraintApplied = rectangle;
+ }
@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 < 3 && relMouseY < 3) {
+ if (relMouseX < 4 && relMouseY < 4) {
selectedPart = 0;
- } else if (relMouseX < 3 && relMouseY > getBounds().height - 3) {
+ } else if (relMouseX < 4 && relMouseY > getBounds().height - 4) {
selectedPart = 2;
- } else if (relMouseX > getBounds().width - 3 && relMouseY > getBounds().height - 3) {
+ } else if (relMouseX > getBounds().width - 4 && relMouseY > getBounds().height - 4) {
selectedPart = 3;
- } else if (relMouseX > getBounds().width - 3 && relMouseY < 3) {
+ } else if (relMouseX > getBounds().width - 4 && relMouseY < 4) {
selectedPart = 1;
} else {
selectedPart = -1;
}
lastX = absMouseX;
lastY = absMouseY;
+ internallyThinking = guiFeature.getFeatureRect().getRectangleNoScale();
+ applyConstraint();
throw new IllegalArgumentException("bruh, a hack to stop event progress");
}
@@ -100,104 +156,50 @@ public class PanelDelegate extends MPanel {
public void mouseReleased(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int state) {
if (!draggable) return;
if (selectedPart >= -1) {
- 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;
- }
- Rectangle rectangle = guiFeature.getFeatureRect().getRectangle().getBounds();
- if (rectangle.width < minWidth || rectangle.height < minHeight) {
- rectangle.width = minWidth;
- rectangle.height= minHeight;
- }
- ScaledResolution sr = new ScaledResolution(Minecraft.getMinecraft());
- if (rectangle.x < 0) rectangle.x = 0;
- if (rectangle.y < 0) rectangle.y = 0;
- if (rectangle.x + rectangle.width + 1 >= sr.getScaledWidth()) rectangle.x = sr.getScaledWidth() - rectangle.width - 1;
- if (rectangle.y + rectangle.height + 1>= sr.getScaledHeight()) rectangle.y = sr.getScaledHeight() - rectangle.height - 1;
- guiFeature.setFeatureRect(new GUIRectangle(rectangle));
+ guiFeature.setFeatureRect(new GUIRectangle(constraintApplied));
}
selectedPart = -2;
-
-
}
@Override
public void mouseClickMove(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int clickedMouseButton, long timeSinceLastClick) {
if (!draggable) return;
- int dx = absMouseX - lastX;
- int dy = absMouseY - lastY;
+ int dx = (absMouseX - lastX);
+ int dy = (absMouseY - lastY);
if (selectedPart >= 0) {
+ Rectangle rectangle = internallyThinking;
+
boolean revChangeX = (selectedPart & 0x1) == 0;
boolean revChangeY = (selectedPart & 0x2) == 0;
- Rectangle rectangle = guiFeature.getFeatureRect().getRectangle().getBounds();
int prevWidth = rectangle.width;
int prevHeight= rectangle.height;
rectangle.width = prevWidth + (revChangeX ? -1 : 1) * dx;
- rectangle.height = prevHeight + (revChangeY ? - 1: 1 ) * dy;
-
- if (guiFeature.isKeepRatio()) {
- double ratio = guiFeature.getDefaultRatio();
- int width1 = rectangle.width;
- int height1 = (int) (width1 / ratio);
-
- int width2 = (int) (rectangle.height * ratio);
- int height2 = rectangle.height;
+ rectangle.height = prevHeight + (revChangeY ? -1 : 1 ) * dy;
- if (ratio >= 1) {
- rectangle.width = width1;
- rectangle.height = height1;
- } else {
- rectangle.width = width2;
- rectangle.height = height2;
- }
+ 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));
lastX = absMouseX;
lastY = absMouseY;
-
- if (rectangle.height < 0) {
- rectangle.height = -rectangle.height;
- rectangle.y -= rectangle.height;
- selectedPart = selectedPart ^ 0x2;
- lastY += revChangeY ? 3 : 3;
- }
-
- if (rectangle.width < 0) {
- rectangle.width = -rectangle.width;
- rectangle.x -= rectangle.width;
- selectedPart = selectedPart ^ 0x1;
- lastX += revChangeX ? 3 : 3;
- }
-
- ScaledResolution sr = new ScaledResolution(Minecraft.getMinecraft());
- if (rectangle.x < 0) rectangle.x = 0;
- if (rectangle.y < 0) rectangle.y = 0;
- if (rectangle.x + rectangle.width + 1 >= sr.getScaledWidth()) rectangle.x = sr.getScaledWidth() - rectangle.width - 1;
- if (rectangle.y + rectangle.height + 1>= sr.getScaledHeight()) rectangle.y = sr.getScaledHeight() - rectangle.height - 1;
-
- guiFeature.setFeatureRect(new GUIRectangle(rectangle));
throw new IllegalArgumentException("bruh, a hack to stop event progress");
} else if (selectedPart == -1){
- Rectangle rectangle = guiFeature.getFeatureRect().getRectangle().getBounds();
+ Rectangle rectangle = internallyThinking;
rectangle.translate(dx, dy);
-
- ScaledResolution sr = new ScaledResolution(Minecraft.getMinecraft());
- if (rectangle.x < 0) rectangle.x = 0;
- if (rectangle.y < 0) rectangle.y = 0;
- if (rectangle.x + rectangle.width + 1 >= sr.getScaledWidth()) rectangle.x = sr.getScaledWidth() - rectangle.width - 1;
- if (rectangle.y + rectangle.height + 1>= sr.getScaledHeight()) rectangle.y = sr.getScaledHeight() - rectangle.height - 1;
- guiFeature.setFeatureRect(new GUIRectangle(rectangle));
+ applyConstraint();
+ guiFeature.setFeatureRect(new GUIRectangle(constraintApplied));
lastX = absMouseX;
lastY = absMouseY;
}
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 8ce619e6..c4fa75d2 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/config/types/GUIRectangle.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/config/types/GUIRectangle.java
@@ -31,21 +31,19 @@ import java.awt.*;
@NoArgsConstructor
public class GUIRectangle {
public GUIRectangle(Rectangle rectangle) {
-
- ScaledResolution sr = new ScaledResolution(Minecraft.getMinecraft());
- if (rectangle.x < sr.getScaledWidth() / 2) {
+ if (rectangle.x < Minecraft.getMinecraft().displayWidth / 2) {
this.x = rectangle.x;
this.width = rectangle.width;
} else {
- this.x = rectangle.x + rectangle.width - sr.getScaledWidth();
+ this.x = rectangle.x + rectangle.width - Minecraft.getMinecraft().displayWidth;
this.width = -rectangle.width;
}
- if (rectangle.y < sr.getScaledHeight() / 2) {
+ if (rectangle.y < Minecraft.getMinecraft().displayHeight / 2) {
this.y = rectangle.y;
this.height = rectangle.height;
} else {
- this.y = rectangle.y +rectangle.height - sr.getScaledHeight();
+ this.y = rectangle.y +rectangle.height - Minecraft.getMinecraft().displayHeight;
this.height = -rectangle.height;
}
}
@@ -56,13 +54,20 @@ public class GUIRectangle {
private int height;
public Rectangle getRectangle() {
- return getRectangle(new ScaledResolution(Minecraft.getMinecraft()));
+ return getRectangleNoScale();
}
- public Rectangle getRectangle(ScaledResolution scaledResolution) {
- int realX = x < 0 ? scaledResolution.getScaledWidth() + x : x;
- int realY = y < 0 ? scaledResolution.getScaledHeight() + y : y;
+// public Rectangle getRectangle(ScaledResolution scaledResolution) {
+// double realX = (int) (x < 0 ? scaledResolution.getScaledWidth() + x : x);
+// double realY = (int) (y < 0 ? scaledResolution.getScaledHeight() + y : y);
+//
+// return new Rectangle((int)Math.min(realX + width, realX), (int)Math.min(realY + height, realY),
+// (int)Math.abs(width), (int)Math.abs(height));
+// }
+ public Rectangle getRectangleNoScale() {
+ double realX = (int) (x < 0 ? Minecraft.getMinecraft().displayWidth + x : x);
+ double realY = (int) (y < 0 ? Minecraft.getMinecraft().displayHeight + y : y);
- return new Rectangle(Math.min(realX + width, realX), Math.min(realY + height, realY),
- Math.abs(width), Math.abs(height));
+ return new Rectangle((int)Math.min(realX + width, realX), (int)Math.min(realY + height, realY),
+ (int)Math.abs(width), (int)Math.abs(height));
}
}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/GuiFeature.java b/src/main/java/kr/syeyoung/dungeonsguide/features/GuiFeature.java
index dd4ed7e4..e195a7d9 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/features/GuiFeature.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/features/GuiFeature.java
@@ -63,9 +63,8 @@ public abstract class GuiFeature extends AbstractFeature implements ScreenRender
if (!isEnabled()) return;
GlStateManager.pushAttrib();
GlStateManager.pushMatrix();
- ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
- Rectangle featureRect = this.featureRect.getRectangle(scaledResolution);
- clip(scaledResolution, featureRect.x, featureRect.y, featureRect.width, featureRect.height);
+ Rectangle featureRect = this.featureRect.getRectangleNoScale();
+ clip(featureRect.x, featureRect.y, featureRect.width, featureRect.height);
GL11.glEnable(GL11.GL_SCISSOR_TEST);
GlStateManager.translate(featureRect.x, featureRect.y, 0);
@@ -88,8 +87,9 @@ public abstract class GuiFeature extends AbstractFeature implements ScreenRender
drawHUD(partialTicks);
}
- private void clip(ScaledResolution resolution, int x, int y, int width, int height) {
- int scale = resolution.getScaleFactor();
+ private void clip(int x, int y, int width, int height) {
+// int scale = resolution.getScaleFactor();
+ int scale = 1;
GL11.glScissor((x ) * scale, Minecraft.getMinecraft().displayHeight - (y + height) * scale, (width) * scale, height * scale);
}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/text/PanelTextParameterConfig.java b/src/main/java/kr/syeyoung/dungeonsguide/features/text/PanelTextParameterConfig.java
index 23132b3a..6559bd61 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/features/text/PanelTextParameterConfig.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/features/text/PanelTextParameterConfig.java
@@ -152,7 +152,6 @@ public class PanelTextParameterConfig extends MPanel {
GlStateManager.popMatrix();
GlStateManager.translate(5, height + 7, 0);
- GlStateManager.scale(0.5,0.5,0);
FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
GlStateManager.enableBlend();
GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA);
@@ -163,7 +162,6 @@ public class PanelTextParameterConfig extends MPanel {
GlStateManager.pushMatrix();
GlStateManager.translate(width + 15, 5, 0);
GlStateManager.pushMatrix();
- GlStateManager.scale(0.5,0.5,0);
fr.drawString("Selected Groups: "+selected, 0, 0, 0xFFBFBFBF);
GlStateManager.popMatrix();
fr.drawString("Text Color: ", 0, 10, 0xFFFFFFFF);
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gui/MGui.java b/src/main/java/kr/syeyoung/dungeonsguide/gui/MGui.java
new file mode 100644
index 00000000..7c35306d
--- /dev/null
+++ b/src/main/java/kr/syeyoung/dungeonsguide/gui/MGui.java
@@ -0,0 +1,172 @@
+/*
+ * 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;
+
+import kr.syeyoung.dungeonsguide.gui.elements.MRootPanel;
+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.input.Mouse;
+import org.lwjgl.opengl.GL11;
+
+import java.awt.*;
+import java.io.IOException;
+
+public class MGui extends GuiScreen {
+
+ @Getter
+ private final MPanel mainPanel = new MRootPanel();
+
+
+ @Override
+ public void initGui() {
+ super.initGui();
+ ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
+ mainPanel.setBounds(new Rectangle(0,0,Minecraft.getMinecraft().displayWidth,Minecraft.getMinecraft().displayHeight));
+ }
+
+ @Override
+ public void drawScreen(int mouseX, int mouseY, float partialTicks) {
+ try {
+
+ int i = Mouse.getEventX();
+ int j = this.mc.displayHeight - Mouse.getEventY();
+ ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
+ GlStateManager.pushMatrix();
+ GlStateManager.pushAttrib();
+ GlStateManager.disableLighting();
+ GlStateManager.disableFog();
+ GlStateManager.disableDepth();
+ GL11.glDisable(GL11.GL_FOG);
+ GlStateManager.enableBlend();
+ GlStateManager.enableAlpha();
+ GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0);
+ GlStateManager.color(1, 1, 1, 1);
+ GlStateManager.scale(1.0/scaledResolution.getScaleFactor(), 1.0/scaledResolution.getScaleFactor(), 1.0d);
+ mainPanel.render0(scaledResolution, new Point(0,0), new Rectangle(0,0,Minecraft.getMinecraft().displayWidth, Minecraft.getMinecraft().displayHeight), i, j, i, j, partialTicks);
+ GlStateManager.popAttrib();
+ GlStateManager.popMatrix();
+ GlStateManager.enableBlend();
+ GlStateManager.enableLighting();
+ } catch (Throwable e) {
+ e.printStackTrace();
+ }
+ GL11.glDisable(GL11.GL_SCISSOR_TEST);
+ }
+
+ @Override
+ public void keyTyped(char typedChar, int keyCode) throws IOException {
+ try {
+ mainPanel.keyTyped0(typedChar, keyCode);
+ super.keyTyped(typedChar, keyCode);
+ } catch (Throwable e) {
+ if (!e.getMessage().contains("hack to stop"))
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
+ try {
+ super.mouseClicked(mouseX, mouseY, mouseButton);
+ mainPanel.mouseClicked0(mouseX, mouseY
+ ,mouseX, mouseY, mouseButton);
+ } catch (Throwable e) {
+ if (!e.getMessage().contains("hack to stop"))
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public void onGuiClosed() {
+ super.onGuiClosed();
+ }
+
+ @Override
+ public void mouseReleased(int mouseX, int mouseY, int state) {
+ try {
+ mainPanel.mouseReleased0(mouseX, mouseY
+ ,mouseX,mouseY , state);
+ } catch (Throwable e) {
+ if (!e.getMessage().contains("hack to stop"))
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) {
+ try {
+ mainPanel.mouseClickMove0(mouseX, mouseY
+ ,mouseX ,mouseY, clickedMouseButton, timeSinceLastClick);
+ } catch (Throwable e) {
+ if (!e.getMessage().contains("hack to stop"))
+ e.printStackTrace();
+ }
+ }
+
+ private int touchValue;
+ private int eventButton;
+ private long lastMouseEvent;
+
+ @Override
+ public void handleMouseInput() throws IOException {
+ try {
+ int i = Mouse.getEventX();
+ int j = this.mc.displayHeight - Mouse.getEventY();
+ int k = Mouse.getEventButton();
+
+ if (Mouse.getEventButtonState())
+ {
+ if (this.mc.gameSettings.touchscreen && this.touchValue++ > 0)
+ {
+ return;
+ }
+
+ this.eventButton = k;
+ this.lastMouseEvent = Minecraft.getSystemTime();
+ this.mouseClicked(i, j, this.eventButton);
+ }
+ else if (k != -1)
+ {
+ if (this.mc.gameSettings.touchscreen && --this.touchValue > 0)
+ {
+ return;
+ }
+
+ this.eventButton = -1;
+ this.mouseReleased(i, j, k);
+ }
+ else if (this.eventButton != -1 && this.lastMouseEvent > 0L)
+ {
+ long l = Minecraft.getSystemTime() - this.lastMouseEvent;
+ this.mouseClickMove(i, j, this.eventButton, l);
+ }
+
+
+ int wheel = Mouse.getDWheel();
+ if (wheel != 0) {
+ mainPanel.mouseScrolled0(i, j,i,j, wheel);
+ }
+ } 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 911038f2..5f7ff538 100755..100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/gui/MPanel.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/gui/MPanel.java
@@ -18,15 +18,13 @@
package kr.syeyoung.dungeonsguide.gui;
+import kr.syeyoung.dungeonsguide.gui.elements.MTooltip;
import lombok.AccessLevel;
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.client.renderer.Tessellator;
-import net.minecraft.client.renderer.WorldRenderer;
-import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import org.lwjgl.opengl.GL11;
import java.awt.*;
@@ -46,6 +44,9 @@ public class MPanel {
@Getter(AccessLevel.PUBLIC)
protected boolean isFocused;
+ @Getter
+ protected MPanel parent;
+
public void setBackgroundColor(Color c) {
if (c == null) return;
this.backgroundColor = c;
@@ -83,19 +84,31 @@ public class MPanel {
}
public void add(MPanel child) {
+ if (child.parent != null) throw new IllegalArgumentException("What have you done");
this.childComponents.add(child);
+ child.parent = this;
+ }
+
+ public void openTooltip(MTooltip mPanel) {
+ parent.openTooltip(mPanel);
+ }
+ public int getTooltipsOpen() {
+ return parent.getTooltipsOpen();
}
public void remove(MPanel panel) {
+ panel.parent = null;
this.childComponents.remove(panel);
}
+ protected Point lastParentPoint;
public void render0(ScaledResolution resolution, Point parentPoint, Rectangle parentClip, int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks) { // 0,0 - a a
+ lastParentPoint = parentPoint;
int relMousex = relMousex0 - getBounds().x;
int relMousey = relMousey0 - getBounds().y;
- GlStateManager.translate(getBounds().x, getBounds().y, 0);
+ GlStateManager.translate(getBounds().x, getBounds().y, 5);
GlStateManager.color(1,1,1,0);
@@ -103,6 +116,7 @@ public class MPanel {
absBound.setLocation(absBound.x + parentPoint.x, absBound.y + parentPoint.y);
Rectangle clip = determineClip(parentClip, absBound);
lastAbsClip = clip;
+ if (clip.getSize().height * clip.getSize().width == 0) return;
clip(resolution, clip.x, clip.y, clip.width, clip.height);
GlStateManager.pushAttrib();
@@ -115,6 +129,12 @@ public class MPanel {
GlStateManager.pushMatrix();
GlStateManager.pushAttrib();
+
+ GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
+ GlStateManager.enableBlend();
+ GlStateManager.enableAlpha();
+ GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0);
+
render(absMousex, absMousey, relMousex, relMousey, partialTicks, clip);
GlStateManager.popAttrib();
GlStateManager.popMatrix();
@@ -137,7 +157,8 @@ public class MPanel {
public static void clip(ScaledResolution resolution, int x, int y, int width, int height) {
if (width < 0 || height < 0) return;
- int scale = resolution.getScaleFactor();
+// int scale = resolution.getScaleFactor();
+ int scale = 1;
GL11.glScissor((x ) * scale, Minecraft.getMinecraft().displayHeight - (y + height) * scale, (width) * scale, height * scale);
}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MRootPanel.java b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MRootPanel.java
new file mode 100644
index 00000000..a6987241
--- /dev/null
+++ b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MRootPanel.java
@@ -0,0 +1,50 @@
+/*
+ * 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 lombok.Getter;
+
+import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+@Getter
+public class MRootPanel extends MPanel {
+ @Getter
+ private List<MTooltip> tooltips = new CopyOnWriteArrayList<>();
+
+
+ @Override
+ public void openTooltip(MTooltip mPanel) {
+ mPanel.setRoot(this);
+ tooltips.add(mPanel);
+ add(mPanel);
+ }
+
+ @Override
+ public int getTooltipsOpen() {
+ return tooltips.size();
+ }
+
+ public void removeTooltip(MTooltip mTooltip) {
+ mTooltip.setRoot(null);
+ tooltips.remove(mTooltip);
+ remove(mTooltip);
+ }
+}
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 432fd0a8..5b99959f 100755
--- a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MToggleButton.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MToggleButton.java
@@ -48,7 +48,7 @@ public class MToggleButton extends MPanel {
FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
- double scale = 2;
+ double scale = 1;
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);
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MTooltip.java b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MTooltip.java
new file mode 100644
index 00000000..56eb2821
--- /dev/null
+++ b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MTooltip.java
@@ -0,0 +1,86 @@
+/*
+ * 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 lombok.Getter;
+import lombok.Setter;
+import net.minecraft.client.gui.GuiScreen;
+import net.minecraft.client.gui.ScaledResolution;
+import net.minecraft.client.renderer.GlStateManager;
+import org.lwjgl.opengl.GL11;
+
+import java.awt.*;
+
+public class MTooltip extends MPanel {
+ @Getter @Setter
+ private MRootPanel root;
+
+ public void open(MPanel component) {
+ component.openTooltip(this);
+ }
+ public void close() {
+ if (root != null)
+ root.removeTooltip(this);
+ }
+
+ @Override
+ public int getTooltipsOpen() {
+ return super.getTooltipsOpen() - 1;
+ }
+
+ public void render0(ScaledResolution resolution, Point parentPoint, Rectangle parentClip, int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks) { // 0,0 - a a
+ int relMousex = relMousex0 - getBounds().x;
+ int relMousey = relMousey0 - getBounds().y;
+
+ GlStateManager.translate(getBounds().x, getBounds().y, 300);
+ GlStateManager.color(1,1,1,0);
+
+
+ Rectangle clip = getBounds().getBounds();
+ GlStateManager.pushAttrib();
+ GL11.glEnable(GL11.GL_SCISSOR_TEST);
+ clip(resolution, clip.x, clip.y, clip.width, clip.height);
+
+ GlStateManager.pushAttrib();
+ GuiScreen.drawRect(0,0, getBounds().width, getBounds().height, backgroundColor.getRGB());
+ GlStateManager.enableBlend();
+ GlStateManager.popAttrib();
+
+ GlStateManager.pushMatrix();
+ GlStateManager.pushAttrib();
+ render(absMousex, absMousey, relMousex, relMousey, partialTicks, clip);
+ GlStateManager.popAttrib();
+ GlStateManager.popMatrix();
+
+ GL11.glDisable(GL11.GL_SCISSOR_TEST);
+ GlStateManager.popAttrib();
+
+
+ Point newPt = new Point(parentPoint.x + getBounds().x, parentPoint.y + getBounds().y);
+
+ for (MPanel mPanel : getChildComponents()){
+ GlStateManager.pushMatrix();
+ GlStateManager.pushAttrib();
+ mPanel.render0(resolution, newPt, clip, absMousex, absMousey, relMousex, relMousey, partialTicks);
+ GlStateManager.popAttrib();
+ GlStateManager.popMatrix();
+ }
+ }
+}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MTooltipText.java b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MTooltipText.java
new file mode 100644
index 00000000..fe93d82a
--- /dev/null
+++ b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MTooltipText.java
@@ -0,0 +1,44 @@
+/*
+ * 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 lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.Setter;
+import net.minecraft.client.Minecraft;
+import net.minecraftforge.fml.client.config.GuiUtils;
+
+import java.awt.*;
+import java.util.ArrayList;
+import java.util.List;
+
+@AllArgsConstructor
+public class MTooltipText extends MTooltip {
+ @Getter @Setter
+ private List<String> tooltipText = new ArrayList<>();
+ @Override
+ public Rectangle getBounds() {
+ return new Rectangle(0,0, Minecraft.getMinecraft().displayWidth, Minecraft.getMinecraft().displayHeight);
+ }
+
+ @Override
+ public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) {
+ GuiUtils.drawHoveringText(tooltipText, relMousex0, relMousey0, Minecraft.getMinecraft().displayWidth, Minecraft.getMinecraft().displayHeight, -1, Minecraft.getMinecraft().fontRendererObj);
+ }
+}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/gui/GuiDungeonAddSet.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/gui/GuiDungeonAddSet.java
index ac560b81..4410d08e 100755
--- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/gui/GuiDungeonAddSet.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/gui/GuiDungeonAddSet.java
@@ -19,6 +19,7 @@
package kr.syeyoung.dungeonsguide.roomedit.gui;
import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint;
+import kr.syeyoung.dungeonsguide.gui.MGui;
import kr.syeyoung.dungeonsguide.roomedit.EditingContext;
import kr.syeyoung.dungeonsguide.gui.MPanel;
import kr.syeyoung.dungeonsguide.gui.elements.*;
@@ -38,9 +39,7 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
-public class GuiDungeonAddSet extends GuiScreen {
-
- private final MPanel mainPanel = new MPanel();
+public class GuiDungeonAddSet extends MGui {
private final ValueEditOffsetPointSet valueEditOffsetPointSet;
@@ -86,7 +85,7 @@ public class GuiDungeonAddSet extends GuiScreen {
public GuiDungeonAddSet(final ValueEditOffsetPointSet processorParameterEditPane) {
this.valueEditOffsetPointSet = processorParameterEditPane;
- mainPanel.setBackgroundColor(new Color(17, 17, 17, 179));
+ getMainPanel().setBackgroundColor(new Color(17, 17, 17, 179));
{
start = new OffsetPoint(EditingContext.getEditingContext().getRoom(), Minecraft.getMinecraft().thePlayer.getPosition());
end = new OffsetPoint(EditingContext.getEditingContext().getRoom(), Minecraft.getMinecraft().thePlayer.getPosition());
@@ -94,10 +93,10 @@ public class GuiDungeonAddSet extends GuiScreen {
{
MValue mValue = new MValue(start, Collections.emptyList());
mValue.setBounds(new Rectangle(0,0,150,20));
- mainPanel.add(mValue);
+ getMainPanel().add(mValue);
MValue mValue2 = new MValue(end,Collections.emptyList());
mValue2.setBounds(new Rectangle(0,20,150,20));
- mainPanel.add(mValue2);
+ getMainPanel().add(mValue2);
}
{
add = new MButton() {
@@ -130,8 +129,8 @@ public class GuiDungeonAddSet extends GuiScreen {
EditingContext.getEditingContext().goBack();
}
});
- mainPanel.add(add);
- mainPanel.add(back);
+ getMainPanel().add(add);
+ getMainPanel().add(back);
}
}
@@ -139,64 +138,6 @@ public class GuiDungeonAddSet extends GuiScreen {
public void initGui() {
super.initGui();
// update bounds
- ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
- mainPanel.setBounds(new Rectangle(10, Math.min((scaledResolution.getScaledHeight() - 300) / 2, scaledResolution.getScaledHeight()),200,300));
- }
-
- @Override
- public void drawScreen(int mouseX, int mouseY, float partialTicks) {
-
-
- ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
- GlStateManager.pushMatrix();
- GlStateManager.pushAttrib();
- GlStateManager.disableLighting();
- GlStateManager.disableFog();
- GL11.glDisable(GL11.GL_FOG);
- GlStateManager.color(1, 1, 1, 1);
- GlStateManager.disableDepth();
- GlStateManager.depthMask(false);
- mainPanel.render0(scaledResolution, new Point(0,0), new Rectangle(0,0,scaledResolution.getScaledWidth(),scaledResolution.getScaledHeight()), mouseX, mouseY, mouseX, mouseY, partialTicks);
- GlStateManager.enableDepth();
- GlStateManager.depthMask(true);
- GlStateManager.popAttrib();
- GlStateManager.popMatrix();
- GlStateManager.enableBlend();
- GlStateManager.enableLighting();
- }
-
- @Override
- public void keyTyped(char typedChar, int keyCode) throws IOException {
- super.keyTyped(typedChar, keyCode);
- mainPanel.keyTyped0(typedChar, keyCode);
- }
-
- @Override
- public void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
- super.mouseClicked(mouseX, mouseY, mouseButton);
- mainPanel.mouseClicked0(mouseX, mouseY,mouseX,mouseY, mouseButton);
- }
-
- @Override
- public void mouseReleased(int mouseX, int mouseY, int state) {
- mainPanel.mouseReleased0(mouseX, mouseY,mouseX,mouseY, state);
- }
-
- @Override
- public void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) {
- mainPanel.mouseClickMove0(mouseX,mouseY,mouseX,mouseY,clickedMouseButton,timeSinceLastClick);
- }
-
- @Override
- public void handleMouseInput() throws IOException {
- super.handleMouseInput();
-
- int i = Mouse.getEventX() * this.width / this.mc.displayWidth;
- int j = this.height - Mouse.getEventY() * this.height / this.mc.displayHeight - 1;
-
- int wheel = Mouse.getDWheel();
- if (wheel != 0) {
- mainPanel.mouseScrolled0(i, j,i,j, wheel);
- }
+ getMainPanel().setBounds(new Rectangle(10, Math.min((Minecraft.getMinecraft().displayHeight - 300) / 2, Minecraft.getMinecraft().displayHeight),200,300));
}
}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/gui/GuiDungeonParameterEdit.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/gui/GuiDungeonParameterEdit.java
index 32403636..584d8472 100755
--- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/gui/GuiDungeonParameterEdit.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/gui/GuiDungeonParameterEdit.java
@@ -19,6 +19,7 @@
package kr.syeyoung.dungeonsguide.roomedit.gui;
import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom;
+import kr.syeyoung.dungeonsguide.gui.MGui;
import kr.syeyoung.dungeonsguide.roomedit.EditingContext;
import kr.syeyoung.dungeonsguide.gui.MPanel;
import kr.syeyoung.dungeonsguide.roomedit.Parameter;
@@ -38,9 +39,7 @@ import org.lwjgl.opengl.GL11;
import java.awt.*;
import java.io.IOException;
-public class GuiDungeonParameterEdit extends GuiScreen {
-
- private final MPanel mainPanel = new MPanel();
+public class GuiDungeonParameterEdit extends MGui {
private final Parameter parameter;
private final DungeonRoom dungeonRoom;
@@ -57,7 +56,7 @@ public class GuiDungeonParameterEdit extends GuiScreen {
public GuiDungeonParameterEdit(final MParameter parameter2, final DynamicEditor processorParameterEditPane) {
dungeonRoom = EditingContext.getEditingContext().getRoom();
- mainPanel.setBackgroundColor(new Color(17, 17, 17, 179));
+ getMainPanel().setBackgroundColor(new Color(17, 17, 17, 179));
this.parameter = parameter2.getParameter();
{
MTextField mTextField = new MTextField() {
@@ -70,7 +69,7 @@ public class GuiDungeonParameterEdit extends GuiScreen {
mTextField.setText(parameter.getName());
mLabelAndElement.setBounds(new Rectangle(0,0,200, 20));
- mainPanel.add(mLabelAndElement);
+ getMainPanel().add(mLabelAndElement);
}
{
classSelection = parameter.getNewData() == null ?"null" : parameter.getNewData().getClass().getName();
@@ -95,7 +94,7 @@ public class GuiDungeonParameterEdit extends GuiScreen {
}
});
mStringSelectionButton.setBounds(new Rectangle(0,20,150,20));
- mainPanel.add(mStringSelectionButton);
+ getMainPanel().add(mStringSelectionButton);
}
{
currentValueEdit = new MPanel(){
@@ -104,7 +103,7 @@ public class GuiDungeonParameterEdit extends GuiScreen {
setBounds(new Rectangle(0, 40, parentWidth,parentHeight - 60));
}
};
- mainPanel.add(currentValueEdit);
+ getMainPanel().add(currentValueEdit);
}
{
delete = new MButton() {
@@ -137,8 +136,8 @@ public class GuiDungeonParameterEdit extends GuiScreen {
EditingContext.getEditingContext().goBack();
}
});
- mainPanel.add(delete);
- mainPanel.add(save);
+ getMainPanel().add(delete);
+ getMainPanel().add(save);
}
updateClassSelection();
}
@@ -175,63 +174,6 @@ public class GuiDungeonParameterEdit extends GuiScreen {
public void initGui() {
super.initGui();
// update bounds
- ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
- mainPanel.setBounds(new Rectangle(10, Math.min((scaledResolution.getScaledHeight() - 300) / 2, scaledResolution.getScaledHeight()),200,300));
- }
-
- @Override
- public void drawScreen(int mouseX, int mouseY, float partialTicks) {
-
- ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
- GlStateManager.pushMatrix();
- GlStateManager.pushAttrib();
- GlStateManager.disableLighting();
- GlStateManager.disableFog();
- GL11.glDisable(GL11.GL_FOG);
- GlStateManager.color(1, 1, 1, 1);
- GlStateManager.disableDepth();
- GlStateManager.depthMask(false);
- mainPanel.render0(scaledResolution, new Point(0,0), new Rectangle(0,0,scaledResolution.getScaledWidth(),scaledResolution.getScaledHeight()), mouseX, mouseY, mouseX, mouseY, partialTicks);
- GlStateManager.enableDepth();
- GlStateManager.depthMask(true);
- GlStateManager.popAttrib();
- GlStateManager.popMatrix();
- GlStateManager.enableBlend();
- GlStateManager.enableLighting();
- }
-
- @Override
- public void keyTyped(char typedChar, int keyCode) throws IOException {
- super.keyTyped(typedChar, keyCode);
- mainPanel.keyTyped0(typedChar, keyCode);
- }
-
- @Override
- public void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
- super.mouseClicked(mouseX, mouseY, mouseButton);
- mainPanel.mouseClicked0(mouseX, mouseY,mouseX,mouseY, mouseButton);
- }
-
- @Override
- public void mouseReleased(int mouseX, int mouseY, int state) {
- mainPanel.mouseReleased0(mouseX, mouseY,mouseX,mouseY, state);
- }
-
- @Override
- public void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) {
- mainPanel.mouseClickMove0(mouseX,mouseY,mouseX,mouseY,clickedMouseButton,timeSinceLastClick);
- }
-
- @Override
- public void handleMouseInput() throws IOException {
- super.handleMouseInput();
-
- int i = Mouse.getEventX() * this.width / this.mc.displayWidth;
- int j = this.height - Mouse.getEventY() * this.height / this.mc.displayHeight - 1;
-
- int wheel = Mouse.getDWheel();
- if (wheel != 0) {
- mainPanel.mouseScrolled0(i, j,i,j, wheel);
- }
+ getMainPanel().setBounds(new Rectangle(10, Math.min((Minecraft.getMinecraft().displayHeight - 300) / 2, Minecraft.getMinecraft().displayHeight),200,300));
}
}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/gui/GuiDungeonRoomEdit.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/gui/GuiDungeonRoomEdit.java
index 87093c4d..fee71b54 100755
--- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/gui/GuiDungeonRoomEdit.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/gui/GuiDungeonRoomEdit.java
@@ -19,6 +19,7 @@
package kr.syeyoung.dungeonsguide.roomedit.gui;
import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom;
+import kr.syeyoung.dungeonsguide.gui.MGui;
import kr.syeyoung.dungeonsguide.gui.MPanel;
import kr.syeyoung.dungeonsguide.gui.elements.MTabbedPane;
import kr.syeyoung.dungeonsguide.roomedit.panes.*;
@@ -33,9 +34,7 @@ import org.lwjgl.opengl.GL11;
import java.awt.*;
import java.io.IOException;
-public class GuiDungeonRoomEdit extends GuiScreen {
-
- private final MPanel mainPanel = new MPanel();
+public class GuiDungeonRoomEdit extends MGui {
private final DungeonRoom room;
@@ -47,7 +46,7 @@ public class GuiDungeonRoomEdit extends GuiScreen {
this.room = room;
MTabbedPane tabbedPane = new MTabbedPane();
- mainPanel.add(tabbedPane);
+ getMainPanel().add(tabbedPane);
tabbedPane.setBackground2(new Color(17, 17, 17, 179));
@@ -71,63 +70,6 @@ public class GuiDungeonRoomEdit extends GuiScreen {
public void initGui() {
super.initGui();
// update bounds
- ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
- mainPanel.setBounds(new Rectangle(Math.min((scaledResolution.getScaledWidth() - 500) / 2, scaledResolution.getScaledWidth()), Math.min((scaledResolution.getScaledHeight() - 300) / 2, scaledResolution.getScaledHeight()),500,300));
- }
-
- @Override
- public void drawScreen(int mouseX, int mouseY, float partialTicks) {
-
- ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
- GlStateManager.pushMatrix();
- GlStateManager.pushAttrib();
- GlStateManager.disableLighting();
- GlStateManager.disableFog();
- GL11.glDisable(GL11.GL_FOG);
- GlStateManager.color(1, 1, 1, 1);
- GlStateManager.disableDepth();
- GlStateManager.depthMask(false);
- mainPanel.render0(scaledResolution, new Point(0,0), new Rectangle(0,0,scaledResolution.getScaledWidth(),scaledResolution.getScaledHeight()), mouseX, mouseY, mouseX, mouseY, partialTicks);
- GlStateManager.enableDepth();
- GlStateManager.depthMask(true);
- GlStateManager.popAttrib();
- GlStateManager.popMatrix();
- GlStateManager.enableBlend();
- GlStateManager.enableLighting();
- }
-
- @Override
- public void keyTyped(char typedChar, int keyCode) throws IOException {
- super.keyTyped(typedChar, keyCode);
- mainPanel.keyTyped0(typedChar, keyCode);
- }
-
- @Override
- public void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
- super.mouseClicked(mouseX, mouseY, mouseButton);
- mainPanel.mouseClicked0(mouseX, mouseY,mouseX,mouseY, mouseButton);
- }
-
- @Override
- public void mouseReleased(int mouseX, int mouseY, int state) {
- mainPanel.mouseReleased0(mouseX, mouseY,mouseX,mouseY, state);
- }
-
- @Override
- public void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) {
- mainPanel.mouseClickMove0(mouseX,mouseY,mouseX,mouseY,clickedMouseButton,timeSinceLastClick);
- }
-
- @Override
- public void handleMouseInput() throws IOException {
- super.handleMouseInput();
-
- int i = Mouse.getEventX() * this.width / this.mc.displayWidth;
- int j = this.height - Mouse.getEventY() * this.height / this.mc.displayHeight - 1;
-
- int wheel = Mouse.getDWheel();
- if (wheel != 0) {
- mainPanel.mouseScrolled0(i, j,i,j, wheel);
- }
+ getMainPanel().setBounds(new Rectangle(10, Math.min((Minecraft.getMinecraft().displayHeight - 300) / 2, Minecraft.getMinecraft().displayHeight),200,300));
}
}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/gui/GuiDungeonValueEdit.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/gui/GuiDungeonValueEdit.java
index 63251ca2..56192361 100755
--- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/gui/GuiDungeonValueEdit.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/gui/GuiDungeonValueEdit.java
@@ -19,6 +19,7 @@
package kr.syeyoung.dungeonsguide.roomedit.gui;
import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom;
+import kr.syeyoung.dungeonsguide.gui.MGui;
import kr.syeyoung.dungeonsguide.roomedit.EditingContext;
import kr.syeyoung.dungeonsguide.gui.MPanel;
import kr.syeyoung.dungeonsguide.roomedit.Parameter;
@@ -38,18 +39,7 @@ import java.awt.*;
import java.util.List;
import java.io.IOException;
-public class GuiDungeonValueEdit extends GuiScreen {
-
- private final MPanel mainPanel = new MPanel() {
- @Override
- public void onBoundsUpdate() {
- for (int i = 0; i < addons.size(); i++) {
- addons.get(i).setBounds(new Rectangle(0, getBounds().height - (i+1) * 20 - 20, getBounds().width, 20));
- }
- save.setBounds(new Rectangle(0 ,getBounds().height - 20, getBounds().width, 20));
- }
- };
-
+public class GuiDungeonValueEdit extends MGui {
private DungeonRoom dungeonRoom;
@@ -69,7 +59,7 @@ public class GuiDungeonValueEdit extends GuiScreen {
dungeonRoom = EditingContext.getEditingContext().getRoom();
this.addons = addons;
this.editingObj = object;
- mainPanel.setBackgroundColor(new Color(17, 17, 17, 179));
+ getMainPanel().setBackgroundColor(new Color(17, 17, 17, 179));
{
currentValueEdit = new MPanel() {
@Override
@@ -77,11 +67,11 @@ public class GuiDungeonValueEdit extends GuiScreen {
setBounds(new Rectangle(0, 0, parentWidth, parentHeight - 20 - addons.size() * 20));
}
};
- mainPanel.add(currentValueEdit);
+ getMainPanel().add(currentValueEdit);
}
for (MPanel addon : addons) {
- mainPanel.add(addon);
+ getMainPanel().add(addon);
}
{
save = new MButton() {
@@ -98,7 +88,7 @@ public class GuiDungeonValueEdit extends GuiScreen {
EditingContext.getEditingContext().goBack();
}
});
- mainPanel.add(save);
+ getMainPanel().add(save);
}
updateClassSelection();
} catch (Exception e){}
@@ -131,89 +121,13 @@ public class GuiDungeonValueEdit extends GuiScreen {
public void initGui() {
super.initGui();
// update bounds
- ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
- mainPanel.setBounds(new Rectangle(10, Math.min((scaledResolution.getScaledHeight() - 300) / 2, scaledResolution.getScaledHeight()),200,300));
- }
+ getMainPanel().setBounds(new Rectangle(10, Math.min((Minecraft.getMinecraft().displayHeight - 300) / 2, Minecraft.getMinecraft().displayHeight),200,300));
- @Override
- public void drawScreen(int mouseX, int mouseY, float partialTicks) {
- try {
- ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
- GlStateManager.pushMatrix();
- GlStateManager.pushAttrib();
- GlStateManager.disableLighting();
- GlStateManager.disableFog();
- GL11.glDisable(GL11.GL_FOG);
- GlStateManager.color(1, 1, 1, 1);
- GlStateManager.disableDepth();
- GlStateManager.depthMask(false);
- mainPanel.render0(scaledResolution, new Point(0,0), new Rectangle(0,0,scaledResolution.getScaledWidth(),scaledResolution.getScaledHeight()), mouseX, mouseY, mouseX, mouseY, partialTicks);
- GlStateManager.enableDepth();
- GlStateManager.depthMask(true);
- GlStateManager.popAttrib();
- GlStateManager.popMatrix();
- GlStateManager.enableBlend();
- GlStateManager.enableLighting();
- } catch (Throwable e) {
- e.printStackTrace();
+ for (int i = 0; i < addons.size(); i++) {
+ addons.get(i).setBounds(new Rectangle(0, getMainPanel().getBounds().height - (i+1) * 20 - 20, getMainPanel().getBounds().width, 20));
}
+ save.setBounds(new Rectangle(0 ,getMainPanel().getBounds().height - 20, getMainPanel().getBounds().width, 20));
}
- @Override
- public void keyTyped(char typedChar, int keyCode) throws IOException {
-
- try {
- super.keyTyped(typedChar, keyCode);
- mainPanel.keyTyped0(typedChar, keyCode);
- } catch (Throwable t) {
- t.printStackTrace();
- }
- }
-
- @Override
- public void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
- try {
- super.mouseClicked(mouseX, mouseY, mouseButton);
- mainPanel.mouseClicked0(mouseX, mouseY,mouseX,mouseY, mouseButton);
- } catch (Throwable t) {
- t.printStackTrace();
- }
- }
-
- @Override
- public void mouseReleased(int mouseX, int mouseY, int state) {
- try {
- mainPanel.mouseReleased0(mouseX, mouseY,mouseX,mouseY, state);
- } catch (Throwable t) {
- t.printStackTrace();
- }
- }
-
- @Override
- public void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) {
- try {
- mainPanel.mouseClickMove0(mouseX,mouseY,mouseX,mouseY,clickedMouseButton,timeSinceLastClick);
-
- } catch (Throwable t) {
- t.printStackTrace();
- }
- }
-
- @Override
- public void handleMouseInput() throws IOException {
- super.handleMouseInput();
-
- int i = Mouse.getEventX() * this.width / this.mc.displayWidth;
- int j = this.height - Mouse.getEventY() * this.height / this.mc.displayHeight - 1;
-
- int wheel = Mouse.getDWheel();
- if (wheel != 0) {
- try {
- mainPanel.mouseScrolled0(i, j,i,j, wheel);
- } catch (Throwable t) {
- t.printStackTrace();
- }
- }
- }
}