diff options
Diffstat (limited to 'src/main/java/kr/syeyoung/dungeonsguide/roomedit')
5 files changed, 236 insertions, 8 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditLever.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditLever.java index 9faebe48..27e26eb3 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditLever.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditLever.java @@ -2,7 +2,7 @@ package kr.syeyoung.dungeonsguide.roomedit.mechanicedit; import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; import kr.syeyoung.dungeonsguide.dungeon.mechanics.DungeonLever; -import kr.syeyoung.dungeonsguide.dungeon.mechanics.DungeonSecret; +import kr.syeyoung.dungeonsguide.dungeon.mechanics.DungeonOnewayLever; import kr.syeyoung.dungeonsguide.roomedit.EditingContext; import kr.syeyoung.dungeonsguide.roomedit.MPanel; import kr.syeyoung.dungeonsguide.roomedit.Parameter; diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditOnewayDoor.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditOnewayDoor.java new file mode 100644 index 00000000..85b6d706 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditOnewayDoor.java @@ -0,0 +1,126 @@ +package kr.syeyoung.dungeonsguide.roomedit.mechanicedit; + +import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; +import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPointSet; +import kr.syeyoung.dungeonsguide.dungeon.mechanics.DungeonDoor; +import kr.syeyoung.dungeonsguide.dungeon.mechanics.DungeonOnewayDoor; +import kr.syeyoung.dungeonsguide.roomedit.EditingContext; +import kr.syeyoung.dungeonsguide.roomedit.MPanel; +import kr.syeyoung.dungeonsguide.roomedit.Parameter; +import kr.syeyoung.dungeonsguide.roomedit.elements.*; +import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEdit; +import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEditCreator; +import kr.syeyoung.dungeonsguide.utils.TextUtils; +import net.minecraft.init.Blocks; +import scala.actors.threadpool.Arrays; + +import java.awt.*; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +public class ValueEditOnewayDoor extends MPanel implements ValueEdit<DungeonOnewayDoor> { + private Parameter parameter; + + // scroll pane + // just create + // add set + private DungeonOnewayDoor dungeonDoor; + + private MLabel label; + private MValue<OffsetPointSet> value; + private MTextField preRequisite; + private MLabelAndElement preRequisite2; + private MButton updateOnlyAir; + + public ValueEditOnewayDoor(final Parameter parameter2) { + this.parameter = parameter2; + this.dungeonDoor = (DungeonOnewayDoor) parameter2.getNewData(); + + + label = new MLabel(); + label.setText("Wall Points"); + label.setAlignment(MLabel.Alignment.LEFT); + add(label); + + value = new MValue(dungeonDoor.getSecretPoint(), Collections.emptyList()); + add(value); + + updateOnlyAir = new MButton(); + updateOnlyAir.setText("Update Air"); + updateOnlyAir.setBackgroundColor(Color.green); + updateOnlyAir.setForeground(Color.black); + updateOnlyAir.setBounds(new Rectangle(0,40,bounds.width, 20)); + add(updateOnlyAir); + updateOnlyAir.setOnActionPerformed(new Runnable() { + @Override + public void run() { + OffsetPointSet ofs = dungeonDoor.getSecretPoint(); + List<OffsetPoint> filtered = new ArrayList<OffsetPoint>(); + for (OffsetPoint offsetPoint : ofs.getOffsetPointList()) { + if (offsetPoint.getBlock(EditingContext.getEditingContext().getRoom()) != Blocks.air) continue; + filtered.add(offsetPoint); + } + dungeonDoor.getSecretPoint().setOffsetPointList(filtered); + } + }); + + preRequisite = new MTextField() { + @Override + public void edit(String str) { + dungeonDoor.setPreRequisite(Arrays.asList(str.split(","))); + } + }; + preRequisite.setText(TextUtils.join(dungeonDoor.getPreRequisite(), ",")); + preRequisite2 = new MLabelAndElement("Req.",preRequisite); + preRequisite2.setBounds(new Rectangle(0,60,bounds.width,20)); + add(preRequisite2); + } + + @Override + public void onBoundsUpdate() { + label.setBounds(new Rectangle(0,0,bounds.width, 20)); + value.setBounds(new Rectangle(0,20,bounds.width, 20)); + updateOnlyAir.setBounds(new Rectangle(0,40,bounds.width, 20)); + preRequisite2.setBounds(new Rectangle(0,60,bounds.width,20)); + } + + @Override + public void setParameter(Parameter parameter) { + this.parameter = parameter; + } + + @Override + public void renderWorld(float partialTicks) { + dungeonDoor.highlight(new Color(0,255,255,50), parameter.getName(), EditingContext.getEditingContext().getRoom(), partialTicks); + } + + @Override + public void resize(int parentWidth, int parentHeight) { + this.setBounds(new Rectangle(0,0,parentWidth, parentHeight)); + } + + public static class Generator implements ValueEditCreator<ValueEditOnewayDoor> { + + @Override + public ValueEditOnewayDoor createValueEdit(Parameter parameter) { + return new ValueEditOnewayDoor(parameter); + } + + @Override + public Object createDefaultValue(Parameter parameter) { + return new DungeonOnewayDoor(); + } + + @Override + public Object cloneObj(Object object) { + try { + return ((DungeonOnewayDoor)object).clone(); + } catch (CloneNotSupportedException e) { + e.printStackTrace(); + } + assert false; + return null; + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditOnewayLever.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditOnewayLever.java new file mode 100644 index 00000000..9a510867 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditOnewayLever.java @@ -0,0 +1,103 @@ +package kr.syeyoung.dungeonsguide.roomedit.mechanicedit; + +import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; +import kr.syeyoung.dungeonsguide.dungeon.mechanics.DungeonOnewayLever; +import kr.syeyoung.dungeonsguide.roomedit.EditingContext; +import kr.syeyoung.dungeonsguide.roomedit.MPanel; +import kr.syeyoung.dungeonsguide.roomedit.Parameter; +import kr.syeyoung.dungeonsguide.roomedit.elements.MLabel; +import kr.syeyoung.dungeonsguide.roomedit.elements.MLabelAndElement; +import kr.syeyoung.dungeonsguide.roomedit.elements.MTextField; +import kr.syeyoung.dungeonsguide.roomedit.elements.MValue; +import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEdit; +import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEditCreator; +import kr.syeyoung.dungeonsguide.utils.TextUtils; +import scala.actors.threadpool.Arrays; + +import java.awt.*; +import java.util.Collections; + +public class ValueEditOnewayLever extends MPanel implements ValueEdit<DungeonOnewayLever> { + private Parameter parameter; + + // scroll pane + // just create + // add set + private DungeonOnewayLever dungeonLever; + + private MLabel label; + private MValue<OffsetPoint> value; + private MTextField preRequisite; + private MLabelAndElement preRequisite2; + + public ValueEditOnewayLever(final Parameter parameter2) { + this.parameter = parameter2; + this.dungeonLever = (DungeonOnewayLever) parameter2.getNewData(); + + + label = new MLabel(); + label.setText("Secret Point"); + label.setAlignment(MLabel.Alignment.LEFT); + add(label); + + value = new MValue(dungeonLever.getLeverPoint(), Collections.emptyList()); + add(value); + + preRequisite = new MTextField() { + @Override + public void edit(String str) { + dungeonLever.setPreRequisite(Arrays.asList(str.split(","))); + } + }; + preRequisite.setText(TextUtils.join(dungeonLever.getPreRequisite(), ",")); + preRequisite2 = new MLabelAndElement("Req.",preRequisite); + preRequisite2.setBounds(new Rectangle(0,40,bounds.width,20)); + add(preRequisite2); + } + + @Override + public void onBoundsUpdate() { + label.setBounds(new Rectangle(0,0,bounds.width, 20)); + value.setBounds(new Rectangle(0,20,bounds.width, 20)); + preRequisite2.setBounds(new Rectangle(0,40,bounds.width,20)); + } + + @Override + public void setParameter(Parameter parameter) { + this.parameter = parameter; + } + + @Override + public void renderWorld(float partialTicks) { + dungeonLever.highlight(new Color(0,255,0,50), parameter.getName(), EditingContext.getEditingContext().getRoom(), partialTicks); + } + + @Override + public void resize(int parentWidth, int parentHeight) { + this.setBounds(new Rectangle(0,0,parentWidth, parentHeight)); + } + + public static class Generator implements ValueEditCreator<ValueEditOnewayLever> { + + @Override + public ValueEditOnewayLever createValueEdit(Parameter parameter) { + return new ValueEditOnewayLever(parameter); + } + + @Override + public Object createDefaultValue(Parameter parameter) { + return new DungeonOnewayLever(); + } + + @Override + public Object cloneObj(Object object) { + try { + return ((DungeonOnewayLever)object).clone(); + } catch (CloneNotSupportedException e) { + e.printStackTrace(); + } + assert false; + return null; + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditPressurePlate.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditPressurePlate.java index db3282c3..9a1bc292 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditPressurePlate.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditPressurePlate.java @@ -1,7 +1,6 @@ package kr.syeyoung.dungeonsguide.roomedit.mechanicedit; import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; -import kr.syeyoung.dungeonsguide.dungeon.mechanics.DungeonLever; import kr.syeyoung.dungeonsguide.dungeon.mechanics.DungeonPressurePlate; import kr.syeyoung.dungeonsguide.roomedit.EditingContext; import kr.syeyoung.dungeonsguide.roomedit.MPanel; 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 d8c4095f..2549a494 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditRegistry.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditRegistry.java @@ -3,9 +3,7 @@ package kr.syeyoung.dungeonsguide.roomedit.valueedit; import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPointSet; import kr.syeyoung.dungeonsguide.dungeon.mechanics.*; -import kr.syeyoung.dungeonsguide.roomedit.mechanicedit.ValueEditBreakableWall; -import kr.syeyoung.dungeonsguide.roomedit.mechanicedit.ValueEditSecret; -import kr.syeyoung.dungeonsguide.roomedit.mechanicedit.ValueEditTomb; +import kr.syeyoung.dungeonsguide.roomedit.mechanicedit.*; import java.util.ArrayList; import java.util.HashMap; @@ -36,8 +34,10 @@ public class ValueEditRegistry { valueEditMap.put(DungeonTomb.class.getName(), new ValueEditTomb.Generator()); valueEditMap.put(DungeonBreakableWall.class.getName(), new ValueEditBreakableWall.Generator()); - valueEditMap.put(DungeonPressurePlate.class.getName(), new ValueEditSecret.Generator()); - valueEditMap.put(DungeonLever.class.getName(), new ValueEditTomb.Generator()); - valueEditMap.put(DungeonDoor.class.getName(), new ValueEditBreakableWall.Generator()); + valueEditMap.put(DungeonPressurePlate.class.getName(), new ValueEditPressurePlate.Generator()); + valueEditMap.put(DungeonOnewayLever.class.getName(), new ValueEditOnewayLever.Generator()); + valueEditMap.put(DungeonLever.class.getName(), new ValueEditLever.Generator()); + valueEditMap.put(DungeonDoor.class.getName(), new ValueEditDoor.Generator()); + valueEditMap.put(DungeonOnewayDoor.class.getName(), new ValueEditOnewayDoor.Generator()); } } |