aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/kr/syeyoung/dungeonsguide/config
diff options
context:
space:
mode:
authorsyeyoung <cyong06@naver.com>2021-01-01 14:24:06 +0900
committersyeyoung <cyong06@naver.com>2021-01-01 14:24:06 +0900
commitbe44a7665e4982934998020d3bb930be25a50c25 (patch)
tree62a8ba38bf5dccf98eec1876f1d3267bf161bca0 /src/main/java/kr/syeyoung/dungeonsguide/config
parenta09e7553a93a177df7a6a3c7db5a1383b08a2416 (diff)
downloadSkyblock-Dungeons-Guide-be44a7665e4982934998020d3bb930be25a50c25.tar.gz
Skyblock-Dungeons-Guide-be44a7665e4982934998020d3bb930be25a50c25.tar.bz2
Skyblock-Dungeons-Guide-be44a7665e4982934998020d3bb930be25a50c25.zip
gui glitch fix and such
Diffstat (limited to 'src/main/java/kr/syeyoung/dungeonsguide/config')
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/config/Config.java3
-rwxr-xr-xsrc/main/java/kr/syeyoung/dungeonsguide/config/FeatureEditPane.java10
-rwxr-xr-xsrc/main/java/kr/syeyoung/dungeonsguide/config/GuiConfig.java9
-rwxr-xr-xsrc/main/java/kr/syeyoung/dungeonsguide/config/MFeature.java34
-rwxr-xr-xsrc/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/GuiGuiLocationConfig.java13
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/PanelDelegate.java84
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/config/types/TypeConverterRegistry.java7
7 files changed, 103 insertions, 57 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/Config.java b/src/main/java/kr/syeyoung/dungeonsguide/config/Config.java
index 908d8ca2..5652a2e5 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/config/Config.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/config/Config.java
@@ -3,11 +3,8 @@ package kr.syeyoung.dungeonsguide.config;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
-import com.google.gson.stream.JsonWriter;
import kr.syeyoung.dungeonsguide.features.AbstractFeature;
import kr.syeyoung.dungeonsguide.features.FeatureRegistry;
-import net.minecraftforge.common.config.Configuration;
-import net.minecraftforge.common.config.Property;
import java.io.*;
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/FeatureEditPane.java b/src/main/java/kr/syeyoung/dungeonsguide/config/FeatureEditPane.java
index f723646c..2296f8a6 100755
--- a/src/main/java/kr/syeyoung/dungeonsguide/config/FeatureEditPane.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/config/FeatureEditPane.java
@@ -2,22 +2,15 @@ package kr.syeyoung.dungeonsguide.config;
import kr.syeyoung.dungeonsguide.features.AbstractFeature;
import kr.syeyoung.dungeonsguide.roomedit.MPanel;
-import kr.syeyoung.dungeonsguide.roomedit.Parameter;
import kr.syeyoung.dungeonsguide.roomedit.elements.*;
-import kr.syeyoung.dungeonsguide.roomedit.panes.DynamicEditor;
-import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEditCreator;
-import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEditRegistry;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
-import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
-import net.minecraftforge.common.config.ConfigCategory;
-import net.minecraftforge.common.config.Property;
import java.awt.*;
import java.io.IOException;
@@ -96,10 +89,11 @@ public class FeatureEditPane extends MPanel {
public void render0(ScaledResolution resolution, Point parentPoint, Rectangle parentClip, int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks) {
super.render0(resolution, parentPoint, parentClip, absMousex, absMousey, relMousex0, relMousey0, partialTicks);
-
if (within instanceof MFeature) {
AbstractFeature feature = ((MFeature) within).getFeature();
+ GlStateManager.pushAttrib();
drawHoveringText(new ArrayList<String>(Arrays.asList(feature.getDescription().split("\n"))), relMousex0, relMousey0, Minecraft.getMinecraft().fontRendererObj);
+ GlStateManager.popAttrib();
}
}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/GuiConfig.java b/src/main/java/kr/syeyoung/dungeonsguide/config/GuiConfig.java
index ef7d0a12..5b408181 100755
--- a/src/main/java/kr/syeyoung/dungeonsguide/config/GuiConfig.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/config/GuiConfig.java
@@ -8,11 +8,13 @@ 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.BufferUtils;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;
import java.awt.*;
import java.io.IOException;
+import java.nio.FloatBuffer;
import java.util.List;
import java.util.Map;
@@ -39,16 +41,15 @@ public class GuiConfig extends GuiScreen {
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) {
ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
-
GL11.glPushMatrix();
- GlStateManager.pushAttrib();
- GlStateManager.color(0,0,0,0);
+ GlStateManager.color(1,1,1,1);
+ GL11.glDisable(GL11.GL_DEPTH_TEST);
mainPanel.render0(scaledResolution, new Point(0,0), new Rectangle(0,0,scaledResolution.getScaledWidth(),scaledResolution.getScaledHeight()), mouseX, mouseY, mouseX, mouseY, partialTicks);
- GlStateManager.popAttrib();
GL11.glPopMatrix();
}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/MFeature.java b/src/main/java/kr/syeyoung/dungeonsguide/config/MFeature.java
index f151b77f..25436572 100755
--- a/src/main/java/kr/syeyoung/dungeonsguide/config/MFeature.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/config/MFeature.java
@@ -34,17 +34,17 @@ public class MFeature extends MPanel {
this.add(this.label = new MLabel());
this.label.setText(abstractFeature.getName());
- if (abstractFeature instanceof GuiFeature) {
- MButton button = new MButton();
- button.setText("GUI");
- button.setOnActionPerformed(new Runnable() {
+ {
+ final MStringSelectionButton mStringSelectionButton = new MStringSelectionButton(new ArrayList<String>(Arrays.asList(new String[] {"on", "off"})), abstractFeature.isEnabled() ? "on" : "off");
+ mStringSelectionButton.setOnUpdate(new Runnable() {
@Override
public void run() {
- Minecraft.getMinecraft().displayGuiScreen(new GuiGuiLocationConfig());
+ String selected = mStringSelectionButton.getSelected();
+ feature.setEnabled("on".equals(selected));
}
});
- addons.add(button);
- add(button);
+ addons.add(mStringSelectionButton);
+ add(mStringSelectionButton);
}
if (!abstractFeature.getParameters().isEmpty()) {
MButton button = new MButton();
@@ -52,17 +52,17 @@ public class MFeature extends MPanel {
addons.add(button);
add(button);
}
- {
- final MStringSelectionButton mStringSelectionButton = new MStringSelectionButton(new ArrayList<String>(Arrays.asList(new String[] {"on", "off"})), abstractFeature.isEnabled() ? "on" : "off");
- mStringSelectionButton.setOnUpdate(new Runnable() {
+ if (abstractFeature instanceof GuiFeature) {
+ MButton button = new MButton();
+ button.setText("GUI");
+ button.setOnActionPerformed(new Runnable() {
@Override
public void run() {
- String selected = mStringSelectionButton.getSelected();
- feature.setEnabled("on".equals(selected));
+ Minecraft.getMinecraft().displayGuiScreen(new GuiGuiLocationConfig());
}
});
- addons.add(mStringSelectionButton);
- add(mStringSelectionButton);
+ addons.add(button);
+ add(button);
}
}
@@ -80,10 +80,10 @@ public class MFeature extends MPanel {
@Override
public void onBoundsUpdate() {
- int x = getBounds().width - 70;
+ int x = getBounds().width - 50;
for (MPanel panel : addons) {
- panel.setBounds(new Rectangle(x, 0, 70, getBounds().height));
- x -= 70;
+ panel.setBounds(new Rectangle(x, 3, 50, getBounds().height - 6));
+ x -= 50;
}
label.setBounds(new Rectangle(0,0,x, getBounds().height));
}
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 75021e66..f7660788 100755
--- a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/GuiGuiLocationConfig.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/GuiGuiLocationConfig.java
@@ -6,7 +6,6 @@ import kr.syeyoung.dungeonsguide.features.FeatureRegistry;
import kr.syeyoung.dungeonsguide.features.GuiFeature;
import kr.syeyoung.dungeonsguide.roomedit.MPanel;
import kr.syeyoung.dungeonsguide.roomedit.elements.MButton;
-import kr.syeyoung.dungeonsguide.roomedit.elements.MTabbedPane;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.ScaledResolution;
@@ -16,8 +15,6 @@ import org.lwjgl.opengl.GL11;
import java.awt.*;
import java.io.IOException;
-import java.util.List;
-import java.util.Map;
public class GuiGuiLocationConfig extends GuiScreen {
@@ -25,15 +22,17 @@ public class GuiGuiLocationConfig extends GuiScreen {
public GuiGuiLocationConfig() {
for (AbstractFeature feature : FeatureRegistry.getFeatureList()) {
- if (feature instanceof GuiFeature) {
+ if (feature instanceof GuiFeature && feature.isEnabled()) {
mainPanel.add(new PanelDelegate((GuiFeature) feature));
}
}
+
+ mainPanel.setBackgroundColor(new Color(0,0,0, 60));
{
MButton button = new MButton() {
@Override
public void resize(int parentWidth, int parentHeight) {
- setBounds(new Rectangle(parentWidth-100,parentHeight-30,100,30));
+ setBounds(new Rectangle(parentWidth-50,parentHeight-20,50,20));
}
};
button.setText("back");
@@ -59,10 +58,10 @@ public class GuiGuiLocationConfig extends GuiScreen {
ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
GL11.glPushMatrix();
- GlStateManager.pushAttrib();
+ GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
GlStateManager.color(0,0,0,0);
mainPanel.render0(scaledResolution, new Point(0,0), new Rectangle(0,0,scaledResolution.getScaledWidth(),scaledResolution.getScaledHeight()), mouseX, mouseY, mouseX, mouseY, partialTicks);
- GlStateManager.popAttrib();
+ GL11.glPopAttrib();
GL11.glPopMatrix();
}
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 fd8b3f25..2e6ca8be 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/PanelDelegate.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/PanelDelegate.java
@@ -3,6 +3,7 @@ package kr.syeyoung.dungeonsguide.config.guiconfig;
import kr.syeyoung.dungeonsguide.features.GuiFeature;
import kr.syeyoung.dungeonsguide.roomedit.MPanel;
import net.minecraft.client.gui.Gui;
+import org.lwjgl.opengl.GL11;
import org.w3c.dom.css.Rect;
import java.awt.*;
@@ -20,28 +21,30 @@ public class PanelDelegate extends MPanel {
@Override
public void render(int absMousex, int absMousey, int relMouseX, int relMouseY, float partialTicks, Rectangle scissor) {
+ GL11.glPushMatrix();
guiFeature.drawDemo(partialTicks);
+ GL11.glPopMatrix();
- Gui.drawRect(0,0, 3, 3, 0x55777777);
- Gui.drawRect(0, getBounds().height - 3, 3, 3, 0x55777777);
- Gui.drawRect(getBounds().width - 3,0, 3, 3, 0x55777777);
- Gui.drawRect(getBounds().width - 3,getBounds().height - 3, 3, 3, 0x55777777);
+ 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);
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, 3, 0x55FFFFFF);
- } else if (relMouseX > getBounds().width - 3 && relMouseY < getBounds().height - 3) {
- Gui.drawRect(getBounds().width - 3,getBounds().height - 3, 3, 3, 0x55FFFFFF);
+ 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, 3, 3, 0x55FFFFFF);
- } else {
+ Gui.drawRect(getBounds().width - 3,0, getBounds().width, 3, 0x55FFFFFF);
+ } else if (selectedPart == -2){
Gui.drawRect(0,0, getBounds().width, getBounds().height, 0x55FFFFFF);
}
}
}
- private int selectedPart = 0;
+ private int selectedPart = -2;
private int lastX = 0;
private int lastY = 0;
@@ -54,7 +57,7 @@ public class PanelDelegate extends MPanel {
selectedPart = 0;
} else if (relMouseX < 3 && relMouseY > getBounds().height - 3) {
selectedPart = 2;
- } else if (relMouseX > getBounds().width - 3 && relMouseY < getBounds().height - 3) {
+ } else if (relMouseX > getBounds().width - 3 && relMouseY > getBounds().height - 3) {
selectedPart = 3;
} else if (relMouseX > getBounds().width - 3 && relMouseY < 3) {
selectedPart = 1;
@@ -67,22 +70,46 @@ public class PanelDelegate extends MPanel {
@Override
public void mouseReleased(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int state) {
- selectedPart = 0;
+ if (selectedPart >= -1) {
+ int minWidth;
+ int minHeight;
+ if (guiFeature.isKeepRatio()) {
+ minHeight = (int) Math.max(10, 10 / guiFeature.getDefaultRatio());
+ minWidth = (int) (guiFeature.getDefaultRatio() * minHeight);
+ } else {
+ minWidth = 10;
+ minHeight = 10;
+ }
+ Rectangle rectangle = guiFeature.getFeatureRect().getBounds();
+ if (rectangle.width < minWidth || rectangle.height < minHeight) {
+ rectangle.width = minWidth;
+ rectangle.height= minHeight;
+ }
+
+ if (rectangle.x < 0) rectangle.x = 0;
+ if (rectangle.y < 0) rectangle.y = 0;
+
+ guiFeature.setFeatureRect(rectangle);
+ }
+
+ selectedPart = -2;
+
+
}
@Override
public void mouseClickMove(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int clickedMouseButton, long timeSinceLastClick) {
int dx = absMouseX - lastX;
int dy = absMouseY - lastY;
- if (selectedPart > 0) {
+ if (selectedPart >= 0) {
boolean revChangeX = (selectedPart & 0x1) == 0;
boolean revChangeY = (selectedPart & 0x2) == 0;
Rectangle rectangle = guiFeature.getFeatureRect().getBounds();
int prevWidth = rectangle.width;
int prevHeight= rectangle.height;
- rectangle.width = prevWidth + dx;
- rectangle.height = prevHeight + dy;
+ rectangle.width = prevWidth + (revChangeX ? -1 : 1) * dx;
+ rectangle.height = prevHeight + (revChangeY ? - 1: 1 ) * dy;
if (guiFeature.isKeepRatio()) {
double ratio = guiFeature.getDefaultRatio();
@@ -92,22 +119,43 @@ public class PanelDelegate extends MPanel {
int width2 = (int) (rectangle.height * ratio);
int height2 = rectangle.height;
- if (width1 * height1 < width2 * height2) {
+ if (ratio >= 1) {
rectangle.width = width1;
rectangle.height = height1;
} else {
rectangle.width = width2;
- rectangle.height= height2;
+ rectangle.height = height2;
}
}
- if (revChangeX) rectangle.x -= (rectangle.width - prevWidth);
+
+
+ if (revChangeX) rectangle.x -= (rectangle.width - prevWidth );
if (revChangeY) rectangle.y -= (rectangle.height - prevHeight);
+ 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;
+ }
+
guiFeature.setFeatureRect(rectangle);
} else if (selectedPart == -1){
Rectangle rectangle = guiFeature.getFeatureRect().getBounds();
rectangle.translate(dx, dy);
guiFeature.setFeatureRect(rectangle);
+ lastX = absMouseX;
+ lastY = absMouseY;
}
}
}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/types/TypeConverterRegistry.java b/src/main/java/kr/syeyoung/dungeonsguide/config/types/TypeConverterRegistry.java
index 82bfe3fc..ee6fdfce 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/config/types/TypeConverterRegistry.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/config/types/TypeConverterRegistry.java
@@ -18,4 +18,11 @@ public class TypeConverterRegistry {
public static <T> TypeConverter<T> getTypeConverter(String type_string, Class<T> t) {
return (TypeConverter<T>)typeConverterMap.get(type_string);
}
+
+ static {
+ register(new TCBoolean());
+ register(new TCInteger());
+ register(new TCRectangle());
+ register(new TCString());
+ }
}