diff options
author | syeyoung <42869671+cyoung06@users.noreply.github.com> | 2020-11-25 23:17:13 +0900 |
---|---|---|
committer | syeyoung <42869671+cyoung06@users.noreply.github.com> | 2020-11-25 23:17:13 +0900 |
commit | 49b083afffdf24f0bcd637909d15b88d9ed272b8 (patch) | |
tree | 4f02d7950d3cc00ac9d17f70a406b1bb543472dc /src/main | |
parent | 3a3b70806358e5e44232e793c84879514b1857b4 (diff) | |
download | Skyblock-Dungeons-Guide-49b083afffdf24f0bcd637909d15b88d9ed272b8.tar.gz Skyblock-Dungeons-Guide-49b083afffdf24f0bcd637909d15b88d9ed272b8.tar.bz2 Skyblock-Dungeons-Guide-49b083afffdf24f0bcd637909d15b88d9ed272b8.zip |
LAST COMMIT OF TODAY
Diffstat (limited to 'src/main')
9 files changed, 224 insertions, 5 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/commands/CommandEditRoom.java b/src/main/java/kr/syeyoung/dungeonsguide/commands/CommandEditRoom.java index 77f9718b..733c3ba5 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/commands/CommandEditRoom.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/commands/CommandEditRoom.java @@ -72,6 +72,7 @@ public class CommandEditRoom extends CommandBase { if ( openGuiReq &&tick.phase == TickEvent.Phase.END && tick.side == Side.CLIENT && tick.type == TickEvent.Type.CLIENT) { DungeonRoom dr = EditingContext.getEditingContext().getRoom(); EditingContext.getEditingContext().openGui(new GuiDungeonRoomEdit(dr)); + openGuiReq = false; } } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/EditingContext.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/EditingContext.java index 8b5cecdd..b9d7c488 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/EditingContext.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/EditingContext.java @@ -37,6 +37,7 @@ public class EditingContext { private Stack<GuiScreen> guiStack = new Stack<GuiScreen>(); + @Getter private GuiScreen current; public void openGui(GuiScreen gui) { diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/GuiDungeonRoomEdit.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/GuiDungeonRoomEdit.java index 5b52bcf0..2d1fe191 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/GuiDungeonRoomEdit.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/GuiDungeonRoomEdit.java @@ -6,6 +6,7 @@ import kr.syeyoung.dungeonsguide.roomedit.elements.MLabel; import kr.syeyoung.dungeonsguide.roomedit.elements.MTabbedPane; import kr.syeyoung.dungeonsguide.roomedit.elements.MTextField; import kr.syeyoung.dungeonsguide.roomedit.panes.GeneralEditPane; +import kr.syeyoung.dungeonsguide.roomedit.panes.ProcessorParameterEditPane; import kr.syeyoung.dungeonsguide.roomedit.panes.RoomDataDisplayPane; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; @@ -32,7 +33,8 @@ public class GuiDungeonRoomEdit extends GuiScreen { tabbedPane.addTab("General", new GeneralEditPane(room)); - tabbedPane.addTab("Room Match", new RoomDataDisplayPane(room)); + tabbedPane.addTab("Match", new RoomDataDisplayPane(room)); + tabbedPane.addTab("Proc.Params", new ProcessorParameterEditPane(room)); } @Override diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/MPanel.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/MPanel.java index fea3706f..5b3e119c 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/MPanel.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/MPanel.java @@ -35,11 +35,13 @@ public class MPanel { public void setPosition(Point pt) { this.bounds.x = pt.x; this.bounds.y = pt.y; + onBoundsUpdate(); } public void setSize(Dimension dim) { this.bounds.width = dim.width; this.bounds.height = dim.height; + onBoundsUpdate(); } public Dimension getSize() { diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/Parameter.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/Parameter.java new file mode 100644 index 00000000..024fa69e --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/Parameter.java @@ -0,0 +1,12 @@ +package kr.syeyoung.dungeonsguide.roomedit; + +import lombok.AllArgsConstructor; +import lombok.Data; + +@Data +@AllArgsConstructor +public class Parameter { + private String name; + private Object data; + +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MLabel.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MLabel.java index bea1601c..457f24fc 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MLabel.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MLabel.java @@ -17,8 +17,8 @@ public class MLabel extends MPanel { @Setter private Color foreground = Color.white; - public static enum Alignment { - LEFT, CENTER, RIGHT; + public enum Alignment { + LEFT, CENTER, RIGHT } @Getter @Setter @@ -29,7 +29,7 @@ public class MLabel extends MPanel { Dimension bounds = getSize(); FontRenderer renderer = Minecraft.getMinecraft().fontRendererObj; - int width = renderer.getStringWidth(text); + int width = renderer.getStringWidth(getText()); int x,y; if (alignment == Alignment.CENTER) { x = (bounds.width - width) / 2; @@ -43,6 +43,6 @@ public class MLabel extends MPanel { } else{ return; } - renderer.drawString(text, x,y, 0xffffff); + renderer.drawString(getText(), x,y, 0xffffff); } } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MLabelAndElement.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MLabelAndElement.java index ba62e8ef..298a88e0 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MLabelAndElement.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MLabelAndElement.java @@ -1,6 +1,9 @@ package kr.syeyoung.dungeonsguide.roomedit.elements; import kr.syeyoung.dungeonsguide.roomedit.MPanel; +import lombok.Getter; +import lombok.Setter; +import net.minecraft.client.gui.Gui; import java.awt.*; @@ -8,6 +11,11 @@ public class MLabelAndElement extends MPanel { private MLabel label; private MPanel element; + @Getter @Setter + private Color hover; + @Getter @Setter + private Runnable onClick; + public MLabelAndElement(String label, MPanel element) { this.add(this.label = new MLabel()); this.label.setText(label); @@ -16,6 +24,20 @@ public class MLabelAndElement extends MPanel { } @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),bounds.getSize()).contains(relMousex0, relMousey0)) { + Gui.drawRect(0,0,bounds.width, bounds.height, hover.getRGB()); + } + } + + @Override + protected void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) { + if (onClick!= null && new Rectangle(new Point(0,0),bounds.getSize()).contains(relMouseX, relMouseY)) { + onClick.run(); + } + } + + @Override public void resize(int parentWidth, int parentHeight) { this.setSize(new Dimension(parentWidth, bounds.height)); label.setBounds(new Rectangle(0,0,parentHeight / 3, bounds.height)); diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MParameter.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MParameter.java new file mode 100644 index 00000000..9a599075 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MParameter.java @@ -0,0 +1,68 @@ +package kr.syeyoung.dungeonsguide.roomedit.elements; + +import kr.syeyoung.dungeonsguide.roomedit.EditingContext; +import kr.syeyoung.dungeonsguide.roomedit.MPanel; +import kr.syeyoung.dungeonsguide.roomedit.Parameter; +import lombok.Getter; +import lombok.Setter; +import net.minecraft.client.gui.Gui; + +import java.awt.*; + +public class MParameter extends MPanel { + private MLabel label; + private MLabel data; + + @Getter @Setter + private Color hover = Color.gray; + + @Getter @Setter + private Parameter parameter; + + public MParameter(final Parameter parameter) { + this.add(this.label = new MLabel() { + @Override + public String getText() { + return parameter.getName(); + } + }); + this.add(this.data = new MLabel() { + @Override + public String getText() { + return parameter.getData() != null ?parameter.getData().toString() :"-empty-"; + } + }); + this.label.setAlignment(MLabel.Alignment.LEFT); + this.data.setAlignment(MLabel.Alignment.RIGHT); + + this.parameter = parameter; + } + + @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),bounds.getSize()).contains(relMousex0, relMousey0)) { + Gui.drawRect(0,0,bounds.width, bounds.height, hover.getRGB()); + } + } + + @Override + protected void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) { + if (this.bounds.x > -20 && new Rectangle(new Point(0,0),bounds.getSize()).contains(relMouseX, relMouseY)) { + // open new gui; + System.out.println("hey I'm "+parameter.getName()+", i'ma open gui"); + } + } + + @Override + public void resize(int parentWidth, int parentHeight) { + this.setSize(new Dimension(parentWidth, bounds.height)); + label.setBounds(new Rectangle(0,0,parentHeight / 3, bounds.height)); + data.setBounds(new Rectangle(parentWidth / 3,0,parentWidth / 3 * 2, bounds.height)); + } + + @Override + public void onBoundsUpdate() { + label.setBounds(new Rectangle(0,0,bounds.width / 3, bounds.height)); + data.setBounds(new Rectangle(bounds.width / 3,0,bounds.width / 3 * 2, bounds.height)); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/ProcessorParameterEditPane.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/ProcessorParameterEditPane.java new file mode 100644 index 00000000..edc81ac3 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/ProcessorParameterEditPane.java @@ -0,0 +1,111 @@ +package kr.syeyoung.dungeonsguide.roomedit.panes; + +import kr.syeyoung.dungeonsguide.dungeon.data.DungeonRoomInfo; +import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; +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.MLabelAndElement; +import kr.syeyoung.dungeonsguide.roomedit.elements.MParameter; + +import java.awt.*; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.UUID; + +public class ProcessorParameterEditPane extends MPanel { + private DungeonRoom dungeonRoom; + + private MButton save; + private MButton create; + private List<MParameter> parameters = new ArrayList<MParameter>(); + + public ProcessorParameterEditPane(DungeonRoom dungeonRoom) { + this.dungeonRoom = dungeonRoom; + buildElements(); + } + + public void buildElements() { + { + create = new MButton(); + create.setText("Create New Parameter"); + create.setBackgroundColor(Color.cyan); + create.setBounds(new Rectangle(0,0,100,20)); + create.setOnActionPerformed(new Runnable() { + @Override + public void run() { + MParameter parameter; + parameters.add(parameter = new MParameter(new Parameter(UUID.randomUUID().toString(), null))); + parameter.setBounds(new Rectangle(0,0,bounds.width, 20)); + } + }); + + 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() { + DungeonRoomInfo dungeonRoomInfo = dungeonRoom.getDungeonRoomInfo(); + dungeonRoomInfo.getProperties().clear(); + + for (MParameter parameter : parameters) { + Parameter real = parameter.getParameter(); + dungeonRoomInfo.getProperties().put(real.getName(), real.getData()); + } + } + }); + } + { + for (Map.Entry<String, Object> en : dungeonRoom.getDungeonRoomInfo().getProperties().entrySet()) { + MParameter mParameter = new MParameter(new Parameter(en.getKey(), en.getValue())); + mParameter.setBounds(new Rectangle(0,0,bounds.width,20)); + parameters.add(mParameter); + } + } + } + + @Override + public void onBoundsUpdate() { + for (MPanel panel :getChildComponents()){ + panel.setSize(new Dimension(bounds.width, 20)); + } + } + @Override + public void resize(int parentWidth, int parentHeight) { + this.setBounds(new Rectangle(5,5,parentWidth-10,parentHeight-10)); + } + + + public void delete(MParameter parameter) { + parameters.remove(parameter); + } + + + @Override + public List<MPanel> getChildComponents() { + ArrayList<MPanel> panels = new ArrayList<MPanel>(parameters); + panels.add(create); + panels.add(save); + return panels; + } + + private int offsetY = 0; + @Override + public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { + int heights = 0; + for (MPanel panel:getChildComponents()) { + panel.setPosition(new Point(0, -offsetY + heights)); + heights += panel.getBounds().height; + } + } + + @Override + protected 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; + } +} |