mirror of
https://github.com/badvision/lawless-legends.git
synced 2024-12-24 21:30:11 +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;
|
||||
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.StringReader;
|
||||
import java.io.StringWriter;
|
||||
@ -14,22 +13,34 @@ import javafx.scene.layout.AnchorPane;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.stage.WindowEvent;
|
||||
import javax.xml.bind.JAXBContext;
|
||||
import javax.xml.bind.JAXBElement;
|
||||
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.Script;
|
||||
import org.w3c.dom.Document;
|
||||
import org.xml.sax.InputSource;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
/**
|
||||
* Mythos Scripting Editor
|
||||
*
|
||||
* @author blurry
|
||||
*/
|
||||
public class MythosEditor {
|
||||
|
||||
Script script;
|
||||
Stage primaryStage;
|
||||
MythosScriptEditorController controller;
|
||||
public static final String XML_HEADER = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n";
|
||||
|
||||
public MythosEditor(Script theScript) {
|
||||
script = theScript;
|
||||
}
|
||||
|
||||
|
||||
public void show() {
|
||||
primaryStage = new Stage();
|
||||
javafx.application.Platform.setImplicitExit(true);
|
||||
@ -45,7 +56,7 @@ public class MythosEditor {
|
||||
} catch (IOException exception) {
|
||||
throw new RuntimeException(exception);
|
||||
}
|
||||
|
||||
|
||||
primaryStage.setOnCloseRequest(new EventHandler<WindowEvent>() {
|
||||
@Override
|
||||
public void handle(final WindowEvent t) {
|
||||
@ -53,9 +64,14 @@ public class MythosEditor {
|
||||
}
|
||||
});
|
||||
primaryStage.show();
|
||||
loadScript();
|
||||
controller.onLoad(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
loadScript();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public void close() {
|
||||
primaryStage.close();
|
||||
}
|
||||
@ -63,15 +79,21 @@ public class MythosEditor {
|
||||
public void applyChanges() {
|
||||
try {
|
||||
String xml = String.valueOf(controller.editorView.getEngine().executeScript("Blockly.Xml.workspaceToDom(Blockly.mainWorkspace).outerHTML"));
|
||||
JAXBContext context = JAXBContext.newInstance(Block.class);
|
||||
Block scriptBlock = (Block) context.createUnmarshaller().unmarshal(new StringReader(xml));
|
||||
script.setBlock(scriptBlock);
|
||||
} catch (JAXBException ex) {
|
||||
xml = xml.replace("<xml>", "");
|
||||
xml = xml.replace("</xml>", "");
|
||||
JAXBContext context = JAXBContext.newInstance("org.badvision.outlaweditor.data.xml");
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void loadScript() {
|
||||
if (script == null || script.getBlock() == null) {
|
||||
loadScript(createDefaultScript());
|
||||
@ -87,15 +109,16 @@ public class MythosEditor {
|
||||
Logger.getLogger(MythosEditor.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void loadScript(String xml) {
|
||||
xml = xml.replaceAll("\"","\\\"");
|
||||
String loadScript = "var xml = Blockly.Xml.textToDom("+xml+");";
|
||||
loadScript += "Blockly.Xml.domToWorkspace(Blockly.mainWorkspace, xml);";
|
||||
controller.editorView.getEngine().executeScript(loadScript);
|
||||
xml = XML_HEADER + xml;
|
||||
xml = xml.replaceAll("'", "\\'");
|
||||
xml = xml.replaceAll("\n", "");
|
||||
String loadScript = "Blockly.Xml.domToWorkspace(Blockly.mainWorkspace, Blockly.Xml.textToDom('" + xml + "'));";
|
||||
controller.editorView.getEngine().executeScript(loadScript);
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
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.fxml.FXML;
|
||||
import javafx.fxml.Initializable;
|
||||
@ -13,6 +18,15 @@ public class MythosScriptEditorController
|
||||
implements Initializable {
|
||||
|
||||
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"
|
||||
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
|
||||
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 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'.";
|
||||
|
@ -31,6 +31,8 @@ import javax.swing.JOptionPane;
|
||||
import javax.xml.bind.JAXB;
|
||||
import org.badvision.outlaweditor.data.TilesetUtils;
|
||||
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;
|
||||
|
||||
/**
|
||||
@ -203,6 +205,10 @@ public class UIAction {
|
||||
script.setName("New Script");
|
||||
MythosEditor editor = new MythosEditor(script);
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -12,15 +12,17 @@ import org.badvision.outlaweditor.data.xml.*;
|
||||
* @author brobert
|
||||
*/
|
||||
public class TileUtils {
|
||||
|
||||
static Map<String, Map<Platform, WritableImage>> display;
|
||||
|
||||
static {
|
||||
clear();
|
||||
}
|
||||
|
||||
|
||||
public static void clear() {
|
||||
display = new ConcurrentHashMap<>();
|
||||
display = new ConcurrentHashMap<>();
|
||||
}
|
||||
|
||||
|
||||
public static Tile newTile() {
|
||||
Tile t = new Tile();
|
||||
t.setObstruction(false);
|
||||
@ -40,18 +42,24 @@ public class TileUtils {
|
||||
}
|
||||
return t.getId();
|
||||
}
|
||||
|
||||
|
||||
public static Map<Platform, WritableImage> getDisplay(Tile t) {
|
||||
if (display.get(getId(t)) == null) {
|
||||
display.put(getId(t), new EnumMap<Platform, WritableImage>(Platform.class));
|
||||
}
|
||||
return display.get(getId(t));
|
||||
}
|
||||
|
||||
|
||||
public static void redrawTile(Tile t) {
|
||||
Map<Platform, WritableImage> displays = getDisplay(t);
|
||||
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)));
|
||||
}
|
||||
DataProducer.notifyObservers(t);
|
||||
@ -63,17 +71,17 @@ public class TileUtils {
|
||||
return d.getValue();
|
||||
}
|
||||
}
|
||||
byte[] out = new byte[p.dataHeight*p.dataWidth];
|
||||
byte[] out = new byte[p.dataHeight * p.dataWidth];
|
||||
setPlatformData(t, p, out);
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
public static WritableImage getImage(Tile t, Platform p) {
|
||||
Map<Platform, WritableImage> displays = getDisplay(t);
|
||||
byte[] data = getPlatformData(t, p);
|
||||
return displays.put(p, p.tileRenderer.redrawSprite(data, displays.get(p)));
|
||||
}
|
||||
|
||||
|
||||
public static void setImage(Tile t, Platform p, WritableImage img) {
|
||||
Map<Platform, WritableImage> displays = getDisplay(t);
|
||||
displays.put(p, img);
|
||||
@ -91,4 +99,4 @@ public class TileUtils {
|
||||
d.setValue(b);
|
||||
t.getDisplayData().add(d);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,15 +2,11 @@
|
||||
|
||||
<?import java.lang.*?>
|
||||
<?import java.net.*?>
|
||||
<?import java.util.*?>
|
||||
<?import javafx.collections.*?>
|
||||
<?import javafx.geometry.*?>
|
||||
<?import javafx.scene.*?>
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import javafx.scene.image.*?>
|
||||
<?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>
|
||||
<VBox prefHeight="500.0" prefWidth="800.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||
<children>
|
||||
@ -73,7 +69,7 @@
|
||||
<Button mnemonicParsing="false" onAction="#onTileDeletePressed" text="Delete" />
|
||||
<MenuButton mnemonicParsing="false" text="Tools">
|
||||
<items>
|
||||
<Menu mnemonicParsing="false" text="Pattern" fx:id="tilePatternMenu" />
|
||||
<Menu fx:id="tilePatternMenu" mnemonicParsing="false" text="Pattern" />
|
||||
<Menu mnemonicParsing="false" text="Draw mode">
|
||||
<items>
|
||||
<MenuItem mnemonicParsing="false" onAction="#tileBitMode" text="Bit Toggle" />
|
||||
@ -90,13 +86,13 @@
|
||||
<children>
|
||||
<AnchorPane id="imageDetailsPane" prefHeight="200.0" prefWidth="200.0">
|
||||
<children>
|
||||
<Label layoutX="4.0" layoutY="14.0" text="Name" />
|
||||
<TextField id="" fx:id="tileNameField" layoutX="53.0" layoutY="11.0" prefWidth="147.0" />
|
||||
<Label layoutX="4.0" layoutY="36.0" text="ID" />
|
||||
<TextField fx:id="tileIdField" layoutX="53.0" layoutY="33.0" prefWidth="147.0" />
|
||||
<Label layoutX="4.0" layoutY="58.0" text="Category" />
|
||||
<TextField fx:id="tileCategoryField" layoutX="74.0" layoutY="55.0" prefWidth="126.0" />
|
||||
<CheckBox fx:id="tileObstructionField" layoutX="4.0" layoutY="78.0" mnemonicParsing="false" text="Physical Obstruction" />
|
||||
<Label layoutX="5.0" layoutY="5.0" prefHeight="29.0" prefWidth="37.0" text="Name" />
|
||||
<TextField id="" fx:id="tileNameField" layoutX="54.0" layoutY="5.0" prefWidth="147.0" />
|
||||
<Label layoutX="5.0" layoutY="33.0" prefHeight="29.0" prefWidth="46.0" text="ID" />
|
||||
<TextField fx:id="tileIdField" layoutX="54.0" layoutY="36.0" prefWidth="147.0" />
|
||||
<Label layoutX="5.0" layoutY="72.0" text="Category" />
|
||||
<TextField fx:id="tileCategoryField" layoutX="64.0" layoutY="67.0" prefHeight="26.0" prefWidth="137.0" />
|
||||
<CheckBox fx:id="tileObstructionField" layoutX="6.0" layoutY="98.0" mnemonicParsing="false" text="Physical Obstruction" />
|
||||
</children>
|
||||
</AnchorPane>
|
||||
<AnchorPane fx:id="tileEditorAnchorPane" prefHeight="387.0" prefWidth="477.0000999999975" HBox.hgrow="ALWAYS" />
|
||||
@ -133,7 +129,7 @@
|
||||
<Button mnemonicParsing="false" onAction="#onMapPreviewPressed" text="Preview" />
|
||||
<MenuButton mnemonicParsing="false" text="Tools">
|
||||
<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">
|
||||
<items>
|
||||
<MenuItem mnemonicParsing="false" onAction="#mapDraw1" text="Radius 1" />
|
||||
@ -220,7 +216,7 @@
|
||||
<Button mnemonicParsing="false" onAction="#onImageDeletePressed" text="Delete" />
|
||||
<MenuButton mnemonicParsing="false" text="Tools">
|
||||
<items>
|
||||
<Menu mnemonicParsing="false" text="Pattern" fx:id="imagePatternMenu" />
|
||||
<Menu fx:id="imagePatternMenu" mnemonicParsing="false" text="Pattern" />
|
||||
<Menu mnemonicParsing="false" text="Draw mode">
|
||||
<items>
|
||||
<MenuItem mnemonicParsing="false" onAction="#imageBitMode" text="Bit Toggle mode" />
|
||||
|
@ -1,14 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import java.lang.*?>
|
||||
<?import java.net.*?>
|
||||
<?import java.util.*?>
|
||||
<?import javafx.scene.*?>
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<?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>
|
||||
<URL value="@/styles/mythosscripteditor.css"/>
|
||||
</stylesheets>-->
|
||||
@ -17,20 +14,20 @@
|
||||
<menus>
|
||||
<Menu mnemonicParsing="false" text="MythosScript">
|
||||
<items>
|
||||
<MenuItem mnemonicParsing="false" onAction="#onApplyChangesSelected" text="Apply changes" fx:id="menuItemApplyChanges" />
|
||||
<MenuItem mnemonicParsing="false" onAction="#onAbortChangesSelected" text="Abort changes" fx:id="menuItemAbortChanges" />
|
||||
<MenuItem fx:id="menuItemApplyChanges" mnemonicParsing="false" onAction="#onApplyChangesSelected" text="Apply changes" />
|
||||
<MenuItem fx:id="menuItemAbortChanges" mnemonicParsing="false" onAction="#onAbortChangesSelected" text="Abort changes" />
|
||||
</items>
|
||||
</Menu>
|
||||
<Menu mnemonicParsing="false" text="Edit">
|
||||
<items>
|
||||
<MenuItem mnemonicParsing="false" onAction="#onUndoSelected" text="Undo" fx:id="menuItemUndo" />
|
||||
<MenuItem mnemonicParsing="false" onAction="#onRedoSelected" text="Redo" fx:id="menuItemRedo" />
|
||||
<MenuItem fx:id="menuItemUndo" mnemonicParsing="false" onAction="#onUndoSelected" text="Undo" />
|
||||
<MenuItem fx:id="menuItemRedo" mnemonicParsing="false" onAction="#onRedoSelected" text="Redo" />
|
||||
</items>
|
||||
</Menu>
|
||||
<Menu mnemonicParsing="false" text="Help">
|
||||
<items>
|
||||
<MenuItem mnemonicParsing="false" onAction="#onMythosHelpSelected" text="Mythos Script Help" fx:id="menuItemMythosHelp" />
|
||||
<MenuItem mnemonicParsing="false" onAction="#onAboutBlocklySelected" text="About Blockly" fx:id="menuItemAboutBlockly" />
|
||||
<MenuItem fx:id="menuItemMythosHelp" mnemonicParsing="false" onAction="#onMythosHelpSelected" text="Mythos Script Help" />
|
||||
<MenuItem fx:id="menuItemAboutBlockly" mnemonicParsing="false" onAction="#onAboutBlocklySelected" text="About Blockly" />
|
||||
</items>
|
||||
</Menu>
|
||||
</menus>
|
||||
|
@ -64,14 +64,9 @@
|
||||
</xs:element>
|
||||
<xs:element name="scripts">
|
||||
<xs:complexType>
|
||||
<xs:choice maxOccurs="unbounded">
|
||||
<xs:element name="enter" type="tns:script" minOccurs="0"/>
|
||||
<xs:element name="exit" type="tns:script" minOccurs="0"/>
|
||||
<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:sequence>
|
||||
<xs:element name="script" type="tns:script" minOccurs="1" maxOccurs="unbounded"/>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:sequence>
|
||||
@ -94,6 +89,9 @@
|
||||
</xs:sequence>
|
||||
<xs:attribute name="inline" type="xs:boolean"/>
|
||||
<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="y" type="xs:integer"/>
|
||||
</xs:complexType>
|
||||
|
@ -19,7 +19,7 @@
|
||||
</style>
|
||||
</head>
|
||||
<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">
|
||||
<category name="Variables">
|
||||
|
@ -2,7 +2,7 @@
|
||||
<gameData xmlns="outlaw">
|
||||
<map>
|
||||
<scripts>
|
||||
<enter>
|
||||
<script>
|
||||
<name>name</name>
|
||||
<description>description</description>
|
||||
<block type="variables_set" inline="true" x="245" y="27">
|
||||
@ -47,7 +47,7 @@
|
||||
</block>
|
||||
</next>
|
||||
</block>
|
||||
</enter>
|
||||
</script>
|
||||
</scripts>
|
||||
</map>
|
||||
</gameData>
|
@ -2,7 +2,7 @@
|
||||
<gameData xmlns="outlaw">
|
||||
<map>
|
||||
<scripts>
|
||||
<enter>
|
||||
<script>
|
||||
<name>name</name>
|
||||
<description>description</description>
|
||||
<block type="procedures_defreturn" inline="false" x="213" y="27">
|
||||
@ -112,7 +112,26 @@
|
||||
<block type="logic_null"></block>
|
||||
</value>
|
||||
</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>
|
||||
</map>
|
||||
</gameData>
|
@ -5,9 +5,7 @@ import java.io.IOException;
|
||||
import java.io.StringWriter;
|
||||
import javax.xml.bind.JAXB;
|
||||
import javax.xml.bind.JAXBContext;
|
||||
import javax.xml.bind.JAXBElement;
|
||||
import javax.xml.bind.Marshaller;
|
||||
import javax.xml.namespace.QName;
|
||||
import org.badvision.outlaweditor.data.xml.Block;
|
||||
import org.badvision.outlaweditor.data.xml.GameData;
|
||||
import org.badvision.outlaweditor.data.xml.Map;
|
||||
@ -53,7 +51,7 @@ public class TestMythosEditor {
|
||||
script.setDescription("description");
|
||||
script.setBlock(theBlock);
|
||||
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);
|
||||
String testOutput = testWriter.getBuffer().toString();
|
||||
assertNotNull(testOutput);
|
||||
@ -92,9 +90,9 @@ public class TestMythosEditor {
|
||||
assertEquals(1, gd.getMap().size());
|
||||
Scripts s = gd.getMap().get(0).getScripts();
|
||||
assertNotNull(s);
|
||||
assertNotNull(s.getEnterOrExitOrStepOn());
|
||||
assertEquals(1, s.getEnterOrExitOrStepOn().size());
|
||||
Script scr = (Script) s.getEnterOrExitOrStepOn().get(0).getValue();
|
||||
assertNotNull(s.getScript());
|
||||
assertTrue(s.getScript().size() > 0);
|
||||
Script scr = (Script) s.getScript().get(0);
|
||||
return scr.getBlock();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user