mirror of
https://github.com/AndorsTrailRelease/ATCS.git
synced 2025-10-27 18:44:03 +01:00
Progress on Dialogue Sketch to JSON Data conversion.
Opportunistic bug fix in JSON import wizard.
This commit is contained in:
@@ -801,7 +801,7 @@ public class Project implements ProjectTreeNode, Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
* @param node. Before calling this method, make sure that no other node with the same class exist in either created or altered.
|
||||
* @param node. Before calling this method, make sure that no other node with the same class and id exist in either created or altered.
|
||||
*/
|
||||
public void createElement(JSONElement node) {
|
||||
node.writable = true;
|
||||
@@ -823,6 +823,34 @@ public class Project implements ProjectTreeNode, Serializable {
|
||||
fireElementAdded(node, getNodeIndex(node));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param node. Before calling this method, make sure that no other node with the same class and id exist in either created or altered.
|
||||
*/
|
||||
public void createElements(List<JSONElement> nodes) {
|
||||
for (JSONElement node : nodes) {
|
||||
//Already added.
|
||||
if (node.getProject() != null) continue;
|
||||
node.writable = true;
|
||||
if (getGameDataElement(node.getClass(), node.id) != null) {
|
||||
GameDataElement existingNode = getGameDataElement(node.getClass(), node.id);
|
||||
for (GameDataElement backlink : existingNode.getBacklinks()) {
|
||||
backlink.elementChanged(existingNode, node);
|
||||
}
|
||||
existingNode.getBacklinks().clear();
|
||||
node.writable = true;
|
||||
alteredContent.gameData.addElement(node);
|
||||
} else {
|
||||
createdContent.gameData.addElement(node);
|
||||
}
|
||||
}
|
||||
for (JSONElement node : nodes) {
|
||||
node.link();
|
||||
node.state = GameDataElement.State.created;
|
||||
fireElementAdded(node, getNodeIndex(node));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void moveToCreated(JSONElement target) {
|
||||
target.childrenRemoved(new ArrayList<ProjectTreeNode>());
|
||||
|
||||
@@ -224,10 +224,7 @@ public class Dialogue extends JSONElement {
|
||||
if (replies != null) {
|
||||
for (Reply reply : replies) {
|
||||
if (reply.next_phrase_id != null) {
|
||||
if (!reply.next_phrase_id.equals(Reply.EXIT_PHRASE_ID)
|
||||
&& !reply.next_phrase_id.equals(Reply.FIGHT_PHRASE_ID)
|
||||
&& !reply.next_phrase_id.equals(Reply.SHOP_PHRASE_ID)
|
||||
&& !reply.next_phrase_id.equals(Reply.REMOVE_PHRASE_ID)) {
|
||||
if (!Reply.KEY_PHRASE_ID.contains(reply.next_phrase_id)) {
|
||||
reply.next_phrase = proj.getDialogue(reply.next_phrase_id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,9 +5,9 @@ import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -78,7 +78,7 @@ public class WriterModeData extends GameDataElement {
|
||||
public int index;
|
||||
public List<WriterReply> replies = new ArrayList<WriterReply>();
|
||||
public List<WriterReply> parents = new ArrayList<WriterReply>();
|
||||
|
||||
public Dialogue dialogue;
|
||||
|
||||
public WriterDialogue() {}
|
||||
|
||||
@@ -137,10 +137,14 @@ public class WriterModeData extends GameDataElement {
|
||||
|
||||
public Dialogue toDialogue(Map<WriterDialogue, Dialogue> visited){
|
||||
if (visited.get(this) != null) return visited.get(this);
|
||||
Dialogue dialogue = new Dialogue();
|
||||
dialogue.state = GameDataElement.State.parsed;
|
||||
if (dialogue == null) {
|
||||
dialogue = new Dialogue();
|
||||
dialogue.id = getID();
|
||||
dialogue.state = GameDataElement.State.parsed;
|
||||
} else {
|
||||
dialogue.state = GameDataElement.State.modified;
|
||||
}
|
||||
visited.put(this, dialogue);
|
||||
dialogue.id = getID();
|
||||
dialogue.message = this.text;
|
||||
if (this.replies != null && !this.replies.isEmpty()) {
|
||||
dialogue.replies = new ArrayList<Dialogue.Reply>();
|
||||
@@ -182,6 +186,7 @@ public class WriterModeData extends GameDataElement {
|
||||
public WriterDialogue parent;
|
||||
public String next_dialogue_id;
|
||||
public WriterDialogue next_dialogue;
|
||||
public Dialogue.Reply reply;
|
||||
|
||||
public WriterReply() {}
|
||||
|
||||
@@ -220,7 +225,9 @@ public class WriterModeData extends GameDataElement {
|
||||
public boolean isSpecial() {return false;}
|
||||
|
||||
public Dialogue.Reply toReply(Map<WriterDialogue, Dialogue> visited) {
|
||||
Dialogue.Reply reply = new Dialogue.Reply();
|
||||
if (reply == null) {
|
||||
reply = new Dialogue.Reply();
|
||||
}
|
||||
reply.text = this.text;
|
||||
if (this.next_dialogue != null) {
|
||||
this.next_dialogue.toDialogue(visited);
|
||||
|
||||
@@ -404,11 +404,8 @@ public class JSONImportWizard extends JDialog {
|
||||
okListener = new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
JSONElement lastNode = null;
|
||||
for (JSONElement node : created) {
|
||||
proj.createElement(node);
|
||||
lastNode = node;
|
||||
}
|
||||
proj.createElements(created);
|
||||
JSONElement lastNode = created.get(created.size() - 1);
|
||||
if (lastNode != null) {
|
||||
lastNode.save();
|
||||
ATContentStudio.frame.selectInTree(lastNode);
|
||||
|
||||
@@ -342,12 +342,7 @@ public class WorkspaceActions {
|
||||
if (selectedNode == null || selectedNode.getProject() == null || !(selectedNode instanceof WriterModeData)) return;
|
||||
WriterModeData wData = (WriterModeData)selectedNode;
|
||||
Collection<Dialogue> exported = wData.toDialogue();
|
||||
for (Dialogue dialogue : exported) {
|
||||
selectedNode.getProject().createElement(dialogue);
|
||||
}
|
||||
for (Dialogue dialogue : exported) {
|
||||
dialogue.link();
|
||||
}
|
||||
selectedNode.getProject().createElements(new ArrayList<JSONElement>(exported));
|
||||
};
|
||||
public void selectionChanged(ProjectTreeNode selectedNode, TreePath[] selectedPaths) {
|
||||
setEnabled(selectedNode != null && selectedNode instanceof WriterModeData);
|
||||
|
||||
Reference in New Issue
Block a user