diff --git a/src/com/gpl/rpg/atcontentstudio/model/tools/writermode/WriterModeData.java b/src/com/gpl/rpg/atcontentstudio/model/tools/writermode/WriterModeData.java index a201ad6..b7cf371 100644 --- a/src/com/gpl/rpg/atcontentstudio/model/tools/writermode/WriterModeData.java +++ b/src/com/gpl/rpg/atcontentstudio/model/tools/writermode/WriterModeData.java @@ -135,7 +135,7 @@ public class WriterModeData extends GameDataElement { public boolean isSpecial() {return false;} - public Dialogue toDialogue(Map visited){ + public Dialogue toDialogue(Map visited) { if (visited.get(this) != null) return visited.get(this); if (dialogue == null) { dialogue = new Dialogue(); @@ -155,6 +155,23 @@ public class WriterModeData extends GameDataElement { return dialogue; } + public boolean hasChanged() { + return dialogue == null || + text == null ? dialogue.message!=null : !text.equals(dialogue.message) || + repliesHaveChanged(); + } + + public boolean repliesHaveChanged() { + if (replies.isEmpty() && (dialogue.replies == null || dialogue.replies.isEmpty())) return false; + if (!replies.isEmpty() && (dialogue.replies == null || dialogue.replies.isEmpty())) return true; + if (replies.isEmpty() && (dialogue.replies != null && !dialogue.replies.isEmpty())) return true; + if (replies.size() != dialogue.replies.size()) return true; + for (WriterReply reply : replies) { + if (reply.hasChanged()) return true; + } + return false; + } + } public abstract class SpecialDialogue extends WriterDialogue { @@ -239,6 +256,21 @@ public class WriterModeData extends GameDataElement { } return reply; } + + public boolean hasChanged() { + if (reply == null) return true; + if (text == null && reply.text != null) return true; + if (text != null && reply.text == null) return true; + if (text != null && !text.equals(reply.text)) return true; + String targetDialogueId = next_dialogue != null ? next_dialogue.getID() : next_dialogue_id; + String replyTargetDialogueId = reply.next_phrase != null ? reply.next_phrase.id : reply.next_phrase_id; + if (targetDialogueId == null && replyTargetDialogueId != null) return true; + if (targetDialogueId != null && replyTargetDialogueId == null) return true; + if (targetDialogueId != null && !targetDialogueId.equals(replyTargetDialogueId)) return true; + return false; + } + + }