mirror of
https://github.com/badvision/lawless-legends.git
synced 2024-08-25 12:28:55 +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;
|
||||
|
||||
public abstract class ApplicationUIController {
|
||||
|
||||
@FXML // ResourceBundle that was given to the FXMLLoader
|
||||
protected ResourceBundle resources;
|
||||
@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
|
||||
@FXML
|
||||
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
|
||||
@FXML
|
||||
|
@ -1,6 +1,5 @@
|
||||
package org.badvision.outlaweditor;
|
||||
|
||||
import org.badvision.outlaweditor.apple.AppleTileRenderer;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
@ -21,12 +20,14 @@ import javafx.scene.input.MouseEvent;
|
||||
import javafx.util.Callback;
|
||||
import static org.badvision.outlaweditor.Application.currentPlatform;
|
||||
import static org.badvision.outlaweditor.Application.gameData;
|
||||
import static org.badvision.outlaweditor.data.PropertyHelper.*;
|
||||
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.TilesetUtils;
|
||||
import org.badvision.outlaweditor.data.xml.Image;
|
||||
import org.badvision.outlaweditor.data.xml.PlatformData;
|
||||
import org.badvision.outlaweditor.data.xml.Script;
|
||||
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.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMapScriptClicked(MouseEvent event) {
|
||||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onMapSelected(ActionEvent event) {
|
||||
setCurrentMap(mapSelect.getSelectionModel().getSelectedItem());
|
||||
@ -737,6 +732,7 @@ public class ApplicationUIControllerImpl extends ApplicationUIController {
|
||||
currentMapEditor.setEntity(m);
|
||||
currentMapEditor.buildEditorUI(mapEditorAnchorPane);
|
||||
}
|
||||
redrawMapScripts();
|
||||
}
|
||||
|
||||
public void rebuildMapSelectors() {
|
||||
@ -837,6 +833,36 @@ public class ApplicationUIControllerImpl extends ApplicationUIController {
|
||||
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> {
|
||||
|
||||
static Map<TextField, Object> lastSelected = new HashMap<>();
|
||||
|
@ -1,10 +1,10 @@
|
||||
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;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import javafx.event.EventHandler;
|
||||
@ -14,28 +14,41 @@ 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.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.Script;
|
||||
import org.w3c.dom.Document;
|
||||
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);
|
||||
|
||||
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 {
|
||||
AnchorPane node = (AnchorPane) fxmlLoader.load();
|
||||
controller = fxmlLoader.getController();
|
||||
@ -45,7 +58,7 @@ public class MythosEditor {
|
||||
} catch (IOException exception) {
|
||||
throw new RuntimeException(exception);
|
||||
}
|
||||
|
||||
|
||||
primaryStage.setOnCloseRequest(new EventHandler<WindowEvent>() {
|
||||
@Override
|
||||
public void handle(final WindowEvent t) {
|
||||
@ -53,49 +66,75 @@ public class MythosEditor {
|
||||
}
|
||||
});
|
||||
primaryStage.show();
|
||||
loadScript();
|
||||
}
|
||||
|
||||
|
||||
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() {
|
||||
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) {
|
||||
String xml = controller.getScriptXml();
|
||||
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());
|
||||
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() {
|
||||
return "<block/>";
|
||||
public String generateLoadScript() {
|
||||
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;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.ListResourceBundle;
|
||||
import java.util.Map;
|
||||
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.fxml.FXML;
|
||||
import javafx.fxml.Initializable;
|
||||
import javafx.scene.control.MenuItem;
|
||||
import javafx.scene.web.WebView;
|
||||
|
||||
import netscape.javascript.JSObject;
|
||||
|
||||
public class MythosScriptEditorController
|
||||
implements Initializable {
|
||||
|
||||
implements Initializable {
|
||||
|
||||
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"
|
||||
WebView editorView; // Value injected by FXMLLoader
|
||||
@ -36,10 +45,11 @@ public class MythosScriptEditorController
|
||||
private MenuItem menuItemUndo; // Value injected by FXMLLoader
|
||||
|
||||
MythosEditor editor;
|
||||
|
||||
public void setEditor(MythosEditor editor) {
|
||||
this.editor = editor;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Handler for MenuItem[fx:id="menuItemAbortChanges"] onAction
|
||||
public void onAbortChangesSelected(ActionEvent event) {
|
||||
editor.close();
|
||||
@ -69,8 +79,8 @@ public class MythosScriptEditorController
|
||||
// Handler for MenuItem[fx:id="menuItemUndo"] onAction
|
||||
public void onUndoSelected(ActionEvent event) {
|
||||
// handle the event here
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override // This method is called by the FXMLLoader when initialization is complete
|
||||
public void initialize(URL fxmlFileLocation, ResourceBundle resources) {
|
||||
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 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'.";
|
||||
|
||||
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.stage.Modality;
|
||||
import javafx.stage.Stage;
|
||||
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.Map;
|
||||
import org.badvision.outlaweditor.data.xml.Script;
|
||||
|
||||
/**
|
||||
@ -201,8 +201,20 @@ public class UIAction {
|
||||
public static Script createAndEditScript() {
|
||||
Script script = 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);
|
||||
editor.show();
|
||||
return 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" />
|
||||
@ -164,7 +160,7 @@
|
||||
<content>
|
||||
<AnchorPane id="Content" minHeight="0.0" minWidth="0.0" prefHeight="200.0" prefWidth="200.0">
|
||||
<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>
|
||||
</AnchorPane>
|
||||
</content>
|
||||
@ -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">
|
||||
|
@ -1,5 +1,23 @@
|
||||
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 = {
|
||||
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',
|
||||
initBlocks: function() {
|
||||
Blockly.Blocks['flow_for'] = {
|
||||
|
@ -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