v0.5.0 ! First release of new Dialogue Sketch feature.

This commit is contained in:
Zukero
2016-12-20 16:43:10 +01:00
parent 6fe4d2a171
commit 900d0bc9b5
11 changed files with 65 additions and 25 deletions

View File

@@ -78,6 +78,14 @@ public class WriterModeData extends GameDataElement {
}
public WriterDialogue createDialogue(Dialogue dialogue) {
if (dialogue.message == null) {
return new SelectorDialogue(dialogue);
} else {
return new WriterDialogue(dialogue);
}
}
public class WriterDialogue extends WriterNode {
public String id;
public String id_prefix;
@@ -104,7 +112,7 @@ public class WriterModeData extends GameDataElement {
nodesById.put(this.id, this);
if (dialogue.replies != null) {
for (Dialogue.Reply reply : dialogue.replies) {
if (Dialogue.Reply.GO_NEXT_TEXT.equals(reply.text)) {
if (Dialogue.Reply.GO_NEXT_TEXT.equals(reply.text) || reply.text == null) {
replies.add(new EmptyReply(this, reply));
} else {
replies.add(new WriterReply(this, reply));
@@ -194,7 +202,9 @@ public class WriterModeData extends GameDataElement {
modified.add(dialogue);
} else {
//Altering a game source Dialogue
Dialogue clone = (Dialogue) dialogue.clone();
//Dialogue clone = (Dialogue) dialogue.clone();
dialogue.getProject().makeWritable(dialogue);
Dialogue clone = dialogue.getProject().getDialogue(dialogue.id);
if (this.replies != null) {
for (WriterReply wReply : this.replies) {
if (wReply.reply != null) {
@@ -247,11 +257,19 @@ public class WriterModeData extends GameDataElement {
public abstract class SpecialDialogue extends WriterDialogue {
public SpecialDialogue() {}
public boolean isSpecial() {return true;}
public abstract SpecialDialogue duplicate();
public SpecialDialogue(Dialogue dialogue) {
super(dialogue);
}
}
public class SelectorDialogue extends SpecialDialogue {
public SelectorDialogue() {}
public SpecialDialogue duplicate() {return new SelectorDialogue();}
public SelectorDialogue(Dialogue dialogue) {
super(dialogue);
}
}
public class ShopDialogue extends SpecialDialogue {
public static final String id = Dialogue.Reply.SHOP_PHRASE_ID;
@@ -369,7 +387,7 @@ public class WriterModeData extends GameDataElement {
super(parent);
}
public SpecialReply(WriterDialogue parent, Map json) {
public SpecialReply(WriterDialogue parent, @SuppressWarnings("rawtypes") Map json) {
super(parent, json);
}
}
@@ -385,7 +403,7 @@ public class WriterModeData extends GameDataElement {
text = Dialogue.Reply.GO_NEXT_TEXT;
}
public EmptyReply(WriterDialogue parent, Map json) {
public EmptyReply(WriterDialogue parent, @SuppressWarnings("rawtypes") Map json) {
super(parent, json);
text = Dialogue.Reply.GO_NEXT_TEXT;
}

View File

@@ -41,7 +41,7 @@ public class WriterModeDataSet implements ProjectTreeNode, Serializable {
public GameSource parent;
public File writerFile;
List<WriterModeData> writerModeDataList = new ArrayList<WriterModeData>();
public List<WriterModeData> writerModeDataList = new ArrayList<WriterModeData>();
public WriterModeDataSet(GameSource gameSource) {
this.parent = gameSource;
@@ -79,6 +79,7 @@ public class WriterModeDataSet implements ProjectTreeNode, Serializable {
return false;
}
@SuppressWarnings("rawtypes")
@Override
public Enumeration children() {
return Collections.enumeration(writerModeDataList);
@@ -201,6 +202,7 @@ public class WriterModeDataSet implements ProjectTreeNode, Serializable {
return events;
}
@SuppressWarnings("rawtypes")
public void parse() {
if (!writerFile.exists()) return;
JSONParser parser = new JSONParser();
@@ -210,7 +212,9 @@ public class WriterModeDataSet implements ProjectTreeNode, Serializable {
List writerDataListJson = (List) parser.parse(reader);
for (Object obj : writerDataListJson) {
Map jsonObj = (Map)obj;
writerModeDataList.add(new WriterModeData(this, jsonObj));
WriterModeData data = new WriterModeData(this, jsonObj);
data.writable = true;
writerModeDataList.add(data);
}
} catch (FileNotFoundException e) {
Notification.addError("Error while parsing JSON file "+writerFile.getAbsolutePath()+": "+e.getMessage());
@@ -252,6 +256,7 @@ public class WriterModeDataSet implements ProjectTreeNode, Serializable {
}
if (higherEmptyParent == this && !this.isEmpty()) higherEmptyParent = null;
writerModeDataList.add(node);
node.writable = true;
if (node.jsonFile == null) node.jsonFile = this.writerFile;
node.parent = this;
if (higherEmptyParent != null) higherEmptyParent.notifyCreated();