diff options
author | syeyoung <cyoung06@naver.com> | 2022-05-21 21:18:14 +0900 |
---|---|---|
committer | syeyoung <cyoung06@naver.com> | 2022-05-21 21:28:52 +0900 |
commit | 20dd3f99a7b139b5848128246c622fd9cfefa478 (patch) | |
tree | 78e5f84ad22fd53876d488f6b58c3528aebe6501 /src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit | |
parent | 50de034c046c4ddea033b73793c8825ecb5bb86f (diff) | |
download | Skyblock-Dungeons-Guide-20dd3f99a7b139b5848128246c622fd9cfefa478.tar.gz Skyblock-Dungeons-Guide-20dd3f99a7b139b5848128246c622fd9cfefa478.tar.bz2 Skyblock-Dungeons-Guide-20dd3f99a7b139b5848128246c622fd9cfefa478.zip |
- Project separation
Diffstat (limited to 'src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit')
12 files changed, 0 insertions, 1601 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEdit.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEdit.java deleted file mode 100755 index b5c135c4..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEdit.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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.roomedit.valueedit; - -import kr.syeyoung.dungeonsguide.roomedit.Parameter; - -public interface ValueEdit<T extends Object> { - void setParameter(Parameter parameter); - - void renderWorld(float partialTicks); -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditAColor.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditAColor.java deleted file mode 100755 index e3e22bf7..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditAColor.java +++ /dev/null @@ -1,339 +0,0 @@ -/* - * 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.roomedit.valueedit; - -import kr.syeyoung.dungeonsguide.config.types.AColor; -import kr.syeyoung.dungeonsguide.gui.MPanel; -import kr.syeyoung.dungeonsguide.roomedit.Parameter; -import kr.syeyoung.dungeonsguide.gui.elements.MColor; -import kr.syeyoung.dungeonsguide.gui.elements.MFloatSelectionButton; -import kr.syeyoung.dungeonsguide.gui.elements.MLabelAndElement; -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 net.minecraft.util.MathHelper; -import org.lwjgl.opengl.GL11; - -import java.awt.*; - -public class ValueEditAColor extends MPanel implements ValueEdit<AColor> { - private Parameter parameter; - private final MFloatSelectionButton h; - private final MFloatSelectionButton s; - private final MFloatSelectionButton v; - private final MFloatSelectionButton a; - - - @Override - public void renderWorld(float partialTicks) { - - } - public ValueEditAColor(final Parameter parameter2) { - this.parameter = parameter2; - { - MColor color = new MColor() { - @Override - public Color getColor() { - return (Color) parameter2.getPreviousData(); - } - }; - MLabelAndElement mLabelAndElement = new MLabelAndElement("Prev",color); - mLabelAndElement.setBounds(new Rectangle(0,0,getBounds().width,20)); - add(mLabelAndElement); - } - { - MColor color = new MColor() { - @Override - public Color getColor() { - return (Color) parameter2.getNewData(); - } - }; - MLabelAndElement mLabelAndElement = new MLabelAndElement("New",color); - mLabelAndElement.setBounds(new Rectangle(0,20,getBounds().width,20)); - add(mLabelAndElement); - } - - Color color = (Color) parameter2.getNewData(); - Color.RGBtoHSB(color.getRed(), color.getGreen(), color.getBlue(), hsv); - alpha = color.getAlpha() / 255.0f; - - { - h = new MFloatSelectionButton(hsv[0] * 360); - h.setOnUpdate(new Runnable() { - @Override - public void run() { - hsv[0] = h.getData() / 360; - update(); - } - }); - MLabelAndElement mLabelAndElement = new MLabelAndElement("H", h); - mLabelAndElement.setBounds(new Rectangle(0,20,getBounds().width,20)); - add(mLabelAndElement); - } - { - s = new MFloatSelectionButton(hsv[1] * 100); - s.setOnUpdate(new Runnable() { - @Override - public void run() { - hsv[1] = s.getData() / 100; - update(); - } - }); - MLabelAndElement mLabelAndElement = new MLabelAndElement("S", s); - mLabelAndElement.setBounds(new Rectangle(0,20,getBounds().width,20)); - add(mLabelAndElement); - } - { - v = new MFloatSelectionButton(hsv[2] * 100); - v.setOnUpdate(new Runnable() { - @Override - public void run() { - hsv[2] = v.getData() / 100; - update(); - } - }); - MLabelAndElement mLabelAndElement = new MLabelAndElement("V", v); - mLabelAndElement.setBounds(new Rectangle(0,20,getBounds().width,20)); - add(mLabelAndElement); - } - { - a = new MFloatSelectionButton(alpha * 100); - a.setOnUpdate(new Runnable() { - @Override - public void run() { - alpha = a.getData() / 100; - update(); - } - }); - MLabelAndElement mLabelAndElement = new MLabelAndElement("A", a); - mLabelAndElement.setBounds(new Rectangle(0,20,getBounds().width,20)); - add(mLabelAndElement); - } - } - - private final float[] hsv = new float[3]; - private float alpha = 0; - - public void update() { - if (hsv[2] > 1) hsv[2] = 1; - if (hsv[2] < 0) hsv[2] = 0; - if (hsv[1] > 1) hsv[1] = 1; - if (hsv[1] < 0) hsv[1] = 0; - parameter.setNewData(new AColor(Color.HSBtoRGB(hsv[0], hsv[1], hsv[2]) & 0xffffff | (MathHelper.clamp_int((int)(alpha * 255), 0, 255) << 24), true )); - h.setData((float) Math.floor(hsv[0] * 360)); - s.setData((float) Math.floor(hsv[1] * 100)); - v.setData((float) Math.floor(hsv[2] * 100)); - a.setData((float) Math.floor(alpha * 100)); - h.updateSelected(); - s.updateSelected(); - v.updateSelected(); - a.updateSelected(); - } - @Override - public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { - // draw CoolRect - int width = getBounds().width - 60; - Tessellator tessellator = Tessellator.getInstance(); - WorldRenderer worldrenderer = tessellator.getWorldRenderer(); - int shademodel = GL11.glGetInteger(GL11.GL_SHADE_MODEL); - GlStateManager.shadeModel(GL11.GL_SMOOTH); - GlStateManager.enableBlend(); - GlStateManager.disableDepth(); - GlStateManager.disableTexture2D(); - GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - -// worldrenderer.begin(GL11.GL_TRIANGLES, DefaultVertexFormats.POSITION_COLOR); - - int rgb = Color.HSBtoRGB(hsv[0], hsv[1], 1); - float r = (rgb >> 16 & 255) / 255.0f; - float g = (rgb >> 8 & 255) / 255.0f; - float b = (rgb & 255) / 255.0f; - GL11.glBegin(GL11.GL_TRIANGLES); - GlStateManager.color(0,0,0,alpha);GL11.glVertex3i(25+width ,45, 0); - GlStateManager.color(0,0,0,alpha);GL11.glVertex3i(10+width , 45, 0); - GlStateManager.color(r,g,b,alpha);GL11.glVertex3i(25+width , 45+width, 0); - - GlStateManager.color(0,0,0,alpha); GL11.glVertex3i(10+width , 45, 0); - GlStateManager.color(r,g,b,alpha);GL11.glVertex3i(10+width , 45 + width, 0); - GlStateManager.color(r,g,b,alpha);GL11.glVertex3i(25+width , 45+width, 0); - GL11.glEnd(); - rgb = Color.HSBtoRGB(hsv[0], hsv[1], hsv[2]); - r = (rgb >> 16 & 255) / 255.0f; - g = (rgb >> 8 & 255) / 255.0f; - b = (rgb & 255) / 255.0f; - GL11.glBegin(GL11.GL_TRIANGLES); - GlStateManager.color(r,g,b,0);GL11.glVertex3i(50+width ,45, 0); - GlStateManager.color(r,g,b,0);GL11.glVertex3i(35+width , 45, 0); - GlStateManager.color(r,g,b,1);GL11.glVertex3i(50+width , 45+width, 0); - -// GlStateManager.color(r,g,b,0); GL11.glVertex3i(35+width , 45, 0); -// GlStateManager.color(r,g,b,1);GL11.glVertex3i(35+width , 45 + width, 0); -// GlStateManager.color(r,g,b,1);GL11.glVertex3i(50+width , 45+width, 0); - GL11.glEnd(); - - - float radius = width/2f; - float cx = 5 + radius; - float cy = 45 + radius; - - GL11.glBegin(GL11.GL_TRIANGLE_FAN); - GlStateManager.color(1,1,1,alpha); - GL11.glVertex3f(cx,cy,0); - for (int i = 0; i <= 360; i++) { - float rad = 3.141592653f * i / 180; - int rgb2 = Color.HSBtoRGB(i / 360f, 1, hsv[2]); - float r2 = (rgb2 >> 16 & 255) / 255.0f; - float g2 = (rgb2 >> 8 & 255) / 255.0f; - float b2 = (rgb2 & 255) / 255.0f; - GlStateManager.color(r2,g2,b2, alpha); - GL11.glVertex3f(MathHelper.sin(rad) * radius + cx, MathHelper.cos(rad) * radius + cy, 0); - } - GL11.glEnd(); - GlStateManager.shadeModel(shademodel); - - GlStateManager.color(1,1,1,1); - worldrenderer.begin(GL11.GL_LINE_LOOP, DefaultVertexFormats.POSITION); - float rad2 = 2 * 3.141592653f * hsv[0] ; - float x = 5 + radius + (MathHelper.sin(rad2)) * hsv[1] * radius; - float y = 45 + radius + (MathHelper.cos(rad2))* hsv[1] * radius; - for (int i = 0; i < 100; i++) { - float rad = 2 * 3.141592653f * (i / 100f); - worldrenderer.pos(MathHelper.sin(rad) * 2 + x, MathHelper.cos(rad) * 2 + y, 0).endVertex(); - } - tessellator.draw(); - - worldrenderer.begin(GL11.GL_LINES, DefaultVertexFormats.POSITION); - worldrenderer.pos(8+width, 45 + (hsv[2]) * width, 0.5).endVertex(); - worldrenderer.pos(27+width, 45 + (hsv[2]) * width, 0.5).endVertex(); - tessellator.draw(); - - worldrenderer.begin(GL11.GL_LINES, DefaultVertexFormats.POSITION); - worldrenderer.pos(33+width, 45 + (alpha) * width, 0.5).endVertex(); - worldrenderer.pos(52+width, 45 + (alpha) * width, 0.5).endVertex(); - tessellator.draw(); - - GlStateManager.enableTexture2D(); - GlStateManager.disableBlend(); - GlStateManager.color(1,1,1,1); - GlStateManager.color(1,1,1,1); - } - private int selected = 0; - - @Override - public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) { - int width = getBounds().width - 60; - float radius = width / 2f; - float circleX = 5 + radius; - float circleY = 45 + radius; - selected = 0; - { - // check circle - float dx = relMouseX - circleX; - float dy = circleY - relMouseY; - if (dx * dx + dy * dy <= radius * radius) { - double theta = (MathHelper.atan2(dy, dx) / Math.PI * 180 + 90) % 360; - hsv[0] = (float) theta / 360f; - hsv[1] = MathHelper.sqrt_float(dx * dx + dy * dy) / radius; - selected = 1; - } - } - { - if (10+width <= relMouseX && relMouseX <= 25 + width && - 45 <= relMouseY && relMouseY <= 45 + width) { - hsv[2] = (relMouseY - 45) / (float)width; - selected = 2; - } - } - { - if (35+width <= relMouseX && relMouseX <= 50 + width && - 45 <= relMouseY && relMouseY <= 45 + width) { - alpha = (relMouseY - 45) / (float)width; - selected = 3; - } - } - update(); - } - - @Override - public void mouseClickMove(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int clickedMouseButton, long timeSinceLastClick) { - int width = getBounds().width - 60; - float radius = width / 2f; - float circleX = 5 + radius; - float circleY = 45 + radius; - { - // check circle - float dx = relMouseX - circleX; - float dy = circleY - relMouseY; - if (selected == 1) { - double theta = (MathHelper.atan2(dy, dx) / Math.PI * 180 + 90) % 360; - hsv[0] = (float) theta / 360f; - hsv[1] = MathHelper.clamp_float(MathHelper.sqrt_float(dx * dx + dy * dy) / radius, 0, 1); - } - } - { - if (selected == 2) { - hsv[2] = MathHelper.clamp_float((relMouseY - 45) / (float)width, 0, 1); - } - if (selected == 3) { - alpha = MathHelper.clamp_float((relMouseY - 45) / (float)width, 0, 1); - } - } - update(); - } - - @Override - public void onBoundsUpdate() { - int cnt = 0; - for (MPanel panel :getChildComponents()){ - panel.setSize(new Dimension(getBounds().width, 20)); cnt++; - if (cnt > 2) { - panel.setPosition(new Point(0, getBounds().width + (cnt - 3) * 20)); - } - } - } - - @Override - public void setParameter(Parameter parameter) { - this.parameter = parameter; - } - - @Override - public void resize(int parentWidth, int parentHeight) { - this.setBounds(new Rectangle(0,0,parentWidth, parentHeight)); - } - - public static class Generator implements ValueEditCreator<ValueEditAColor> { - - @Override - public ValueEditAColor createValueEdit(Parameter parameter) { - return new ValueEditAColor(parameter); - } - - @Override - public Object createDefaultValue(Parameter parameter) { - return new AColor(255,0,0,255); - } - - @Override - public Object cloneObj(Object object) { - return object; - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditBoolean.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditBoolean.java deleted file mode 100755 index dfd854bf..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditBoolean.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * 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.roomedit.valueedit; - -import kr.syeyoung.dungeonsguide.gui.MPanel; -import kr.syeyoung.dungeonsguide.roomedit.Parameter; -import kr.syeyoung.dungeonsguide.gui.elements.MLabel; -import kr.syeyoung.dungeonsguide.gui.elements.MLabelAndElement; -import kr.syeyoung.dungeonsguide.gui.elements.MStringSelectionButton; - -import java.awt.*; -import java.util.Arrays; - -public class ValueEditBoolean extends MPanel implements ValueEdit<Boolean> { - private Parameter parameter; - - - public ValueEditBoolean(Parameter parameter2) { - this.parameter = parameter2; - { - MLabel label = new MLabel() { - @Override - public String getText() { - return parameter.getPreviousData().toString(); - } - }; - MLabelAndElement mLabelAndElement = new MLabelAndElement("Prev",label); - mLabelAndElement.setBounds(new Rectangle(0,0,getBounds().width,20)); - add(mLabelAndElement); - } - { - boolean newData = (Boolean) parameter.getNewData(); - final MStringSelectionButton textField = new MStringSelectionButton(Arrays.asList("true", "false"), Boolean.toString(newData)); - textField.setOnUpdate(new Runnable() { - @Override - public void run() { - parameter.setNewData(Boolean.valueOf(textField.getSelected())); - } - }); - MLabelAndElement mLabelAndElement = new MLabelAndElement("New",textField); - mLabelAndElement.setBounds(new Rectangle(0,20,getBounds().width,20)); - add(mLabelAndElement); - } - } - - @Override - public void onBoundsUpdate() { - for (MPanel panel :getChildComponents()){ - panel.setSize(new Dimension(getBounds().width, 20)); - } - } - - @Override - public void setParameter(Parameter parameter) { - this.parameter = parameter; - } - - @Override - public void renderWorld(float partialTicks) { - - } - - @Override - public void resize(int parentWidth, int parentHeight) { - this.setBounds(new Rectangle(0,0,parentWidth, parentHeight)); - } - - public static class Generator implements ValueEditCreator<ValueEditBoolean> { - - @Override - public ValueEditBoolean createValueEdit(Parameter parameter) { - return new ValueEditBoolean(parameter); - } - - @Override - public Object createDefaultValue(Parameter parameter) { - return true; - } - - @Override - public Object cloneObj(Object object) { - return object; - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditColor.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditColor.java deleted file mode 100755 index 3e59154e..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditColor.java +++ /dev/null @@ -1,287 +0,0 @@ -/* - * 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.roomedit.valueedit; - -import kr.syeyoung.dungeonsguide.gui.MPanel; -import kr.syeyoung.dungeonsguide.roomedit.Parameter; -import kr.syeyoung.dungeonsguide.gui.elements.*; -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 net.minecraft.util.MathHelper; -import org.lwjgl.opengl.GL11; - -import java.awt.*; - -public class ValueEditColor extends MPanel implements ValueEdit<Color> { - private Parameter parameter; - private final MFloatSelectionButton h; - private final MFloatSelectionButton s; - private final MFloatSelectionButton v; - - - @Override - public void renderWorld(float partialTicks) { - - } - public ValueEditColor(final Parameter parameter2) { - this.parameter = parameter2; - { - MColor color = new MColor() { - @Override - public Color getColor() { - return (Color) parameter2.getPreviousData(); - } - }; - MLabelAndElement mLabelAndElement = new MLabelAndElement("Prev",color); - mLabelAndElement.setBounds(new Rectangle(0,0,getBounds().width,20)); - add(mLabelAndElement); - } - { - MColor color = new MColor() { - @Override - public Color getColor() { - return (Color) parameter2.getNewData(); - } - }; - MLabelAndElement mLabelAndElement = new MLabelAndElement("New",color); - mLabelAndElement.setBounds(new Rectangle(0,20,getBounds().width,20)); - add(mLabelAndElement); - } - - Color color = (Color) parameter2.getNewData(); - Color.RGBtoHSB(color.getRed(), color.getGreen(), color.getBlue(), hsv); - - { - h = new MFloatSelectionButton(hsv[0] * 360); - h.setOnUpdate(new Runnable() { - @Override - public void run() { - hsv[0] = h.getData() / 360; - update(); - } - }); - MLabelAndElement mLabelAndElement = new MLabelAndElement("H", h); - mLabelAndElement.setBounds(new Rectangle(0,20,getBounds().width,20)); - add(mLabelAndElement); - } - { - s = new MFloatSelectionButton(hsv[1] * 100); - s.setOnUpdate(new Runnable() { - @Override - public void run() { - hsv[1] = s.getData() / 100; - update(); - } - }); - MLabelAndElement mLabelAndElement = new MLabelAndElement("S", s); - mLabelAndElement.setBounds(new Rectangle(0,20,getBounds().width,20)); - add(mLabelAndElement); - } - { - v = new MFloatSelectionButton(hsv[2] * 100); - v.setOnUpdate(new Runnable() { - @Override - public void run() { - hsv[2] = v.getData() / 100; - update(); - } - }); - MLabelAndElement mLabelAndElement = new MLabelAndElement("V", v); - mLabelAndElement.setBounds(new Rectangle(0,20,getBounds().width,20)); - add(mLabelAndElement); - } - } - - private final float[] hsv = new float[3]; - - public void update() { - if (hsv[2] > 1) hsv[2] = 1; - if (hsv[2] < 0) hsv[2] = 0; - if (hsv[1] > 1) hsv[1] = 1; - if (hsv[1] < 0) hsv[1] = 0; - parameter.setNewData(new Color(Color.HSBtoRGB(hsv[0], hsv[1], hsv[2]))); - h.setData((float) Math.floor(hsv[0] * 360)); - s.setData((float) Math.floor(hsv[1] * 100)); - v.setData((float) Math.floor(hsv[2] * 100)); - h.updateSelected(); - s.updateSelected(); - v.updateSelected(); - } - @Override - public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { - // draw CoolRect - int width = getBounds().width - 30; - Tessellator tessellator = Tessellator.getInstance(); - WorldRenderer worldrenderer = tessellator.getWorldRenderer(); - int shademodel = GL11.glGetInteger(GL11.GL_SHADE_MODEL); - GlStateManager.shadeModel(GL11.GL_SMOOTH); - GlStateManager.enableBlend(); - GlStateManager.disableTexture2D(); - GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); -// worldrenderer.begin(GL11.GL_TRIANGLES, DefaultVertexFormats.POSITION_COLOR); - - int rgb = Color.HSBtoRGB(hsv[0], hsv[1], 1); - float r = (rgb >> 16 & 255) / 255.0f; - float g = (rgb >> 8 & 255) / 255.0f; - float b = (rgb & 255) / 255.0f; - GL11.glBegin(GL11.GL_TRIANGLES); - GlStateManager.color(0,0,0,1);GL11.glVertex3i(25+width ,45, 0); - GlStateManager.color(0,0,0,1);GL11.glVertex3i(10+width , 45, 0); - GlStateManager.color(r,g,b,1);GL11.glVertex3i(25+width , 45+width, 0); - - GlStateManager.color(0,0,0,1); GL11.glVertex3i(10+width , 45, 0); - GlStateManager.color(r,g,b,1);GL11.glVertex3i(10+width , 45 + width, 0); - GlStateManager.color(r,g,b,1);GL11.glVertex3i(25+width , 45+width, 0); - GL11.glEnd(); - - float radius = width/2f; - float cx = 5 + radius; - float cy = 45 + radius; - - GL11.glBegin(GL11.GL_TRIANGLE_FAN); - GlStateManager.color(1,1,1,1); - GL11.glVertex3f(cx,cy,0); - for (int i = 0; i <= 360; i++) { - float rad = 3.141592653f * i / 180; - int rgb2 = Color.HSBtoRGB(i / 360f, 1, hsv[2]); - float r2 = (rgb2 >> 16 & 255) / 255.0f; - float g2 = (rgb2 >> 8 & 255) / 255.0f; - float b2 = (rgb2 & 255) / 255.0f; - GlStateManager.color(r2,g2,b2, 1); - GL11.glVertex3f(MathHelper.sin(rad) * radius + cx, MathHelper.cos(rad) * radius + cy, 0); - } - GL11.glEnd(); - GlStateManager.shadeModel(shademodel); - - GlStateManager.color(1,1,1,1); - worldrenderer.begin(GL11.GL_LINE_LOOP, DefaultVertexFormats.POSITION); - float rad2 = 2 * 3.141592653f * hsv[0] ; - float x = 5 + radius + (MathHelper.sin(rad2)) * hsv[1] * radius; - float y = 45 + radius + (MathHelper.cos(rad2))* hsv[1] * radius; - for (int i = 0; i < 100; i++) { - float rad = 2 * 3.141592653f * (i / 100f); - worldrenderer.pos(MathHelper.sin(rad) * 2 + x, MathHelper.cos(rad) * 2 + y, 0).endVertex(); - } - tessellator.draw(); - - worldrenderer.begin(GL11.GL_LINES, DefaultVertexFormats.POSITION); - worldrenderer.pos(8+width, 45 + (hsv[2]) * width, 0.5).endVertex(); - worldrenderer.pos(27+width, 45 + (hsv[2]) * width, 0.5).endVertex(); - tessellator.draw(); - - GlStateManager.enableTexture2D(); - GlStateManager.disableBlend(); - GlStateManager.color(1,1,1,1); - GlStateManager.color(1,1,1,1); - } - private int selected = 0; - - @Override - public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) { - int width = getBounds().width - 30; - float radius = width / 2f; - float circleX = 5 + radius; - float circleY = 45 + radius; - selected = 0; - { - // check circle - float dx = relMouseX - circleX; - float dy = circleY - relMouseY; - if (dx * dx + dy * dy <= radius * radius) { - double theta = (MathHelper.atan2(dy, dx) / Math.PI * 180 + 90) % 360; - hsv[0] = (float) theta / 360f; - hsv[1] = MathHelper.sqrt_float(dx * dx + dy * dy) / radius; - selected = 1; - } - } - { - if (10+width <= relMouseX && relMouseX <= 25 + width && - 45 <= relMouseY && relMouseY <= 45 + width) { - hsv[2] = (relMouseY - 45) / (float)width; - selected = 2; - } - } - update(); - } - - @Override - public void mouseClickMove(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int clickedMouseButton, long timeSinceLastClick) { - int width = getBounds().width - 30; - float radius = width / 2f; - float circleX = 5 + radius; - float circleY = 45 + radius; - { - // check circle - float dx = relMouseX - circleX; - float dy = circleY - relMouseY; - if (selected == 1) { - double theta = (MathHelper.atan2(dy, dx) / Math.PI * 180 + 90) % 360; - hsv[0] = (float) theta / 360f; - hsv[1] = MathHelper.clamp_float(MathHelper.sqrt_float(dx * dx + dy * dy) / radius, 0, 1); - } - } - { - if (selected == 2) { - hsv[2] = MathHelper.clamp_float((relMouseY - 45) / (float)width, 0, 1); - } - } - update(); - } - - @Override - public void onBoundsUpdate() { - int cnt = 0; - for (MPanel panel :getChildComponents()){ - panel.setSize(new Dimension(getBounds().width, 20)); cnt++; - if (cnt > 2) { - panel.setPosition(new Point(0, getBounds().width + (cnt - 2) * 20)); - } - } - } - - @Override - public void setParameter(Parameter parameter) { - this.parameter = parameter; - } - - @Override - public void resize(int parentWidth, int parentHeight) { - this.setBounds(new Rectangle(0,0,parentWidth, parentHeight)); - } - - public static class Generator implements ValueEditCreator<ValueEditColor> { - - @Override - public ValueEditColor createValueEdit(Parameter parameter) { - return new ValueEditColor(parameter); - } - - @Override - public Object createDefaultValue(Parameter parameter) { - return Color.red; - } - - @Override - public Object cloneObj(Object object) { - return object; - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditCreator.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditCreator.java deleted file mode 100755 index dda484d9..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditCreator.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * 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.roomedit.valueedit; - -import kr.syeyoung.dungeonsguide.roomedit.Parameter; - -public interface ValueEditCreator<T extends ValueEdit> { - T createValueEdit(Parameter parameter); - - Object createDefaultValue(Parameter parameter); - - Object cloneObj(Object object); -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditFloat.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditFloat.java deleted file mode 100755 index 4092cf28..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditFloat.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * 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.roomedit.valueedit; - -import kr.syeyoung.dungeonsguide.gui.MPanel; -import kr.syeyoung.dungeonsguide.roomedit.Parameter; -import kr.syeyoung.dungeonsguide.gui.elements.MFloatSelectionButton; -import kr.syeyoung.dungeonsguide.gui.elements.MLabel; -import kr.syeyoung.dungeonsguide.gui.elements.MLabelAndElement; - -import java.awt.*; - -public class ValueEditFloat extends MPanel implements ValueEdit<Float> { - private Parameter parameter; - - - @Override - public void renderWorld(float partialTicks) { - - } - public ValueEditFloat(final Parameter parameter2) { - this.parameter = parameter2; - { - MLabel label = new MLabel() { - @Override - public String getText() { - return parameter.getPreviousData().toString(); - } - }; - MLabelAndElement mLabelAndElement = new MLabelAndElement("Prev",label); - mLabelAndElement.setBounds(new Rectangle(0,0,getBounds().width,20)); - add(mLabelAndElement); - } - { - float newData = (Float) parameter.getNewData(); - final MFloatSelectionButton textField = new MFloatSelectionButton(newData); - textField.setOnUpdate(new Runnable() { - @Override - public void run() { - parameter.setNewData(textField.getData()); - } - }); - MLabelAndElement mLabelAndElement = new MLabelAndElement("New",textField); - mLabelAndElement.setBounds(new Rectangle(0,20,getBounds().width,20)); - add(mLabelAndElement); - } - } - - @Override - public void onBoundsUpdate() { - for (MPanel panel :getChildComponents()){ - panel.setSize(new Dimension(getBounds().width, 20)); - } - } - - @Override - public void setParameter(Parameter parameter) { - this.parameter = parameter; - } - - @Override - public void resize(int parentWidth, int parentHeight) { - this.setBounds(new Rectangle(0,0,parentWidth, parentHeight)); - } - - public static class Generator implements ValueEditCreator<ValueEditFloat> { - - @Override - public ValueEditFloat createValueEdit(Parameter parameter) { - return new ValueEditFloat(parameter); - } - - @Override - public Object createDefaultValue(Parameter parameter) { - return 0.0f; - } - - @Override - public Object cloneObj(Object object) { - return object; - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditInteger.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditInteger.java deleted file mode 100755 index 8a5f36c9..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditInteger.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * 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.roomedit.valueedit; - -import kr.syeyoung.dungeonsguide.gui.MPanel; -import kr.syeyoung.dungeonsguide.roomedit.Parameter; -import kr.syeyoung.dungeonsguide.gui.elements.MIntegerSelectionButton; -import kr.syeyoung.dungeonsguide.gui.elements.MLabel; -import kr.syeyoung.dungeonsguide.gui.elements.MLabelAndElement; - -import java.awt.*; - -public class ValueEditInteger extends MPanel implements ValueEdit<Integer> { - private Parameter parameter; - - - @Override - public void renderWorld(float partialTicks) { - - } - public ValueEditInteger(final Parameter parameter2) { - this.parameter = parameter2; - { - MLabel label = new MLabel() { - @Override - public String getText() { - return parameter.getPreviousData().toString(); - } - }; - MLabelAndElement mLabelAndElement = new MLabelAndElement("Prev",label); - mLabelAndElement.setBounds(new Rectangle(0,0,getBounds().width,20)); - add(mLabelAndElement); - } - { - int newData = (Integer) parameter.getNewData(); - final MIntegerSelectionButton textField = new MIntegerSelectionButton(newData); - textField.setOnUpdate(new Runnable() { - @Override - public void run() { - parameter.setNewData(textField.getData()); - } - }); - MLabelAndElement mLabelAndElement = new MLabelAndElement("New",textField); - mLabelAndElement.setBounds(new Rectangle(0,20,getBounds().width,20)); - add(mLabelAndElement); - } - } - - @Override - public void onBoundsUpdate() { - for (MPanel panel :getChildComponents()){ - panel.setSize(new Dimension(getBounds().width, 20)); - } - } - - @Override - public void setParameter(Parameter parameter) { - this.parameter = parameter; - } - - @Override - public void resize(int parentWidth, int parentHeight) { - this.setBounds(new Rectangle(0,0,parentWidth, parentHeight)); - } - - public static class Generator implements ValueEditCreator<ValueEditInteger> { - - @Override - public ValueEditInteger createValueEdit(Parameter parameter) { - return new ValueEditInteger(parameter); - } - - @Override - public Object createDefaultValue(Parameter parameter) { - return 0; - } - - @Override - public Object cloneObj(Object object) { - return object; - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditNull.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditNull.java deleted file mode 100755 index 4c9e32a7..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditNull.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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.roomedit.valueedit; - -import kr.syeyoung.dungeonsguide.roomedit.Parameter; - -public class ValueEditNull implements ValueEditCreator { - @Override - public ValueEdit createValueEdit(Parameter parameter) { - return null; - } - - @Override - public Cloneable createDefaultValue(Parameter parameter) { - return null; - } - - @Override - public Object cloneObj(Object object) { - return null; - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditOffsetPoint.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditOffsetPoint.java deleted file mode 100755 index 1cd4deba..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditOffsetPoint.java +++ /dev/null @@ -1,163 +0,0 @@ -/* - * 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.roomedit.valueedit; - -import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; -import kr.syeyoung.dungeonsguide.roomedit.EditingContext; -import kr.syeyoung.dungeonsguide.gui.MPanel; -import kr.syeyoung.dungeonsguide.roomedit.Parameter; -import kr.syeyoung.dungeonsguide.gui.elements.*; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; -import net.minecraft.block.Block; -import net.minecraft.client.Minecraft; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.util.BlockPos; -import java.awt.*; - -public class ValueEditOffsetPoint extends MPanel implements ValueEdit<String> { - private Parameter parameter; - - @Override - public void renderWorld(float partialTicks) { - RenderUtils.highlightBlock(((OffsetPoint)parameter.getPreviousData()).getBlockPos(EditingContext.getEditingContext().getRoom()), new Color(255,0,0,150), partialTicks); - RenderUtils.highlightBlock(((OffsetPoint)parameter.getNewData()).getBlockPos(EditingContext.getEditingContext().getRoom()), new Color(0,255,0,150), partialTicks); - } - - public ValueEditOffsetPoint(final Parameter parameter2) { - this.parameter = parameter2; - { - MLabel label = new MLabel() { - @Override - public String getText() { - return parameter.getPreviousData().toString(); - } - }; - MLabelAndElement mLabelAndElement = new MLabelAndElement("Prev",label); - mLabelAndElement.setBounds(new Rectangle(0,0,getBounds().width,20)); - add(mLabelAndElement); - } - OffsetPoint newData = (OffsetPoint) parameter.getNewData(); - { - final MIntegerSelectionButton textField = new MIntegerSelectionButton(newData.getX()); - textField.setOnUpdate(new Runnable() { - @Override - public void run() { - ((OffsetPoint) parameter.getNewData()).setX(textField.getData()); - } - }); - MLabelAndElement mLabelAndElement = new MLabelAndElement("x",textField); - mLabelAndElement.setBounds(new Rectangle(0,20,getBounds().width,20)); - add(mLabelAndElement); - } - { - final MIntegerSelectionButton textField = new MIntegerSelectionButton(newData.getY()); - textField.setOnUpdate(new Runnable() { - @Override - public void run() { - ((OffsetPoint) parameter.getNewData()).setY(textField.getData()); - } - }); - MLabelAndElement mLabelAndElement = new MLabelAndElement("y",textField); - mLabelAndElement.setBounds(new Rectangle(0,40,getBounds().width,20)); - add(mLabelAndElement); - } - { - final MIntegerSelectionButton textField = new MIntegerSelectionButton(newData.getZ()); - textField.setOnUpdate(new Runnable() { - @Override - public void run() { - ((OffsetPoint) parameter.getNewData()).setZ(textField.getData()); - } - }); - MLabelAndElement mLabelAndElement = new MLabelAndElement("z",textField); - mLabelAndElement.setBounds(new Rectangle(0,60,getBounds().width,20)); - add(mLabelAndElement); - } - { - final MLabel setToHEre = new MLabel() { - @Override - public String getText() { - OffsetPoint offsetPoint = (OffsetPoint) parameter.getNewData(); - return Block.getIdFromBlock(offsetPoint.getBlock(EditingContext.getEditingContext().getRoom())) + - ":" + offsetPoint.getData(EditingContext.getEditingContext().getRoom()); - } - }; - MLabelAndElement mLabelAndElement = new MLabelAndElement("newPt",setToHEre); - mLabelAndElement.setBounds(new Rectangle(0,80,getBounds().width,20)); - add(mLabelAndElement); - } - { - final MButton setToHEre2 = new MButton(); - setToHEre2.setText("Set to here"); - setToHEre2.setBackgroundColor(Color.green); - setToHEre2.setOnActionPerformed(new Runnable() { - @Override - public void run() { - EntityPlayer player = Minecraft.getMinecraft().thePlayer; - BlockPos pos = new BlockPos(player.posX, player.posY, player.posZ); - ((OffsetPoint)parameter2.getNewData()).setPosInWorld(EditingContext.getEditingContext().getRoom(),pos ); - } - }); - MLabelAndElement mLabelAndElement = new MLabelAndElement("set",setToHEre2); - mLabelAndElement.setBounds(new Rectangle(0,100,getBounds().width,20)); - add(mLabelAndElement); - } - } - - @Override - public void onBoundsUpdate() { - for (MPanel panel :getChildComponents()){ - panel.setSize(new Dimension(getBounds().width, 20)); - } - } - - @Override - public void setParameter(Parameter parameter) { - this.parameter = parameter; - } - - @Override - public void resize(int parentWidth, int parentHeight) { - this.setBounds(new Rectangle(0,0,parentWidth, parentHeight)); - } - - public static class Generator implements ValueEditCreator<ValueEditOffsetPoint> { - - @Override - public ValueEditOffsetPoint createValueEdit(Parameter parameter) { - return new ValueEditOffsetPoint(parameter); - } - - @Override - public Object createDefaultValue(Parameter parameter) { - return new OffsetPoint(EditingContext.getEditingContext().getRoom(), Minecraft.getMinecraft().thePlayer.getPosition()); - } - - @Override - public Object cloneObj(Object object) { - try { - return ((OffsetPoint)object).clone(); - } catch (CloneNotSupportedException e) { - e.printStackTrace(); - } - assert false; - return null; - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditOffsetPointSet.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditOffsetPointSet.java deleted file mode 100755 index 0cdaab0d..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditOffsetPointSet.java +++ /dev/null @@ -1,250 +0,0 @@ -/* - * 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.roomedit.valueedit; - -import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; -import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPointSet; -import kr.syeyoung.dungeonsguide.roomedit.EditingContext; -import kr.syeyoung.dungeonsguide.gui.MPanel; -import kr.syeyoung.dungeonsguide.roomedit.Parameter; -import kr.syeyoung.dungeonsguide.gui.elements.MButton; -import kr.syeyoung.dungeonsguide.gui.elements.MValue; -import kr.syeyoung.dungeonsguide.roomedit.gui.GuiDungeonAddSet; -import kr.syeyoung.dungeonsguide.utils.RenderUtils; -import lombok.Getter; -import net.minecraft.client.Minecraft; - -import java.awt.*; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -public class ValueEditOffsetPointSet extends MPanel implements ValueEdit<OffsetPointSet> { - private Parameter parameter; - - // scroll pane - // just create - // add set - - private final MPanel scroll; - @Getter - private final List<MPanel> MParameters = new ArrayList<MPanel>(); - - private final MButton add; - private final MButton addSet; - - public void delete(OffsetPoint offsetPoint) { - ((OffsetPointSet)parameter.getNewData()).getOffsetPointList().remove(offsetPoint); - Iterator<MPanel> iterator = MParameters.iterator(); - while (iterator.hasNext()) { - MValue panel = (MValue) iterator.next(); - if (panel.getData() == offsetPoint) { - iterator.remove(); - break; - } - } - - } - - public ValueEditOffsetPointSet(final Parameter parameter2) { - this.parameter = parameter2; - { - scroll = new MPanel() { - private int offsetY = 0; - - @Override - public List<MPanel> getChildComponents() { - return MParameters; - } - - @Override - public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { - int heights = 0; - for (MPanel panel:getChildComponents()) { - panel.setPosition(new Point(0, -offsetY + heights)); - heights += panel.getBounds().height; - } - } - - @Override - public boolean mouseClicked0(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0, int mouseButton) { - if (!getBounds().contains(relMouseX0, relMouseY0)) { - return false; - } - - int relMousex = relMouseX0 - getBounds().x; - int relMousey = relMouseY0 - getBounds().y; - - boolean noClip = true; - boolean focusedOverall = false; - for (MPanel childComponent : getChildComponents()) { - if (childComponent.mouseClicked0(absMouseX, absMouseY, relMousex, relMousey, mouseButton)) { - noClip = false; - focusedOverall = true; - } - } - - if (getBounds().contains(relMouseX0, relMouseY0) && noClip) { - isFocused = true; - focusedOverall = true; - } else { - isFocused = false; - } - - mouseClicked(absMouseX, absMouseY, relMousex, relMousey, mouseButton); - return focusedOverall; - } - - @Override - public void onBoundsUpdate() { - for (MPanel panel :getChildComponents()){ - panel.setSize(new Dimension(getBounds().width, 20)); - } - } - @Override - public void resize(int parentWidth, int parentHeight) { - this.setBounds(new Rectangle(5,5,parentWidth-10,parentHeight-10)); - } - - @Override - public void mouseScrolled(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0, int scrollAmount) { - if (new Rectangle(new Point(0,0), getSize()).contains(relMouseX0, relMouseY0)) { - if (scrollAmount >0) offsetY += 20; - else if (scrollAmount < 0) offsetY -= 20; - if (offsetY <0) offsetY = 0; - } - } - }; - scroll.setBounds(new Rectangle(0,0,getBounds().width, getBounds().height-20)); - add(scroll); - } - - { - add = new MButton() { - @Override - public void resize(int parentWidth, int parentHeight) { - setBounds(new Rectangle(0,parentHeight - 20, parentWidth / 2, 20)); - } - }; - add.setText("Add"); - add.setBackgroundColor(Color.green); - add.setOnActionPerformed(new Runnable() { - @Override - public void run() { - OffsetPoint offsetPoint = new OffsetPoint(EditingContext.getEditingContext().getRoom(), Minecraft.getMinecraft().thePlayer.getPosition()); - MValue mValue; - MParameters.add(mValue = new MValue(offsetPoint, buildAddonsFor(offsetPoint))); - ((OffsetPointSet)parameter.getNewData()).getOffsetPointList().add(offsetPoint); - mValue.setSize(new Dimension(getBounds().width, 20)); - } - }); - - addSet = new MButton(){ - @Override - public void resize(int parentWidth, int parentHeight) { - setBounds(new Rectangle(parentWidth / 2,parentHeight - 20, parentWidth / 2, 20)); - } - }; - addSet.setText("Add Set"); - addSet.setBackgroundColor(Color.cyan); - addSet.setOnActionPerformed(new Runnable() { - @Override - public void run() { - EditingContext.getEditingContext().openGui(new GuiDungeonAddSet(ValueEditOffsetPointSet.this)); - } - }); - add(add); - add(addSet); - } - for (OffsetPoint offsetPoint : ((OffsetPointSet)parameter.getNewData()).getOffsetPointList()) { - MParameters.add(new MValue(offsetPoint, buildAddonsFor(offsetPoint))); - } - } - - public List<MPanel> buildAddonsFor(final OffsetPoint offsetPoint) { - ArrayList<MPanel> panels = new ArrayList<MPanel>(); - MButton mButton = new MButton(); - mButton.setText("Delete"); - mButton.setForeground(Color.white); - mButton.setBackgroundColor(Color.red); - mButton.setOnActionPerformed(new Runnable() { - @Override - public void run() { - delete(offsetPoint); - } - }); - panels.add(mButton); - return panels; - } - - @Override - public void onBoundsUpdate() { - scroll.setBounds(new Rectangle(0,0,getBounds().width, getBounds().height-20)); - add.setBounds(new Rectangle(0,getBounds().height-20,getBounds().width / 2, 20)); - addSet.setBounds(new Rectangle(getBounds().width / 2,getBounds().height-20,getBounds().width / 2, 20)); - } - - @Override - public void setParameter(Parameter parameter) { - this.parameter = parameter; - } - - @Override - public void renderWorld(float partialTicks) { - for (OffsetPoint offsetPoint :((OffsetPointSet)parameter.getNewData()).getOffsetPointList()) { - RenderUtils.highlightBlock(offsetPoint.getBlockPos(EditingContext.getEditingContext().getRoom()), new Color(0,255,255,50), partialTicks); - } - } - - @Override - public void resize(int parentWidth, int parentHeight) { - this.setBounds(new Rectangle(0,0,parentWidth, parentHeight)); - } - - public void addAll(List<OffsetPoint> blockPoses) { - ((OffsetPointSet)parameter.getNewData()).getOffsetPointList().addAll(blockPoses); - for (OffsetPoint blockPose : blockPoses) { - MParameters.add(new MValue(blockPose, buildAddonsFor(blockPose))); - } - } - - public static class Generator implements ValueEditCreator<ValueEditOffsetPointSet> { - - @Override - public ValueEditOffsetPointSet createValueEdit(Parameter parameter) { - return new ValueEditOffsetPointSet(parameter); - } - - @Override - public Object createDefaultValue(Parameter parameter) { - return new OffsetPointSet(); - } - - @Override - public Object cloneObj(Object object) { - try { - return ((OffsetPointSet)object).clone(); - } catch (CloneNotSupportedException e) { - e.printStackTrace(); - } - assert false; - return null; - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditRegistry.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditRegistry.java deleted file mode 100755 index 1df64a6c..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditRegistry.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * 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.roomedit.valueedit; - -import kr.syeyoung.dungeonsguide.config.types.AColor; -import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; -import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPointSet; -import kr.syeyoung.dungeonsguide.dungeon.mechanics.*; -import kr.syeyoung.dungeonsguide.roomedit.mechanicedit.*; - -import java.awt.*; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -public class ValueEditRegistry { - private static final Map<String, ValueEditCreator> valueEditMap = new HashMap<String, ValueEditCreator>(); - - public static ValueEditCreator getValueEditMap(String className) { - return valueEditMap.get(className); - } - - public static List<String> getClassesSupported() { - return new ArrayList<String>(valueEditMap.keySet()); - } - - static { - valueEditMap.put("null", new ValueEditNull()); - valueEditMap.put(String.class.getName(), new ValueEditString.Generator()); - valueEditMap.put(Boolean.class.getName(), new ValueEditBoolean.Generator()); - valueEditMap.put(Integer.class.getName(), new ValueEditInteger.Generator()); - valueEditMap.put(Float.class.getName(), new ValueEditFloat.Generator()); - valueEditMap.put(OffsetPoint.class.getName(), new ValueEditOffsetPoint.Generator()); - valueEditMap.put(OffsetPointSet.class.getName(), new ValueEditOffsetPointSet.Generator()); - valueEditMap.put(Color.class.getName(), new ValueEditColor.Generator()); - valueEditMap.put(AColor.class.getName(), new ValueEditAColor.Generator()); - - - valueEditMap.put(DungeonSecret.class.getName(), new ValueEditSecret.Generator()); - valueEditMap.put(DungeonFairySoul.class.getName(), new ValueEditFairySoul.Generator()); - valueEditMap.put(DungeonNPC.class.getName(), new ValueEditNPC.Generator()); - valueEditMap.put(DungeonTomb.class.getName(), new ValueEditTomb.Generator()); - valueEditMap.put(DungeonBreakableWall.class.getName(), new ValueEditBreakableWall.Generator()); - valueEditMap.put(DungeonJournal.class.getName(), new ValueEditJournal.Generator()); - valueEditMap.put(DungeonDummy.class.getName(), new ValueEditDummy.Generator()); - - valueEditMap.put(DungeonPressurePlate.class.getName(), new ValueEditPressurePlate.Generator()); - valueEditMap.put(DungeonOnewayLever.class.getName(), new ValueEditOnewayLever.Generator()); - valueEditMap.put(DungeonLever.class.getName(), new ValueEditLever.Generator()); - valueEditMap.put(DungeonDoor.class.getName(), new ValueEditDoor.Generator()); - valueEditMap.put(DungeonOnewayDoor.class.getName(), new ValueEditOnewayDoor.Generator()); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditString.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditString.java deleted file mode 100755 index 157e7b42..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditString.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * 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.roomedit.valueedit; - -import kr.syeyoung.dungeonsguide.gui.MPanel; -import kr.syeyoung.dungeonsguide.roomedit.Parameter; -import kr.syeyoung.dungeonsguide.gui.elements.MLabel; -import kr.syeyoung.dungeonsguide.gui.elements.MLabelAndElement; -import kr.syeyoung.dungeonsguide.gui.elements.MTextField; - -import java.awt.*; - -public class ValueEditString extends MPanel implements ValueEdit<String> { - private Parameter parameter; - - @Override - public void renderWorld(float partialTicks) { - - } - - public ValueEditString(Parameter parameter2) { - this.parameter = parameter2; - { - MLabel label = new MLabel() { - @Override - public String getText() { - return parameter.getPreviousData().toString(); - } - }; - MLabelAndElement mLabelAndElement = new MLabelAndElement("Prev",label); - mLabelAndElement.setBounds(new Rectangle(0,0,getBounds().width,20)); - add(mLabelAndElement); - } - { - String newData = (String) parameter.getNewData(); - MTextField textField = new MTextField() { - @Override - public void edit(String str) { - parameter.setNewData(str); - } - }; - textField.setText(newData); - MLabelAndElement mLabelAndElement = new MLabelAndElement("New",textField); - mLabelAndElement.setBounds(new Rectangle(0,20,getBounds().width,20)); - add(mLabelAndElement); - } - } - - @Override - public void onBoundsUpdate() { - for (MPanel panel :getChildComponents()){ - panel.setSize(new Dimension(getBounds().width, 20)); - } - } - - @Override - public void setParameter(Parameter parameter) { - this.parameter = parameter; - } - - @Override - public void resize(int parentWidth, int parentHeight) { - this.setBounds(new Rectangle(0,0,parentWidth, parentHeight)); - } - - public static class Generator implements ValueEditCreator<ValueEditString> { - - @Override - public ValueEditString createValueEdit(Parameter parameter) { - return new ValueEditString(parameter); - } - - @Override - public Object createDefaultValue(Parameter parameter) { - return "default"; - } - - @Override - public Object cloneObj(Object object) { - return object; - } - } -} |