mirror of
https://github.com/ProjectSWGCore/ConversationScriptCreator.git
synced 2026-01-16 23:05:01 -05:00
Finished save feature, added splash and icon, removed nbproject/private folders
This commit is contained in:
9
.gitignore
vendored
9
.gitignore
vendored
@@ -4,9 +4,9 @@
|
||||
.mtj.tmp/
|
||||
|
||||
# Package Files #
|
||||
*.jar
|
||||
*.war
|
||||
*.ear
|
||||
#*.jar
|
||||
#*.war
|
||||
#*.ear
|
||||
|
||||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||
hs_err_pid*
|
||||
@@ -14,4 +14,5 @@ hs_err_pid*
|
||||
/ConversationCompiler/build/
|
||||
/build/
|
||||
/ConversationEditor/build/
|
||||
/dist/
|
||||
/dist/
|
||||
/nbproject/private/
|
||||
@@ -1,7 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project-private xmlns="http://www.netbeans.org/ns/project-private/1">
|
||||
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/>
|
||||
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
|
||||
<group/>
|
||||
</open-files>
|
||||
</project-private>
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.projectswg.tools.csc.compiler;
|
||||
|
||||
import com.projectswg.tools.csc.conversationeditor.ConversationNode;
|
||||
import com.projectswg.tools.csc.conversationeditor.ConversationWidget;
|
||||
import com.projectswg.tools.csc.conversationeditor.EditorTopComponent;
|
||||
import com.projectswg.tools.csc.conversationeditor.SceneView;
|
||||
import java.io.BufferedWriter;
|
||||
@@ -10,11 +9,8 @@ import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.swing.JOptionPane;
|
||||
import org.netbeans.api.visual.widget.ConnectionWidget;
|
||||
import org.netbeans.api.visual.widget.Widget;
|
||||
import org.openide.windows.TopComponent;
|
||||
|
||||
public class Compiler {
|
||||
@@ -43,30 +39,7 @@ public class Compiler {
|
||||
try (BufferedWriter bw = new BufferedWriter(new FileWriter(file.getAbsolutePath()))) {
|
||||
createBaseFile(bw);
|
||||
|
||||
List<Widget> connectedNodes = scene.getConnectionLayer().getChildren();
|
||||
LinkedHashMap<ConversationNode, ArrayList<ConversationNode>> conversationLinks = new LinkedHashMap<>();
|
||||
|
||||
for (Widget widget : connectedNodes) {
|
||||
ConnectionWidget connection = (ConnectionWidget) widget;
|
||||
|
||||
ConversationWidget source = (ConversationWidget) connection.getSourceAnchor().getRelatedWidget();
|
||||
ConversationNode sNode = source.getAttachedNode();
|
||||
|
||||
if (!conversationLinks.containsKey(sNode)) {
|
||||
conversationLinks.put(sNode, new ArrayList<ConversationNode>());
|
||||
}
|
||||
|
||||
ConversationWidget target = (ConversationWidget) connection.getTargetAnchor().getRelatedWidget();
|
||||
ConversationNode tNode = target.getAttachedNode();
|
||||
|
||||
if (conversationLinks.containsKey(sNode))
|
||||
conversationLinks.get(sNode).add(tNode);
|
||||
else
|
||||
System.out.println("No key for node " + sNode.getStf());
|
||||
|
||||
//System.out.println("This connection widget came from " + sNode.getStf() + " and is pointing to " + tNode.getStf());
|
||||
//compiler.compileTarget(tNode);
|
||||
}
|
||||
LinkedHashMap<ConversationNode, ArrayList<ConversationNode>> conversationLinks = scene.getConversationLinks();
|
||||
|
||||
for (Map.Entry<ConversationNode, ArrayList<ConversationNode>> entry : conversationLinks.entrySet()) {
|
||||
/*System.out.println("Handling for node " + entry.getKey().getStf());
|
||||
@@ -105,14 +78,15 @@ public class Compiler {
|
||||
for (ConversationNode selectedOption : options) {
|
||||
bw.write(" " + (options.indexOf(selectedOption) > 0 ? "elif" : "if") + " selection == " + options.indexOf(selectedOption) + ":\n");
|
||||
if (conversationLinks.containsKey(selectedOption)) {
|
||||
bw.write(" #Handler for Option " + selectedOption.getStf() + "\n");
|
||||
bw.write(" #Handler for Option Node " + selectedOption.getId() + "\n");
|
||||
for (ConversationNode handleNode : conversationLinks.get(selectedOption)) {
|
||||
if (!handleNode.isOption()) {
|
||||
if (conversationLinks.get(handleNode) == null) {
|
||||
bw.write(" core.conversationService.sendStopConversation(actor, npc, 'conversation/c_newbie_secondchance', 's_136')\n");
|
||||
} else {
|
||||
createOptions(bw, conversationLinks.get(handleNode), count++, " ");
|
||||
bw.write(" core.conversationService.sendConversationMessage(actor, npc, OutOfBand.ProsePackage('@" + handleNode.getStf() + "')\n");
|
||||
bw.write(" core.conversationService.sendConversationMessage(actor, npc, OutOfBand.ProsePackage('@conversation/"
|
||||
+ handleNode.getStf() + "')\n");
|
||||
handleFuncs.put(handleNode, conversationLinks.get(handleNode)); // Put these nodes in list so we can create the handlers later.
|
||||
}
|
||||
}
|
||||
@@ -142,16 +116,16 @@ public class Compiler {
|
||||
orderedOptions.add(unOrdered.getOptionId(), unOrdered);
|
||||
}
|
||||
for (ConversationNode option : orderedOptions) {
|
||||
bw.write(" options.add(ConversationOption(OutOfBand.ProsePackage('@" + option.getStf() +"'), " + options.indexOf(option) + ")\n");
|
||||
bw.write(" options.add(ConversationOption(OutOfBand.ProsePackage('@conversation/" + option.getStf() +"'), " + options.indexOf(option) + ")\n");
|
||||
}
|
||||
} else {
|
||||
for (ConversationNode option : options) {
|
||||
bw.write(" options.add(ConversationOption(OutOfBand.ProsePackage('@" + option.getStf() +"'), " + options.indexOf(option) + ")\n");
|
||||
bw.write(" options.add(ConversationOption(OutOfBand.ProsePackage('@conversation/" + option.getStf() +"'), " + options.indexOf(option) + ")\n");
|
||||
}
|
||||
}
|
||||
|
||||
bw.write(" core.conversationService.sendConversationOptions(actor, npc, handleOptionScreen" + String.valueOf(handleScreenNum) + ")\n");
|
||||
bw.write(" core.conversationService.sendConversationMessage(actor, npc, OutOfBand.ProsePackage('@" + response.getStf() + "'))\n");
|
||||
bw.write(" core.conversationService.sendConversationMessage(actor, npc, OutOfBand.ProsePackage('@conversation/" + response.getStf() + "'))\n");
|
||||
bw.write(" return\n");
|
||||
bw.newLine();
|
||||
createResponseHandler(bw, options, handleScreenNum, conversationLinks);
|
||||
@@ -166,11 +140,11 @@ public class Compiler {
|
||||
orderedOptions.add(unOrdered.getOptionId(), unOrdered);
|
||||
}
|
||||
for (ConversationNode option : orderedOptions) {
|
||||
bw.write(space + "options.add(ConversationOption(OutOfBand.ProsePackage('@" + option.getStf() +"'), " + options.indexOf(option) + ")\n");
|
||||
bw.write(space + "options.add(ConversationOption(OutOfBand.ProsePackage('@conversation/" + option.getStf() +"'), " + options.indexOf(option) + ")\n");
|
||||
}
|
||||
} else {
|
||||
for (ConversationNode option : options) {
|
||||
bw.write(space + "options.add(ConversationOption(OutOfBand.ProsePackage('@" + option.getStf() +"'), " + options.indexOf(option) + ")\n");
|
||||
bw.write(space + "options.add(ConversationOption(OutOfBand.ProsePackage('@conversation/" + option.getStf() +"'), " + options.indexOf(option) + ")\n");
|
||||
}
|
||||
}
|
||||
bw.write(space + "core.conversationService.sendConversationOptions(actor, npc, handleOptionScreen" + String.valueOf(handleScreenNum) + ")\n");
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project-private xmlns="http://www.netbeans.org/ns/project-private/1">
|
||||
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/>
|
||||
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
|
||||
<group/>
|
||||
</open-files>
|
||||
</project-private>
|
||||
@@ -171,7 +171,7 @@ class StfProperty extends PropertySupport.ReadWrite<String> {
|
||||
private final ConversationNode node;
|
||||
|
||||
public StfProperty(ConversationNode node) {
|
||||
super("stf", String.class, "STF", "STF file for this conversation node. Ex: conversation/c_newbie_mentor:s_109");
|
||||
super("stf", String.class, "STF", "STF file for this conversation node, excluding conversation/. Ex: conversation/c_newbie_mentor:s_109 would be c_newbie_mentor:s_109");
|
||||
this.setValue("oneline", true);
|
||||
this.node = node;
|
||||
}
|
||||
|
||||
@@ -1,33 +1,55 @@
|
||||
package com.projectswg.tools.csc.conversationeditor;
|
||||
|
||||
import java.awt.Point;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.swing.SwingUtilities;
|
||||
import org.netbeans.api.visual.graph.GraphScene;
|
||||
import org.netbeans.api.visual.widget.ConnectionWidget;
|
||||
import org.netbeans.api.visual.widget.Widget;
|
||||
import org.w3c.dom.Attr;
|
||||
import org.w3c.dom.DOMException;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.NamedNodeMap;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
// Based off of http://bits.netbeans.org/dev/javadoc/org-netbeans-api-visual/org/netbeans/api/visual/widget/doc-files/documentation.html#Serialization
|
||||
public class SceneSaver {
|
||||
private static final String NODE_ELEMENT = "SceneNode"; // NOI18N
|
||||
private static final String NODE_ELEMENT = "SceneView"; // NOI18N
|
||||
private static final String VERSION_ATTR = "version"; // NOI18N
|
||||
private static final String NODE_NODE = "Node"; // NOI18N
|
||||
|
||||
private static final String TYPE = "type"; // NOI18N
|
||||
private static final String NODEID_ATTR = "nodeID"; // NOI18N
|
||||
private static final String X_NODE = "posX"; // NOI18N
|
||||
private static final String Y_NODE = "posY"; // NOI18N
|
||||
private static final String SOURCE = "source";
|
||||
private static final String LOCKED = "locked";
|
||||
private static final String STF = "stf";
|
||||
private static final String OPTION_ID = "optionId";
|
||||
|
||||
private static final String VERSION_VALUE_1 = "1.0"; // NOI18N
|
||||
|
||||
private static final String VERSION_VALUE_1 = "1"; // NOI18N
|
||||
public Node serializeData (SceneView scene, Document file) {
|
||||
|
||||
// creates an sceneXMLNode that has to be placed to the XML file then
|
||||
public Node serializeData (GraphScene<ConversationNode, String> scene, Document file) {
|
||||
Node root = file.createElement("Conversation");
|
||||
|
||||
Node properties = file.createElement("Properties");
|
||||
root.appendChild(properties);
|
||||
|
||||
setTextProperty(properties, file, "name", scene.getSceneName());
|
||||
|
||||
Node sceneXMLNode = file.createElement(NODE_ELEMENT);
|
||||
root.appendChild(sceneXMLNode);
|
||||
|
||||
setAttribute(file, sceneXMLNode, VERSION_ATTR, VERSION_VALUE_1); // NOI18N
|
||||
|
||||
|
||||
LinkedHashMap<ConversationNode, ArrayList<ConversationNode>> conversationLinks = scene.getConversationLinks();
|
||||
|
||||
for (ConversationNode node : scene.getNodes ()) {
|
||||
Widget widget = scene.findWidget(node);
|
||||
if (widget != null) {
|
||||
@@ -35,20 +57,51 @@ public class SceneSaver {
|
||||
if (location != null) {
|
||||
Node dataXMLNode = file.createElement(NODE_NODE);
|
||||
|
||||
if (node.isOption())
|
||||
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");
|
||||
|
||||
if (!node.isStartNode())
|
||||
setAttribute(file, dataXMLNode, SOURCE, String.valueOf(getSourceNode(conversationLinks, node).getId()));
|
||||
|
||||
setAttribute(file, dataXMLNode, NODEID_ATTR, String.valueOf(node.getId()));
|
||||
setAttribute(file, dataXMLNode, X_NODE, Integer.toString(location.x));
|
||||
setAttribute(file, dataXMLNode, Y_NODE, Integer.toString(location.y));
|
||||
|
||||
setAttribute(file, dataXMLNode, LOCKED, Boolean.toString(node.isLocked()));
|
||||
setAttribute(file, dataXMLNode, STF, node.getStf());
|
||||
setAttribute(file, dataXMLNode, OPTION_ID, Integer.toString(node.getOptionId()));
|
||||
|
||||
sceneXMLNode.appendChild(dataXMLNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
return sceneXMLNode;
|
||||
return root;
|
||||
}
|
||||
|
||||
private ConversationNode getSourceNode(LinkedHashMap<ConversationNode, ArrayList<ConversationNode>> conversationLinks, ConversationNode lookNode) {
|
||||
for (Map.Entry<ConversationNode, ArrayList<ConversationNode>> entry : conversationLinks.entrySet()) {
|
||||
if (entry.getValue().contains(lookNode))
|
||||
return entry.getKey();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private ConversationNode getTargetNode(LinkedHashMap<ConversationNode, ArrayList<ConversationNode>> conversationLinks, ConversationNode lookNode) {
|
||||
for (Map.Entry<ConversationNode, ArrayList<ConversationNode>> entry : conversationLinks.entrySet()) {
|
||||
if (entry.getValue().contains(lookNode))
|
||||
return entry.getValue().get(entry.getValue().indexOf(lookNode));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// Returns true if deserialization is successfull
|
||||
// sceneXMLNode has to be found in the XML file first
|
||||
public boolean deserializeData(final GraphScene<ConversationNode, String> scene, final Node sceneXMLNode) {
|
||||
public boolean deserializeData(final SceneView scene, final Node sceneXMLNode) {
|
||||
if (!VERSION_VALUE_1.equals(getAttributeValue(sceneXMLNode, VERSION_ATTR)))
|
||||
return false;
|
||||
|
||||
@@ -63,7 +116,7 @@ public class SceneSaver {
|
||||
return true;
|
||||
}
|
||||
|
||||
private void deserializeDataVersion1(GraphScene<ConversationNode, String> scene, Node data) {
|
||||
private void deserializeDataVersion1(SceneView scene, Node data) {
|
||||
for (Node node : getChildNode (data)) {
|
||||
if(NODE_NODE.equals(node.getNodeName())) {
|
||||
String nodeID = getAttributeValue(node, NODEID_ATTR);
|
||||
@@ -99,6 +152,12 @@ public class SceneSaver {
|
||||
map.setNamedItem (attribute);
|
||||
}
|
||||
|
||||
private static void setTextProperty(Node root, Document xml, String name, String value) {
|
||||
Element txtProperty = xml.createElement(name);
|
||||
txtProperty.appendChild(xml.createTextNode(value));
|
||||
root.appendChild(txtProperty);
|
||||
}
|
||||
|
||||
private static Node[] getChildNode (Node node) {
|
||||
NodeList childNodes = node.getChildNodes ();
|
||||
Node[] nodes = new Node[childNodes != null ? childNodes.getLength () : 0];
|
||||
|
||||
@@ -2,29 +2,19 @@ package com.projectswg.tools.csc.conversationeditor;
|
||||
|
||||
import java.beans.PropertyChangeEvent;
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import javax.xml.transform.OutputKeys;
|
||||
import javax.xml.transform.Transformer;
|
||||
import javax.xml.transform.TransformerConfigurationException;
|
||||
import javax.xml.transform.TransformerException;
|
||||
import javax.xml.transform.TransformerFactory;
|
||||
import javax.xml.transform.dom.DOMSource;
|
||||
import javax.xml.transform.stream.StreamResult;
|
||||
import org.netbeans.api.visual.action.ActionFactory;
|
||||
import org.netbeans.api.visual.graph.GraphScene;
|
||||
import org.netbeans.api.visual.widget.ConnectionWidget;
|
||||
import org.netbeans.api.visual.widget.LayerWidget;
|
||||
import org.netbeans.api.visual.widget.Widget;
|
||||
import org.openide.explorer.ExplorerManager;
|
||||
import org.openide.windows.TopComponent;
|
||||
import org.openide.windows.WindowManager;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Node;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
public class SceneView extends GraphScene<ConversationNode, String>{
|
||||
private final LayerWidget backgroundLayer;
|
||||
@@ -115,4 +105,29 @@ public class SceneView extends GraphScene<ConversationNode, String>{
|
||||
public void setSceneName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public LinkedHashMap<ConversationNode, ArrayList<ConversationNode>> getConversationLinks() {
|
||||
List<Widget> connectedNodes = connectionLayer.getChildren();
|
||||
LinkedHashMap<ConversationNode, ArrayList<ConversationNode>> conversationLinks = new LinkedHashMap<>();
|
||||
|
||||
for (Widget widget : connectedNodes) {
|
||||
ConnectionWidget connection = (ConnectionWidget) widget;
|
||||
|
||||
ConversationWidget source = (ConversationWidget) connection.getSourceAnchor().getRelatedWidget();
|
||||
ConversationNode sNode = source.getAttachedNode();
|
||||
|
||||
if (!conversationLinks.containsKey(sNode)) {
|
||||
conversationLinks.put(sNode, new ArrayList<ConversationNode>());
|
||||
}
|
||||
|
||||
ConversationWidget target = (ConversationWidget) connection.getTargetAnchor().getRelatedWidget();
|
||||
ConversationNode tNode = target.getAttachedNode();
|
||||
|
||||
if (conversationLinks.containsKey(sNode))
|
||||
conversationLinks.get(sNode).add(tNode);
|
||||
else
|
||||
System.out.println("No key for node " + sNode.getStf());
|
||||
}
|
||||
return conversationLinks;
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,6 @@ import java.awt.event.ActionListener;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.filechooser.FileFilter;
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
@@ -33,6 +32,7 @@ import org.openide.util.Exceptions;
|
||||
import org.openide.util.NbBundle.Messages;
|
||||
import org.openide.windows.TopComponent;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
@@ -101,8 +101,6 @@ public final class SaveConversation implements ActionListener {
|
||||
DocumentBuilder builder = factory.newDocumentBuilder();
|
||||
Document document = builder.newDocument();
|
||||
|
||||
document.createElement("Properties");
|
||||
|
||||
Node xmlNode = saver.serializeData(scene, document);
|
||||
document.appendChild(xmlNode);
|
||||
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
currentVersion=Conversation Script Creator {0}
|
||||
LBL_splash_window_title=Starting Conversation Script Creator
|
||||
SPLASH_HEIGHT=259
|
||||
SPLASH_WIDTH=500
|
||||
SplashProgressBarBounds=0,241,500,6
|
||||
SplashProgressBarColor=0x9FFFFF
|
||||
SplashRunningTextBounds=11,230,475,12
|
||||
SplashRunningTextFontSize=14
|
||||
BIN
branding/core/core.jar/org/netbeans/core/startup/frame.gif
Normal file
BIN
branding/core/core.jar/org/netbeans/core/startup/frame.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 794 B |
BIN
branding/core/core.jar/org/netbeans/core/startup/frame32.gif
Normal file
BIN
branding/core/core.jar/org/netbeans/core/startup/frame32.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.8 KiB |
BIN
branding/core/core.jar/org/netbeans/core/startup/frame48.gif
Normal file
BIN
branding/core/core.jar/org/netbeans/core/startup/frame48.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.1 KiB |
BIN
branding/core/core.jar/org/netbeans/core/startup/splash.gif
Normal file
BIN
branding/core/core.jar/org/netbeans/core/startup/splash.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 80 KiB |
@@ -0,0 +1,2 @@
|
||||
CTL_MainWindow_Title=Conversation Script Creator {0}
|
||||
CTL_MainWindow_Title_No_Project=Conversation Script Creator {0}
|
||||
@@ -1 +0,0 @@
|
||||
user.properties.file=C:\\Users\\Wave\\AppData\\Roaming\\NetBeans\\8.0\\build.properties
|
||||
@@ -1,7 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project-private xmlns="http://www.netbeans.org/ns/project-private/1">
|
||||
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/>
|
||||
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
|
||||
<group/>
|
||||
</open-files>
|
||||
</project-private>
|
||||
Reference in New Issue
Block a user