diff options
author | syeyoung <42869671+cyoung06@users.noreply.github.com> | 2020-12-14 18:31:24 +0900 |
---|---|---|
committer | syeyoung <42869671+cyoung06@users.noreply.github.com> | 2020-12-14 18:31:24 +0900 |
commit | 299a569e6e37870bf7828500244916acefc3e1a0 (patch) | |
tree | 238597b930190b441382e73c4df0926fc757a799 /src/main/java/kr/syeyoung/dungeonsguide | |
parent | 54b2804d7ff5c1d560893376070979d993ef0580 (diff) | |
download | Skyblock-Dungeons-Guide-299a569e6e37870bf7828500244916acefc3e1a0.tar.gz Skyblock-Dungeons-Guide-299a569e6e37870bf7828500244916acefc3e1a0.tar.bz2 Skyblock-Dungeons-Guide-299a569e6e37870bf7828500244916acefc3e1a0.zip |
oneway and two way
Diffstat (limited to 'src/main/java/kr/syeyoung/dungeonsguide')
14 files changed, 478 insertions, 21 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonBreakableWall.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonBreakableWall.java index 0096ba80..9daf6bf3 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonBreakableWall.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonBreakableWall.java @@ -88,4 +88,9 @@ public class DungeonBreakableWall implements DungeonMechanic, RouteBlocker { return b == Blocks.air ?"open" :"closed"; } + + @Override + public Set<String> getPossibleStates(DungeonRoom dungeonRoom) { + return isBlocking(dungeonRoom) ? Collections.singleton("open") : Collections.<String>emptySet(); + } } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonDoor.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonDoor.java index 0182f938..93370c6c 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonDoor.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonDoor.java @@ -32,7 +32,7 @@ public class DungeonDoor implements DungeonMechanic, RouteBlocker { } Set<Action> base; Set<Action> preRequisites = base = new HashSet<Action>(); - { + if (!state.equalsIgnoreCase(getCurrentState(dungeonRoom))) { ActionClickSet actionClick; preRequisites.add(actionClick = new ActionClickSet(secretPoint)); actionClick.setPredicate(PredicateSuperBoom.INSTANCE); @@ -84,4 +84,15 @@ public class DungeonDoor implements DungeonMechanic, RouteBlocker { public String getCurrentState(DungeonRoom dungeonRoom) { return isBlocking(dungeonRoom) ?"closed":"open"; } + + + @Override + public Set<String> getPossibleStates(DungeonRoom dungeonRoom) { + String currentStatus = getCurrentState(dungeonRoom); + if (currentStatus.equalsIgnoreCase("closed")) + return Collections.singleton("open"); + else if (currentStatus.equalsIgnoreCase("open")) + return Collections.singleton("closed"); + return Collections.emptySet(); + } } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonLever.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonLever.java index a29ae770..79752eab 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonLever.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonLever.java @@ -1,17 +1,18 @@ package kr.syeyoung.dungeonsguide.dungeon.mechanics; import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; -import kr.syeyoung.dungeonsguide.dungeon.mechanics.action.*; +import kr.syeyoung.dungeonsguide.dungeon.mechanics.action.Action; +import kr.syeyoung.dungeonsguide.dungeon.mechanics.action.ActionChangeState; +import kr.syeyoung.dungeonsguide.dungeon.mechanics.action.ActionClick; +import kr.syeyoung.dungeonsguide.dungeon.mechanics.action.ActionMove; import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; import kr.syeyoung.dungeonsguide.utils.RenderUtils; import lombok.Data; import net.minecraft.util.BlockPos; import java.awt.*; -import java.util.ArrayList; -import java.util.HashSet; import java.util.List; -import java.util.Set; +import java.util.*; @Data public class DungeonLever implements DungeonMechanic { @@ -24,7 +25,7 @@ public class DungeonLever implements DungeonMechanic { if (!("triggered".equalsIgnoreCase(state) || "untriggered".equalsIgnoreCase(state))) throw new IllegalArgumentException(state+" is not valid state for secret"); Set<Action> base; Set<Action> preRequisites = base = new HashSet<Action>(); - { + if (!state.equalsIgnoreCase(getCurrentState(dungeonRoom))){ ActionClick actionClick; preRequisites.add(actionClick = new ActionClick(leverPoint)); preRequisites = actionClick.getPreRequisite(); @@ -76,4 +77,14 @@ public class DungeonLever implements DungeonMechanic { } } } + + @Override + public Set<String> getPossibleStates(DungeonRoom dungeonRoom) { + String currentStatus = getCurrentState(dungeonRoom); + if (currentStatus.equalsIgnoreCase("untriggered")) + return Collections.singleton("triggered"); + else if (currentStatus.equalsIgnoreCase("triggered")) + return Collections.singleton("untriggered"); + return Collections.emptySet(); + } } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonMechanic.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonMechanic.java index 232af04b..7bd4d71b 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonMechanic.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonMechanic.java @@ -12,4 +12,6 @@ public interface DungeonMechanic { void highlight(Color color, String name, DungeonRoom dungeonRoom, float partialTicks); String getCurrentState(DungeonRoom dungeonRoom); + + Set<String> getPossibleStates(DungeonRoom dungeonRoom); } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonOnewayDoor.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonOnewayDoor.java new file mode 100644 index 00000000..5b32e29a --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonOnewayDoor.java @@ -0,0 +1,95 @@ +package kr.syeyoung.dungeonsguide.dungeon.mechanics; + +import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; +import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPointSet; +import kr.syeyoung.dungeonsguide.dungeon.mechanics.action.Action; +import kr.syeyoung.dungeonsguide.dungeon.mechanics.action.ActionChangeState; +import kr.syeyoung.dungeonsguide.dungeon.mechanics.action.ActionClickSet; +import kr.syeyoung.dungeonsguide.dungeon.mechanics.action.ActionMoveNearestAir; +import kr.syeyoung.dungeonsguide.dungeon.mechanics.predicates.PredicateSuperBoom; +import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.utils.RenderUtils; +import lombok.Data; +import net.minecraft.init.Blocks; +import net.minecraft.util.BlockPos; + +import java.awt.*; +import java.util.List; +import java.util.*; + +@Data +public class DungeonOnewayDoor implements DungeonMechanic, RouteBlocker { + private OffsetPointSet secretPoint = new OffsetPointSet(); + private List<String> preRequisite = new ArrayList<String>(); + + + @Override + public Set<Action> getAction(String state, DungeonRoom dungeonRoom) { + if (!("open".equalsIgnoreCase(state))) throw new IllegalArgumentException(state+" is not valid state for door"); + if (!isBlocking(dungeonRoom)) { + return Collections.emptySet(); + } + Set<Action> base; + Set<Action> preRequisites = base = new HashSet<Action>(); + { + ActionClickSet actionClick; + preRequisites.add(actionClick = new ActionClickSet(secretPoint)); + actionClick.setPredicate(PredicateSuperBoom.INSTANCE); + preRequisites = actionClick.getPreRequisite(); + } + { + ActionMoveNearestAir actionMove = new ActionMoveNearestAir(secretPoint.getOffsetPointList().get(0)); + preRequisites.add(actionMove); + preRequisites = actionMove.getPreRequisite(); + } + { + for (String str : preRequisite) { + ActionChangeState actionChangeState = new ActionChangeState(str.split(":")[0], str.split(":")[1]); + preRequisites.add(actionChangeState); + } + } + return base; + } + + @Override + public void highlight(Color color, String name, DungeonRoom dungeonRoom, float partialTicks) { + if (secretPoint.getOffsetPointList().isEmpty()) return; + OffsetPoint firstpt = secretPoint.getOffsetPointList().get(0); + BlockPos pos = firstpt.getBlockPos(dungeonRoom); + RenderUtils.drawTextAtWorld(name, pos.getX() +0.5f, pos.getY()+0.25f, pos.getZ()+0.5f, 0xFFFFFFFF, 0.03f, false, true, partialTicks); + RenderUtils.drawTextAtWorld(getCurrentState(dungeonRoom), pos.getX() +0.5f, pos.getY()+0.75f, pos.getZ()+0.5f, 0xFFFFFFFF, 0.03f, false, true, partialTicks); + + for (OffsetPoint offsetPoint : secretPoint.getOffsetPointList()) { + RenderUtils.highlightBlock(offsetPoint.getBlockPos(dungeonRoom), color,partialTicks); + } + } + + @Override + public boolean isBlocking(DungeonRoom dungeonRoom) { + for (OffsetPoint offsetPoint : secretPoint.getOffsetPointList()) { + if (offsetPoint.getBlock(dungeonRoom) != Blocks.air) return true; + } + return false; + } + + public DungeonOnewayDoor clone() throws CloneNotSupportedException { + DungeonOnewayDoor dungeonSecret = new DungeonOnewayDoor(); + dungeonSecret.secretPoint = (OffsetPointSet) secretPoint.clone(); + dungeonSecret.preRequisite = new ArrayList<String>(preRequisite); + return dungeonSecret; + } + + @Override + public String getCurrentState(DungeonRoom dungeonRoom) { + return isBlocking(dungeonRoom) ?"closed":"open"; + } + + + @Override + public Set<String> getPossibleStates(DungeonRoom dungeonRoom) { + String currentStatus = getCurrentState(dungeonRoom); + if (currentStatus.equalsIgnoreCase("closed")) + return Collections.singleton("open"); + return Collections.emptySet(); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonOnewayLever.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonOnewayLever.java new file mode 100644 index 00000000..10a6ecab --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonOnewayLever.java @@ -0,0 +1,85 @@ +package kr.syeyoung.dungeonsguide.dungeon.mechanics; + +import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; +import kr.syeyoung.dungeonsguide.dungeon.mechanics.action.*; +import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.utils.RenderUtils; +import lombok.Data; +import net.minecraft.util.BlockPos; + +import java.awt.*; +import java.util.*; +import java.util.List; + +@Data +public class DungeonOnewayLever implements DungeonMechanic { + private OffsetPoint leverPoint = new OffsetPoint(0,0,0); + private List<String> preRequisite = new ArrayList<String>(); + private String triggering; + + @Override + public Set<Action> getAction(String state, DungeonRoom dungeonRoom) { + if (!("triggered".equalsIgnoreCase(state) || "untriggered".equalsIgnoreCase(state))) throw new IllegalArgumentException(state+" is not valid state for secret"); + Set<Action> base; + Set<Action> preRequisites = base = new HashSet<Action>(); + { + ActionClick actionClick; + preRequisites.add(actionClick = new ActionClick(leverPoint)); + preRequisites = actionClick.getPreRequisite(); + } + { + ActionMove actionMove = new ActionMove(leverPoint); + preRequisites.add(actionMove); + preRequisites = actionMove.getPreRequisite(); + } + { + for (String str : preRequisite) { + ActionChangeState actionChangeState = new ActionChangeState(str.split(":")[0], str.split(":")[1]); + preRequisites.add(actionChangeState); + } + } + return base; + } + + @Override + public void highlight(Color color, String name, DungeonRoom dungeonRoom, float partialTicks) { + BlockPos pos = getLeverPoint().getBlockPos(dungeonRoom); + RenderUtils.highlightBlock(pos, color,partialTicks); + RenderUtils.drawTextAtWorld(name, pos.getX() +0.5f, pos.getY()+0.75f, pos.getZ()+0.5f, 0xFFFFFFFF, 0.03f, false, true, partialTicks); + RenderUtils.drawTextAtWorld(getCurrentState(dungeonRoom), pos.getX() +0.5f, pos.getY()+0.25f, pos.getZ()+0.5f, 0xFFFFFFFF, 0.03f, false, true, partialTicks); + } + + public DungeonOnewayLever clone() throws CloneNotSupportedException { + DungeonOnewayLever dungeonSecret = new DungeonOnewayLever(); + dungeonSecret.leverPoint = (OffsetPoint) leverPoint.clone(); + dungeonSecret.triggering = triggering; + dungeonSecret.preRequisite = new ArrayList<String>(preRequisite); + return dungeonSecret; + } + + + @Override + public String getCurrentState(DungeonRoom dungeonRoom) { + + DungeonMechanic mechanic = dungeonRoom.getDungeonRoomInfo().getMechanics().get(triggering); + if (mechanic == null) + { + return "undeterminable"; + } else { + String state = mechanic.getCurrentState(dungeonRoom); + if ("open".equalsIgnoreCase(state)) { + return "triggered"; + } else { + return "untriggered"; + } + } + } + + @Override + public Set<String> getPossibleStates(DungeonRoom dungeonRoom) { + String currentStatus = getCurrentState(dungeonRoom); + if (currentStatus.equalsIgnoreCase("untriggered")) + return Collections.singleton("triggered"); + return Collections.emptySet(); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonPressurePlate.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonPressurePlate.java index 56826abd..a59b44b5 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonPressurePlate.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonPressurePlate.java @@ -8,10 +8,8 @@ import lombok.Data; import net.minecraft.util.BlockPos; import java.awt.*; -import java.util.ArrayList; -import java.util.HashSet; +import java.util.*; import java.util.List; -import java.util.Set; @Data public class DungeonPressurePlate implements DungeonMechanic { @@ -22,6 +20,8 @@ public class DungeonPressurePlate implements DungeonMechanic { @Override public Set<Action> getAction(String state, DungeonRoom dungeonRoom) { if (!("triggered".equalsIgnoreCase(state) || "untriggered".equalsIgnoreCase(state))) throw new IllegalArgumentException(state+" is not valid state for secret"); + if (state.equalsIgnoreCase(getCurrentState(dungeonRoom))) return Collections.emptySet(); + Set<Action> base; Set<Action> preRequisites = base = new HashSet<Action>(); if ("triggered".equalsIgnoreCase(state)) { @@ -76,4 +76,14 @@ public class DungeonPressurePlate implements DungeonMechanic { } } } + + @Override + public Set<String> getPossibleStates(DungeonRoom dungeonRoom) { + String currentStatus = getCurrentState(dungeonRoom); + if (currentStatus.equalsIgnoreCase("triggered")) + return Collections.singleton("untriggered"); + else if (currentStatus.equalsIgnoreCase("untriggered")) + return Collections.singleton("triggered"); + return Collections.emptySet(); + } } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonSecret.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonSecret.java index 90adb774..fe5ad8c7 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonSecret.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonSecret.java @@ -18,10 +18,8 @@ import net.minecraft.util.BlockPos; import org.jetbrains.annotations.Nullable; import java.awt.*; -import java.util.ArrayList; -import java.util.HashSet; +import java.util.*; import java.util.List; -import java.util.Set; @Data public class DungeonSecret implements DungeonMechanic { @@ -52,7 +50,7 @@ public class DungeonSecret implements DungeonMechanic { @Override public Set<Action> getAction(String state, DungeonRoom dungeonRoom) { - if (!"claimed".equalsIgnoreCase(state)) throw new IllegalArgumentException(state+" is not valid state for secret"); + if (!"found".equalsIgnoreCase(state)) throw new IllegalArgumentException(state+" is not valid state for secret"); Set<Action> base; Set<Action> preRequisites = base = new HashSet<Action>(); if (secretType == SecretType.CHEST) { @@ -109,4 +107,11 @@ public class DungeonSecret implements DungeonMechanic { public String getCurrentState(DungeonRoom dungeonRoom) { return getSecretStatus(dungeonRoom).name(); } + + @Override + public Set<String> getPossibleStates(DungeonRoom dungeonRoom) { + SecretStatus status = getSecretStatus(dungeonRoom); + if (status == SecretStatus.FOUND) return Collections.emptySet(); + else return Collections.singleton("found"); + } } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonTomb.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonTomb.java index 02b90455..f65b0c0d 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonTomb.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonTomb.java @@ -91,4 +91,9 @@ public class DungeonTomb implements DungeonMechanic, RouteBlocker { b = secretPoint.getOffsetPointList().get(0).getBlock(dungeonRoom); return b == Blocks.air ?"open" :"closed"; } + + @Override + public Set<String> getPossibleStates(DungeonRoom dungeonRoom) { + return isBlocking(dungeonRoom) ? Collections.singleton("open") : Collections.<String>emptySet(); + } } 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()); } } |