diff options
Diffstat (limited to 'src/main/java/kr/syeyoung')
17 files changed, 611 insertions, 46 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/commands/CommandDungeonsGuide.java b/src/main/java/kr/syeyoung/dungeonsguide/commands/CommandDungeonsGuide.java index 93f0745a..1fa740ce 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/commands/CommandDungeonsGuide.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/commands/CommandDungeonsGuide.java @@ -1,6 +1,6 @@ package kr.syeyoung.dungeonsguide.commands; -import kr.syeyoung.dungeonsguide.config.GuiConfig; +import kr.syeyoung.dungeonsguide.config.guiconfig.GuiConfig; import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoomInfoRegistry; import kr.syeyoung.dungeonsguide.e; import net.minecraft.client.Minecraft; diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/FeatureEditPane.java b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/FeatureEditPane.java index 2296f8a6..7684c5f2 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/config/FeatureEditPane.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/FeatureEditPane.java @@ -1,5 +1,6 @@ -package kr.syeyoung.dungeonsguide.config; +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.*; @@ -23,8 +24,10 @@ public class FeatureEditPane extends MPanel { private MButton save; private List<MFeature> le = new ArrayList<MFeature>(); - public FeatureEditPane(List<AbstractFeature> features) { + private GuiConfig config; + public FeatureEditPane(List<AbstractFeature> features, GuiConfig config) { this.features = features; + this.config = config; buildElements(); } @@ -47,7 +50,7 @@ public class FeatureEditPane extends MPanel { }); } for (AbstractFeature feature : features) { - MFeature mFeature = new MFeature(feature); + MFeature mFeature = new MFeature(feature, config); mFeature.setHover(new Color(100,100,100,200)); le.add(mFeature); add(mFeature); @@ -97,8 +100,8 @@ public class FeatureEditPane extends MPanel { } } - private float zLevel = 0; - protected void drawHoveringText(List<String> textLines, int x, int y, FontRenderer font) + private static float zLevel = 0; + public static void drawHoveringText(List<String> textLines, int x, int y, FontRenderer font) { if (!textLines.isEmpty()) { @@ -127,19 +130,19 @@ public class FeatureEditPane extends MPanel { k += 2 + (textLines.size() - 1) * 10; } - this.zLevel = 300.0F; + zLevel = 300.0F; int l = -267386864; - this.drawGradientRect(l1 - 3, i2 - 4, l1 + i + 3, i2 - 3, l, l); - this.drawGradientRect(l1 - 3, i2 + k + 3, l1 + i + 3, i2 + k + 4, l, l); - this.drawGradientRect(l1 - 3, i2 - 3, l1 + i + 3, i2 + k + 3, l, l); - this.drawGradientRect(l1 - 4, i2 - 3, l1 - 3, i2 + k + 3, l, l); - this.drawGradientRect(l1 + i + 3, i2 - 3, l1 + i + 4, i2 + k + 3, l, l); + 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; - this.drawGradientRect(l1 - 3, i2 - 3 + 1, l1 - 3 + 1, i2 + k + 3 - 1, i1, j1); - this.drawGradientRect(l1 + i + 2, i2 - 3 + 1, l1 + i + 3, i2 + k + 3 - 1, i1, j1); - this.drawGradientRect(l1 - 3, i2 - 3, l1 + i + 3, i2 - 3 + 1, i1, i1); - this.drawGradientRect(l1 - 3, i2 + k + 2, l1 + i + 3, i2 + k + 3, j1, j1); + 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) { @@ -154,14 +157,14 @@ public class FeatureEditPane extends MPanel { i2 += 10; } - this.zLevel = 0.0F; + zLevel = 0.0F; GlStateManager.enableLighting(); GlStateManager.enableDepth(); RenderHelper.enableStandardItemLighting(); GlStateManager.enableRescaleNormal(); } } - protected void drawGradientRect(int left, int top, int right, int bottom, int startColor, int endColor) + 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; @@ -179,10 +182,10 @@ public class FeatureEditPane extends MPanel { Tessellator tessellator = Tessellator.getInstance(); WorldRenderer worldrenderer = tessellator.getWorldRenderer(); worldrenderer.begin(7, DefaultVertexFormats.POSITION_COLOR); - worldrenderer.pos((double)right, (double)top, (double)this.zLevel).color(f1, f2, f3, f).endVertex(); - worldrenderer.pos((double)left, (double)top, (double)this.zLevel).color(f1, f2, f3, f).endVertex(); - worldrenderer.pos((double)left, (double)bottom, (double)this.zLevel).color(f5, f6, f7, f4).endVertex(); - worldrenderer.pos((double)right, (double)bottom, (double)this.zLevel).color(f5, f6, f7, f4).endVertex(); + 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(); diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/GuiConfig.java b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/GuiConfig.java index 5b408181..32921db5 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/config/GuiConfig.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/GuiConfig.java @@ -1,4 +1,4 @@ -package kr.syeyoung.dungeonsguide.config; +package kr.syeyoung.dungeonsguide.config.guiconfig; import kr.syeyoung.dungeonsguide.features.AbstractFeature; import kr.syeyoung.dungeonsguide.features.FeatureRegistry; @@ -31,7 +31,7 @@ public class GuiConfig extends GuiScreen { for (Map.Entry<String, List<AbstractFeature>> cate: FeatureRegistry.getFeaturesByCategory().entrySet()) if (!cate.getKey().equals("hidden")) - tabbedPane.addTab(cate.getKey(), new FeatureEditPane(cate.getValue())); + tabbedPane.addTab(cate.getKey(), new FeatureEditPane(cate.getValue(), this)); this.tabbedPane = tabbedPane; } 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/MFeature.java b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/MFeature.java index 25436572..fcbfdc11 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/config/MFeature.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/MFeature.java @@ -1,5 +1,6 @@ -package kr.syeyoung.dungeonsguide.config; +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; @@ -28,7 +29,10 @@ public class MFeature extends MPanel { @Getter @Setter private Color hover; - public MFeature(AbstractFeature abstractFeature) { + private GuiConfig config; + + public MFeature(final AbstractFeature abstractFeature, final GuiConfig config) { + this.config = config; this.feature = abstractFeature; this.add(this.label = new MLabel()); @@ -49,6 +53,12 @@ public class MFeature extends MPanel { 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); } @@ -58,7 +68,7 @@ public class MFeature extends MPanel { button.setOnActionPerformed(new Runnable() { @Override public void run() { - Minecraft.getMinecraft().displayGuiScreen(new GuiGuiLocationConfig()); + Minecraft.getMinecraft().displayGuiScreen(new GuiGuiLocationConfig(config)); } }); addons.add(button); 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) { diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/types/TCColor.java b/src/main/java/kr/syeyoung/dungeonsguide/config/types/TCColor.java new file mode 100644 index 00000000..31ae8a43 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/config/types/TCColor.java @@ -0,0 +1,24 @@ +package kr.syeyoung.dungeonsguide.config.types; + +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonPrimitive; + +import java.awt.*; + +public class TCColor implements TypeConverter<Color> { + @Override + public String getTypeString() { + return "color"; + } + + @Override + public Color deserialize(JsonElement element) { + return new Color(element.getAsInt()); + } + + @Override + public JsonElement serialize(Color element) { + return new JsonPrimitive(element.getRGB()); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/types/TypeConverterRegistry.java b/src/main/java/kr/syeyoung/dungeonsguide/config/types/TypeConverterRegistry.java index ee6fdfce..5f4947a1 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/config/types/TypeConverterRegistry.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/config/types/TypeConverterRegistry.java @@ -24,5 +24,6 @@ public class TypeConverterRegistry { register(new TCInteger()); register(new TCRectangle()); register(new TCString()); + register(new TCColor()); } } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/FeatureListener.java b/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/FeatureListener.java index 31a70285..4bf332c8 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/FeatureListener.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/FeatureListener.java @@ -4,15 +4,13 @@ import kr.syeyoung.dungeonsguide.SkyblockStatus; import kr.syeyoung.dungeonsguide.e; import kr.syeyoung.dungeonsguide.features.*; import kr.syeyoung.dungeonsguide.features.AbstractFeature; -import kr.syeyoung.dungeonsguide.features.listener.ChatListener; -import kr.syeyoung.dungeonsguide.features.listener.ScreenRenderListener; -import kr.syeyoung.dungeonsguide.features.listener.TooltipListener; -import kr.syeyoung.dungeonsguide.features.listener.WorldRenderListener; +import kr.syeyoung.dungeonsguide.features.listener.*; import net.minecraftforge.client.event.ClientChatReceivedEvent; import net.minecraftforge.client.event.RenderGameOverlayEvent; import net.minecraftforge.client.event.RenderWorldLastEvent; import net.minecraftforge.event.entity.player.ItemTooltipEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.common.gameevent.TickEvent; public class FeatureListener { @SubscribeEvent @@ -81,4 +79,22 @@ public class FeatureListener { t.printStackTrace(); } } + + @SubscribeEvent + public void onTick(TickEvent.ClientTickEvent tick) { + if (tick.phase == TickEvent.Phase.END && tick.type == TickEvent.Type.PLAYER ) { + try { + SkyblockStatus skyblockStatus = e.getDungeonsGuide().getSkyblockStatus(); + if (!skyblockStatus.isOnSkyblock()) return; + + for (AbstractFeature abstractFeature : FeatureRegistry.getFeatureList()) { + if (abstractFeature instanceof TickListener) { + ((TickListener) abstractFeature).onTick(); + } + } + } catch (Throwable t) { + t.printStackTrace(); + } + } + } } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/AbstractFeature.java b/src/main/java/kr/syeyoung/dungeonsguide/features/AbstractFeature.java index 2facddbe..30b1a29a 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/AbstractFeature.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/AbstractFeature.java @@ -37,7 +37,9 @@ public abstract class AbstractFeature { public List<FeatureParameter> getParameters() { return new ArrayList<FeatureParameter>(parameters.values()); } - + public <T> FeatureParameter<T> getParameter(String key) { + return parameters.get(key); + } public void loadConfig(JsonObject jsonObject) { // gets key, calls it enabled = jsonObject.get("$enabled").getAsBoolean(); diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/GuiFeature.java b/src/main/java/kr/syeyoung/dungeonsguide/features/GuiFeature.java index 98f8af15..d9d964c1 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/GuiFeature.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/GuiFeature.java @@ -7,10 +7,12 @@ import lombok.AccessLevel; import lombok.Getter; import lombok.Setter; import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.renderer.OpenGlHelper; import org.lwjgl.opengl.GL11; +import javax.sound.midi.MidiEvent; import java.awt.*; @Getter @@ -66,6 +68,11 @@ public abstract class GuiFeature extends AbstractFeature implements ScreenRender GL11.glScissor((x ) * scale, Minecraft.getMinecraft().displayHeight - (y + height) * scale, (width) * scale, height * scale); } + public static FontRenderer getFontRenderer() { + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + return fr; + } + @Override public void loadConfig(JsonObject jsonObject) { super.loadConfig(jsonObject); diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/FeatureCooldownCounter.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/FeatureCooldownCounter.java index dc2b7dd8..76a942a2 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/FeatureCooldownCounter.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/FeatureCooldownCounter.java @@ -1,13 +1,18 @@ package kr.syeyoung.dungeonsguide.features.impl; +import kr.syeyoung.dungeonsguide.features.FeatureParameter; import kr.syeyoung.dungeonsguide.features.GuiFeature; +import kr.syeyoung.dungeonsguide.features.listener.TickListener; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import org.lwjgl.opengl.GL11; -public class FeatureCooldownCounter extends GuiFeature { +import java.awt.*; + +public class FeatureCooldownCounter extends GuiFeature implements TickListener { public FeatureCooldownCounter() { - super("QoL", "Dungeon Cooldown Counter", "Counts 10 seconds after leaving dungeon", "qol.cooldown", true, 100, 50); + super("QoL", "Dungeon Cooldown Counter", "Counts 10 seconds after leaving dungeon", "qol.cooldown", true, getFontRenderer().getStringWidth("Cooldown: 10s "), getFontRenderer().FONT_HEIGHT); + parameters.put("color", new FeatureParameter<Color>("color", "Color", "Color of text", Color.white, "color")); } @Override @@ -15,7 +20,7 @@ public class FeatureCooldownCounter extends GuiFeature { FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; double scale = getFeatureRect().getHeight() / fr.FONT_HEIGHT; GL11.glScaled(scale, scale, 0); - fr.drawString("Cooldown: 1s", 0,0,0xFFFFFFFF); + fr.drawString("Cooldown: 1s", 0,0,this.<Color>getParameter("color").getValue().getRGB()); } @Override @@ -23,6 +28,11 @@ public class FeatureCooldownCounter extends GuiFeature { FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; double scale = getFeatureRect().getHeight() / fr.FONT_HEIGHT; GL11.glScaled(scale, scale, 0); - fr.drawString("Cooldown: 1s", 0,0,0xFFFFFFFF); + fr.drawString("Cooldown: 10s", 0,0,this.<Color>getParameter("color").getValue().getRGB()); + } + + @Override + public void onTick() { + } } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/listener/TickListener.java b/src/main/java/kr/syeyoung/dungeonsguide/features/listener/TickListener.java new file mode 100644 index 00000000..dc040fc9 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/listener/TickListener.java @@ -0,0 +1,5 @@ +package kr.syeyoung.dungeonsguide.features.listener; + +public interface TickListener { + void onTick(); +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditColor.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditColor.java new file mode 100755 index 00000000..24b01713 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditColor.java @@ -0,0 +1,81 @@ +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 java.awt.*; + +public class ValueEditColor extends MPanel implements ValueEdit<Integer> { + private Parameter parameter; + + + @Override + public void renderWorld(float partialTicks) { + + } + public ValueEditColor(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<ValueEditColor> { + + @Override + public ValueEditColor createValueEdit(Parameter parameter) { + return new ValueEditColor(parameter); + } + + @Override + public Object createDefaultValue(Parameter parameter) { + return 0; + } + + @Override + public Object cloneObj(Object object) { + return object; + } + } +} |