diff options
author | syeyoung <cyong06@naver.com> | 2021-01-02 00:00:51 +0900 |
---|---|---|
committer | syeyoung <cyong06@naver.com> | 2021-01-02 00:00:51 +0900 |
commit | 43ca7d03db3f75e1820138fb269a7b6ee5b95f08 (patch) | |
tree | c9b160e22febf3959338d205eb45e67009cb1d72 /src/main/java/kr/syeyoung | |
parent | 5503237b9b2a2b75188188341f2dd8abe477c9f5 (diff) | |
download | Skyblock-Dungeons-Guide-43ca7d03db3f75e1820138fb269a7b6ee5b95f08.tar.gz Skyblock-Dungeons-Guide-43ca7d03db3f75e1820138fb269a7b6ee5b95f08.tar.bz2 Skyblock-Dungeons-Guide-43ca7d03db3f75e1820138fb269a7b6ee5b95f08.zip |
color edit done
Diffstat (limited to 'src/main/java/kr/syeyoung')
14 files changed, 348 insertions, 35 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/Config.java b/src/main/java/kr/syeyoung/dungeonsguide/config/Config.java index 5652a2e5..e001d6f4 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/config/Config.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/config/Config.java @@ -15,7 +15,7 @@ public class Config { public static void loadConfig(File f) throws IOException { try { - configuration = (JsonObject) new JsonParser().parse(new InputStreamReader(new FileInputStream(Config.f = f))); + configuration = (JsonObject) new JsonParser().parse(new InputStreamReader(new FileInputStream(Config.f = f == null ? Config.f : f))); } catch (Exception e) { configuration = new JsonObject(); } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/GuiParameterConfig.java b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/GuiParameterConfig.java index a234249b..bf2f811a 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/GuiParameterConfig.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/GuiParameterConfig.java @@ -18,7 +18,14 @@ import java.util.Arrays; public class GuiParameterConfig extends GuiScreen { - private MPanel mainPanel = new MPanel(); + private MPanel mainPanel = new MPanel() { + @Override + public void onBoundsUpdate() { + for (MPanel childComponent : getChildComponents()) { + childComponent.setSize(new Dimension(getBounds().width - 10, childComponent.getSize().height)); + } + } + }; private GuiScreen before; private AbstractFeature feature; @@ -38,6 +45,7 @@ public class GuiParameterConfig extends GuiScreen { } }); mainPanel.add(save); + mainPanel.setBackgroundColor(new Color(17, 17, 17, 179)); } @@ -58,12 +66,15 @@ public class GuiParameterConfig extends GuiScreen { int heights = 0; within = null; for (MPanel panel:mainPanel.getChildComponents()) { - panel.setPosition(new Point(0, -offsetY + heights)); + panel.setPosition(new Point(5, -offsetY + heights + 5)); heights += panel.getBounds().height; if (panel.getBounds().contains(mouseX - mainPanel.getBounds().x, mouseY - mainPanel.getBounds().y)) within = panel; } mainPanel.render0(scaledResolution, new Point(0,0), new Rectangle(0,0,scaledResolution.getScaledWidth(),scaledResolution.getScaledHeight()), mouseX, mouseY, mouseX, mouseY, partialTicks); + GL11.glPopMatrix(); + GL11.glPushMatrix(); + GlStateManager.color(1,1,1,1); if (within instanceof MParameter) { FeatureParameter feature = ((MParameter) within).getParameter(); GlStateManager.pushAttrib(); 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 7b993a11..c3f18103 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/GuiParameterValueEdit.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/GuiParameterValueEdit.java @@ -32,8 +32,6 @@ public class GuiParameterValueEdit extends GuiScreen { } }; - private DungeonRoom dungeonRoom; - private MPanel currentValueEdit; @@ -52,15 +50,13 @@ public class GuiParameterValueEdit extends GuiScreen { public GuiParameterValueEdit(final Object object, final GuiParameterConfig prev) { try { - this.onUpdate = onUpdate; - dungeonRoom = EditingContext.getEditingContext().getRoom(); this.editingObj = object; mainPanel.setBackgroundColor(new Color(17, 17, 17, 179)); { currentValueEdit = new MPanel() { @Override public void resize(int parentWidth, int parentHeight) { - setBounds(new Rectangle(0, 0, parentWidth, parentHeight - 20)); + setBounds(new Rectangle(5, 5, parentWidth-10, parentHeight - 25)); } }; mainPanel.add(currentValueEdit); diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/MParameter.java b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/MParameter.java index 882de0e4..efa3b4fd 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/MParameter.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/MParameter.java @@ -76,6 +76,7 @@ public class MParameter extends MPanel { add(button); label2 = button; } + setSize(new Dimension(100,20)); } @Override diff --git a/src/main/java/kr/syeyoung/dungeonsguide/e.java b/src/main/java/kr/syeyoung/dungeonsguide/e.java index 4835b114..8e5bb478 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/e.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/e.java @@ -46,6 +46,13 @@ public class e implements c { public void init(FMLInitializationEvent event) { + + try { + Config.loadConfig( null ); + } catch (IOException e) { + e.printStackTrace(); + } + dungeonsGuide = this; skyblockStatus = new SkyblockStatus(); @@ -83,11 +90,7 @@ public class e implements c { if (!configFile.exists()) { configDir.mkdirs(); } - try { - Config.loadConfig( configFile ); - } catch (IOException e) { - e.printStackTrace(); - } + Config.f = configFile; } private void copy(InputStream inputStream, File f) throws IOException { FileOutputStream fos = new FileOutputStream(f); diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MColor.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MColor.java new file mode 100644 index 00000000..360d1992 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MColor.java @@ -0,0 +1,30 @@ +package kr.syeyoung.dungeonsguide.roomedit.elements; + +import kr.syeyoung.dungeonsguide.roomedit.MPanel; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import net.minecraft.client.gui.Gui; + +import java.awt.*; + +@AllArgsConstructor +@NoArgsConstructor +public class MColor extends MPanel { + @Getter + @Setter + private Color color = Color.white; + @Getter + @Setter + private Dimension size = new Dimension(20,15); + @Override + public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { + Rectangle rectangle = getBounds(); + + int x = (rectangle.width - getSize().width) / 2; + int y = (rectangle.height - getSize().height) / 2; + + Gui.drawRect(x,y,x+getSize().width,y+getSize().height, getColor().getRGB()); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MFloatSelectionButton.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MFloatSelectionButton.java new file mode 100755 index 00000000..504d3e33 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MFloatSelectionButton.java @@ -0,0 +1,74 @@ +package kr.syeyoung.dungeonsguide.roomedit.elements; + +import kr.syeyoung.dungeonsguide.roomedit.MPanel; +import lombok.Getter; +import lombok.Setter; + +import java.awt.*; + +@Getter +@Setter +public class MFloatSelectionButton extends MPanel { + + private float data; + + private MButton dec; + private MButton inc; + private MTextField selected; + + @Getter + @Setter + private Runnable onUpdate; + + public MFloatSelectionButton(float data2) { + this.data = data2; + + dec = new MButton(); dec.setText("<"); add(dec); + inc = new MButton(); inc.setText(">"); add(inc); + selected = new MTextField() { + @Override + public String getText() { + return data +""; + } + @Override + public void edit(String str) { + try { + data = Float.parseFloat(str); + onUpdate.run(); + } catch (Exception e) {} + } + }; updateSelected(); add(selected); + + dec.setOnActionPerformed(new Runnable() { + @Override + public void run() { + data--; + updateSelected(); + onUpdate.run(); + } + }); + inc.setOnActionPerformed(new Runnable() { + @Override + public void run() { + data ++; + updateSelected(); + onUpdate.run(); + } + }); + } + + public float getSelected() { + return data; + } + + public void updateSelected() { + selected.setText(data+""); + } + + @Override + public void onBoundsUpdate() { + dec.setBounds(new Rectangle(0,0,getBounds().height, getBounds().height)); + inc.setBounds(new Rectangle(getBounds().width - getBounds().height, 0, getBounds().height, getBounds().height)); + selected.setBounds(new Rectangle(getBounds().height, 0, getBounds().width - getBounds().height - getBounds().height, getBounds().height)); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MTextField.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MTextField.java index 4f6a54cf..39808808 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MTextField.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MTextField.java @@ -36,6 +36,9 @@ public class MTextField extends MPanel { public void setText(String text) { this.text = text; + } + private void setText0(String text) { + this.text = text; edit(text); } @@ -177,14 +180,14 @@ public class MTextField extends MPanel { // backspace if (keycode == 14 && cursor > 0) { - setText(this.text.substring(0, cursor - 1) + this.text.substring(cursor)); + setText0(this.text.substring(0, cursor - 1) + this.text.substring(cursor)); cursor--; return; } //del if (keycode == 211 && cursor < text.length()) { - setText(this.text.substring(0, cursor) + this.text.substring(cursor+1)); + setText0(this.text.substring(0, cursor) + this.text.substring(cursor+1)); return; } @@ -206,7 +209,7 @@ public class MTextField extends MPanel { if (transferable != null && transferable.isDataFlavorSupported(DataFlavor.stringFlavor)) { try { Object theText = transferable.getTransferData(DataFlavor.stringFlavor); - setText( + setText0( this.text.substring(0, this.cursor) + theText + this.text.substring(this.cursor)); @@ -223,7 +226,7 @@ public class MTextField extends MPanel { // text if (isPrintableChar(typedChar)) { - setText( + setText0( this.text.substring(0, this.cursor) + typedChar + this.text.substring(this.cursor)); @@ -257,7 +260,7 @@ public class MTextField extends MPanel { // backspace if (keycode == 14 && cursor > 0) { - setText(this.text.substring(0, selectionStart) + this.text.substring(selectionEnd)); + setText0(this.text.substring(0, selectionStart) + this.text.substring(selectionEnd)); cursor = selectionStart; selectionStart = -1; return; @@ -265,7 +268,7 @@ public class MTextField extends MPanel { //del if (keycode == 211 && cursor < text.length()) { - setText(this.text.substring(0, selectionStart) + this.text.substring(selectionEnd)); + setText0(this.text.substring(0, selectionStart) + this.text.substring(selectionEnd)); cursor = selectionStart; selectionStart = -1; return; @@ -289,7 +292,7 @@ public class MTextField extends MPanel { if (transferable != null && transferable.isDataFlavorSupported(DataFlavor.stringFlavor)) { try { Object theText = transferable.getTransferData(DataFlavor.stringFlavor); - setText( + setText0( this.text.substring(0, this.selectionStart) + theText + this.text.substring(this.selectionEnd)); @@ -324,7 +327,7 @@ public class MTextField extends MPanel { // text if (isPrintableChar(typedChar)) { - setText( + setText0( this.text.substring(0, this.selectionStart) + typedChar + this.text.substring(this.selectionEnd)); 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 2498888f..95ec38fb 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/gui/GuiDungeonAddSet.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/gui/GuiDungeonAddSet.java @@ -126,6 +126,7 @@ public class GuiDungeonAddSet extends GuiScreen { public void drawScreen(int mouseX, int mouseY, float partialTicks) { ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); GL11.glPushMatrix(); + GlStateManager.color(1,1,1,1); GlStateManager.pushAttrib(); mainPanel.render0(scaledResolution, new Point(0,0), new Rectangle(0,0,scaledResolution.getScaledWidth(),scaledResolution.getScaledHeight()), mouseX, mouseY, mouseX, mouseY, partialTicks); GlStateManager.popAttrib(); 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 777f9736..ada2e486 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/gui/GuiDungeonParameterEdit.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/gui/GuiDungeonParameterEdit.java @@ -165,6 +165,7 @@ public class GuiDungeonParameterEdit extends GuiScreen { public void drawScreen(int mouseX, int mouseY, float partialTicks) { ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); GL11.glPushMatrix(); + GlStateManager.color(1,1,1,1); GlStateManager.pushAttrib(); mainPanel.render0(scaledResolution, new Point(0,0), new Rectangle(0,0,scaledResolution.getScaledWidth(),scaledResolution.getScaledHeight()), mouseX, mouseY, mouseX, mouseY, partialTicks); GlStateManager.popAttrib(); 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 2c5a7b69..4160dbd5 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/gui/GuiDungeonRoomEdit.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/gui/GuiDungeonRoomEdit.java @@ -60,6 +60,7 @@ public class GuiDungeonRoomEdit extends GuiScreen { public void drawScreen(int mouseX, int mouseY, float partialTicks) { ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); GL11.glPushMatrix(); + GlStateManager.color(1,1,1,1); GlStateManager.pushAttrib(); mainPanel.render0(scaledResolution, new Point(0,0), new Rectangle(0,0,scaledResolution.getScaledWidth(),scaledResolution.getScaledHeight()), mouseX, mouseY, mouseX, mouseY, partialTicks); GlStateManager.popAttrib(); 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 7ae06f34..0e679265 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/gui/GuiDungeonValueEdit.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/gui/GuiDungeonValueEdit.java @@ -123,6 +123,7 @@ public class GuiDungeonValueEdit extends GuiScreen { try { ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); GL11.glPushMatrix(); + GlStateManager.color(1,1,1,1); GlStateManager.pushAttrib(); mainPanel.render0(scaledResolution, new Point(0, 0), new Rectangle(0, 0, scaledResolution.getScaledWidth(), scaledResolution.getScaledHeight()), mouseX, mouseY, mouseX, mouseY, partialTicks); GlStateManager.popAttrib(); diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditColor.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditColor.java index 24b01713..6a4c17c5 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditColor.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditColor.java @@ -2,14 +2,22 @@ package kr.syeyoung.dungeonsguide.roomedit.valueedit; import kr.syeyoung.dungeonsguide.roomedit.MPanel; import kr.syeyoung.dungeonsguide.roomedit.Parameter; -import kr.syeyoung.dungeonsguide.roomedit.elements.MIntegerSelectionButton; -import kr.syeyoung.dungeonsguide.roomedit.elements.MLabel; -import kr.syeyoung.dungeonsguide.roomedit.elements.MLabelAndElement; +import kr.syeyoung.dungeonsguide.roomedit.elements.*; +import net.minecraft.client.gui.Gui; +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<Integer> { +public class ValueEditColor extends MPanel implements ValueEdit<Color> { private Parameter parameter; + private final MFloatSelectionButton h; + private final MFloatSelectionButton s; + private final MFloatSelectionButton v; @Override @@ -19,35 +27,216 @@ public class ValueEditColor extends MPanel implements ValueEdit<Integer> { public ValueEditColor(final Parameter parameter2) { this.parameter = parameter2; { - MLabel label = new MLabel() { + MColor color = new MColor() { @Override - public String getText() { - return parameter.getPreviousData().toString(); + public Color getColor() { + return (Color) parameter2.getPreviousData(); } }; - MLabelAndElement mLabelAndElement = new MLabelAndElement("Prev",label); + MLabelAndElement mLabelAndElement = new MLabelAndElement("Prev",color); 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() { + 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]); + h.setOnUpdate(new Runnable() { @Override public void run() { - parameter.setNewData(textField.getData()); + hsv[0] = h.getData() / 360; + update(); } }); - MLabelAndElement mLabelAndElement = new MLabelAndElement("New",textField); + MLabelAndElement mLabelAndElement = new MLabelAndElement("H", h); mLabelAndElement.setBounds(new Rectangle(0,20,getBounds().width,20)); add(mLabelAndElement); } + { + s = new MFloatSelectionButton(hsv[0]); + 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[0]); + 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 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); + GL11.glShadeModel(GL11.GL_SMOOTH); + GL11.glEnable(GL11.GL_BLEND); + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glDisable(GL11.GL_CULL_FACE); + GL11.glBlendFunc(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); + GL11.glColor4f(0,0,0,1);GL11.glVertex3i(25+width ,45, 0); + GL11.glColor4f(0,0,0,1);GL11.glVertex3i(10+width , 45, 0); + GL11.glColor4f(r,g,b,1);GL11.glVertex3i(25+width , 45+width, 0); + + GL11.glColor4f(0,0,0,1); GL11.glVertex3i(10+width , 45, 0); + GL11.glColor4f(r,g,b,1);GL11.glVertex3i(10+width , 45 + width, 0); + GL11.glColor4f(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); + GL11.glColor4f(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; + GL11.glColor4f(r2,g2,b2, 1); + GL11.glVertex3f(MathHelper.cos(rad) * radius + cx, MathHelper.sin(rad) * radius + cy, 0); + } + GL11.glEnd(); + GL11.glShadeModel(shademodel); + + GL11.glColor4f(1,1,1,1); + worldrenderer.begin(GL11.GL_LINE_LOOP, DefaultVertexFormats.POSITION); + float rad2 = 2 * 3.141592653f * hsv[0] ; + float x = 5 + radius + (MathHelper.cos(rad2)) * hsv[1] * radius; + float y = 45 + radius + (MathHelper.sin(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(); + + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glDisable(GL11.GL_BLEND); + 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(dx, dy) / Math.PI * 180 + 270) % 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(dx, dy) / Math.PI * 180 + 270) % 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)); + panel.setSize(new Dimension(getBounds().width, 20)); cnt++; + if (cnt > 2) { + panel.setPosition(new Point(0, getBounds().width + (cnt - 2) * 20)); + } } } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditRegistry.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditRegistry.java index 2549a494..5605f996 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditRegistry.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditRegistry.java @@ -5,6 +5,7 @@ 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; @@ -28,6 +29,7 @@ public class ValueEditRegistry { valueEditMap.put(Integer.class.getName(), new ValueEditInteger.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(DungeonSecret.class.getName(), new ValueEditSecret.Generator()); |