diff --git a/.gitignore b/.gitignore index 8b9152b..b7b7f70 100644 --- a/.gitignore +++ b/.gitignore @@ -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/ \ No newline at end of file +/dist/ +/nbproject/private/ \ No newline at end of file diff --git a/ConversationCompiler/nbproject/private/private.xml b/ConversationCompiler/nbproject/private/private.xml deleted file mode 100644 index 6807a2b..0000000 --- a/ConversationCompiler/nbproject/private/private.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/ConversationCompiler/src/com/projectswg/tools/csc/compiler/Compiler.java b/ConversationCompiler/src/com/projectswg/tools/csc/compiler/Compiler.java index a2b71f7..68a4f02 100644 --- a/ConversationCompiler/src/com/projectswg/tools/csc/compiler/Compiler.java +++ b/ConversationCompiler/src/com/projectswg/tools/csc/compiler/Compiler.java @@ -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 connectedNodes = scene.getConnectionLayer().getChildren(); - LinkedHashMap> 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()); - } - - 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> conversationLinks = scene.getConversationLinks(); for (Map.Entry> 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"); diff --git a/ConversationEditor/nbproject/private/private.xml b/ConversationEditor/nbproject/private/private.xml deleted file mode 100644 index 6807a2b..0000000 --- a/ConversationEditor/nbproject/private/private.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/ConversationEditor/src/com/projectswg/tools/csc/conversationeditor/ConversationNode.java b/ConversationEditor/src/com/projectswg/tools/csc/conversationeditor/ConversationNode.java index 9025bda..a095489 100644 --- a/ConversationEditor/src/com/projectswg/tools/csc/conversationeditor/ConversationNode.java +++ b/ConversationEditor/src/com/projectswg/tools/csc/conversationeditor/ConversationNode.java @@ -171,7 +171,7 @@ class StfProperty extends PropertySupport.ReadWrite { 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; } diff --git a/ConversationEditor/src/com/projectswg/tools/csc/conversationeditor/SceneSaver.java b/ConversationEditor/src/com/projectswg/tools/csc/conversationeditor/SceneSaver.java index da1fcb5..a9bda0e 100644 --- a/ConversationEditor/src/com/projectswg/tools/csc/conversationeditor/SceneSaver.java +++ b/ConversationEditor/src/com/projectswg/tools/csc/conversationeditor/SceneSaver.java @@ -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 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> 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> conversationLinks, ConversationNode lookNode) { + for (Map.Entry> entry : conversationLinks.entrySet()) { + if (entry.getValue().contains(lookNode)) + return entry.getKey(); + } + return null; + } + + private ConversationNode getTargetNode(LinkedHashMap> conversationLinks, ConversationNode lookNode) { + for (Map.Entry> 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 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 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]; diff --git a/ConversationEditor/src/com/projectswg/tools/csc/conversationeditor/SceneView.java b/ConversationEditor/src/com/projectswg/tools/csc/conversationeditor/SceneView.java index c315001..7268b5c 100644 --- a/ConversationEditor/src/com/projectswg/tools/csc/conversationeditor/SceneView.java +++ b/ConversationEditor/src/com/projectswg/tools/csc/conversationeditor/SceneView.java @@ -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{ private final LayerWidget backgroundLayer; @@ -115,4 +105,29 @@ public class SceneView extends GraphScene{ public void setSceneName(String name) { this.name = name; } + + public LinkedHashMap> getConversationLinks() { + List connectedNodes = connectionLayer.getChildren(); + LinkedHashMap> 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()); + } + + 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; + } } \ No newline at end of file diff --git a/ConversationEditor/src/com/projectswg/tools/csc/conversationeditor/actions/SaveConversation.java b/ConversationEditor/src/com/projectswg/tools/csc/conversationeditor/actions/SaveConversation.java index e111be3..88d2e81 100644 --- a/ConversationEditor/src/com/projectswg/tools/csc/conversationeditor/actions/SaveConversation.java +++ b/ConversationEditor/src/com/projectswg/tools/csc/conversationeditor/actions/SaveConversation.java @@ -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); diff --git a/branding/core/core.jar/org/netbeans/core/startup/Bundle.properties b/branding/core/core.jar/org/netbeans/core/startup/Bundle.properties new file mode 100644 index 0000000..d80ef27 --- /dev/null +++ b/branding/core/core.jar/org/netbeans/core/startup/Bundle.properties @@ -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 diff --git a/branding/core/core.jar/org/netbeans/core/startup/frame.gif b/branding/core/core.jar/org/netbeans/core/startup/frame.gif new file mode 100644 index 0000000..2891709 Binary files /dev/null and b/branding/core/core.jar/org/netbeans/core/startup/frame.gif differ diff --git a/branding/core/core.jar/org/netbeans/core/startup/frame32.gif b/branding/core/core.jar/org/netbeans/core/startup/frame32.gif new file mode 100644 index 0000000..7dfb408 Binary files /dev/null and b/branding/core/core.jar/org/netbeans/core/startup/frame32.gif differ diff --git a/branding/core/core.jar/org/netbeans/core/startup/frame48.gif b/branding/core/core.jar/org/netbeans/core/startup/frame48.gif new file mode 100644 index 0000000..7679a28 Binary files /dev/null and b/branding/core/core.jar/org/netbeans/core/startup/frame48.gif differ diff --git a/branding/core/core.jar/org/netbeans/core/startup/splash.gif b/branding/core/core.jar/org/netbeans/core/startup/splash.gif new file mode 100644 index 0000000..1041ca9 Binary files /dev/null and b/branding/core/core.jar/org/netbeans/core/startup/splash.gif differ diff --git a/branding/modules/org-netbeans-core-windows.jar/org/netbeans/core/windows/view/ui/Bundle.properties b/branding/modules/org-netbeans-core-windows.jar/org/netbeans/core/windows/view/ui/Bundle.properties new file mode 100644 index 0000000..a5f48c7 --- /dev/null +++ b/branding/modules/org-netbeans-core-windows.jar/org/netbeans/core/windows/view/ui/Bundle.properties @@ -0,0 +1,2 @@ +CTL_MainWindow_Title=Conversation Script Creator {0} +CTL_MainWindow_Title_No_Project=Conversation Script Creator {0} diff --git a/nbproject/private/platform-private.properties b/nbproject/private/platform-private.properties deleted file mode 100644 index b0eb319..0000000 --- a/nbproject/private/platform-private.properties +++ /dev/null @@ -1 +0,0 @@ -user.properties.file=C:\\Users\\Wave\\AppData\\Roaming\\NetBeans\\8.0\\build.properties diff --git a/nbproject/private/private.xml b/nbproject/private/private.xml deleted file mode 100644 index 6807a2b..0000000 --- a/nbproject/private/private.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - -