mirror of
https://github.com/badvision/lawless-legends.git
synced 2025-01-13 03:30:28 +00:00
Additional working fixes to blockly integration, the marshalling/unmarshalling of blockly script code is starting to function!
This commit is contained in:
parent
b9b12c9ead
commit
160821f077
@ -1,7 +1,6 @@
|
|||||||
package org.badvision.outlaweditor;
|
package org.badvision.outlaweditor;
|
||||||
|
|
||||||
import java.io.BufferedOutputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.BufferedWriter;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.StringReader;
|
import java.io.StringReader;
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
@ -14,18 +13,30 @@ import javafx.scene.layout.AnchorPane;
|
|||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
import javafx.stage.WindowEvent;
|
import javafx.stage.WindowEvent;
|
||||||
import javax.xml.bind.JAXBContext;
|
import javax.xml.bind.JAXBContext;
|
||||||
|
import javax.xml.bind.JAXBElement;
|
||||||
import javax.xml.bind.JAXBException;
|
import javax.xml.bind.JAXBException;
|
||||||
|
import javax.xml.bind.Unmarshaller;
|
||||||
|
import javax.xml.parsers.DocumentBuilder;
|
||||||
|
import javax.xml.parsers.DocumentBuilderFactory;
|
||||||
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
import org.badvision.outlaweditor.data.xml.Block;
|
import org.badvision.outlaweditor.data.xml.Block;
|
||||||
import org.badvision.outlaweditor.data.xml.Script;
|
import org.badvision.outlaweditor.data.xml.Script;
|
||||||
|
import org.w3c.dom.Document;
|
||||||
|
import org.xml.sax.InputSource;
|
||||||
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mythos Scripting Editor
|
* Mythos Scripting Editor
|
||||||
|
*
|
||||||
* @author blurry
|
* @author blurry
|
||||||
*/
|
*/
|
||||||
public class MythosEditor {
|
public class MythosEditor {
|
||||||
|
|
||||||
Script script;
|
Script script;
|
||||||
Stage primaryStage;
|
Stage primaryStage;
|
||||||
MythosScriptEditorController controller;
|
MythosScriptEditorController controller;
|
||||||
|
public static final String XML_HEADER = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n";
|
||||||
|
|
||||||
public MythosEditor(Script theScript) {
|
public MythosEditor(Script theScript) {
|
||||||
script = theScript;
|
script = theScript;
|
||||||
}
|
}
|
||||||
@ -53,8 +64,13 @@ public class MythosEditor {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
primaryStage.show();
|
primaryStage.show();
|
||||||
|
controller.onLoad(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
loadScript();
|
loadScript();
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public void close() {
|
public void close() {
|
||||||
primaryStage.close();
|
primaryStage.close();
|
||||||
@ -63,13 +79,19 @@ public class MythosEditor {
|
|||||||
public void applyChanges() {
|
public void applyChanges() {
|
||||||
try {
|
try {
|
||||||
String xml = String.valueOf(controller.editorView.getEngine().executeScript("Blockly.Xml.workspaceToDom(Blockly.mainWorkspace).outerHTML"));
|
String xml = String.valueOf(controller.editorView.getEngine().executeScript("Blockly.Xml.workspaceToDom(Blockly.mainWorkspace).outerHTML"));
|
||||||
JAXBContext context = JAXBContext.newInstance(Block.class);
|
xml = xml.replace("<xml>", "");
|
||||||
Block scriptBlock = (Block) context.createUnmarshaller().unmarshal(new StringReader(xml));
|
xml = xml.replace("</xml>", "");
|
||||||
script.setBlock(scriptBlock);
|
JAXBContext context = JAXBContext.newInstance("org.badvision.outlaweditor.data.xml");
|
||||||
} catch (JAXBException ex) {
|
Unmarshaller unmarshaller = context.createUnmarshaller();
|
||||||
|
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
|
||||||
|
dbf.setNamespaceAware(true);
|
||||||
|
DocumentBuilder db = dbf.newDocumentBuilder();
|
||||||
|
Document doc = db.parse(new ByteArrayInputStream(xml.getBytes("UTF-8")));
|
||||||
|
JAXBElement<Block> b = unmarshaller.unmarshal(doc, Block.class);
|
||||||
|
script.setBlock(b.getValue());
|
||||||
|
} catch (JAXBException | ParserConfigurationException | SAXException | IOException ex) {
|
||||||
Logger.getLogger(MythosEditor.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(MythosEditor.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadScript() {
|
public void loadScript() {
|
||||||
@ -89,13 +111,14 @@ public class MythosEditor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void loadScript(String xml) {
|
public void loadScript(String xml) {
|
||||||
xml = xml.replaceAll("\"","\\\"");
|
xml = XML_HEADER + xml;
|
||||||
String loadScript = "var xml = Blockly.Xml.textToDom("+xml+");";
|
xml = xml.replaceAll("'", "\\'");
|
||||||
loadScript += "Blockly.Xml.domToWorkspace(Blockly.mainWorkspace, xml);";
|
xml = xml.replaceAll("\n", "");
|
||||||
|
String loadScript = "Blockly.Xml.domToWorkspace(Blockly.mainWorkspace, Blockly.Xml.textToDom('" + xml + "'));";
|
||||||
controller.editorView.getEngine().executeScript(loadScript);
|
controller.editorView.getEngine().executeScript(loadScript);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String createDefaultScript() {
|
private String createDefaultScript() {
|
||||||
return "<block/>";
|
return "<xml><block type=\"procedures_defreturn\" id=\"1\" inline=\"false\" x=\"5\" y=\"5\"><mutation></mutation><field name=\"NAME\">New function</field></block></xml>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,12 @@
|
|||||||
package org.badvision.outlaweditor;
|
package org.badvision.outlaweditor;
|
||||||
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
import java.util.ResourceBundle;
|
import java.util.ResourceBundle;
|
||||||
|
import javafx.beans.value.ChangeListener;
|
||||||
|
import javafx.beans.value.ObservableValue;
|
||||||
|
import javafx.concurrent.Worker.State;
|
||||||
import javafx.event.ActionEvent;
|
import javafx.event.ActionEvent;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.fxml.Initializable;
|
import javafx.fxml.Initializable;
|
||||||
@ -13,6 +18,15 @@ public class MythosScriptEditorController
|
|||||||
implements Initializable {
|
implements Initializable {
|
||||||
|
|
||||||
public static final String MYTHOS_EDITOR = "/mythos/mythos-editor/html/editor.html";
|
public static final String MYTHOS_EDITOR = "/mythos/mythos-editor/html/editor.html";
|
||||||
|
private final List<Runnable> onLoadEvents = new ArrayList<>();
|
||||||
|
boolean loaded = false;
|
||||||
|
public synchronized void onLoad(Runnable runnable) {
|
||||||
|
if (loaded) {
|
||||||
|
runnable.run();
|
||||||
|
} else {
|
||||||
|
onLoadEvents.add(runnable);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@FXML // fx:id="editorView"
|
@FXML // fx:id="editorView"
|
||||||
WebView editorView; // Value injected by FXMLLoader
|
WebView editorView; // Value injected by FXMLLoader
|
||||||
@ -73,6 +87,19 @@ public class MythosScriptEditorController
|
|||||||
|
|
||||||
@Override // This method is called by the FXMLLoader when initialization is complete
|
@Override // This method is called by the FXMLLoader when initialization is complete
|
||||||
public void initialize(URL fxmlFileLocation, ResourceBundle resources) {
|
public void initialize(URL fxmlFileLocation, ResourceBundle resources) {
|
||||||
|
editorView.getEngine().getLoadWorker().stateProperty().addListener(
|
||||||
|
new ChangeListener<State>() {
|
||||||
|
public void changed(ObservableValue ov, State oldState, State newState) {
|
||||||
|
if (newState == State.SUCCEEDED) {
|
||||||
|
loaded = true;
|
||||||
|
for (Runnable r : onLoadEvents) {
|
||||||
|
r.run();
|
||||||
|
}
|
||||||
|
onLoadEvents.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
assert editorView != null : "fx:id=\"editorView\" was not injected: check your FXML file 'MythosScriptEditor.fxml'.";
|
assert editorView != null : "fx:id=\"editorView\" was not injected: check your FXML file 'MythosScriptEditor.fxml'.";
|
||||||
assert menuItemAbortChanges != null : "fx:id=\"menuItemAbortChanges\" was not injected: check your FXML file 'MythosScriptEditor.fxml'.";
|
assert menuItemAbortChanges != null : "fx:id=\"menuItemAbortChanges\" was not injected: check your FXML file 'MythosScriptEditor.fxml'.";
|
||||||
assert menuItemAboutBlockly != null : "fx:id=\"menuItemAboutBlockly\" was not injected: check your FXML file 'MythosScriptEditor.fxml'.";
|
assert menuItemAboutBlockly != null : "fx:id=\"menuItemAboutBlockly\" was not injected: check your FXML file 'MythosScriptEditor.fxml'.";
|
||||||
|
@ -31,6 +31,8 @@ import javax.swing.JOptionPane;
|
|||||||
import javax.xml.bind.JAXB;
|
import javax.xml.bind.JAXB;
|
||||||
import org.badvision.outlaweditor.data.TilesetUtils;
|
import org.badvision.outlaweditor.data.TilesetUtils;
|
||||||
import org.badvision.outlaweditor.data.xml.GameData;
|
import org.badvision.outlaweditor.data.xml.GameData;
|
||||||
|
import org.badvision.outlaweditor.data.xml.IntervalScript;
|
||||||
|
import org.badvision.outlaweditor.data.xml.Map;
|
||||||
import org.badvision.outlaweditor.data.xml.Script;
|
import org.badvision.outlaweditor.data.xml.Script;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -203,6 +205,10 @@ public class UIAction {
|
|||||||
script.setName("New Script");
|
script.setName("New Script");
|
||||||
MythosEditor editor = new MythosEditor(script);
|
MythosEditor editor = new MythosEditor(script);
|
||||||
editor.show();
|
editor.show();
|
||||||
|
if (Application.instance.controller.currentMap.getScripts() == null) {
|
||||||
|
Application.instance.controller.currentMap.setScripts(new Map.Scripts());
|
||||||
|
}
|
||||||
|
Application.instance.controller.currentMap.getScripts().getScript().add(script);
|
||||||
return script;
|
return script;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,9 @@ import org.badvision.outlaweditor.data.xml.*;
|
|||||||
* @author brobert
|
* @author brobert
|
||||||
*/
|
*/
|
||||||
public class TileUtils {
|
public class TileUtils {
|
||||||
|
|
||||||
static Map<String, Map<Platform, WritableImage>> display;
|
static Map<String, Map<Platform, WritableImage>> display;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
clear();
|
clear();
|
||||||
}
|
}
|
||||||
@ -51,7 +53,13 @@ public class TileUtils {
|
|||||||
public static void redrawTile(Tile t) {
|
public static void redrawTile(Tile t) {
|
||||||
Map<Platform, WritableImage> displays = getDisplay(t);
|
Map<Platform, WritableImage> displays = getDisplay(t);
|
||||||
for (PlatformData d : t.getDisplayData()) {
|
for (PlatformData d : t.getDisplayData()) {
|
||||||
Platform p = Platform.valueOf(d.getPlatform());
|
Platform p;
|
||||||
|
try {
|
||||||
|
p = Platform.valueOf(d.getPlatform());
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
System.err.println("Unable to find any platform support for '" + d.getPlatform() + "'");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
displays.put(p, p.tileRenderer.redrawSprite(d.getValue(), displays.get(p)));
|
displays.put(p, p.tileRenderer.redrawSprite(d.getValue(), displays.get(p)));
|
||||||
}
|
}
|
||||||
DataProducer.notifyObservers(t);
|
DataProducer.notifyObservers(t);
|
||||||
|
@ -2,15 +2,11 @@
|
|||||||
|
|
||||||
<?import java.lang.*?>
|
<?import java.lang.*?>
|
||||||
<?import java.net.*?>
|
<?import java.net.*?>
|
||||||
<?import java.util.*?>
|
|
||||||
<?import javafx.collections.*?>
|
<?import javafx.collections.*?>
|
||||||
<?import javafx.geometry.*?>
|
|
||||||
<?import javafx.scene.*?>
|
|
||||||
<?import javafx.scene.control.*?>
|
<?import javafx.scene.control.*?>
|
||||||
<?import javafx.scene.image.*?>
|
|
||||||
<?import javafx.scene.layout.*?>
|
<?import javafx.scene.layout.*?>
|
||||||
|
|
||||||
<AnchorPane id="AnchorPane" prefHeight="500.0" prefWidth="800.0" styleClass="mainFxmlClass" xmlns:fx="http://javafx.com/fxml" fx:controller="org.badvision.outlaweditor.ApplicationUIControllerImpl">
|
<AnchorPane id="AnchorPane" prefHeight="575.0" prefWidth="1000.0" styleClass="mainFxmlClass" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="org.badvision.outlaweditor.ApplicationUIControllerImpl">
|
||||||
<children>
|
<children>
|
||||||
<VBox prefHeight="500.0" prefWidth="800.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
<VBox prefHeight="500.0" prefWidth="800.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||||
<children>
|
<children>
|
||||||
@ -73,7 +69,7 @@
|
|||||||
<Button mnemonicParsing="false" onAction="#onTileDeletePressed" text="Delete" />
|
<Button mnemonicParsing="false" onAction="#onTileDeletePressed" text="Delete" />
|
||||||
<MenuButton mnemonicParsing="false" text="Tools">
|
<MenuButton mnemonicParsing="false" text="Tools">
|
||||||
<items>
|
<items>
|
||||||
<Menu mnemonicParsing="false" text="Pattern" fx:id="tilePatternMenu" />
|
<Menu fx:id="tilePatternMenu" mnemonicParsing="false" text="Pattern" />
|
||||||
<Menu mnemonicParsing="false" text="Draw mode">
|
<Menu mnemonicParsing="false" text="Draw mode">
|
||||||
<items>
|
<items>
|
||||||
<MenuItem mnemonicParsing="false" onAction="#tileBitMode" text="Bit Toggle" />
|
<MenuItem mnemonicParsing="false" onAction="#tileBitMode" text="Bit Toggle" />
|
||||||
@ -90,13 +86,13 @@
|
|||||||
<children>
|
<children>
|
||||||
<AnchorPane id="imageDetailsPane" prefHeight="200.0" prefWidth="200.0">
|
<AnchorPane id="imageDetailsPane" prefHeight="200.0" prefWidth="200.0">
|
||||||
<children>
|
<children>
|
||||||
<Label layoutX="4.0" layoutY="14.0" text="Name" />
|
<Label layoutX="5.0" layoutY="5.0" prefHeight="29.0" prefWidth="37.0" text="Name" />
|
||||||
<TextField id="" fx:id="tileNameField" layoutX="53.0" layoutY="11.0" prefWidth="147.0" />
|
<TextField id="" fx:id="tileNameField" layoutX="54.0" layoutY="5.0" prefWidth="147.0" />
|
||||||
<Label layoutX="4.0" layoutY="36.0" text="ID" />
|
<Label layoutX="5.0" layoutY="33.0" prefHeight="29.0" prefWidth="46.0" text="ID" />
|
||||||
<TextField fx:id="tileIdField" layoutX="53.0" layoutY="33.0" prefWidth="147.0" />
|
<TextField fx:id="tileIdField" layoutX="54.0" layoutY="36.0" prefWidth="147.0" />
|
||||||
<Label layoutX="4.0" layoutY="58.0" text="Category" />
|
<Label layoutX="5.0" layoutY="72.0" text="Category" />
|
||||||
<TextField fx:id="tileCategoryField" layoutX="74.0" layoutY="55.0" prefWidth="126.0" />
|
<TextField fx:id="tileCategoryField" layoutX="64.0" layoutY="67.0" prefHeight="26.0" prefWidth="137.0" />
|
||||||
<CheckBox fx:id="tileObstructionField" layoutX="4.0" layoutY="78.0" mnemonicParsing="false" text="Physical Obstruction" />
|
<CheckBox fx:id="tileObstructionField" layoutX="6.0" layoutY="98.0" mnemonicParsing="false" text="Physical Obstruction" />
|
||||||
</children>
|
</children>
|
||||||
</AnchorPane>
|
</AnchorPane>
|
||||||
<AnchorPane fx:id="tileEditorAnchorPane" prefHeight="387.0" prefWidth="477.0000999999975" HBox.hgrow="ALWAYS" />
|
<AnchorPane fx:id="tileEditorAnchorPane" prefHeight="387.0" prefWidth="477.0000999999975" HBox.hgrow="ALWAYS" />
|
||||||
@ -133,7 +129,7 @@
|
|||||||
<Button mnemonicParsing="false" onAction="#onMapPreviewPressed" text="Preview" />
|
<Button mnemonicParsing="false" onAction="#onMapPreviewPressed" text="Preview" />
|
||||||
<MenuButton mnemonicParsing="false" text="Tools">
|
<MenuButton mnemonicParsing="false" text="Tools">
|
||||||
<items>
|
<items>
|
||||||
<Menu mnemonicParsing="false" text="Change tile" fx:id="mapSelectTile" />
|
<Menu fx:id="mapSelectTile" mnemonicParsing="false" text="Change tile" />
|
||||||
<Menu mnemonicParsing="false" text="Draw mode">
|
<Menu mnemonicParsing="false" text="Draw mode">
|
||||||
<items>
|
<items>
|
||||||
<MenuItem mnemonicParsing="false" onAction="#mapDraw1" text="Radius 1" />
|
<MenuItem mnemonicParsing="false" onAction="#mapDraw1" text="Radius 1" />
|
||||||
@ -220,7 +216,7 @@
|
|||||||
<Button mnemonicParsing="false" onAction="#onImageDeletePressed" text="Delete" />
|
<Button mnemonicParsing="false" onAction="#onImageDeletePressed" text="Delete" />
|
||||||
<MenuButton mnemonicParsing="false" text="Tools">
|
<MenuButton mnemonicParsing="false" text="Tools">
|
||||||
<items>
|
<items>
|
||||||
<Menu mnemonicParsing="false" text="Pattern" fx:id="imagePatternMenu" />
|
<Menu fx:id="imagePatternMenu" mnemonicParsing="false" text="Pattern" />
|
||||||
<Menu mnemonicParsing="false" text="Draw mode">
|
<Menu mnemonicParsing="false" text="Draw mode">
|
||||||
<items>
|
<items>
|
||||||
<MenuItem mnemonicParsing="false" onAction="#imageBitMode" text="Bit Toggle mode" />
|
<MenuItem mnemonicParsing="false" onAction="#imageBitMode" text="Bit Toggle mode" />
|
||||||
|
@ -1,14 +1,11 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
<?import java.lang.*?>
|
<?import java.lang.*?>
|
||||||
<?import java.net.*?>
|
|
||||||
<?import java.util.*?>
|
|
||||||
<?import javafx.scene.*?>
|
|
||||||
<?import javafx.scene.control.*?>
|
<?import javafx.scene.control.*?>
|
||||||
<?import javafx.scene.layout.*?>
|
<?import javafx.scene.layout.*?>
|
||||||
<?import javafx.scene.web.*?>
|
<?import javafx.scene.web.*?>
|
||||||
|
|
||||||
<AnchorPane id="AnchorPane" prefHeight="400.0" prefWidth="600.0" styleClass="mainFxmlClass" xmlns:fx="http://javafx.com/fxml" fx:controller="org.badvision.outlaweditor.MythosScriptEditorController">
|
<AnchorPane id="AnchorPane" prefHeight="748.0" prefWidth="1024.0" styleClass="mainFxmlClass" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/8" fx:controller="org.badvision.outlaweditor.MythosScriptEditorController">
|
||||||
<!-- <stylesheets>
|
<!-- <stylesheets>
|
||||||
<URL value="@/styles/mythosscripteditor.css"/>
|
<URL value="@/styles/mythosscripteditor.css"/>
|
||||||
</stylesheets>-->
|
</stylesheets>-->
|
||||||
@ -17,20 +14,20 @@
|
|||||||
<menus>
|
<menus>
|
||||||
<Menu mnemonicParsing="false" text="MythosScript">
|
<Menu mnemonicParsing="false" text="MythosScript">
|
||||||
<items>
|
<items>
|
||||||
<MenuItem mnemonicParsing="false" onAction="#onApplyChangesSelected" text="Apply changes" fx:id="menuItemApplyChanges" />
|
<MenuItem fx:id="menuItemApplyChanges" mnemonicParsing="false" onAction="#onApplyChangesSelected" text="Apply changes" />
|
||||||
<MenuItem mnemonicParsing="false" onAction="#onAbortChangesSelected" text="Abort changes" fx:id="menuItemAbortChanges" />
|
<MenuItem fx:id="menuItemAbortChanges" mnemonicParsing="false" onAction="#onAbortChangesSelected" text="Abort changes" />
|
||||||
</items>
|
</items>
|
||||||
</Menu>
|
</Menu>
|
||||||
<Menu mnemonicParsing="false" text="Edit">
|
<Menu mnemonicParsing="false" text="Edit">
|
||||||
<items>
|
<items>
|
||||||
<MenuItem mnemonicParsing="false" onAction="#onUndoSelected" text="Undo" fx:id="menuItemUndo" />
|
<MenuItem fx:id="menuItemUndo" mnemonicParsing="false" onAction="#onUndoSelected" text="Undo" />
|
||||||
<MenuItem mnemonicParsing="false" onAction="#onRedoSelected" text="Redo" fx:id="menuItemRedo" />
|
<MenuItem fx:id="menuItemRedo" mnemonicParsing="false" onAction="#onRedoSelected" text="Redo" />
|
||||||
</items>
|
</items>
|
||||||
</Menu>
|
</Menu>
|
||||||
<Menu mnemonicParsing="false" text="Help">
|
<Menu mnemonicParsing="false" text="Help">
|
||||||
<items>
|
<items>
|
||||||
<MenuItem mnemonicParsing="false" onAction="#onMythosHelpSelected" text="Mythos Script Help" fx:id="menuItemMythosHelp" />
|
<MenuItem fx:id="menuItemMythosHelp" mnemonicParsing="false" onAction="#onMythosHelpSelected" text="Mythos Script Help" />
|
||||||
<MenuItem mnemonicParsing="false" onAction="#onAboutBlocklySelected" text="About Blockly" fx:id="menuItemAboutBlockly" />
|
<MenuItem fx:id="menuItemAboutBlockly" mnemonicParsing="false" onAction="#onAboutBlocklySelected" text="About Blockly" />
|
||||||
</items>
|
</items>
|
||||||
</Menu>
|
</Menu>
|
||||||
</menus>
|
</menus>
|
||||||
|
@ -64,14 +64,9 @@
|
|||||||
</xs:element>
|
</xs:element>
|
||||||
<xs:element name="scripts">
|
<xs:element name="scripts">
|
||||||
<xs:complexType>
|
<xs:complexType>
|
||||||
<xs:choice maxOccurs="unbounded">
|
<xs:sequence>
|
||||||
<xs:element name="enter" type="tns:script" minOccurs="0"/>
|
<xs:element name="script" type="tns:script" minOccurs="1" maxOccurs="unbounded"/>
|
||||||
<xs:element name="exit" type="tns:script" minOccurs="0"/>
|
</xs:sequence>
|
||||||
<xs:element name="stepOn" type="tns:locationScript" minOccurs="0"/>
|
|
||||||
<xs:element name="stepOff" type="tns:locationScript" minOccurs="0" />
|
|
||||||
<xs:element name="interact" type="tns:locationScript" minOccurs="0"/>
|
|
||||||
<xs:element name="interval" type="tns:intervalScript" minOccurs="0"/>
|
|
||||||
</xs:choice>
|
|
||||||
</xs:complexType>
|
</xs:complexType>
|
||||||
</xs:element>
|
</xs:element>
|
||||||
</xs:sequence>
|
</xs:sequence>
|
||||||
@ -94,6 +89,9 @@
|
|||||||
</xs:sequence>
|
</xs:sequence>
|
||||||
<xs:attribute name="inline" type="xs:boolean"/>
|
<xs:attribute name="inline" type="xs:boolean"/>
|
||||||
<xs:attribute name="type" use="required" type="xs:NCName"/>
|
<xs:attribute name="type" use="required" type="xs:NCName"/>
|
||||||
|
<xs:attribute name="id" type="xs:integer"/>
|
||||||
|
<xs:attribute name="uri" type="xs:string"/>
|
||||||
|
<xs:attribute name="local" type="xs:string"/>
|
||||||
<xs:attribute name="x" type="xs:integer"/>
|
<xs:attribute name="x" type="xs:integer"/>
|
||||||
<xs:attribute name="y" type="xs:integer"/>
|
<xs:attribute name="y" type="xs:integer"/>
|
||||||
</xs:complexType>
|
</xs:complexType>
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="blocklyDiv" style="height: 550px; width: 800px;"></div>
|
<div id="blocklyDiv" style="height: 700px; width: 996px;"></div>
|
||||||
|
|
||||||
<xml id="toolbox" style="display: none">
|
<xml id="toolbox" style="display: none">
|
||||||
<category name="Variables">
|
<category name="Variables">
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
<gameData xmlns="outlaw">
|
<gameData xmlns="outlaw">
|
||||||
<map>
|
<map>
|
||||||
<scripts>
|
<scripts>
|
||||||
<enter>
|
<script>
|
||||||
<name>name</name>
|
<name>name</name>
|
||||||
<description>description</description>
|
<description>description</description>
|
||||||
<block type="variables_set" inline="true" x="245" y="27">
|
<block type="variables_set" inline="true" x="245" y="27">
|
||||||
@ -47,7 +47,7 @@
|
|||||||
</block>
|
</block>
|
||||||
</next>
|
</next>
|
||||||
</block>
|
</block>
|
||||||
</enter>
|
</script>
|
||||||
</scripts>
|
</scripts>
|
||||||
</map>
|
</map>
|
||||||
</gameData>
|
</gameData>
|
@ -2,7 +2,7 @@
|
|||||||
<gameData xmlns="outlaw">
|
<gameData xmlns="outlaw">
|
||||||
<map>
|
<map>
|
||||||
<scripts>
|
<scripts>
|
||||||
<enter>
|
<script>
|
||||||
<name>name</name>
|
<name>name</name>
|
||||||
<description>description</description>
|
<description>description</description>
|
||||||
<block type="procedures_defreturn" inline="false" x="213" y="27">
|
<block type="procedures_defreturn" inline="false" x="213" y="27">
|
||||||
@ -112,7 +112,26 @@
|
|||||||
<block type="logic_null"></block>
|
<block type="logic_null"></block>
|
||||||
</value>
|
</value>
|
||||||
</block>
|
</block>
|
||||||
</enter>
|
</script>
|
||||||
|
<script>
|
||||||
|
<name>name</name>
|
||||||
|
<description>description</description>
|
||||||
|
<block type="procedures_defreturn" id="2" inline="false" x="3" y="5">
|
||||||
|
<mutation></mutation>
|
||||||
|
<field name="NAME">New function2</field>
|
||||||
|
<statement name="STACK">
|
||||||
|
<block type="text_moveto" id="20">
|
||||||
|
<field name="x">0</field>
|
||||||
|
<field name="y">0</field>
|
||||||
|
<next>
|
||||||
|
<block type="math_change" id="32" inline="true">
|
||||||
|
<field name="VAR">item</field>
|
||||||
|
</block>
|
||||||
|
</next>
|
||||||
|
</block>
|
||||||
|
</statement>
|
||||||
|
</block>
|
||||||
|
</script>
|
||||||
</scripts>
|
</scripts>
|
||||||
</map>
|
</map>
|
||||||
</gameData>
|
</gameData>
|
@ -5,9 +5,7 @@ import java.io.IOException;
|
|||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
import javax.xml.bind.JAXB;
|
import javax.xml.bind.JAXB;
|
||||||
import javax.xml.bind.JAXBContext;
|
import javax.xml.bind.JAXBContext;
|
||||||
import javax.xml.bind.JAXBElement;
|
|
||||||
import javax.xml.bind.Marshaller;
|
import javax.xml.bind.Marshaller;
|
||||||
import javax.xml.namespace.QName;
|
|
||||||
import org.badvision.outlaweditor.data.xml.Block;
|
import org.badvision.outlaweditor.data.xml.Block;
|
||||||
import org.badvision.outlaweditor.data.xml.GameData;
|
import org.badvision.outlaweditor.data.xml.GameData;
|
||||||
import org.badvision.outlaweditor.data.xml.Map;
|
import org.badvision.outlaweditor.data.xml.Map;
|
||||||
@ -53,7 +51,7 @@ public class TestMythosEditor {
|
|||||||
script.setDescription("description");
|
script.setDescription("description");
|
||||||
script.setBlock(theBlock);
|
script.setBlock(theBlock);
|
||||||
map.setScripts(new Scripts());
|
map.setScripts(new Scripts());
|
||||||
map.getScripts().getEnterOrExitOrStepOn().add(new JAXBElement<Script>(new QName("outlaw", "enter"), Script.class, script));
|
map.getScripts().getScript().add(script);
|
||||||
m.marshal(d, testWriter);
|
m.marshal(d, testWriter);
|
||||||
String testOutput = testWriter.getBuffer().toString();
|
String testOutput = testWriter.getBuffer().toString();
|
||||||
assertNotNull(testOutput);
|
assertNotNull(testOutput);
|
||||||
@ -92,9 +90,9 @@ public class TestMythosEditor {
|
|||||||
assertEquals(1, gd.getMap().size());
|
assertEquals(1, gd.getMap().size());
|
||||||
Scripts s = gd.getMap().get(0).getScripts();
|
Scripts s = gd.getMap().get(0).getScripts();
|
||||||
assertNotNull(s);
|
assertNotNull(s);
|
||||||
assertNotNull(s.getEnterOrExitOrStepOn());
|
assertNotNull(s.getScript());
|
||||||
assertEquals(1, s.getEnterOrExitOrStepOn().size());
|
assertTrue(s.getScript().size() > 0);
|
||||||
Script scr = (Script) s.getEnterOrExitOrStepOn().get(0).getValue();
|
Script scr = (Script) s.getScript().get(0);
|
||||||
return scr.getBlock();
|
return scr.getBlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user