Refactored conversation node to use inheritance
@@ -1,8 +1,8 @@
|
|||||||
package com.projectswg.tools.csc.conversationeditor;
|
package com.projectswg.tools.csc.conversationeditor;
|
||||||
|
|
||||||
|
import com.projectswg.tools.csc.conversationeditor.scene.SceneView;
|
||||||
import com.projectswg.tools.csc.conversationeditor.nodes.ConversationNode;
|
import com.projectswg.tools.csc.conversationeditor.nodes.ConversationNode;
|
||||||
import com.projectswg.tools.csc.conversationeditor.EditorTopComponent;
|
import com.projectswg.tools.csc.conversationeditor.nodes.OptionNode;
|
||||||
import com.projectswg.tools.csc.conversationeditor.SceneView;
|
|
||||||
import java.io.BufferedWriter;
|
import java.io.BufferedWriter;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileWriter;
|
import java.io.FileWriter;
|
||||||
@@ -48,7 +48,7 @@ public class Compiler {
|
|||||||
LinkedHashMap<ConversationNode, ArrayList<ConversationNode>> conversationLinks = scene.getConversationLinks();
|
LinkedHashMap<ConversationNode, ArrayList<ConversationNode>> conversationLinks = scene.getConversationLinks();
|
||||||
|
|
||||||
for (Map.Entry<ConversationNode, ArrayList<ConversationNode>> entry : conversationLinks.entrySet()) {
|
for (Map.Entry<ConversationNode, ArrayList<ConversationNode>> entry : conversationLinks.entrySet()) {
|
||||||
if (entry.getKey().isStartNode()) {
|
if (entry.getKey().getType().equals(ConversationNode.BEGIN)) {
|
||||||
createOptionsAndHandler(bw, entry.getKey(), entry.getValue(), 1, conversationLinks);
|
createOptionsAndHandler(bw, entry.getKey(), entry.getValue(), 1, conversationLinks);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -82,28 +82,42 @@ public class Compiler {
|
|||||||
|
|
||||||
int count = handleNum + 1;
|
int count = handleNum + 1;
|
||||||
for (ConversationNode selectedOption : options) {
|
for (ConversationNode selectedOption : options) {
|
||||||
bw.write(indent4 + (options.indexOf(selectedOption) > 0 ? "elif" : "if") + " selection == " + options.indexOf(selectedOption) + ":\n");
|
if (!(selectedOption instanceof OptionNode))
|
||||||
if (conversationLinks.containsKey(selectedOption)) {
|
continue;
|
||||||
if (comments) bw.write(indent8 + "# " + (selectedOption.getDisplayText().equals("") ? selectedOption.getStf() : selectedOption.getDisplayText()) + "\n");
|
|
||||||
|
OptionNode option = (OptionNode) selectedOption;
|
||||||
|
|
||||||
|
bw.write(indent4 + (options.indexOf(option) > 0 ? "elif" : "if") + " selection == " + options.indexOf(option) + ":\n");
|
||||||
|
if (conversationLinks.containsKey(option)) {
|
||||||
|
|
||||||
|
if (comments) bw.write(indent8 + "# " + (option.getDisplayText().equals("") ? option.getStf() : option.getDisplayText()) + "\n");
|
||||||
|
|
||||||
for (ConversationNode handleNode : conversationLinks.get(selectedOption)) {
|
for (ConversationNode handleNode : conversationLinks.get(selectedOption)) {
|
||||||
if (!handleNode.isOption() && !handleNode.isEndNode()) {
|
switch(handleNode.getType()) {
|
||||||
if (conversationLinks.get(handleNode) == null) {
|
|
||||||
bw.write(indent8 + "# NULL Error printing out handle for " + handleNode.getStf());
|
case ConversationNode.RESPONSE:
|
||||||
} else {
|
if (conversationLinks.get(handleNode) == null) {
|
||||||
createOptions(bw, conversationLinks.get(handleNode), count++, indent8);
|
bw.write(indent8 + "# NULL Error printing out handle for " + handleNode.getStf());
|
||||||
bw.write(indent8 + "core.conversationService.sendConversationMessage(actor, npc, OutOfBand.ProsePackage('@conversation/"
|
} else {
|
||||||
+ handleNode.getStf() + "')\n");
|
createOptions(bw, conversationLinks.get(handleNode), count++, indent8);
|
||||||
handleFuncs.put(handleNode, conversationLinks.get(handleNode)); // Put these nodes in list so we can create the handlers later.
|
bw.write(indent8 + "core.conversationService.sendConversationMessage(actor, npc, OutOfBand.ProsePackage('@conversation/"
|
||||||
}
|
+ handleNode.getStf() + "')\n");
|
||||||
} else if (handleNode.isEndNode()) {
|
handleFuncs.put(handleNode, conversationLinks.get(handleNode)); // Put these nodes in list so we can create the handlers later.
|
||||||
if (handleNode.getStf().contains(":")) {
|
}
|
||||||
String[] split = handleNode.getStf().split(":");
|
break;
|
||||||
bw.write(indent8 + "core.conversationService.sendStopConversation(actor, npc, 'conversation/" + split[0] + "', '" + split[1] + "')\n");
|
|
||||||
} else {
|
case ConversationNode.END:
|
||||||
bw.write(indent8 + "# Couldn't write end response because of bad format!");
|
if (handleNode.getStf().contains(":")) {
|
||||||
}
|
String[] split = handleNode.getStf().split(":");
|
||||||
|
bw.write(indent8 + "core.conversationService.sendStopConversation(actor, npc, 'conversation/" + split[0] + "', '" + split[1] + "')\n");
|
||||||
|
} else {
|
||||||
|
bw.write(indent8 + "# Couldn't write end response because of bad format!");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
bw.write(indent8 + "return\n");
|
bw.write(indent8 + "return\n");
|
||||||
bw.newLine();
|
bw.newLine();
|
||||||
@@ -129,7 +143,7 @@ public class Compiler {
|
|||||||
if (options.size() > 1) {
|
if (options.size() > 1) {
|
||||||
for (ConversationNode option : options) {
|
for (ConversationNode option : options) {
|
||||||
bw.write(indent4 + "options.add(ConversationOption(OutOfBand.ProsePackage('@conversation/" + option.getStf() +"'), "
|
bw.write(indent4 + "options.add(ConversationOption(OutOfBand.ProsePackage('@conversation/" + option.getStf() +"'), "
|
||||||
+ String.valueOf(option.getOptionId()) + ")\n");
|
+ String.valueOf(((OptionNode)option).getNumber()) + ")\n");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (ConversationNode option : options) {
|
for (ConversationNode option : options) {
|
||||||
@@ -151,7 +165,7 @@ public class Compiler {
|
|||||||
if (options.size() > 1) {
|
if (options.size() > 1) {
|
||||||
ArrayList<ConversationNode> orderedOptions = new ArrayList<>();
|
ArrayList<ConversationNode> orderedOptions = new ArrayList<>();
|
||||||
for (ConversationNode unOrdered : options) {
|
for (ConversationNode unOrdered : options) {
|
||||||
orderedOptions.add(unOrdered.getOptionId(), unOrdered);
|
orderedOptions.add(((OptionNode)unOrdered).getNumber(), unOrdered);
|
||||||
}
|
}
|
||||||
for (ConversationNode option : orderedOptions) {
|
for (ConversationNode option : orderedOptions) {
|
||||||
bw.write(space + "options.add(ConversationOption(OutOfBand.ProsePackage('@conversation/" + option.getStf() +"'), " + options.indexOf(option) + ")\n");
|
bw.write(space + "options.add(ConversationOption(OutOfBand.ProsePackage('@conversation/" + option.getStf() +"'), " + options.indexOf(option) + ")\n");
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
package com.projectswg.tools.csc.conversationeditor;
|
package com.projectswg.tools.csc.conversationeditor;
|
||||||
|
|
||||||
|
import com.projectswg.tools.csc.conversationeditor.scene.SceneView;
|
||||||
import com.projectswg.tools.csc.conversationeditor.nodes.ConversationNode;
|
import com.projectswg.tools.csc.conversationeditor.nodes.ConversationNode;
|
||||||
|
import com.projectswg.tools.csc.conversationeditor.nodes.EndNode;
|
||||||
import java.awt.Point;
|
import java.awt.Point;
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
import org.netbeans.api.visual.action.ConnectProvider;
|
import org.netbeans.api.visual.action.ConnectProvider;
|
||||||
@@ -42,34 +44,17 @@ public class ConversationConnectProvider implements ConnectProvider {
|
|||||||
@Override
|
@Override
|
||||||
public void createConnection(Widget source, Widget target) {
|
public void createConnection(Widget source, Widget target) {
|
||||||
if (source instanceof ConversationWidget && target instanceof ConversationWidget) {
|
if (source instanceof ConversationWidget && target instanceof ConversationWidget) {
|
||||||
if (((ConversationWidget)source).getAttachedNode().isEndNode()) {
|
if (((ConversationWidget)source).getAttachedNode() instanceof EndNode) {
|
||||||
JOptionPane.showMessageDialog(null, "Cannot attach end conversation node to responses/options!", "Conversation Script Creator", JOptionPane.INFORMATION_MESSAGE);
|
JOptionPane.showMessageDialog(null, "Cannot attach end conversation node to responses/options!", "Conversation Script Creator", JOptionPane.INFORMATION_MESSAGE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ConversationNode cSource = ((ConversationWidget) source).getAttachedNode();
|
ConversationNode cSource = ((ConversationWidget) source).getAttachedNode();
|
||||||
ConversationNode cTarget = ((ConversationWidget) target).getAttachedNode();
|
ConversationNode cTarget = ((ConversationWidget) target).getAttachedNode();
|
||||||
|
|
||||||
if (cSource.isOption()) {
|
// TODO: messages for each linking type
|
||||||
if (cTarget.isOption())
|
if (!cSource.doesLink(cTarget))
|
||||||
return;
|
|
||||||
|
|
||||||
else if (cTarget.isStartNode())
|
|
||||||
return;
|
|
||||||
|
|
||||||
} else if (cSource.isStartNode()) {
|
|
||||||
if (cTarget.isEndNode())
|
|
||||||
return;
|
|
||||||
} else if (cSource.isEndNode()) {
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
} else { // Response nodes
|
|
||||||
if (cTarget.isEndNode())
|
|
||||||
return;
|
|
||||||
|
|
||||||
else if (cTarget.isStartNode())
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* This won't work for preventing linking to same node 2x's. Need to find another way :(
|
/* This won't work for preventing linking to same node 2x's. Need to find another way :(
|
||||||
if (scene.getConnectionLayer().getChildren().size() > 0) {
|
if (scene.getConnectionLayer().getChildren().size() > 0) {
|
||||||
for (Widget widget : scene.getConnectionLayer().getChildren()) {
|
for (Widget widget : scene.getConnectionLayer().getChildren()) {
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.projectswg.tools.csc.conversationeditor;
|
package com.projectswg.tools.csc.conversationeditor;
|
||||||
|
|
||||||
|
import com.projectswg.tools.csc.conversationeditor.scene.SceneView;
|
||||||
import com.projectswg.tools.csc.conversationeditor.nodes.ConversationNode;
|
import com.projectswg.tools.csc.conversationeditor.nodes.ConversationNode;
|
||||||
import java.awt.Point;
|
import java.awt.Point;
|
||||||
import java.beans.PropertyVetoException;
|
import java.beans.PropertyVetoException;
|
||||||
@@ -21,25 +22,14 @@ public class ConversationWidget extends IconNodeWidget implements LookupListener
|
|||||||
private final ExplorerManager mgr;
|
private final ExplorerManager mgr;
|
||||||
private boolean selected;
|
private boolean selected;
|
||||||
|
|
||||||
public ConversationWidget(SceneView scene, final ExplorerManager mgr, final ConversationNode node, boolean endConversation) {
|
public ConversationWidget(SceneView scene, final ExplorerManager mgr, final ConversationNode node) {
|
||||||
super(scene.getScene());
|
super(scene.getScene());
|
||||||
|
|
||||||
this.attachedNode = node;
|
this.attachedNode = node;
|
||||||
this.mgr = mgr;
|
this.mgr = mgr;
|
||||||
|
|
||||||
if (node.isEndNode()) {
|
setLabel(node.getStf());
|
||||||
setLabel(node.getStf());
|
setImage(ImageUtilities.loadImage(node.getImageStr()));
|
||||||
setImage(ImageUtilities.loadImage("com/projectswg/tools/csc/conversationeditor/conversation_end.png"));
|
|
||||||
} else {
|
|
||||||
setLabel(node.getStf());
|
|
||||||
|
|
||||||
if (node.isStartNode()) {
|
|
||||||
setImage(ImageUtilities.loadImage("com/projectswg/tools/csc/conversationeditor/conversation_begin.png"));
|
|
||||||
} else {
|
|
||||||
setImage(node.isOption() ? ImageUtilities.loadImage("com/projectswg/tools/csc/conversationeditor/conversation_option.png")
|
|
||||||
: ImageUtilities.loadImage("com/projectswg/tools/csc/conversationeditor/conversation_response.png"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Alignment/pos/ori
|
// Alignment/pos/ori
|
||||||
getLabelWidget().setAlignment(LabelWidget.Alignment.CENTER);
|
getLabelWidget().setAlignment(LabelWidget.Alignment.CENTER);
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
package com.projectswg.tools.csc.conversationeditor;
|
package com.projectswg.tools.csc.conversationeditor;
|
||||||
|
|
||||||
import com.projectswg.tools.csc.conversationeditor.nodes.ConversationNode;
|
import com.projectswg.tools.csc.conversationeditor.scene.SceneView;
|
||||||
import com.projectswg.tools.csc.conversationeditor.actions.OpenConversation;
|
import com.projectswg.tools.csc.conversationeditor.actions.OpenConversation;
|
||||||
|
import com.projectswg.tools.csc.conversationeditor.nodes.BeginNode;
|
||||||
|
import com.projectswg.tools.csc.conversationeditor.nodes.EndNode;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
import org.netbeans.api.settings.ConvertAsProperties;
|
import org.netbeans.api.settings.ConvertAsProperties;
|
||||||
@@ -122,7 +124,7 @@ public final class EditorTopComponent extends TopComponent implements ExplorerMa
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void blankSlate() {
|
public void blankSlate() {
|
||||||
scene.addNode(new ConversationNode("Begin Conversation", false, 0, false, true, 0));
|
scene.addNode(new BeginNode("sdafsdf", 0));
|
||||||
scene.addNode(new ConversationNode("End Conversation", false, 1, true, false, 0));
|
scene.addNode(new EndNode("asdfasdfsaf", 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,9 +5,9 @@
|
|||||||
*/
|
*/
|
||||||
package com.projectswg.tools.csc.conversationeditor.actions;
|
package com.projectswg.tools.csc.conversationeditor.actions;
|
||||||
|
|
||||||
import com.projectswg.tools.csc.conversationeditor.nodes.ConversationNode;
|
|
||||||
import com.projectswg.tools.csc.conversationeditor.EditorTopComponent;
|
import com.projectswg.tools.csc.conversationeditor.EditorTopComponent;
|
||||||
import com.projectswg.tools.csc.conversationeditor.SceneView;
|
import com.projectswg.tools.csc.conversationeditor.nodes.EndNode;
|
||||||
|
import com.projectswg.tools.csc.conversationeditor.scene.SceneView;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
import org.openide.awt.ActionID;
|
import org.openide.awt.ActionID;
|
||||||
@@ -45,7 +45,7 @@ public final class NewConvEnd implements ActionListener {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
int id = scene.getNextId();
|
int id = scene.getNextId();
|
||||||
scene.addNode(new ConversationNode("New End Conversation " + String.valueOf(id), false, id, true, false, 0));
|
scene.addNode(new EndNode("New End Conversation " + String.valueOf(id), id));
|
||||||
|
|
||||||
scene.validate();
|
scene.validate();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
package com.projectswg.tools.csc.conversationeditor.actions;
|
package com.projectswg.tools.csc.conversationeditor.actions;
|
||||||
|
|
||||||
import com.projectswg.tools.csc.conversationeditor.nodes.ConversationNode;
|
|
||||||
import com.projectswg.tools.csc.conversationeditor.EditorTopComponent;
|
import com.projectswg.tools.csc.conversationeditor.EditorTopComponent;
|
||||||
import com.projectswg.tools.csc.conversationeditor.SceneView;
|
import com.projectswg.tools.csc.conversationeditor.nodes.OptionNode;
|
||||||
|
import com.projectswg.tools.csc.conversationeditor.scene.SceneView;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
import org.openide.awt.ActionID;
|
import org.openide.awt.ActionID;
|
||||||
@@ -40,7 +40,7 @@ public final class NewConvOption implements ActionListener {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
int id = scene.getNextId();
|
int id = scene.getNextId();
|
||||||
scene.addNode(new ConversationNode("New Conversation Option " + String.valueOf(id), true, id, false, false, 0));
|
scene.addNode(new OptionNode("New Conversation Option " + String.valueOf(id), id));
|
||||||
|
|
||||||
scene.validate();
|
scene.validate();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,9 +5,9 @@
|
|||||||
*/
|
*/
|
||||||
package com.projectswg.tools.csc.conversationeditor.actions;
|
package com.projectswg.tools.csc.conversationeditor.actions;
|
||||||
|
|
||||||
import com.projectswg.tools.csc.conversationeditor.nodes.ConversationNode;
|
|
||||||
import com.projectswg.tools.csc.conversationeditor.EditorTopComponent;
|
import com.projectswg.tools.csc.conversationeditor.EditorTopComponent;
|
||||||
import com.projectswg.tools.csc.conversationeditor.SceneView;
|
import com.projectswg.tools.csc.conversationeditor.nodes.ResponseNode;
|
||||||
|
import com.projectswg.tools.csc.conversationeditor.scene.SceneView;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
import org.openide.awt.ActionID;
|
import org.openide.awt.ActionID;
|
||||||
@@ -45,7 +45,7 @@ public final class NewConvResponse implements ActionListener {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
int id = scene.getNextId();
|
int id = scene.getNextId();
|
||||||
scene.addNode(new ConversationNode("New Conversation Response " + String.valueOf(id), false, id, false, false, 0));
|
scene.addNode(new ResponseNode("New Conversation Response " + String.valueOf(id), id));
|
||||||
scene.validate();
|
scene.validate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
package com.projectswg.tools.csc.conversationeditor.actions;
|
package com.projectswg.tools.csc.conversationeditor.actions;
|
||||||
|
|
||||||
import com.projectswg.tools.csc.conversationeditor.EditorTopComponent;
|
import com.projectswg.tools.csc.conversationeditor.EditorTopComponent;
|
||||||
import com.projectswg.tools.csc.conversationeditor.SceneSaver;
|
import com.projectswg.tools.csc.conversationeditor.scene.SceneSaver;
|
||||||
import com.projectswg.tools.csc.conversationeditor.SceneView;
|
import com.projectswg.tools.csc.conversationeditor.scene.SceneView;
|
||||||
import com.projectswg.tools.csc.conversationeditor.wizard.CompileWizardAction;
|
import com.projectswg.tools.csc.conversationeditor.wizard.CompileWizardAction;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
|
|||||||
@@ -6,8 +6,8 @@
|
|||||||
package com.projectswg.tools.csc.conversationeditor.actions;
|
package com.projectswg.tools.csc.conversationeditor.actions;
|
||||||
|
|
||||||
import com.projectswg.tools.csc.conversationeditor.EditorTopComponent;
|
import com.projectswg.tools.csc.conversationeditor.EditorTopComponent;
|
||||||
import com.projectswg.tools.csc.conversationeditor.SceneSaver;
|
import com.projectswg.tools.csc.conversationeditor.scene.SceneSaver;
|
||||||
import com.projectswg.tools.csc.conversationeditor.SceneView;
|
import com.projectswg.tools.csc.conversationeditor.scene.SceneView;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|||||||
@@ -5,16 +5,14 @@
|
|||||||
*/
|
*/
|
||||||
package com.projectswg.tools.csc.conversationeditor.actions;
|
package com.projectswg.tools.csc.conversationeditor.actions;
|
||||||
|
|
||||||
import com.projectswg.tools.csc.conversationeditor.nodes.ConversationNode;
|
|
||||||
import com.projectswg.tools.csc.conversationeditor.ConversationWidget;
|
import com.projectswg.tools.csc.conversationeditor.ConversationWidget;
|
||||||
import com.projectswg.tools.csc.conversationeditor.EditorTopComponent;
|
import com.projectswg.tools.csc.conversationeditor.EditorTopComponent;
|
||||||
import com.projectswg.tools.csc.conversationeditor.SceneView;
|
import com.projectswg.tools.csc.conversationeditor.nodes.ConversationNode;
|
||||||
|
import com.projectswg.tools.csc.conversationeditor.scene.SceneView;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import javax.swing.SwingUtilities;
|
import javax.swing.SwingUtilities;
|
||||||
import org.netbeans.api.visual.widget.ConnectionWidget;
|
import org.netbeans.api.visual.widget.ConnectionWidget;
|
||||||
import org.netbeans.api.visual.widget.Widget;
|
import org.netbeans.api.visual.widget.Widget;
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package com.projectswg.tools.csc.conversationeditor.nodes;
|
||||||
|
|
||||||
|
public class BeginNode extends ConversationNode {
|
||||||
|
|
||||||
|
public BeginNode(String stf, int id) {
|
||||||
|
super(getImgDirectory() + "conversation_begin.png", ConversationNode.BEGIN, stf, id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean doesLink(ConversationNode target) {
|
||||||
|
switch (target.getType()) {
|
||||||
|
case ConversationNode.OPTION:
|
||||||
|
return true;
|
||||||
|
case ConversationNode.RESPONSE:
|
||||||
|
return false;
|
||||||
|
case ConversationNode.END:
|
||||||
|
return false;
|
||||||
|
case ConversationNode.BEGIN:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.projectswg.tools.csc.conversationeditor.nodes;
|
package com.projectswg.tools.csc.conversationeditor.nodes;
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.util.HashMap;
|
||||||
import org.openide.nodes.AbstractNode;
|
import org.openide.nodes.AbstractNode;
|
||||||
import org.openide.nodes.Children;
|
import org.openide.nodes.Children;
|
||||||
import org.openide.nodes.PropertySupport;
|
import org.openide.nodes.PropertySupport;
|
||||||
@@ -8,169 +9,121 @@ import org.openide.nodes.Sheet;
|
|||||||
import org.openide.util.Lookup;
|
import org.openide.util.Lookup;
|
||||||
|
|
||||||
public class ConversationNode extends AbstractNode implements Lookup.Provider {
|
public class ConversationNode extends AbstractNode implements Lookup.Provider {
|
||||||
private int id;
|
|
||||||
private int optionId;
|
private final int id;
|
||||||
private String displayText;
|
|
||||||
private String stf;
|
private String stf;
|
||||||
private boolean option;
|
|
||||||
private boolean locked;
|
private boolean locked;
|
||||||
private boolean compiled;
|
|
||||||
private boolean endNode;
|
|
||||||
private boolean startNode;
|
|
||||||
|
|
||||||
public ConversationNode(String stf, boolean isOption, int id, boolean isEndNode, boolean isStartNode, int optionId) {
|
private final Sheet sheet;
|
||||||
|
private final String imageStr;
|
||||||
|
private final String type;
|
||||||
|
|
||||||
|
public static final String OPTION = "Option";
|
||||||
|
public static final String RESPONSE = "Response";
|
||||||
|
public static final String END = "End";
|
||||||
|
public static final String BEGIN = "Begin";
|
||||||
|
|
||||||
|
HashMap<String, Object> specificAttrs = new HashMap<>();
|
||||||
|
|
||||||
|
public ConversationNode(String imageStr, String type, String stf, int id) {
|
||||||
super(Children.LEAF);
|
super(Children.LEAF);
|
||||||
|
|
||||||
this.stf = stf;
|
|
||||||
this.option = isOption;
|
|
||||||
this.displayText = "";
|
|
||||||
this.endNode = isEndNode;
|
|
||||||
this.startNode = isStartNode;
|
|
||||||
this.optionId = optionId;
|
|
||||||
this.id = id;
|
this.id = id;
|
||||||
|
|
||||||
// Properties Window
|
|
||||||
if (!isStartNode)
|
|
||||||
setDisplayName("Conversation " + ((isOption) ? "Option " + String.valueOf(id) : ((isEndNode) ? "End" : "Response " + String.valueOf(id))));
|
|
||||||
else
|
|
||||||
setDisplayName("Begin Conversation Node");
|
|
||||||
|
|
||||||
setShortDescription("Properties for this Conversation Node");
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getStf() {
|
|
||||||
return stf;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setStf(String stf) {
|
|
||||||
firePropertyChange("stf", this.stf, stf);
|
|
||||||
this.stf = stf;
|
this.stf = stf;
|
||||||
}
|
this.imageStr = imageStr;
|
||||||
|
this.sheet = super.createSheet();
|
||||||
|
|
||||||
|
Sheet.Set properties = Sheet.createPropertiesSet();
|
||||||
|
|
||||||
public String getDisplayText() {
|
properties.setDisplayName("General");
|
||||||
return displayText;
|
properties.setShortDescription("Basic properties for all conversation nodes.");
|
||||||
}
|
|
||||||
|
properties.put(new IdProperty(this));
|
||||||
public void setDisplayText(String displayText) {
|
properties.put(new StfProperty(this));
|
||||||
firePropertyChange("display", this.displayText, displayText);
|
properties.put(new LockedProperty(this));
|
||||||
this.displayText = displayText;
|
|
||||||
|
sheet.put(properties);
|
||||||
|
|
||||||
|
this.type = type;
|
||||||
|
|
||||||
|
this.setDisplayName(stf);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isOption() {
|
public final int getId() {
|
||||||
return option;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setOption(boolean option) {
|
|
||||||
this.option = option;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isLocked() {
|
|
||||||
return locked;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLocked(boolean locked) {
|
|
||||||
this.locked = locked;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getId() {
|
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setId(int id) {
|
public final String getStf() {
|
||||||
this.id = id;
|
return stf;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isCompiled() {
|
public final void setStf(String stf) {
|
||||||
return compiled;
|
this.stf = stf;
|
||||||
}
|
|
||||||
|
|
||||||
public void setCompiled(boolean compiled) {
|
|
||||||
this.compiled = compiled;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isEndNode() {
|
public final boolean isLocked() {
|
||||||
return endNode;
|
return locked;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final void setLocked(boolean isLocked) {
|
||||||
|
this.locked = isLocked;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final String getImageStr() {
|
||||||
|
return imageStr;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final String getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final void addNodeProperties(Sheet.Set properties) {
|
||||||
|
sheet.put(properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setEndNode(boolean endNode) {
|
public boolean doesLink(ConversationNode target) {
|
||||||
this.endNode = endNode;
|
return true;
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isStartNode() {
|
|
||||||
return this.startNode;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setStartNode(boolean startNode) {
|
|
||||||
this.startNode = startNode;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getOptionId() {
|
|
||||||
return this.optionId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setOptionId(int optionId) {
|
|
||||||
this.optionId = optionId;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Sheet createSheet() {
|
protected final Sheet createSheet() {
|
||||||
Sheet sheet = super.createSheet();
|
|
||||||
Sheet.Set set = Sheet.createPropertiesSet();
|
|
||||||
|
|
||||||
set.put(new IdProperty(this));
|
|
||||||
set.put(new StfProperty(this));
|
|
||||||
set.put(new DisplayProperty(this));
|
|
||||||
if (!endNode) {
|
|
||||||
set.put(new TypeProperty(this));
|
|
||||||
|
|
||||||
if (option) {
|
|
||||||
set.put(new OptionIdProperty(this));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
set.put(new LockedProperty(this));
|
|
||||||
|
|
||||||
sheet.put(set);
|
|
||||||
return sheet;
|
return sheet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public final static String getImgDirectory() {
|
||||||
|
return "com/projectswg/tools/csc/conversationeditor/nodes/imgs/";
|
||||||
|
}
|
||||||
|
|
||||||
|
public final Object addSpecificAttribute(String name, Object value) {
|
||||||
|
return specificAttrs.put(name, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public HashMap<String, Object> getAttributes() {
|
||||||
|
return specificAttrs;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class OptionIdProperty extends PropertySupport.ReadWrite<Integer> {
|
final class LockedProperty extends PropertySupport.ReadWrite<Boolean> {
|
||||||
|
|
||||||
private final ConversationNode node;
|
|
||||||
|
|
||||||
public OptionIdProperty(ConversationNode node) {
|
|
||||||
super("optionId", Integer.class, "Option ID", "ID used for displaying the order of this option in relation to the response (what option should show first in"
|
|
||||||
+ "list of options)");
|
|
||||||
this.node = node;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Integer getValue() throws IllegalAccessException, InvocationTargetException {
|
|
||||||
return node.getOptionId();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setValue(Integer val) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
|
||||||
node.setOptionId(val);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
class IdProperty extends PropertySupport.ReadOnly<Integer> {
|
|
||||||
private final ConversationNode node;
|
private final ConversationNode node;
|
||||||
|
|
||||||
public IdProperty(ConversationNode node) {
|
public LockedProperty(ConversationNode node) {
|
||||||
super("id", Integer.class, "Id", "Conversation Node Id");
|
super("locked", Boolean.class, "Locked", "Determines if this node can be moved.");
|
||||||
this.node = node;
|
this.node = node;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Integer getValue() throws IllegalAccessException, InvocationTargetException {
|
public Boolean getValue() throws IllegalAccessException, InvocationTargetException {
|
||||||
return node.getId();
|
return node.isLocked();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setValue(Boolean val) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
|
node.setLocked(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
class StfProperty extends PropertySupport.ReadWrite<String> {
|
|
||||||
|
final class StfProperty extends PropertySupport.ReadWrite<String> {
|
||||||
|
|
||||||
private final ConversationNode node;
|
private final ConversationNode node;
|
||||||
|
|
||||||
@@ -191,62 +144,16 @@ class StfProperty extends PropertySupport.ReadWrite<String> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class TypeProperty extends PropertySupport.ReadOnly<Boolean> {
|
final class IdProperty extends PropertySupport.ReadOnly<Integer> {
|
||||||
|
|
||||||
private final ConversationNode node;
|
private final ConversationNode node;
|
||||||
|
|
||||||
public TypeProperty(ConversationNode node) {
|
|
||||||
super("option", Boolean.class, "Option", "The conversation node is a response or a option");
|
|
||||||
this.node = node;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Boolean getValue() throws IllegalAccessException, InvocationTargetException {
|
|
||||||
return node.isOption();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setValue(Boolean val) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
|
||||||
node.setOption(val);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class DisplayProperty extends PropertySupport.ReadWrite<String> {
|
public IdProperty(ConversationNode node) {
|
||||||
private final ConversationNode node;
|
super("id", Integer.class, "Id", "Conversation Node Id");
|
||||||
|
|
||||||
public DisplayProperty(ConversationNode node) {
|
|
||||||
super ("display", String.class, "Text", "Optional text. This won't affect anything and can be left blank.\n" +
|
|
||||||
"You can use this for entering the value of a key from the coresponding STF for quick reference.");
|
|
||||||
this.node = node;
|
this.node = node;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getValue() throws IllegalAccessException, InvocationTargetException {
|
public Integer getValue() throws IllegalAccessException, InvocationTargetException {
|
||||||
return node.getDisplayText();
|
return node.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setValue(String val) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
|
||||||
node.setDisplayText(val);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class LockedProperty extends PropertySupport.ReadWrite<Boolean> {
|
|
||||||
private final ConversationNode node;
|
|
||||||
|
|
||||||
public LockedProperty(ConversationNode node) {
|
|
||||||
super("locked", Boolean.class, "Locked", "Determines if this node can be moved.");
|
|
||||||
this.node = node;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Boolean getValue() throws IllegalAccessException, InvocationTargetException {
|
|
||||||
return node.isLocked();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setValue(Boolean val) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
|
||||||
node.setLocked(val);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package com.projectswg.tools.csc.conversationeditor.nodes;
|
||||||
|
|
||||||
|
public class EndNode extends ConversationNode {
|
||||||
|
|
||||||
|
public EndNode(String stf, int id) {
|
||||||
|
super(getImgDirectory() + "conversation_end.png", ConversationNode.END, stf, id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean doesLink(ConversationNode target) {
|
||||||
|
switch (target.getType()) {
|
||||||
|
case ConversationNode.OPTION:
|
||||||
|
return true;
|
||||||
|
case ConversationNode.RESPONSE:
|
||||||
|
return false;
|
||||||
|
case ConversationNode.END:
|
||||||
|
return false;
|
||||||
|
case ConversationNode.BEGIN:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,104 @@
|
|||||||
|
package com.projectswg.tools.csc.conversationeditor.nodes;
|
||||||
|
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import org.openide.nodes.PropertySupport;
|
||||||
|
import org.openide.nodes.Sheet;
|
||||||
|
|
||||||
|
public class OptionNode extends ConversationNode {
|
||||||
|
|
||||||
|
private int number;
|
||||||
|
private String displayText = "";
|
||||||
|
|
||||||
|
public OptionNode(String stf, int id, int optionNumber) {
|
||||||
|
super(getImgDirectory() + "conversation_option.png", ConversationNode.OPTION, stf, id);
|
||||||
|
|
||||||
|
Sheet.Set properties = Sheet.createPropertiesSet();
|
||||||
|
|
||||||
|
properties.setName("optionNode"); // Name must be set or properties will not show properly
|
||||||
|
properties.setDisplayName("Conversation Option");
|
||||||
|
properties.setShortDescription("Properties specific to Option Node");
|
||||||
|
|
||||||
|
properties.put(new OptionIdProperty(this));
|
||||||
|
properties.put(new DisplayTextProperty(this));
|
||||||
|
|
||||||
|
addNodeProperties(properties);
|
||||||
|
|
||||||
|
this.number = optionNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OptionNode(String stf, int id) {
|
||||||
|
this(stf, id, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNumber(int num) {
|
||||||
|
this.number = num;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getNumber() {
|
||||||
|
return number;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDisplayText(String txt) {
|
||||||
|
this.displayText = txt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDisplayText() {
|
||||||
|
return displayText;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean doesLink(ConversationNode target) {
|
||||||
|
switch (target.getType()) {
|
||||||
|
case ConversationNode.OPTION:
|
||||||
|
return false;
|
||||||
|
case ConversationNode.RESPONSE:
|
||||||
|
return true;
|
||||||
|
case ConversationNode.END:
|
||||||
|
return true;
|
||||||
|
case ConversationNode.BEGIN:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class OptionIdProperty extends PropertySupport.ReadWrite<Integer> {
|
||||||
|
|
||||||
|
private final OptionNode node;
|
||||||
|
|
||||||
|
public OptionIdProperty(OptionNode node) {
|
||||||
|
super("optionId", Integer.class, "Option ID", "ID used for displaying the order of this option in relation to the response (what option should show first in"
|
||||||
|
+ "list of options)");
|
||||||
|
this.node = node;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer getValue() throws IllegalAccessException, InvocationTargetException {
|
||||||
|
return node.getNumber();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setValue(Integer val) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
|
node.setNumber(val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class DisplayTextProperty extends PropertySupport.ReadWrite<String> {
|
||||||
|
|
||||||
|
private final OptionNode node;
|
||||||
|
|
||||||
|
public DisplayTextProperty(OptionNode node) {
|
||||||
|
super("displayTxt", String.class, "Display Text", "Text displayed in comment for this node at compile time");
|
||||||
|
this.node = node;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getValue() throws IllegalAccessException, InvocationTargetException {
|
||||||
|
return node.getDisplayText();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setValue(String val) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
|
node.setDisplayText(val);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package com.projectswg.tools.csc.conversationeditor.nodes;
|
||||||
|
|
||||||
|
public class ResponseNode extends ConversationNode {
|
||||||
|
|
||||||
|
public ResponseNode(String stf, int id) {
|
||||||
|
super(getImgDirectory() + "conversation_response.png", ConversationNode.RESPONSE, stf, id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean doesLink(ConversationNode target) {
|
||||||
|
switch (target.getType()) {
|
||||||
|
case ConversationNode.OPTION:
|
||||||
|
return true;
|
||||||
|
case ConversationNode.RESPONSE:
|
||||||
|
return false;
|
||||||
|
case ConversationNode.END:
|
||||||
|
return false;
|
||||||
|
case ConversationNode.BEGIN:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 20 KiB |
|
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 23 KiB |
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
@@ -1,6 +1,11 @@
|
|||||||
package com.projectswg.tools.csc.conversationeditor;
|
package com.projectswg.tools.csc.conversationeditor.scene;
|
||||||
|
|
||||||
|
import com.projectswg.tools.csc.conversationeditor.ConversationWidget;
|
||||||
|
import com.projectswg.tools.csc.conversationeditor.nodes.BeginNode;
|
||||||
import com.projectswg.tools.csc.conversationeditor.nodes.ConversationNode;
|
import com.projectswg.tools.csc.conversationeditor.nodes.ConversationNode;
|
||||||
|
import com.projectswg.tools.csc.conversationeditor.nodes.EndNode;
|
||||||
|
import com.projectswg.tools.csc.conversationeditor.nodes.OptionNode;
|
||||||
|
import com.projectswg.tools.csc.conversationeditor.nodes.ResponseNode;
|
||||||
import java.awt.Point;
|
import java.awt.Point;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
@@ -33,6 +38,7 @@ public class SceneSaver {
|
|||||||
private static final String LOCKED = "locked";
|
private static final String LOCKED = "locked";
|
||||||
private static final String STF = "stf";
|
private static final String STF = "stf";
|
||||||
private static final String OPTION_ID = "optionId";
|
private static final String OPTION_ID = "optionId";
|
||||||
|
private static final String TEXT = "txt";
|
||||||
|
|
||||||
private static final String VERSION_VALUE_1 = "1.0"; // NOI18N
|
private static final String VERSION_VALUE_1 = "1.0"; // NOI18N
|
||||||
|
|
||||||
@@ -60,14 +66,7 @@ public class SceneSaver {
|
|||||||
if (location != null) {
|
if (location != null) {
|
||||||
Node dataXMLNode = file.createElement(NODE_NODE);
|
Node dataXMLNode = file.createElement(NODE_NODE);
|
||||||
|
|
||||||
if (node.isOption())
|
setAttribute(file, dataXMLNode, TYPE, node.getType());
|
||||||
setAttribute(file, dataXMLNode, TYPE, "option");
|
|
||||||
else if (!node.isEndNode() && !node.isStartNode())
|
|
||||||
setAttribute(file, dataXMLNode, TYPE, "response");
|
|
||||||
else if (node.isEndNode())
|
|
||||||
setAttribute(file, dataXMLNode, TYPE, "end");
|
|
||||||
else
|
|
||||||
setAttribute(file, dataXMLNode, TYPE, "begin");
|
|
||||||
|
|
||||||
setAttribute(file, dataXMLNode, TARGETS, getTargets(conversationLinks, node));
|
setAttribute(file, dataXMLNode, TARGETS, getTargets(conversationLinks, node));
|
||||||
|
|
||||||
@@ -76,7 +75,10 @@ public class SceneSaver {
|
|||||||
setAttribute(file, dataXMLNode, Y_NODE, Integer.toString(location.y));
|
setAttribute(file, dataXMLNode, Y_NODE, Integer.toString(location.y));
|
||||||
setAttribute(file, dataXMLNode, LOCKED, Boolean.toString(node.isLocked()));
|
setAttribute(file, dataXMLNode, LOCKED, Boolean.toString(node.isLocked()));
|
||||||
setAttribute(file, dataXMLNode, STF, node.getStf());
|
setAttribute(file, dataXMLNode, STF, node.getStf());
|
||||||
setAttribute(file, dataXMLNode, OPTION_ID, Integer.toString(node.getOptionId()));
|
|
||||||
|
for (HashMap.Entry<String, Object> entry : node.getAttributes().entrySet()) {
|
||||||
|
setAttribute(file, dataXMLNode, entry.getKey(), entry.getValue().toString());
|
||||||
|
}
|
||||||
|
|
||||||
sceneXMLNode.appendChild(dataXMLNode);
|
sceneXMLNode.appendChild(dataXMLNode);
|
||||||
}
|
}
|
||||||
@@ -135,21 +137,22 @@ public class SceneSaver {
|
|||||||
String targets = getAttributeValue(node, TARGETS);
|
String targets = getAttributeValue(node, TARGETS);
|
||||||
String stf = getAttributeValue(node, STF);
|
String stf = getAttributeValue(node, STF);
|
||||||
String type = getAttributeValue(node, TYPE);
|
String type = getAttributeValue(node, TYPE);
|
||||||
|
String txt = getAttributeValue(node, TEXT);
|
||||||
|
|
||||||
ConversationWidget widget = null;
|
ConversationWidget widget = null;
|
||||||
// ConversationNode(String stf, boolean isOption, int id, boolean isEndNode, boolean isStartNode, int optionId)
|
// ConversationNode(String stf, boolean isOption, int id, boolean isEndNode, boolean isStartNode, int optionId)
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case "option":
|
case ConversationNode.OPTION:
|
||||||
widget = (ConversationWidget) scene.addNode(new ConversationNode(stf, true, nodeID, false, false, optionId));
|
widget = (ConversationWidget) scene.addNode(new OptionNode(stf, nodeID, optionId));
|
||||||
break;
|
break;
|
||||||
case "response":
|
case ConversationNode.RESPONSE:
|
||||||
widget = (ConversationWidget) scene.addNode(new ConversationNode(stf, false, nodeID, false, false, optionId));
|
widget = (ConversationWidget) scene.addNode(new ResponseNode(stf, nodeID));
|
||||||
break;
|
break;
|
||||||
case "begin":
|
case ConversationNode.BEGIN:
|
||||||
widget = (ConversationWidget) scene.addNode(new ConversationNode(stf, false, nodeID, false, true, optionId));
|
widget = (ConversationWidget) scene.addNode(new BeginNode(stf, nodeID));
|
||||||
break;
|
break;
|
||||||
case "end":
|
case ConversationNode.END:
|
||||||
widget = (ConversationWidget) scene.addNode(new ConversationNode(stf, false, nodeID, true, false, optionId));
|
widget = (ConversationWidget) scene.addNode(new EndNode(stf, nodeID));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,5 +1,8 @@
|
|||||||
package com.projectswg.tools.csc.conversationeditor;
|
package com.projectswg.tools.csc.conversationeditor.scene;
|
||||||
|
|
||||||
|
import com.projectswg.tools.csc.conversationeditor.ConversationLookFeel;
|
||||||
|
import com.projectswg.tools.csc.conversationeditor.ConversationWidget;
|
||||||
|
import com.projectswg.tools.csc.conversationeditor.EditorTopComponent;
|
||||||
import com.projectswg.tools.csc.conversationeditor.nodes.ConversationNode;
|
import com.projectswg.tools.csc.conversationeditor.nodes.ConversationNode;
|
||||||
import java.beans.PropertyChangeEvent;
|
import java.beans.PropertyChangeEvent;
|
||||||
import java.beans.PropertyChangeListener;
|
import java.beans.PropertyChangeListener;
|
||||||
@@ -49,7 +52,7 @@ public class SceneView extends GraphScene<ConversationNode, String>{
|
|||||||
@Override
|
@Override
|
||||||
protected Widget attachNodeWidget(ConversationNode n) {
|
protected Widget attachNodeWidget(ConversationNode n) {
|
||||||
|
|
||||||
final ConversationWidget widget = new ConversationWidget(this, mgr, n, n.isEndNode());
|
final ConversationWidget widget = new ConversationWidget(this, mgr, n);
|
||||||
widget.getActions().addAction(createObjectHoverAction());
|
widget.getActions().addAction(createObjectHoverAction());
|
||||||
|
|
||||||
n.addPropertyChangeListener(new PropertyChangeListener() {
|
n.addPropertyChangeListener(new PropertyChangeListener() {
|
||||||