From 496efb764360cd26fa40982532048aa18ae4c6be Mon Sep 17 00:00:00 2001 From: syeyoung <42869671+cyoung06@users.noreply.github.com> Date: Tue, 15 Dec 2020 00:40:58 +0900 Subject: dungeon actions and secrets --- .../dungeonsguide/dungeon/actions/Action.java | 9 ++ .../dungeon/actions/ActionChangeState.java | 32 +++++ .../dungeonsguide/dungeon/actions/ActionClick.java | 32 +++++ .../dungeon/actions/ActionClickSet.java | 32 +++++ .../dungeon/actions/ActionDropItem.java | 32 +++++ .../dungeonsguide/dungeon/actions/ActionKill.java | 32 +++++ .../dungeonsguide/dungeon/actions/ActionMove.java | 29 +++++ .../dungeon/actions/ActionMoveNearestAir.java | 28 +++++ .../dungeonsguide/dungeon/actions/ActionRoot.java | 25 ++++ .../dungeon/actions/tree/ActionTree.java | 49 ++++++++ .../dungeon/mechanics/DungeonBreakableWall.java | 8 +- .../dungeon/mechanics/DungeonDoor.java | 9 +- .../dungeon/mechanics/DungeonLever.java | 8 +- .../dungeon/mechanics/DungeonMechanic.java | 2 +- .../dungeon/mechanics/DungeonOnewayDoor.java | 8 +- .../dungeon/mechanics/DungeonOnewayLever.java | 5 +- .../dungeon/mechanics/DungeonPressurePlate.java | 5 +- .../dungeon/mechanics/DungeonSecret.java | 8 +- .../dungeon/mechanics/DungeonTomb.java | 12 +- .../dungeon/mechanics/action/Action.java | 9 -- .../mechanics/action/ActionChangeState.java | 28 ----- .../dungeon/mechanics/action/ActionClick.java | 27 ----- .../dungeon/mechanics/action/ActionClickSet.java | 28 ----- .../dungeon/mechanics/action/ActionDropItem.java | 23 ---- .../dungeon/mechanics/action/ActionKill.java | 28 ----- .../dungeon/mechanics/action/ActionMove.java | 24 ---- .../mechanics/action/ActionMoveNearestAir.java | 23 ---- .../roomedit/gui/GuiDungeonRoomEdit.java | 6 +- .../roomedit/panes/ActionDisplayPane.java | 72 +++++++++++ .../roomedit/panes/ActionTreeDisplayPane.java | 131 +++++++++++++++++++++ 30 files changed, 535 insertions(+), 229 deletions(-) create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/Action.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionChangeState.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionClick.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionClickSet.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionDropItem.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionKill.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionMove.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionMoveNearestAir.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionRoot.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/tree/ActionTree.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/action/Action.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/action/ActionChangeState.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/action/ActionClick.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/action/ActionClickSet.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/action/ActionDropItem.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/action/ActionKill.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/action/ActionMove.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/action/ActionMoveNearestAir.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/ActionDisplayPane.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/ActionTreeDisplayPane.java (limited to 'src') diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/Action.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/Action.java new file mode 100644 index 00000000..7e3318c7 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/Action.java @@ -0,0 +1,9 @@ +package kr.syeyoung.dungeonsguide.dungeon.actions; + +import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; + +import java.util.Set; + +public interface Action { + Set getPreRequisites(DungeonRoom dungeonRoom); +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionChangeState.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionChangeState.java new file mode 100644 index 00000000..b17625d7 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionChangeState.java @@ -0,0 +1,32 @@ +package kr.syeyoung.dungeonsguide.dungeon.actions; + +import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; +import lombok.Data; + +import java.util.HashSet; +import java.util.Set; + +@Data +public class ActionChangeState implements Action{ + private Set preRequisite2 = new HashSet(); + + private String mechanicName; + private String state; + + public ActionChangeState(String mechanicName, String state) { + this.mechanicName = mechanicName; + this.state = state; + } + + @Override + public Set getPreRequisites(DungeonRoom dungeonRoom) { + Set set = new HashSet(); + set.addAll(preRequisite2); + set.addAll(dungeonRoom.getDungeonRoomInfo().getMechanics().get(mechanicName).getAction(state, dungeonRoom)); + return set; + } + @Override + public String toString() { + return "ChangeState\n\ttarget: "+mechanicName+"\n\tstate: "+state; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionClick.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionClick.java new file mode 100644 index 00000000..13e4ee76 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionClick.java @@ -0,0 +1,32 @@ +package kr.syeyoung.dungeonsguide.dungeon.actions; + +import com.google.common.base.Predicate; +import com.google.common.base.Predicates; +import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; +import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; +import lombok.Data; +import net.minecraft.item.ItemStack; + +import java.util.HashSet; +import java.util.Set; + +@Data +public class ActionClick implements Action { + private Set preRequisite = new HashSet(); + private OffsetPoint target; + private Predicate predicate = Predicates.alwaysTrue(); + + public ActionClick(OffsetPoint target) { + this.target = target; + } + + @Override + public Set getPreRequisites(DungeonRoom dungeonRoom) { + return preRequisite; + } + + @Override + public String toString() { + return "Click\n\ttarget: "+target.toString()+"\n\tpredicate: "+predicate.getClass().getSimpleName(); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionClickSet.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionClickSet.java new file mode 100644 index 00000000..454bfad3 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionClickSet.java @@ -0,0 +1,32 @@ +package kr.syeyoung.dungeonsguide.dungeon.actions; + +import com.google.common.base.Predicate; +import com.google.common.base.Predicates; +import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPointSet; +import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; +import lombok.Data; +import net.minecraft.item.ItemStack; + +import java.util.HashSet; +import java.util.Set; + +@Data +public class ActionClickSet implements Action { + private Set preRequisite = new HashSet(); + private OffsetPointSet target; + private Predicate predicate = Predicates.alwaysTrue(); + + public ActionClickSet(OffsetPointSet target) { + this.target = target; + } + + @Override + public Set getPreRequisites(DungeonRoom dungeonRoom) { + return preRequisite; + } + + @Override + public String toString() { + return "ClickSet\n\ttargets size: "+target.getOffsetPointList().size()+"\n\tpredicate: "+predicate.getClass().getSimpleName(); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionDropItem.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionDropItem.java new file mode 100644 index 00000000..ad2eb5e2 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionDropItem.java @@ -0,0 +1,32 @@ +package kr.syeyoung.dungeonsguide.dungeon.actions; + +import com.google.common.base.Predicate; +import com.google.common.base.Predicates; +import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; +import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; +import lombok.Data; +import net.minecraft.item.ItemStack; + +import java.util.HashSet; +import java.util.Set; + +@Data +public class ActionDropItem implements Action { + private Set preRequisite = new HashSet(); + private OffsetPoint target; + private Predicate predicate = Predicates.alwaysTrue(); + + public ActionDropItem(OffsetPoint target) { + this.target = target; + } + + @Override + public Set getPreRequisites(DungeonRoom dungeonRoom) { + return preRequisite; + } + + @Override + public String toString() { + return "DropItem\n\ttarget: "+target.toString()+"\n\tpredicate: "+predicate.getClass().getSimpleName(); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionKill.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionKill.java new file mode 100644 index 00000000..162d0345 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionKill.java @@ -0,0 +1,32 @@ +package kr.syeyoung.dungeonsguide.dungeon.actions; + +import com.google.common.base.Predicate; +import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; +import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; +import lombok.Data; +import net.minecraft.entity.Entity; + +import java.util.HashSet; +import java.util.Set; + +@Data +public class ActionKill implements Action { + private Set preRequisite = new HashSet(); + private OffsetPoint target; + private Predicate predicate; + private int radius; + + public ActionKill(OffsetPoint target) { + this.target = target; + } + + @Override + public Set getPreRequisites(DungeonRoom dungeonRoom) { + return preRequisite; + } + + @Override + public String toString() { + return "KillEntity\n\ttarget: "+target.toString()+"\n\tradius: "+radius+"\n\tpredicate: "+(predicate == null ? "null" : predicate.getClass().getSimpleName()); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionMove.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionMove.java new file mode 100644 index 00000000..15bc9814 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionMove.java @@ -0,0 +1,29 @@ +package kr.syeyoung.dungeonsguide.dungeon.actions; + +import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; +import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; +import lombok.Data; + +import java.util.HashSet; +import java.util.Set; + +@Data +public class ActionMove implements Action { + private Set preRequisite = new HashSet(); + private OffsetPoint target; + + public ActionMove(OffsetPoint target) { + this.target = target; + } + + @Override + public Set getPreRequisites(DungeonRoom dungeonRoom) { + return preRequisite; + } + + + @Override + public String toString() { + return "Move\n\ttarget: "+target.toString(); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionMoveNearestAir.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionMoveNearestAir.java new file mode 100644 index 00000000..3e3f3016 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionMoveNearestAir.java @@ -0,0 +1,28 @@ +package kr.syeyoung.dungeonsguide.dungeon.actions; + +import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; +import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; +import lombok.Data; + +import java.util.HashSet; +import java.util.Set; + +@Data +public class ActionMoveNearestAir implements Action { + private Set preRequisite = new HashSet(); + private OffsetPoint target; + + public ActionMoveNearestAir(OffsetPoint target) { + this.target = target; + } + + @Override + public Set getPreRequisites(DungeonRoom dungeonRoom) { + return preRequisite; + } + + @Override + public String toString() { + return "MoveNearestAir\n\ttarget: "+target.toString(); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionRoot.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionRoot.java new file mode 100644 index 00000000..3d625371 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionRoot.java @@ -0,0 +1,25 @@ +package kr.syeyoung.dungeonsguide.dungeon.actions; + +import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; +import lombok.Data; + +import java.util.HashSet; +import java.util.Set; + +@Data +public class ActionRoot implements Action { + private Set preRequisite = new HashSet(); + + public ActionRoot() { + } + + @Override + public Set getPreRequisites(DungeonRoom dungeonRoom) { + return preRequisite; + } + + @Override + public String toString() { + return "Action Root"; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/tree/ActionTree.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/tree/ActionTree.java new file mode 100644 index 00000000..1db6767c --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/tree/ActionTree.java @@ -0,0 +1,49 @@ +package kr.syeyoung.dungeonsguide.dungeon.actions.tree; + +import kr.syeyoung.dungeonsguide.dungeon.actions.Action; +import kr.syeyoung.dungeonsguide.dungeon.actions.ActionRoot; +import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; +import lombok.Data; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +@Data +public class ActionTree { + private ActionTree parent; + private Action current; + private Set children; + + + public static ActionTree buildActionTree(Set actions, DungeonRoom dungeonRoom) { + ActionRoot root = new ActionRoot(); + root.setPreRequisite(actions); + ActionTree tree = new ActionTree(); + tree.setParent(null); + tree.setCurrent(root); + HashSet set = new HashSet(); + for (Action action : actions) { + set.add(buildActionTree(tree, action, dungeonRoom, new HashMap())); + } + tree.setChildren(set); + return tree; + } + + private static ActionTree buildActionTree(ActionTree parent, Action action, DungeonRoom dungeonRoom, Map alreadyBuilt) { + if (action == null) return null; + if (alreadyBuilt.containsKey(action)) return alreadyBuilt.get(action); + + ActionTree tree = new ActionTree(); + alreadyBuilt.put(action, tree); + tree.setParent(parent); + tree.setCurrent(action); + HashSet set = new HashSet(); + for (Action action2 : action.getPreRequisites(dungeonRoom)) { + set.add(buildActionTree(tree, action2, dungeonRoom, alreadyBuilt)); + } + tree.setChildren(set); + return tree; + } +} 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 6f56c800..fe89b7cb 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonBreakableWall.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonBreakableWall.java @@ -2,10 +2,10 @@ 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.actions.Action; +import kr.syeyoung.dungeonsguide.dungeon.actions.ActionChangeState; +import kr.syeyoung.dungeonsguide.dungeon.actions.ActionClickSet; +import kr.syeyoung.dungeonsguide.dungeon.actions.ActionMoveNearestAir; import kr.syeyoung.dungeonsguide.dungeon.mechanics.predicates.PredicateSuperBoom; import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; import kr.syeyoung.dungeonsguide.utils.RenderUtils; 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 48c13367..cbf7520f 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonDoor.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonDoor.java @@ -2,15 +2,14 @@ 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.actions.Action; +import kr.syeyoung.dungeonsguide.dungeon.actions.ActionChangeState; +import kr.syeyoung.dungeonsguide.dungeon.actions.ActionClickSet; +import kr.syeyoung.dungeonsguide.dungeon.actions.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.block.Block; import net.minecraft.init.Blocks; import net.minecraft.util.BlockPos; 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 9965e11d..9fe0165f 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonLever.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonLever.java @@ -1,10 +1,10 @@ package kr.syeyoung.dungeonsguide.dungeon.mechanics; import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; -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.actions.Action; +import kr.syeyoung.dungeonsguide.dungeon.actions.ActionChangeState; +import kr.syeyoung.dungeonsguide.dungeon.actions.ActionClick; +import kr.syeyoung.dungeonsguide.dungeon.actions.ActionMove; import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; import kr.syeyoung.dungeonsguide.utils.RenderUtils; import lombok.Data; 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 31f03eac..a1180f02 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonMechanic.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonMechanic.java @@ -1,6 +1,6 @@ package kr.syeyoung.dungeonsguide.dungeon.mechanics; -import kr.syeyoung.dungeonsguide.dungeon.mechanics.action.Action; +import kr.syeyoung.dungeonsguide.dungeon.actions.Action; import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; import java.awt.*; diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonOnewayDoor.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonOnewayDoor.java index 4c99fb94..3ee41f1b 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonOnewayDoor.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonOnewayDoor.java @@ -2,10 +2,10 @@ 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.actions.Action; +import kr.syeyoung.dungeonsguide.dungeon.actions.ActionChangeState; +import kr.syeyoung.dungeonsguide.dungeon.actions.ActionClickSet; +import kr.syeyoung.dungeonsguide.dungeon.actions.ActionMoveNearestAir; import kr.syeyoung.dungeonsguide.dungeon.mechanics.predicates.PredicateSuperBoom; import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; import kr.syeyoung.dungeonsguide.utils.RenderUtils; diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonOnewayLever.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonOnewayLever.java index 87e2b44d..d9b396f0 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonOnewayLever.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonOnewayLever.java @@ -1,7 +1,10 @@ package kr.syeyoung.dungeonsguide.dungeon.mechanics; +import kr.syeyoung.dungeonsguide.dungeon.actions.Action; +import kr.syeyoung.dungeonsguide.dungeon.actions.ActionChangeState; +import kr.syeyoung.dungeonsguide.dungeon.actions.ActionClick; +import kr.syeyoung.dungeonsguide.dungeon.actions.ActionMove; 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; 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 d36c8cd2..da126215 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonPressurePlate.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonPressurePlate.java @@ -1,7 +1,10 @@ package kr.syeyoung.dungeonsguide.dungeon.mechanics; +import kr.syeyoung.dungeonsguide.dungeon.actions.Action; +import kr.syeyoung.dungeonsguide.dungeon.actions.ActionChangeState; +import kr.syeyoung.dungeonsguide.dungeon.actions.ActionDropItem; +import kr.syeyoung.dungeonsguide.dungeon.actions.ActionMove; 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; 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 fe5ad8c7..e5b8d54a 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonSecret.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonSecret.java @@ -1,21 +1,15 @@ package kr.syeyoung.dungeonsguide.dungeon.mechanics; -import com.google.common.base.Predicate; +import kr.syeyoung.dungeonsguide.dungeon.actions.*; import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; -import kr.syeyoung.dungeonsguide.dungeon.mechanics.action.*; import kr.syeyoung.dungeonsguide.dungeon.mechanics.predicates.PredicateBat; import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import kr.syeyoung.dungeonsguide.roomedit.EditingContext; import kr.syeyoung.dungeonsguide.utils.RenderUtils; import lombok.Data; -import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; -import net.minecraft.entity.Entity; -import net.minecraft.entity.passive.EntityBat; import net.minecraft.init.Blocks; import net.minecraft.tileentity.TileEntityChest; import net.minecraft.util.BlockPos; -import org.jetbrains.annotations.Nullable; import java.awt.*; import java.util.*; 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 5d9aa06d..ce74e955 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonTomb.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonTomb.java @@ -1,22 +1,18 @@ package kr.syeyoung.dungeonsguide.dungeon.mechanics; -import com.google.common.base.Predicate; +import kr.syeyoung.dungeonsguide.dungeon.actions.Action; +import kr.syeyoung.dungeonsguide.dungeon.actions.ActionChangeState; +import kr.syeyoung.dungeonsguide.dungeon.actions.ActionClickSet; +import kr.syeyoung.dungeonsguide.dungeon.actions.ActionMoveNearestAir; import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPointSet; -import kr.syeyoung.dungeonsguide.dungeon.mechanics.action.*; import kr.syeyoung.dungeonsguide.dungeon.mechanics.predicates.PredicateSuperBoom; import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import kr.syeyoung.dungeonsguide.roomedit.EditingContext; import kr.syeyoung.dungeonsguide.utils.RenderUtils; import lombok.Data; import net.minecraft.block.Block; -import net.minecraft.block.state.IBlockState; -import net.minecraft.entity.Entity; -import net.minecraft.entity.passive.EntityBat; import net.minecraft.init.Blocks; -import net.minecraft.tileentity.TileEntityChest; import net.minecraft.util.BlockPos; -import org.jetbrains.annotations.Nullable; import java.awt.*; import java.util.*; diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/action/Action.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/action/Action.java deleted file mode 100644 index 2d461d07..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/action/Action.java +++ /dev/null @@ -1,9 +0,0 @@ -package kr.syeyoung.dungeonsguide.dungeon.mechanics.action; - -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; - -import java.util.Set; - -public interface Action { - Set getPreRequisites(DungeonRoom dungeonRoom); -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/action/ActionChangeState.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/action/ActionChangeState.java deleted file mode 100644 index 7c14406d..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/action/ActionChangeState.java +++ /dev/null @@ -1,28 +0,0 @@ -package kr.syeyoung.dungeonsguide.dungeon.mechanics.action; - -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import lombok.Data; - -import java.util.HashSet; -import java.util.Set; - -@Data -public class ActionChangeState implements Action{ - private Set preRequisite2 = new HashSet(); - - private String mechanicName; - private String state; - - public ActionChangeState(String mechanicName, String state) { - this.mechanicName = mechanicName; - this.state = state; - } - - @Override - public Set getPreRequisites(DungeonRoom dungeonRoom) { - Set set = new HashSet(); - set.addAll(preRequisite2); - set.addAll(dungeonRoom.getDungeonRoomInfo().getMechanics().get(mechanicName).getAction(state, dungeonRoom)); - return set; - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/action/ActionClick.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/action/ActionClick.java deleted file mode 100644 index 683cbc33..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/action/ActionClick.java +++ /dev/null @@ -1,27 +0,0 @@ -package kr.syeyoung.dungeonsguide.dungeon.mechanics.action; - -import com.google.common.base.Predicate; -import com.google.common.base.Predicates; -import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import lombok.Data; -import net.minecraft.item.ItemStack; - -import java.util.HashSet; -import java.util.Set; - -@Data -public class ActionClick implements Action { - private Set preRequisite = new HashSet(); - private OffsetPoint target; - private Predicate predicate = Predicates.alwaysTrue(); - - public ActionClick(OffsetPoint target) { - this.target = target; - } - - @Override - public Set getPreRequisites(DungeonRoom dungeonRoom) { - return preRequisite; - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/action/ActionClickSet.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/action/ActionClickSet.java deleted file mode 100644 index dff52b5d..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/action/ActionClickSet.java +++ /dev/null @@ -1,28 +0,0 @@ -package kr.syeyoung.dungeonsguide.dungeon.mechanics.action; - -import com.google.common.base.Predicate; -import com.google.common.base.Predicates; -import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; -import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPointSet; -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import lombok.Data; -import net.minecraft.item.ItemStack; - -import java.util.HashSet; -import java.util.Set; - -@Data -public class ActionClickSet implements Action { - private Set preRequisite = new HashSet(); - private OffsetPointSet target; - private Predicate predicate = Predicates.alwaysTrue(); - - public ActionClickSet(OffsetPointSet target) { - this.target = target; - } - - @Override - public Set getPreRequisites(DungeonRoom dungeonRoom) { - return preRequisite; - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/action/ActionDropItem.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/action/ActionDropItem.java deleted file mode 100644 index 841ed121..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/action/ActionDropItem.java +++ /dev/null @@ -1,23 +0,0 @@ -package kr.syeyoung.dungeonsguide.dungeon.mechanics.action; - -import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import lombok.Data; - -import java.util.HashSet; -import java.util.Set; - -@Data -public class ActionDropItem implements Action { - private Set preRequisite = new HashSet(); - private OffsetPoint target; - - public ActionDropItem(OffsetPoint target) { - this.target = target; - } - - @Override - public Set getPreRequisites(DungeonRoom dungeonRoom) { - return preRequisite; - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/action/ActionKill.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/action/ActionKill.java deleted file mode 100644 index 1603b52f..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/action/ActionKill.java +++ /dev/null @@ -1,28 +0,0 @@ -package kr.syeyoung.dungeonsguide.dungeon.mechanics.action; - -import com.google.common.base.Predicate; -import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import lombok.Data; -import net.minecraft.entity.Entity; -import net.minecraft.item.ItemStack; - -import java.util.HashSet; -import java.util.Set; - -@Data -public class ActionKill implements Action { - private Set preRequisite = new HashSet(); - private OffsetPoint target; - private Predicate predicate; - private int radius; - - public ActionKill(OffsetPoint target) { - this.target = target; - } - - @Override - public Set getPreRequisites(DungeonRoom dungeonRoom) { - return preRequisite; - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/action/ActionMove.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/action/ActionMove.java deleted file mode 100644 index b0048c11..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/action/ActionMove.java +++ /dev/null @@ -1,24 +0,0 @@ -package kr.syeyoung.dungeonsguide.dungeon.mechanics.action; - -import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import lombok.Data; -import net.minecraft.util.BlockPos; - -import java.util.HashSet; -import java.util.Set; - -@Data -public class ActionMove implements Action { - private Set preRequisite = new HashSet(); - private OffsetPoint target; - - public ActionMove(OffsetPoint target) { - this.target = target; - } - - @Override - public Set getPreRequisites(DungeonRoom dungeonRoom) { - return preRequisite; - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/action/ActionMoveNearestAir.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/action/ActionMoveNearestAir.java deleted file mode 100644 index 4ed826e1..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/action/ActionMoveNearestAir.java +++ /dev/null @@ -1,23 +0,0 @@ -package kr.syeyoung.dungeonsguide.dungeon.mechanics.action; - -import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; -import lombok.Data; - -import java.util.HashSet; -import java.util.Set; - -@Data -public class ActionMoveNearestAir implements Action { - private Set preRequisite = new HashSet(); - private OffsetPoint target; - - public ActionMoveNearestAir(OffsetPoint target) { - this.target = target; - } - - @Override - public Set getPreRequisites(DungeonRoom dungeonRoom) { - return preRequisite; - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/gui/GuiDungeonRoomEdit.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/gui/GuiDungeonRoomEdit.java index c332dd20..2c5a7b69 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/gui/GuiDungeonRoomEdit.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/gui/GuiDungeonRoomEdit.java @@ -6,10 +6,7 @@ import kr.syeyoung.dungeonsguide.roomedit.elements.MButton; 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 kr.syeyoung.dungeonsguide.roomedit.panes.SecretEditPane; +import kr.syeyoung.dungeonsguide.roomedit.panes.*; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.ScaledResolution; @@ -39,6 +36,7 @@ public class GuiDungeonRoomEdit extends GuiScreen { tabbedPane.addTab("General", new GeneralEditPane(room)); tabbedPane.addTab("Match", new RoomDataDisplayPane(room)); tabbedPane.addTab("Secrets", new SecretEditPane(room)); + tabbedPane.addTab("Actions", new ActionDisplayPane(room)); tabbedPane.addTab("Proc.Params", new ProcessorParameterEditPane(room)); this.tabbedPane = tabbedPane; } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/ActionDisplayPane.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/ActionDisplayPane.java new file mode 100644 index 00000000..974e46b5 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/ActionDisplayPane.java @@ -0,0 +1,72 @@ +package kr.syeyoung.dungeonsguide.roomedit.panes; + +import kr.syeyoung.dungeonsguide.dungeon.actions.Action; +import kr.syeyoung.dungeonsguide.dungeon.actions.tree.ActionTree; +import kr.syeyoung.dungeonsguide.dungeon.mechanics.DungeonMechanic; +import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoomInfoRegistry; +import kr.syeyoung.dungeonsguide.roomedit.EditingContext; +import kr.syeyoung.dungeonsguide.roomedit.MPanel; +import kr.syeyoung.dungeonsguide.roomedit.elements.*; +import kr.syeyoung.dungeonsguide.roomprocessor.ProcessorFactory; + +import java.awt.*; +import java.util.ArrayList; +import java.util.Set; + +public class ActionDisplayPane extends MPanel { + private DungeonRoom dungeonRoom; + + private ActionTreeDisplayPane displayPane; + + private MTextField textField; + private MButton calculate; + public ActionDisplayPane(final DungeonRoom dungeonRoom) { + this.dungeonRoom = dungeonRoom; + + { + textField = new MTextField(); + textField.setBounds(new Rectangle(0,0,bounds.width - 100, 20)); + add(textField); + } + { + calculate = new MButton(); + calculate.setBounds(new Rectangle(bounds.width - 100,0,100, 20)); + calculate.setText("calculate"); + calculate.setOnActionPerformed(new Runnable() { + @Override + public void run() { + try { + remove(displayPane); + + String text = textField.getText(); + String target = text.split(":")[0]; + String state = text.split(":")[1]; + + DungeonMechanic mechanic = dungeonRoom.getDungeonRoomInfo().getMechanics().get(target); + Set actionSet = mechanic.getAction(state, dungeonRoom); + ActionTree tree= ActionTree.buildActionTree(actionSet, dungeonRoom); + + displayPane = new ActionTreeDisplayPane(dungeonRoom, tree); + displayPane.setBounds(new Rectangle(0,25,bounds.width,bounds.height-25)); + add(displayPane); + } catch (Throwable t) { + t.printStackTrace(); + } + } + }); + add(calculate); + } + } + + @Override + public void resize(int parentWidth, int parentHeight) { + this.setBounds(new Rectangle(5,5,parentWidth-10,parentHeight-10)); + } + + @Override + public void onBoundsUpdate() { + textField.setBounds(new Rectangle(0,0,bounds.width - 100, 20)); + calculate.setBounds(new Rectangle(bounds.width - 100,0,100, 20)); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/ActionTreeDisplayPane.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/ActionTreeDisplayPane.java new file mode 100644 index 00000000..20c5242d --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/ActionTreeDisplayPane.java @@ -0,0 +1,131 @@ +package kr.syeyoung.dungeonsguide.roomedit.panes; + +import kr.syeyoung.dungeonsguide.dungeon.actions.Action; +import kr.syeyoung.dungeonsguide.dungeon.actions.tree.ActionTree; +import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.roomedit.MPanel; +import kr.syeyoung.dungeonsguide.utils.RenderUtils; +import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.Gui; +import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.WorldRenderer; +import net.minecraft.client.renderer.vertex.DefaultVertexFormats; +import net.minecraft.client.renderer.vertex.VertexFormat; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import org.lwjgl.opengl.GL11; + +import java.awt.*; +import java.util.*; + +public class ActionTreeDisplayPane extends MPanel { + + private int offsetX = 0; + private int offsetY = 0; + + private DungeonRoom dungeonRoom; + private ActionTree tree; + public ActionTreeDisplayPane(DungeonRoom dungeonRoom, ActionTree tree) { + this.dungeonRoom = dungeonRoom; + this.tree = tree; + } + + @Override + public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle clip) { + ScaledResolution sr = new ScaledResolution(Minecraft.getMinecraft()); + + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + + GL11.glPushMatrix(); + GL11.glTranslated(-offsetX, -offsetY, 0); + renderTree(tree, 5, 5, Minecraft.getMinecraft().fontRendererObj, null, new HashMap()); + GL11.glPopMatrix(); + } + + public int renderTree(ActionTree actionTree, int x, int y, FontRenderer fr, Point drawLineFrom, HashMap drawmPoints) { + if (drawmPoints.containsKey(actionTree)) { + // recursive, fu + Point pt = drawmPoints.get(actionTree); + + GlStateManager.pushMatrix(); + GlStateManager.pushAttrib(); + WorldRenderer renderer = Tessellator.getInstance().getWorldRenderer(); + GlStateManager.color(255,0,0, 255); + renderer.begin(GL11.GL_LINES, DefaultVertexFormats.POSITION); + renderer.pos(pt.x, pt.y, 0).endVertex(); + renderer.pos(drawLineFrom.x, drawLineFrom.y, 0).endVertex(); + Tessellator.getInstance().draw(); + GlStateManager.popMatrix(); + GlStateManager.popAttrib(); + return 0; + } + + Dimension dim = renderAction(actionTree.getCurrent(), x, y, fr); + if (drawLineFrom != null) { + GlStateManager.pushMatrix(); + GlStateManager.pushAttrib(); + WorldRenderer renderer = Tessellator.getInstance().getWorldRenderer(); + GlStateManager.color(255,255,255, 255); + renderer.begin(GL11.GL_LINES, DefaultVertexFormats.POSITION); + renderer.pos(x + dim.width, y, 0).endVertex(); + renderer.pos(drawLineFrom.x, drawLineFrom.y, 0).endVertex(); + Tessellator.getInstance().draw(); + GlStateManager.popMatrix(); + GlStateManager.popAttrib(); + } + Point pt = new Point(x + dim.width / 2, y + dim.height); + + drawmPoints.put(actionTree, new Point(x + dim.width / 2, y + dim.height / 2)); + int xOff = 0; + for (ActionTree tree:actionTree.getChildren()) { + xOff += renderTree(tree, x + xOff, y + dim.height + 10, fr, pt, drawmPoints) + 10; + } + return xOff; + } + + public Dimension renderAction(Action action, int x, int y, FontRenderer fr) { + String[] lines = action.toString().split("\n"); + int maxWidth = 0; + for (String line : lines) { + if (fr.getStringWidth(line) > maxWidth) maxWidth= fr.getStringWidth(line); + } + int offset = 2; + int height = (fr.FONT_HEIGHT + offset) * lines.length; + + Gui.drawRect(x,y,x + maxWidth +10, y + height + 10, 0xff000000); + Gui.drawRect(x+1,y+1,x + maxWidth +8, y + height + 8, 0xff4d4d4d); + for (int i = 0; i < lines.length; i++) { + fr.drawString(lines[i], 5, 5 + i*(fr.FONT_HEIGHT + offset), 0xffffffff); + } + + return new Dimension(maxWidth + 10, height + 10); + } + + @Override + public void resize(int parentWidth, int parentHeight) { + this.setBounds(new Rectangle(0,25,parentWidth,parentHeight-25)); + } + + + private int lastX; + private int lastY; + @Override + public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) { + lastX = absMouseX; + lastY = absMouseY; + } + + @Override + public void mouseClickMove(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int clickedMouseButton, long timeSinceLastClick) { + int dX = absMouseX - lastX; + int dY = absMouseY - lastY; + offsetX += dX; + offsetY += dY; + lastX = absMouseX; + lastY = absMouseY; + } +} -- cgit