diff options
author | syeyoung <cyong06@naver.com> | 2021-01-01 20:29:29 +0900 |
---|---|---|
committer | syeyoung <cyong06@naver.com> | 2021-01-01 20:29:29 +0900 |
commit | 5503237b9b2a2b75188188341f2dd8abe477c9f5 (patch) | |
tree | 53566f82f118b52ef2d432abf9f21d2976ee9ca2 /src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig | |
parent | be44a7665e4982934998020d3bb930be25a50c25 (diff) | |
download | Skyblock-Dungeons-Guide-5503237b9b2a2b75188188341f2dd8abe477c9f5.tar.gz Skyblock-Dungeons-Guide-5503237b9b2a2b75188188341f2dd8abe477c9f5.tar.bz2 Skyblock-Dungeons-Guide-5503237b9b2a2b75188188341f2dd8abe477c9f5.zip |
ah yes?
Diffstat (limited to 'src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig')
8 files changed, 808 insertions, 10 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/FeatureEditPane.java b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/FeatureEditPane.java new file mode 100755 index 00000000..7684c5f2 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/FeatureEditPane.java @@ -0,0 +1,202 @@ +package kr.syeyoung.dungeonsguide.config.guiconfig; + +import kr.syeyoung.dungeonsguide.config.Config; +import kr.syeyoung.dungeonsguide.features.AbstractFeature; +import kr.syeyoung.dungeonsguide.roomedit.MPanel; +import kr.syeyoung.dungeonsguide.roomedit.elements.*; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +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 java.awt.*; +import java.io.IOException; +import java.util.*; +import java.util.List; + +public class FeatureEditPane extends MPanel { + private List<AbstractFeature> features; + + private MButton save; + private List<MFeature> le = new ArrayList<MFeature>(); + + private GuiConfig config; + public FeatureEditPane(List<AbstractFeature> features, GuiConfig config) { + this.features = features; + this.config = config; + buildElements(); + } + + + public void buildElements() { + { + save = new MButton(); + save.setText("Save"); + save.setBackgroundColor(Color.green); + save.setBounds(new Rectangle(0,0,100,20)); + save.setOnActionPerformed(new Runnable() { + @Override + public void run() { + try { + Config.saveConfig(); + } catch (IOException e) { + e.printStackTrace(); + } + } + }); + } + for (AbstractFeature feature : features) { + MFeature mFeature = new MFeature(feature, config); + mFeature.setHover(new Color(100,100,100,200)); + le.add(mFeature); + add(mFeature); + } + } + @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 List<MPanel> getChildComponents() { + ArrayList<MPanel> panels = new ArrayList<MPanel>(le); + panels.add(save); + return panels; + } + + private int offsetY = 0; + private MPanel within; + @Override + public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { + int heights = 0; + within = null; + for (MPanel panel:getChildComponents()) { + panel.setPosition(new Point(0, -offsetY + heights)); + heights += panel.getBounds().height; + + if (panel.getBounds().contains(relMousex0, relMousey0)) within = panel; + } + } + + @Override + 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(); + } + } + + private static float zLevel = 0; + public static void drawHoveringText(List<String> textLines, int x, int y, FontRenderer font) + { + if (!textLines.isEmpty()) + { + GlStateManager.disableRescaleNormal(); + RenderHelper.disableStandardItemLighting(); + GlStateManager.disableLighting(); + GlStateManager.disableDepth(); + int i = 0; + + for (String s : textLines) + { + int j = font.getStringWidth(s); + + if (j > i) + { + i = j; + } + } + + int l1 = x + 12; + int i2 = y - 12; + int k = 8; + + if (textLines.size() > 1) + { + k += 2 + (textLines.size() - 1) * 10; + } + + zLevel = 300.0F; + int l = -267386864; + drawGradientRect(l1 - 3, i2 - 4, l1 + i + 3, i2 - 3, l, l); + drawGradientRect(l1 - 3, i2 + k + 3, l1 + i + 3, i2 + k + 4, l, l); + drawGradientRect(l1 - 3, i2 - 3, l1 + i + 3, i2 + k + 3, l, l); + drawGradientRect(l1 - 4, i2 - 3, l1 - 3, i2 + k + 3, l, l); + drawGradientRect(l1 + i + 3, i2 - 3, l1 + i + 4, i2 + k + 3, l, l); + int i1 = 1347420415; + int j1 = (i1 & 16711422) >> 1 | i1 & -16777216; + drawGradientRect(l1 - 3, i2 - 3 + 1, l1 - 3 + 1, i2 + k + 3 - 1, i1, j1); + drawGradientRect(l1 + i + 2, i2 - 3 + 1, l1 + i + 3, i2 + k + 3 - 1, i1, j1); + drawGradientRect(l1 - 3, i2 - 3, l1 + i + 3, i2 - 3 + 1, i1, i1); + drawGradientRect(l1 - 3, i2 + k + 2, l1 + i + 3, i2 + k + 3, j1, j1); + + for (int k1 = 0; k1 < textLines.size(); ++k1) + { + String s1 = (String)textLines.get(k1); + font.drawStringWithShadow(s1, (float)l1, (float)i2, -1); + + if (k1 == 0) + { + i2 += 2; + } + + i2 += 10; + } + + zLevel = 0.0F; + GlStateManager.enableLighting(); + GlStateManager.enableDepth(); + RenderHelper.enableStandardItemLighting(); + GlStateManager.enableRescaleNormal(); + } + } + protected static void drawGradientRect(int left, int top, int right, int bottom, int startColor, int endColor) + { + float f = (float)(startColor >> 24 & 255) / 255.0F; + float f1 = (float)(startColor >> 16 & 255) / 255.0F; + float f2 = (float)(startColor >> 8 & 255) / 255.0F; + float f3 = (float)(startColor & 255) / 255.0F; + float f4 = (float)(endColor >> 24 & 255) / 255.0F; + float f5 = (float)(endColor >> 16 & 255) / 255.0F; + float f6 = (float)(endColor >> 8 & 255) / 255.0F; + float f7 = (float)(endColor & 255) / 255.0F; + GlStateManager.disableTexture2D(); + GlStateManager.enableBlend(); + GlStateManager.disableAlpha(); + GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); + GlStateManager.shadeModel(7425); + Tessellator tessellator = Tessellator.getInstance(); + WorldRenderer worldrenderer = tessellator.getWorldRenderer(); + worldrenderer.begin(7, DefaultVertexFormats.POSITION_COLOR); + worldrenderer.pos((double)right, (double)top, (double)zLevel).color(f1, f2, f3, f).endVertex(); + worldrenderer.pos((double)left, (double)top, (double)zLevel).color(f1, f2, f3, f).endVertex(); + worldrenderer.pos((double)left, (double)bottom, (double)zLevel).color(f5, f6, f7, f4).endVertex(); + worldrenderer.pos((double)right, (double)bottom, (double)zLevel).color(f5, f6, f7, f4).endVertex(); + tessellator.draw(); + GlStateManager.shadeModel(7424); + GlStateManager.disableBlend(); + GlStateManager.enableAlpha(); + GlStateManager.enableTexture2D(); + } + + @Override + public void mouseScrolled(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0, int scrollAmount) { + if (scrollAmount > 0) offsetY -= 20; + else if (scrollAmount < 0) offsetY += 20; + if (offsetY < 0) offsetY = 0; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/GuiConfig.java b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/GuiConfig.java new file mode 100755 index 00000000..32921db5 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/GuiConfig.java @@ -0,0 +1,90 @@ +package kr.syeyoung.dungeonsguide.config.guiconfig; + +import kr.syeyoung.dungeonsguide.features.AbstractFeature; +import kr.syeyoung.dungeonsguide.features.FeatureRegistry; +import kr.syeyoung.dungeonsguide.roomedit.MPanel; +import kr.syeyoung.dungeonsguide.roomedit.elements.MTabbedPane; +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; + +public class GuiConfig extends GuiScreen { + + private MPanel mainPanel = new MPanel(); + + private MTabbedPane tabbedPane; + + public GuiConfig() { + MTabbedPane tabbedPane = new MTabbedPane(); + mainPanel.add(tabbedPane); + tabbedPane.setBackground2(new Color(17, 17, 17, 179)); + + for (Map.Entry<String, List<AbstractFeature>> cate: FeatureRegistry.getFeaturesByCategory().entrySet()) + if (!cate.getKey().equals("hidden")) + tabbedPane.addTab(cate.getKey(), new FeatureEditPane(cate.getValue(), this)); + this.tabbedPane = tabbedPane; + } + + @Override + public void initGui() { + super.initGui(); + ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); + mainPanel.setBounds(new Rectangle(Math.min((scaledResolution.getScaledWidth() - 500) / 2, scaledResolution.getScaledWidth()), Math.min((scaledResolution.getScaledHeight() - 300) / 2, scaledResolution.getScaledHeight()),500,300)); + } + FloatBuffer floatBuffer = BufferUtils.createFloatBuffer(16); + + @Override + public void drawScreen(int mouseX, int mouseY, float partialTicks) { + ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); + GL11.glPushMatrix(); + 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); + GL11.glPopMatrix(); + } + + @Override + public void keyTyped(char typedChar, int keyCode) throws IOException { + super.keyTyped(typedChar, keyCode); + mainPanel.keyTyped0(typedChar, keyCode); + } + + @Override + public void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException { + super.mouseClicked(mouseX, mouseY, mouseButton); + mainPanel.mouseClicked0(mouseX, mouseY,mouseX,mouseY, mouseButton); + } + + @Override + public void mouseReleased(int mouseX, int mouseY, int state) { + mainPanel.mouseReleased0(mouseX, mouseY,mouseX,mouseY, state); + } + + @Override + public void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) { + mainPanel.mouseClickMove0(mouseX,mouseY,mouseX,mouseY,clickedMouseButton,timeSinceLastClick); + } + + @Override + public void handleMouseInput() throws IOException { + super.handleMouseInput(); + + int i = Mouse.getEventX() * this.width / this.mc.displayWidth; + int j = this.height - Mouse.getEventY() * this.height / this.mc.displayHeight - 1; + + int wheel = Mouse.getDWheel(); + if (wheel != 0) { + mainPanel.mouseScrolled0(i, j,i,j, wheel); + } + } +} 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 f7660788..2080c9dc 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/GuiGuiLocationConfig.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/GuiGuiLocationConfig.java @@ -1,6 +1,5 @@ package kr.syeyoung.dungeonsguide.config.guiconfig; -import kr.syeyoung.dungeonsguide.config.GuiConfig; import kr.syeyoung.dungeonsguide.features.AbstractFeature; import kr.syeyoung.dungeonsguide.features.FeatureRegistry; import kr.syeyoung.dungeonsguide.features.GuiFeature; @@ -19,8 +18,10 @@ import java.io.IOException; public class GuiGuiLocationConfig extends GuiScreen { private MPanel mainPanel = new MPanel(); + private GuiScreen before; - public GuiGuiLocationConfig() { + public GuiGuiLocationConfig(final GuiScreen before) { + this.before = before; for (AbstractFeature feature : FeatureRegistry.getFeatureList()) { if (feature instanceof GuiFeature && feature.isEnabled()) { mainPanel.add(new PanelDelegate((GuiFeature) feature)); @@ -39,7 +40,7 @@ public class GuiGuiLocationConfig extends GuiScreen { button.setOnActionPerformed(new Runnable() { @Override public void run() { - Minecraft.getMinecraft().displayGuiScreen(new GuiConfig()); + Minecraft.getMinecraft().displayGuiScreen(before); } }); mainPanel.add(button); @@ -56,12 +57,10 @@ public class GuiGuiLocationConfig extends GuiScreen { @Override public void drawScreen(int mouseX, int mouseY, float partialTicks) { ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); - GL11.glPushMatrix(); - GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS); - 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); - GL11.glPopAttrib(); GL11.glPopMatrix(); } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/GuiParameterConfig.java b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/GuiParameterConfig.java new file mode 100755 index 00000000..a234249b --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/GuiParameterConfig.java @@ -0,0 +1,115 @@ +package kr.syeyoung.dungeonsguide.config.guiconfig; + +import kr.syeyoung.dungeonsguide.features.AbstractFeature; +import kr.syeyoung.dungeonsguide.features.FeatureParameter; +import kr.syeyoung.dungeonsguide.roomedit.MPanel; +import kr.syeyoung.dungeonsguide.roomedit.elements.MButton; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.client.renderer.GlStateManager; +import org.lwjgl.input.Mouse; +import org.lwjgl.opengl.GL11; + +import java.awt.*; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; + +public class GuiParameterConfig extends GuiScreen { + + private MPanel mainPanel = new MPanel(); + private GuiScreen before; + private AbstractFeature feature; + + public GuiParameterConfig(final GuiScreen before, AbstractFeature feature) { + this.before = before; + for (FeatureParameter parameter: feature.getParameters()) { + mainPanel.add(new MParameter(feature, parameter, this)); + } + MButton save = new MButton(); + save.setText("Back"); + save.setBackgroundColor(Color.green); + save.setBounds(new Rectangle(0,0,100,20)); + save.setOnActionPerformed(new Runnable() { + @Override + public void run() { + Minecraft.getMinecraft().displayGuiScreen(before); + } + }); + mainPanel.add(save); + + } + + @Override + public void initGui() { + super.initGui(); + ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); + mainPanel.setBounds(new Rectangle(Math.min((scaledResolution.getScaledWidth() - 500) / 2, scaledResolution.getScaledWidth()), Math.min((scaledResolution.getScaledHeight() - 300) / 2, scaledResolution.getScaledHeight()),500,300)); + } + + MPanel within; + @Override + public void drawScreen(int mouseX, int mouseY, float partialTicks) { + ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); + GL11.glPushMatrix(); + GlStateManager.color(1,1,1,1); + GL11.glDisable(GL11.GL_DEPTH_TEST); + int heights = 0; + within = null; + for (MPanel panel:mainPanel.getChildComponents()) { + panel.setPosition(new Point(0, -offsetY + heights)); + 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); + if (within instanceof MParameter) { + FeatureParameter feature = ((MParameter) within).getParameter(); + GlStateManager.pushAttrib(); + drawHoveringText(new ArrayList<String>(Arrays.asList(feature.getDescription().split("\n"))), mouseX, mouseY, Minecraft.getMinecraft().fontRendererObj); + GlStateManager.popAttrib(); + } + GL11.glPopMatrix(); + } + + @Override + public void keyTyped(char typedChar, int keyCode) throws IOException { + super.keyTyped(typedChar, keyCode); + mainPanel.keyTyped0(typedChar, keyCode); + } + + @Override + public void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException { + super.mouseClicked(mouseX, mouseY, mouseButton); + mainPanel.mouseClicked0(mouseX, mouseY,mouseX,mouseY, mouseButton); + } + + @Override + public void mouseReleased(int mouseX, int mouseY, int state) { + mainPanel.mouseReleased0(mouseX, mouseY,mouseX,mouseY, state); + } + + @Override + public void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) { + mainPanel.mouseClickMove0(mouseX,mouseY,mouseX,mouseY,clickedMouseButton,timeSinceLastClick); + } + + public int offsetY = 0; + @Override + public void handleMouseInput() throws IOException { + super.handleMouseInput(); + + int i = Mouse.getEventX() * this.width / this.mc.displayWidth; + int j = this.height - Mouse.getEventY() * this.height / this.mc.displayHeight - 1; + + int wheel = Mouse.getDWheel(); + if (wheel != 0) { + mainPanel.mouseScrolled0(i, j,i,j, wheel); + } + + if (wheel > 0) offsetY -= 20; + else if (wheel < 0) offsetY += 20; + if (offsetY < 0) offsetY = 0; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/GuiParameterValueEdit.java b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/GuiParameterValueEdit.java new file mode 100755 index 00000000..7b993a11 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/GuiParameterValueEdit.java @@ -0,0 +1,190 @@ +package kr.syeyoung.dungeonsguide.config.guiconfig; + +import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.roomedit.EditingContext; +import kr.syeyoung.dungeonsguide.roomedit.MPanel; +import kr.syeyoung.dungeonsguide.roomedit.Parameter; +import kr.syeyoung.dungeonsguide.roomedit.elements.MButton; +import kr.syeyoung.dungeonsguide.roomedit.elements.MLabel; +import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEdit; +import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEditCreator; +import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEditRegistry; +import lombok.Getter; +import lombok.Setter; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraftforge.common.MinecraftForge; +import org.lwjgl.input.Mouse; +import org.lwjgl.opengl.GL11; + +import java.awt.*; +import java.io.IOException; +import java.util.List; + +public class GuiParameterValueEdit extends GuiScreen { + + private MPanel mainPanel = new MPanel() { + @Override + public void onBoundsUpdate() { + save.setBounds(new Rectangle(0 ,getBounds().height - 20, getBounds().width, 20)); + } + }; + + private DungeonRoom dungeonRoom; + + + private MPanel currentValueEdit; + + private MButton save; + + @Getter + private ValueEdit valueEdit; + + private Object editingObj; + + @Getter + @Setter + private Runnable onUpdate; + @Getter + private Parameter parameter; + + 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)); + } + }; + mainPanel.add(currentValueEdit); + } + { + save = new MButton() { + @Override + public void resize(int parentWidth, int parentHeight) { + setBounds(new Rectangle(0, parentHeight - 20, parentWidth, 20)); + } + }; + save.setText("Go back"); + save.setBackgroundColor(Color.green); + save.setOnActionPerformed(new Runnable() { + @Override + public void run() { + onUpdate.run(); + Minecraft.getMinecraft().displayGuiScreen(prev); + } + }); + mainPanel.add(save); + } + updateClassSelection(); + } catch (Exception e){} + } + + public void updateClassSelection() { + currentValueEdit.getChildComponents().clear(); + + ValueEditCreator valueEditCreator = ValueEditRegistry.getValueEditMap(editingObj == null ?"null":editingObj.getClass().getName()); + + MPanel valueEdit = (MPanel) valueEditCreator.createValueEdit(parameter= new Parameter("", editingObj, editingObj)); + if (valueEdit == null) { + MLabel valueEdit2 = new MLabel() { + @Override + public void resize(int parentWidth, int parentHeight) { + setBounds(new Rectangle(0, 0, parentWidth,20)); + } + }; + valueEdit2.setText("No Value Edit"); + valueEdit2.setBounds(new Rectangle(0,0,150,20)); + valueEdit = valueEdit2; + this.valueEdit = null; + } else{ + this.valueEdit = (ValueEdit) valueEdit; + } + valueEdit.resize0(currentValueEdit.getBounds().width, currentValueEdit.getBounds().height); + currentValueEdit.add(valueEdit); + } + @Override + public void initGui() { + super.initGui(); + // update bounds + ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); + mainPanel.setBounds(new Rectangle(10, Math.min((scaledResolution.getScaledHeight() - 300) / 2, scaledResolution.getScaledHeight()),200,300)); + } + + @Override + public void drawScreen(int mouseX, int mouseY, float partialTicks) { + try { + ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); + GL11.glPushMatrix(); + GlStateManager.color(1,1,1,1); + mainPanel.render0(scaledResolution, new Point(0, 0), new Rectangle(0, 0, scaledResolution.getScaledWidth(), scaledResolution.getScaledHeight()), mouseX, mouseY, mouseX, mouseY, partialTicks); + GL11.glPopMatrix(); + } catch (Throwable e) { + e.printStackTrace(); + } + } + + @Override + public void keyTyped(char typedChar, int keyCode) throws IOException { + + try { + super.keyTyped(typedChar, keyCode); + mainPanel.keyTyped0(typedChar, keyCode); + } catch (Throwable t) { + t.printStackTrace(); + } + } + + @Override + public void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException { + try { + super.mouseClicked(mouseX, mouseY, mouseButton); + mainPanel.mouseClicked0(mouseX, mouseY,mouseX,mouseY, mouseButton); + } catch (Throwable t) { + t.printStackTrace(); + } + } + + @Override + public void mouseReleased(int mouseX, int mouseY, int state) { + try { + mainPanel.mouseReleased0(mouseX, mouseY,mouseX,mouseY, state); + } catch (Throwable t) { + t.printStackTrace(); + } + } + + @Override + public void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) { + try { + mainPanel.mouseClickMove0(mouseX,mouseY,mouseX,mouseY,clickedMouseButton,timeSinceLastClick); + + } catch (Throwable t) { + t.printStackTrace(); + } + } + + @Override + public void handleMouseInput() throws IOException { + super.handleMouseInput(); + + int i = Mouse.getEventX() * this.width / this.mc.displayWidth; + int j = this.height - Mouse.getEventY() * this.height / this.mc.displayHeight - 1; + + int wheel = Mouse.getDWheel(); + if (wheel != 0) { + try { + mainPanel.mouseScrolled0(i, j,i,j, wheel); + } catch (Throwable t) { + t.printStackTrace(); + } + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/MFeature.java b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/MFeature.java new file mode 100755 index 00000000..fcbfdc11 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/MFeature.java @@ -0,0 +1,100 @@ +package kr.syeyoung.dungeonsguide.config.guiconfig; + +import kr.syeyoung.dungeonsguide.config.guiconfig.GuiConfig; +import kr.syeyoung.dungeonsguide.config.guiconfig.GuiGuiLocationConfig; +import kr.syeyoung.dungeonsguide.features.AbstractFeature; +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.MLabel; +import kr.syeyoung.dungeonsguide.roomedit.elements.MStringSelectionButton; +import lombok.Getter; +import lombok.Setter; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.Gui; +import scala.actors.threadpool.Arrays; + +import java.awt.*; +import java.util.List; +import java.util.ArrayList; + +public class MFeature extends MPanel { + private MLabel label; + + @Getter + private AbstractFeature feature; + + private List<MPanel> addons = new ArrayList<MPanel>(); + + @Getter @Setter + private Color hover; + + private GuiConfig config; + + public MFeature(final AbstractFeature abstractFeature, final GuiConfig config) { + this.config = config; + this.feature = abstractFeature; + + this.add(this.label = new MLabel()); + this.label.setText(abstractFeature.getName()); + + { + 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() { + String selected = mStringSelectionButton.getSelected(); + feature.setEnabled("on".equals(selected)); + } + }); + addons.add(mStringSelectionButton); + add(mStringSelectionButton); + } + if (!abstractFeature.getParameters().isEmpty()) { + MButton button = new MButton(); + button.setText("Edit"); + button.setOnActionPerformed(new Runnable() { + @Override + public void run() { + Minecraft.getMinecraft().displayGuiScreen(new GuiParameterConfig(config, abstractFeature)); + } + }); + addons.add(button); + add(button); + } + if (abstractFeature instanceof GuiFeature) { + MButton button = new MButton(); + button.setText("GUI"); + button.setOnActionPerformed(new Runnable() { + @Override + public void run() { + Minecraft.getMinecraft().displayGuiScreen(new GuiGuiLocationConfig(config)); + } + }); + addons.add(button); + add(button); + } + } + + @Override + public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { + if (hover != null && new Rectangle(new Point(0,0),getBounds().getSize()).contains(relMousex0, relMousey0)) { + Gui.drawRect(0,0,getBounds().width, getBounds().height, hover.getRGB()); + } + } + + @Override + public void resize(int parentWidth, int parentHeight) { + this.setSize(new Dimension(parentWidth, getBounds().height)); + } + + @Override + public void onBoundsUpdate() { + int x = getBounds().width - 50; + for (MPanel panel : addons) { + 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/MParameter.java b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/MParameter.java new file mode 100755 index 00000000..882de0e4 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/MParameter.java @@ -0,0 +1,102 @@ +package kr.syeyoung.dungeonsguide.config.guiconfig; + +import kr.syeyoung.dungeonsguide.config.guiconfig.GuiGuiLocationConfig; +import kr.syeyoung.dungeonsguide.config.guiconfig.GuiParameterConfig; +import kr.syeyoung.dungeonsguide.config.guiconfig.GuiParameterValueEdit; +import kr.syeyoung.dungeonsguide.features.AbstractFeature; +import kr.syeyoung.dungeonsguide.features.FeatureParameter; +import kr.syeyoung.dungeonsguide.features.GuiFeature; +import kr.syeyoung.dungeonsguide.roomedit.EditingContext; +import kr.syeyoung.dungeonsguide.roomedit.MPanel; +import kr.syeyoung.dungeonsguide.roomedit.Parameter; +import kr.syeyoung.dungeonsguide.roomedit.elements.MButton; +import kr.syeyoung.dungeonsguide.roomedit.elements.MLabel; +import kr.syeyoung.dungeonsguide.roomedit.elements.MStringSelectionButton; +import kr.syeyoung.dungeonsguide.roomedit.gui.GuiDungeonValueEdit; +import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEdit; +import lombok.Getter; +import lombok.Setter; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.Gui; +import scala.actors.threadpool.Arrays; + +import java.awt.*; +import java.util.ArrayList; +import java.util.List; + +public class MParameter extends MPanel { + private MLabel label; + + @Getter + private AbstractFeature feature; + @Getter + private FeatureParameter parameter; + + private List<MPanel> addons = new ArrayList<MPanel>(); + + @Getter @Setter + private Color hover; + + private GuiParameterConfig config; + + private MLabel label2; + public MParameter(AbstractFeature abstractFeature, final FeatureParameter parameter, final GuiParameterConfig config) { + this.config = config; + this.parameter = parameter; + this.feature = abstractFeature; + + this.add(this.label = new MLabel()); + this.label.setText(parameter.getName()); + + { + MButton button = new MButton(); + button.setText("Edit"); + button.setOnActionPerformed(new Runnable() { + @Override + public void run() { + final GuiParameterValueEdit guiParameterValueEdit = new GuiParameterValueEdit(parameter.getValue(), config); + guiParameterValueEdit.setOnUpdate(new Runnable() { + @Override + public void run() { + Parameter parameter1 = guiParameterValueEdit.getParameter(); + parameter.setValue(parameter1.getNewData()); + label2.setText(parameter.getValue().toString()); + } + }); + Minecraft.getMinecraft().displayGuiScreen(guiParameterValueEdit); + } + }); + addons.add(button); + add(button); + } + { + MLabel button = new MLabel(); + button.setText(parameter.getValue().toString()); + addons.add(button); + add(button); + label2 = button; + } + } + + @Override + public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { + if (hover != null && new Rectangle(new Point(0,0),getBounds().getSize()).contains(relMousex0, relMousey0)) { + Gui.drawRect(0,0,getBounds().width, getBounds().height, hover.getRGB()); + } + } + + @Override + public void resize(int parentWidth, int parentHeight) { + this.setSize(new Dimension(parentWidth, getBounds().height)); + } + + @Override + public void onBoundsUpdate() { + int x = getBounds().width - 50; + for (MPanel panel : addons) { + 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/PanelDelegate.java b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/PanelDelegate.java index 2e6ca8be..8fa6d371 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/PanelDelegate.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/PanelDelegate.java @@ -74,11 +74,11 @@ public class PanelDelegate extends MPanel { int minWidth; int minHeight; if (guiFeature.isKeepRatio()) { - minHeight = (int) Math.max(10, 10 / guiFeature.getDefaultRatio()); + minHeight = (int) Math.max(8, 8 / guiFeature.getDefaultRatio()); minWidth = (int) (guiFeature.getDefaultRatio() * minHeight); } else { - minWidth = 10; - minHeight = 10; + minWidth = 8; + minHeight = 8; } Rectangle rectangle = guiFeature.getFeatureRect().getBounds(); if (rectangle.width < minWidth || rectangle.height < minHeight) { |