mirror of
https://github.com/badvision/lawless-legends.git
synced 2024-10-11 18:23:48 +00:00
Merge branch 'master' of https://github.com/badvision/lawless-legends
This commit is contained in:
commit
e47ba3fd97
@ -18,7 +18,6 @@ import org.badvision.outlaweditor.data.xml.Script;
|
|||||||
import org.badvision.outlaweditor.data.xml.Tile;
|
import org.badvision.outlaweditor.data.xml.Tile;
|
||||||
|
|
||||||
public abstract class ApplicationUIController {
|
public abstract class ApplicationUIController {
|
||||||
|
|
||||||
@FXML // ResourceBundle that was given to the FXMLLoader
|
@FXML // ResourceBundle that was given to the FXMLLoader
|
||||||
protected ResourceBundle resources;
|
protected ResourceBundle resources;
|
||||||
@FXML // URL location of the FXML file that was given to the FXMLLoader
|
@FXML // URL location of the FXML file that was given to the FXMLLoader
|
||||||
@ -218,10 +217,6 @@ public abstract class ApplicationUIController {
|
|||||||
// Handler for Button[Button[id=null, styleClass=button]] onAction
|
// Handler for Button[Button[id=null, styleClass=button]] onAction
|
||||||
@FXML
|
@FXML
|
||||||
abstract public void onMapScriptClonePressed(ActionEvent event);
|
abstract public void onMapScriptClonePressed(ActionEvent event);
|
||||||
|
|
||||||
// Handler for onClick
|
|
||||||
@FXML
|
|
||||||
abstract public void onMapScriptClicked(MouseEvent event);
|
|
||||||
|
|
||||||
// Handler for Button[Button[id=null, styleClass=button]] onAction
|
// Handler for Button[Button[id=null, styleClass=button]] onAction
|
||||||
@FXML
|
@FXML
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package org.badvision.outlaweditor;
|
package org.badvision.outlaweditor;
|
||||||
|
|
||||||
import org.badvision.outlaweditor.apple.AppleTileRenderer;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -21,12 +20,14 @@ import javafx.scene.input.MouseEvent;
|
|||||||
import javafx.util.Callback;
|
import javafx.util.Callback;
|
||||||
import static org.badvision.outlaweditor.Application.currentPlatform;
|
import static org.badvision.outlaweditor.Application.currentPlatform;
|
||||||
import static org.badvision.outlaweditor.Application.gameData;
|
import static org.badvision.outlaweditor.Application.gameData;
|
||||||
import static org.badvision.outlaweditor.data.PropertyHelper.*;
|
|
||||||
import static org.badvision.outlaweditor.UIAction.*;
|
import static org.badvision.outlaweditor.UIAction.*;
|
||||||
|
import org.badvision.outlaweditor.apple.AppleTileRenderer;
|
||||||
|
import static org.badvision.outlaweditor.data.PropertyHelper.*;
|
||||||
import org.badvision.outlaweditor.data.TileUtils;
|
import org.badvision.outlaweditor.data.TileUtils;
|
||||||
import org.badvision.outlaweditor.data.TilesetUtils;
|
import org.badvision.outlaweditor.data.TilesetUtils;
|
||||||
import org.badvision.outlaweditor.data.xml.Image;
|
import org.badvision.outlaweditor.data.xml.Image;
|
||||||
import org.badvision.outlaweditor.data.xml.PlatformData;
|
import org.badvision.outlaweditor.data.xml.PlatformData;
|
||||||
|
import org.badvision.outlaweditor.data.xml.Script;
|
||||||
import org.badvision.outlaweditor.data.xml.Tile;
|
import org.badvision.outlaweditor.data.xml.Tile;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -465,12 +466,6 @@ public class ApplicationUIControllerImpl extends ApplicationUIController {
|
|||||||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onMapScriptClicked(MouseEvent event) {
|
|
||||||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onMapSelected(ActionEvent event) {
|
public void onMapSelected(ActionEvent event) {
|
||||||
setCurrentMap(mapSelect.getSelectionModel().getSelectedItem());
|
setCurrentMap(mapSelect.getSelectionModel().getSelectedItem());
|
||||||
@ -737,6 +732,7 @@ public class ApplicationUIControllerImpl extends ApplicationUIController {
|
|||||||
currentMapEditor.setEntity(m);
|
currentMapEditor.setEntity(m);
|
||||||
currentMapEditor.buildEditorUI(mapEditorAnchorPane);
|
currentMapEditor.buildEditorUI(mapEditorAnchorPane);
|
||||||
}
|
}
|
||||||
|
redrawMapScripts();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void rebuildMapSelectors() {
|
public void rebuildMapSelectors() {
|
||||||
@ -837,6 +833,36 @@ public class ApplicationUIControllerImpl extends ApplicationUIController {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void redrawMapScripts() {
|
||||||
|
mapScriptsList.setOnEditStart(new EventHandler<ListView.EditEvent<Script>>() {
|
||||||
|
@Override
|
||||||
|
public void handle(ListView.EditEvent<Script> event) {
|
||||||
|
UIAction.editScript(event.getSource().getItems().get(event.getIndex()));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
mapScriptsList.setCellFactory(new Callback<ListView<Script>, ListCell<Script>>() {
|
||||||
|
@Override
|
||||||
|
public ListCell<Script> call(ListView<Script> param) {
|
||||||
|
return new ListCell<Script>() {
|
||||||
|
@Override
|
||||||
|
protected void updateItem(Script item, boolean empty) {
|
||||||
|
super.updateItem(item, empty);
|
||||||
|
if (empty || item == null) {
|
||||||
|
setText("");
|
||||||
|
} else {
|
||||||
|
setText(item.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (currentMap == null) {
|
||||||
|
mapScriptsList.getItems().clear();
|
||||||
|
} else {
|
||||||
|
mapScriptsList.getItems().setAll(currentMap.getScripts().getScript());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
abstract public static class EntitySelectorCell<T> extends ComboBoxListCell<T> {
|
abstract public static class EntitySelectorCell<T> extends ComboBoxListCell<T> {
|
||||||
|
|
||||||
static Map<TextField, Object> lastSelected = new HashMap<>();
|
static Map<TextField, Object> lastSelected = new HashMap<>();
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
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.StringWriter;
|
import java.io.StringWriter;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import javafx.event.EventHandler;
|
import javafx.event.EventHandler;
|
||||||
@ -14,28 +14,41 @@ 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.namespace.QName;
|
||||||
|
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.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;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void show() {
|
public void show() {
|
||||||
primaryStage = new Stage();
|
primaryStage = new Stage();
|
||||||
javafx.application.Platform.setImplicitExit(true);
|
|
||||||
|
|
||||||
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/MythosScriptEditor.fxml"));
|
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/MythosScriptEditor.fxml"));
|
||||||
fxmlLoader.setResources(null);
|
Map<String,String> properties = new HashMap<>();
|
||||||
|
properties.put(MythosScriptEditorController.ONLOAD_SCRIPT, generateLoadScript());
|
||||||
|
fxmlLoader.setResources(MythosScriptEditorController.createResourceBundle(properties));
|
||||||
try {
|
try {
|
||||||
AnchorPane node = (AnchorPane) fxmlLoader.load();
|
AnchorPane node = (AnchorPane) fxmlLoader.load();
|
||||||
controller = fxmlLoader.getController();
|
controller = fxmlLoader.getController();
|
||||||
@ -45,7 +58,7 @@ public class MythosEditor {
|
|||||||
} catch (IOException exception) {
|
} catch (IOException exception) {
|
||||||
throw new RuntimeException(exception);
|
throw new RuntimeException(exception);
|
||||||
}
|
}
|
||||||
|
|
||||||
primaryStage.setOnCloseRequest(new EventHandler<WindowEvent>() {
|
primaryStage.setOnCloseRequest(new EventHandler<WindowEvent>() {
|
||||||
@Override
|
@Override
|
||||||
public void handle(final WindowEvent t) {
|
public void handle(final WindowEvent t) {
|
||||||
@ -53,49 +66,75 @@ public class MythosEditor {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
primaryStage.show();
|
primaryStage.show();
|
||||||
loadScript();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void close() {
|
public void close() {
|
||||||
primaryStage.close();
|
javafx.application.Platform.runLater(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
primaryStage.getScene().getRoot().setDisable(true);
|
||||||
|
primaryStage.close();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void applyChanges() {
|
public void applyChanges() {
|
||||||
try {
|
try {
|
||||||
String xml = String.valueOf(controller.editorView.getEngine().executeScript("Blockly.Xml.workspaceToDom(Blockly.mainWorkspace).outerHTML"));
|
String xml = controller.getScriptXml();
|
||||||
JAXBContext context = JAXBContext.newInstance(Block.class);
|
JAXBContext context = JAXBContext.newInstance("org.badvision.outlaweditor.data.xml");
|
||||||
Block scriptBlock = (Block) context.createUnmarshaller().unmarshal(new StringReader(xml));
|
Unmarshaller unmarshaller = context.createUnmarshaller();
|
||||||
script.setBlock(scriptBlock);
|
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
|
||||||
} catch (JAXBException ex) {
|
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() {
|
|
||||||
if (script == null || script.getBlock() == null) {
|
|
||||||
loadScript(createDefaultScript());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
JAXBContext context = JAXBContext.newInstance(Block.class);
|
|
||||||
StringWriter buffer = new StringWriter();
|
|
||||||
context.createMarshaller().marshal(script.getBlock(), buffer);
|
|
||||||
String xml = buffer.toString();
|
|
||||||
loadScript(xml);
|
|
||||||
} catch (JAXBException ex) {
|
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String createDefaultScript() {
|
public String generateLoadScript() {
|
||||||
return "<block/>";
|
if (script == null || script.getBlock() == null) {
|
||||||
|
return generateLoadScript(getDefaultBlockMarkup());
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
JAXBContext context = JAXBContext.newInstance(Block.class);
|
||||||
|
StringWriter buffer = new StringWriter();
|
||||||
|
QName qName = new QName("outlaw","block");
|
||||||
|
JAXBElement<Block> root = new JAXBElement<>(qName, Block.class, script.getBlock());
|
||||||
|
context.createMarshaller().marshal(root, buffer);
|
||||||
|
String xml = buffer.toString();
|
||||||
|
xml=xml.replace("?>", "?><xml>");
|
||||||
|
xml += "</xml>";
|
||||||
|
System.out.println("xml: "+xml);
|
||||||
|
return generateLoadScript(xml);
|
||||||
|
} catch (JAXBException ex) {
|
||||||
|
Logger.getLogger(MythosEditor.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String generateLoadScript(String xml) {
|
||||||
|
xml = xml.replaceAll("'", "\\'");
|
||||||
|
xml = xml.replaceAll("\n", "");
|
||||||
|
String loadScript = "Mythos.setScriptXml('"+xml+"');";
|
||||||
|
return loadScript;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getDefaultBlockMarkup() {
|
||||||
|
return XML_HEADER+"<xml><block type=\"procedures_defreturn\" id=\"1\" inline=\"false\" x=\"5\" y=\"5\"><mutation></mutation><field name=\"NAME\">NewScript</field></block></xml>";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Called when the name of the root block is changed in the JS editor
|
||||||
|
public void setFunctionName(String name) {
|
||||||
|
if (script == null) {
|
||||||
|
System.out.println("How can the script be null?? wanted to set script name to "+name);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
script.setName(name);
|
||||||
|
System.out.println("Function title changed! >> "+name);
|
||||||
|
Application.instance.controller.redrawMapScripts();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,18 +1,27 @@
|
|||||||
package org.badvision.outlaweditor;
|
package org.badvision.outlaweditor;
|
||||||
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.util.ListResourceBundle;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.ResourceBundle;
|
import java.util.ResourceBundle;
|
||||||
|
import java.util.Set;
|
||||||
|
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;
|
||||||
import javafx.scene.control.MenuItem;
|
import javafx.scene.control.MenuItem;
|
||||||
import javafx.scene.web.WebView;
|
import javafx.scene.web.WebView;
|
||||||
|
import netscape.javascript.JSObject;
|
||||||
|
|
||||||
public class MythosScriptEditorController
|
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";
|
||||||
|
public static final String ONLOAD_SCRIPT = "onloadScript";
|
||||||
|
// This is tied to the Mythos object defined in mythos_uncompressed
|
||||||
|
JSObject mythos;
|
||||||
|
|
||||||
@FXML // fx:id="editorView"
|
@FXML // fx:id="editorView"
|
||||||
WebView editorView; // Value injected by FXMLLoader
|
WebView editorView; // Value injected by FXMLLoader
|
||||||
@ -36,10 +45,11 @@ public class MythosScriptEditorController
|
|||||||
private MenuItem menuItemUndo; // Value injected by FXMLLoader
|
private MenuItem menuItemUndo; // Value injected by FXMLLoader
|
||||||
|
|
||||||
MythosEditor editor;
|
MythosEditor editor;
|
||||||
|
|
||||||
public void setEditor(MythosEditor editor) {
|
public void setEditor(MythosEditor editor) {
|
||||||
this.editor = editor;
|
this.editor = editor;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handler for MenuItem[fx:id="menuItemAbortChanges"] onAction
|
// Handler for MenuItem[fx:id="menuItemAbortChanges"] onAction
|
||||||
public void onAbortChangesSelected(ActionEvent event) {
|
public void onAbortChangesSelected(ActionEvent event) {
|
||||||
editor.close();
|
editor.close();
|
||||||
@ -69,8 +79,8 @@ public class MythosScriptEditorController
|
|||||||
// Handler for MenuItem[fx:id="menuItemUndo"] onAction
|
// Handler for MenuItem[fx:id="menuItemUndo"] onAction
|
||||||
public void onUndoSelected(ActionEvent event) {
|
public void onUndoSelected(ActionEvent event) {
|
||||||
// handle the event here
|
// handle the event here
|
||||||
}
|
}
|
||||||
|
|
||||||
@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) {
|
||||||
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'.";
|
||||||
@ -80,7 +90,41 @@ public class MythosScriptEditorController
|
|||||||
assert menuItemMythosHelp != null : "fx:id=\"menuItemMythosHelp\" was not injected: check your FXML file 'MythosScriptEditor.fxml'.";
|
assert menuItemMythosHelp != null : "fx:id=\"menuItemMythosHelp\" was not injected: check your FXML file 'MythosScriptEditor.fxml'.";
|
||||||
assert menuItemRedo != null : "fx:id=\"menuItemRedo\" was not injected: check your FXML file 'MythosScriptEditor.fxml'.";
|
assert menuItemRedo != null : "fx:id=\"menuItemRedo\" was not injected: check your FXML file 'MythosScriptEditor.fxml'.";
|
||||||
assert menuItemUndo != null : "fx:id=\"menuItemUndo\" was not injected: check your FXML file 'MythosScriptEditor.fxml'.";
|
assert menuItemUndo != null : "fx:id=\"menuItemUndo\" was not injected: check your FXML file 'MythosScriptEditor.fxml'.";
|
||||||
|
|
||||||
editorView.getEngine().load(getClass().getResource(MYTHOS_EDITOR).toExternalForm());
|
final String loadScript = resources.getString(ONLOAD_SCRIPT);
|
||||||
|
if (loadScript != null) {
|
||||||
|
editorView.getEngine().getLoadWorker().stateProperty().addListener(
|
||||||
|
new ChangeListener<State>() {
|
||||||
|
@Override
|
||||||
|
public void changed(ObservableValue ov, State oldState, State newState) {
|
||||||
|
if (newState == State.SUCCEEDED) {
|
||||||
|
mythos = (JSObject) editorView.getEngine().executeScript("Mythos");
|
||||||
|
mythos.setMember("editor", editor);
|
||||||
|
editorView.getEngine().executeScript(loadScript);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
editorView.getEngine().load(getClass().getResource(MYTHOS_EDITOR).toExternalForm());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ResourceBundle createResourceBundle(final Map<String, String> input) {
|
||||||
|
return new ListResourceBundle() {
|
||||||
|
@Override
|
||||||
|
protected Object[][] getContents() {
|
||||||
|
Object[][] output = new Object[input.size()][2];
|
||||||
|
Set<String> keys = input.keySet();
|
||||||
|
int i = 0;
|
||||||
|
for (String key : keys) {
|
||||||
|
output[i] = new Object[]{key, input.get(key)};
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getScriptXml() {
|
||||||
|
return String.valueOf(editorView.getEngine().executeScript("Mythos.getScriptXml();"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,10 +27,10 @@ import javafx.scene.layout.VBoxBuilder;
|
|||||||
import javafx.scene.text.Text;
|
import javafx.scene.text.Text;
|
||||||
import javafx.stage.Modality;
|
import javafx.stage.Modality;
|
||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
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.Map;
|
||||||
import org.badvision.outlaweditor.data.xml.Script;
|
import org.badvision.outlaweditor.data.xml.Script;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -201,8 +201,20 @@ public class UIAction {
|
|||||||
public static Script createAndEditScript() {
|
public static Script createAndEditScript() {
|
||||||
Script script = new Script();
|
Script script = new Script();
|
||||||
script.setName("New Script");
|
script.setName("New Script");
|
||||||
|
if (Application.instance.controller.currentMap.getScripts() == null) {
|
||||||
|
Application.instance.controller.currentMap.setScripts(new Map.Scripts());
|
||||||
|
}
|
||||||
|
Application.instance.controller.currentMap.getScripts().getScript().add(script);
|
||||||
|
return editScript(script);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Script editScript(Script script) {
|
||||||
|
if (script == null) {
|
||||||
|
System.err.println("Requested to edit a null script object, ignoring!");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
MythosEditor editor = new MythosEditor(script);
|
MythosEditor editor = new MythosEditor(script);
|
||||||
editor.show();
|
editor.show();
|
||||||
return script;
|
return script;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,15 +12,17 @@ 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();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void clear() {
|
public static void clear() {
|
||||||
display = new ConcurrentHashMap<>();
|
display = new ConcurrentHashMap<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Tile newTile() {
|
public static Tile newTile() {
|
||||||
Tile t = new Tile();
|
Tile t = new Tile();
|
||||||
t.setObstruction(false);
|
t.setObstruction(false);
|
||||||
@ -40,18 +42,24 @@ public class TileUtils {
|
|||||||
}
|
}
|
||||||
return t.getId();
|
return t.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Map<Platform, WritableImage> getDisplay(Tile t) {
|
public static Map<Platform, WritableImage> getDisplay(Tile t) {
|
||||||
if (display.get(getId(t)) == null) {
|
if (display.get(getId(t)) == null) {
|
||||||
display.put(getId(t), new EnumMap<Platform, WritableImage>(Platform.class));
|
display.put(getId(t), new EnumMap<Platform, WritableImage>(Platform.class));
|
||||||
}
|
}
|
||||||
return display.get(getId(t));
|
return display.get(getId(t));
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
||||||
@ -63,17 +71,17 @@ public class TileUtils {
|
|||||||
return d.getValue();
|
return d.getValue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
byte[] out = new byte[p.dataHeight*p.dataWidth];
|
byte[] out = new byte[p.dataHeight * p.dataWidth];
|
||||||
setPlatformData(t, p, out);
|
setPlatformData(t, p, out);
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static WritableImage getImage(Tile t, Platform p) {
|
public static WritableImage getImage(Tile t, Platform p) {
|
||||||
Map<Platform, WritableImage> displays = getDisplay(t);
|
Map<Platform, WritableImage> displays = getDisplay(t);
|
||||||
byte[] data = getPlatformData(t, p);
|
byte[] data = getPlatformData(t, p);
|
||||||
return displays.put(p, p.tileRenderer.redrawSprite(data, displays.get(p)));
|
return displays.put(p, p.tileRenderer.redrawSprite(data, displays.get(p)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setImage(Tile t, Platform p, WritableImage img) {
|
public static void setImage(Tile t, Platform p, WritableImage img) {
|
||||||
Map<Platform, WritableImage> displays = getDisplay(t);
|
Map<Platform, WritableImage> displays = getDisplay(t);
|
||||||
displays.put(p, img);
|
displays.put(p, img);
|
||||||
@ -91,4 +99,4 @@ public class TileUtils {
|
|||||||
d.setValue(b);
|
d.setValue(b);
|
||||||
t.getDisplayData().add(d);
|
t.getDisplayData().add(d);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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" />
|
||||||
@ -164,7 +160,7 @@
|
|||||||
<content>
|
<content>
|
||||||
<AnchorPane id="Content" minHeight="0.0" minWidth="0.0" prefHeight="200.0" prefWidth="200.0">
|
<AnchorPane id="Content" minHeight="0.0" minWidth="0.0" prefHeight="200.0" prefWidth="200.0">
|
||||||
<children>
|
<children>
|
||||||
<ListView fx:id="mapScriptsList" onMouseClicked="#onMapScriptClicked" prefHeight="217.0" prefWidth="199.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" />
|
<ListView fx:id="mapScriptsList" editable="true" prefHeight="217.0" prefWidth="199.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" />
|
||||||
</children>
|
</children>
|
||||||
</AnchorPane>
|
</AnchorPane>
|
||||||
</content>
|
</content>
|
||||||
@ -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">
|
||||||
|
@ -1,5 +1,23 @@
|
|||||||
if (typeof Mythos === "undefined") {
|
if (typeof Mythos === "undefined") {
|
||||||
|
// Hook up the rename function to notify the java editor when changes occur
|
||||||
|
Blockly.Procedures.rename_old = Blockly.Procedures.rename;
|
||||||
|
Blockly.Procedures.rename = function(name) {
|
||||||
|
Mythos.editor.setFunctionName(name);
|
||||||
|
return Blockly.Procedures.rename_old.call(this,name);
|
||||||
|
};
|
||||||
|
|
||||||
Mythos = {
|
Mythos = {
|
||||||
|
setScriptXml: function(xml) {
|
||||||
|
Blockly.mainWorkspace.clear();
|
||||||
|
var dom = Blockly.Xml.textToDom(xml);
|
||||||
|
Blockly.Xml.domToWorkspace(Blockly.mainWorkspace, dom);
|
||||||
|
while (Blockly.mainWorkspace.topBlocks_.length > 1) {
|
||||||
|
Blockly.mainWorkspace.topBlocks_[1].dispose();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
getScriptXml: function() {
|
||||||
|
return Blockly.Xml.workspaceToDom(Blockly.mainWorkspace).innerHTML;
|
||||||
|
},
|
||||||
helpUrl: 'https://docs.google.com/document/d/1VXbiY4G533-cokjQevZFhwvqMMCL--17ziMAoFoeJ5M/edit#heading=h.yv9dmneqjr2b',
|
helpUrl: 'https://docs.google.com/document/d/1VXbiY4G533-cokjQevZFhwvqMMCL--17ziMAoFoeJ5M/edit#heading=h.yv9dmneqjr2b',
|
||||||
initBlocks: function() {
|
initBlocks: function() {
|
||||||
Blockly.Blocks['flow_for'] = {
|
Blockly.Blocks['flow_for'] = {
|
||||||
|
@ -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…
Reference in New Issue
Block a user