1
0
mirror of https://github.com/badvision/lawless-legends.git synced 2025-03-30 09:30:58 +00:00
This commit is contained in:
David Schmenk 2014-06-12 18:40:35 -07:00
commit 3eaf2d1bed
6 changed files with 132 additions and 92 deletions
OutlawEditor
pom.xml
src/main
java/org/badvision/outlaweditor
resources/jaxb/OutlawSchema
Platform/Apple/tools/A2Copy/nbproject

@ -40,8 +40,8 @@
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
<configuration> <configuration>
<source>1.7</source> <source>1.8</source>
<target>1.7</target> <target>1.8</target>
</configuration> </configuration>
<version>3.1</version> <version>3.1</version>
</plugin> </plugin>
@ -69,14 +69,13 @@
</build> </build>
<dependencies> <dependencies>
<dependency> <!-- <dependency>
<groupId>com.oracle</groupId> <groupId>com.oracle</groupId>
<artifactId>javafx</artifactId> <artifactId>javafx</artifactId>
<version>2</version> <version>2</version>
<!--<systemPath>/usr/lib/jvm/jdk1.7.0_21/jre/lib/jfxrt.jar</systemPath>-->
<systemPath>${java.home}/lib/jfxrt.jar</systemPath> <systemPath>${java.home}/lib/jfxrt.jar</systemPath>
<scope>system</scope> <scope>system</scope>
</dependency> </dependency>-->
<dependency> <dependency>
<groupId>javafx-packager</groupId> <groupId>javafx-packager</groupId>
<artifactId>javafx-packager</artifactId> <artifactId>javafx-packager</artifactId>

@ -1,19 +1,13 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package org.badvision.outlaweditor; package org.badvision.outlaweditor;
import java.util.HashMap; import java.util.HashMap;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import javafx.application.Platform; import javafx.application.Platform;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue; import javafx.beans.value.ObservableValue;
import javafx.event.EventHandler; import javafx.event.EventHandler;
import javafx.scene.Group; import javafx.scene.Group;
import javafx.scene.ImageCursor; import javafx.scene.ImageCursor;
import javafx.scene.Node;
import javafx.scene.Scene; import javafx.scene.Scene;
import javafx.scene.canvas.Canvas; import javafx.scene.canvas.Canvas;
import javafx.scene.image.ImageView; import javafx.scene.image.ImageView;
@ -27,7 +21,6 @@ import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle; import javafx.scene.shape.Rectangle;
import javafx.stage.Stage; import javafx.stage.Stage;
import static org.badvision.outlaweditor.Application.currentPlatform; import static org.badvision.outlaweditor.Application.currentPlatform;
import org.badvision.outlaweditor.TransferHelper.DropEventHandler;
import org.badvision.outlaweditor.data.TileMap; import org.badvision.outlaweditor.data.TileMap;
import org.badvision.outlaweditor.data.TileUtils; import org.badvision.outlaweditor.data.TileUtils;
import org.badvision.outlaweditor.data.xml.Map; import org.badvision.outlaweditor.data.xml.Map;
@ -62,16 +55,13 @@ public class MapEditor extends Editor<Map, MapEditor.DrawMode> implements EventH
return currentMap; return currentMap;
} }
EventHandler<ScrollEvent> scrollHandler = new EventHandler<ScrollEvent>() { EventHandler<ScrollEvent> scrollHandler = (ScrollEvent t) -> {
@Override if (t.isShiftDown()) {
public void handle(ScrollEvent t) { t.consume();
if (t.isShiftDown()) { if (t.getDeltaY() > 0) {
t.consume(); zoomIn();
if (t.getDeltaY() > 0) { } else {
zoomIn(); zoomOut();
} else {
zoomOut();
}
} }
} }
}; };
@ -101,28 +91,19 @@ public class MapEditor extends Editor<Map, MapEditor.DrawMode> implements EventH
drawCanvas.heightProperty().bind(Application.getPrimaryStage().heightProperty().subtract(120)); drawCanvas.heightProperty().bind(Application.getPrimaryStage().heightProperty().subtract(120));
drawCanvas.widthProperty().bind(Application.getPrimaryStage().widthProperty().subtract(200)); drawCanvas.widthProperty().bind(Application.getPrimaryStage().widthProperty().subtract(200));
// drawCanvas.widthProperty().bind(anchorPane.widthProperty()); // drawCanvas.widthProperty().bind(anchorPane.widthProperty());
drawCanvas.widthProperty().addListener(new ChangeListener<Number>() { drawCanvas.widthProperty().addListener((ObservableValue<? extends Number> ov, Number t, Number t1) -> {
@Override redraw();
public void changed(ObservableValue<? extends Number> ov, Number t, Number t1) {
redraw();
}
}); });
drawCanvas.heightProperty().addListener(new ChangeListener<Number>() { drawCanvas.heightProperty().addListener((ObservableValue<? extends Number> ov, Number t, Number t1) -> {
@Override redraw();
public void changed(ObservableValue<? extends Number> ov, Number t, Number t1) {
redraw();
}
}); });
drawCanvas.addEventFilter(ScrollEvent.ANY, scrollHandler); drawCanvas.addEventFilter(ScrollEvent.ANY, scrollHandler);
drawCanvas.setOnMousePressed(this); drawCanvas.setOnMousePressed(this);
drawCanvas.setOnMouseDragged(this); drawCanvas.setOnMouseDragged(this);
drawCanvas.setOnMouseDragReleased(this); drawCanvas.setOnMouseDragReleased(this);
drawCanvas.setOnMouseReleased(this); drawCanvas.setOnMouseReleased(this);
scriptDragDrop.registerDropSupport(drawCanvas, new DropEventHandler<Script>() { scriptDragDrop.registerDropSupport(drawCanvas, (Script script, double x, double y) -> {
@Override assignScript(script, x, y);
public void handle(Script script, double x, double y) {
assignScript(script, x, y);
}
}); });
anchorPane.getChildren().add(0, drawCanvas); anchorPane.getChildren().add(0, drawCanvas);
} }
@ -140,12 +121,9 @@ public class MapEditor extends Editor<Map, MapEditor.DrawMode> implements EventH
} }
public void togglePanZoom() { public void togglePanZoom() {
for (Node n : anchorPane.getChildren()) { anchorPane.getChildren().stream().filter((n) -> !(n == drawCanvas)).forEach((n) -> {
if (n == drawCanvas) {
continue;
}
n.setVisible(!n.isVisible()); n.setVisible(!n.isVisible());
} });
} }
public void scrollBy(int deltaX, int deltaY) { public void scrollBy(int deltaX, int deltaY) {
@ -198,34 +176,29 @@ public class MapEditor extends Editor<Map, MapEditor.DrawMode> implements EventH
private long redrawRequested; private long redrawRequested;
private Thread redrawThread; private Thread redrawThread;
@Override
public void redraw() { public void redraw() {
redrawRequested = System.nanoTime(); redrawRequested = System.nanoTime();
if (redrawThread == null || redrawThread.isAlive()) { if (redrawThread == null || redrawThread.isAlive()) {
redrawThread = new Thread(new Runnable() { redrawThread = new Thread(() -> {
@Override long test = redrawRequested;
public void run() { try {
long test = redrawRequested; Thread.sleep(10);
} catch (InterruptedException ex) {
Logger.getLogger(MapEditor.class.getName()).log(Level.SEVERE, null, ex);
}
while (test != redrawRequested) {
test = redrawRequested;
try { try {
Thread.sleep(10); Thread.sleep(10);
} catch (InterruptedException ex) { } catch (InterruptedException ex) {
Logger.getLogger(MapEditor.class.getName()).log(Level.SEVERE, null, ex); Logger.getLogger(MapEditor.class.getName()).log(Level.SEVERE, null, ex);
} }
while (test != redrawRequested) {
test = redrawRequested;
try {
Thread.sleep(10);
} catch (InterruptedException ex) {
Logger.getLogger(MapEditor.class.getName()).log(Level.SEVERE, null, ex);
}
}
Platform.runLater(new Runnable() {
@Override
public void run() {
doRedraw();
}
});
redrawThread = null;
} }
Platform.runLater(() -> {
doRedraw();
});
redrawThread = null;
}); });
redrawThread.start(); redrawThread.start();
} }

@ -1,20 +1,25 @@
package org.badvision.outlaweditor.data; package org.badvision.outlaweditor.data;
import org.badvision.outlaweditor.Platform;
import java.io.Serializable; import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import javafx.scene.image.WritableImage; import javafx.scene.image.WritableImage;
import javafx.scene.paint.Color;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
import javax.xml.bind.JAXBElement; import javax.xml.bind.JAXBElement;
import org.badvision.outlaweditor.Application; import org.badvision.outlaweditor.Application;
import org.badvision.outlaweditor.ui.UIAction; import org.badvision.outlaweditor.Platform;
import org.badvision.outlaweditor.data.xml.Map; import org.badvision.outlaweditor.data.xml.Map;
import org.badvision.outlaweditor.data.xml.Map.Chunk; import org.badvision.outlaweditor.data.xml.Map.Chunk;
import org.badvision.outlaweditor.data.xml.ObjectFactory; import org.badvision.outlaweditor.data.xml.ObjectFactory;
import org.badvision.outlaweditor.data.xml.Script;
import org.badvision.outlaweditor.data.xml.Script.LocationTrigger;
import org.badvision.outlaweditor.data.xml.Tile; import org.badvision.outlaweditor.data.xml.Tile;
import org.badvision.outlaweditor.ui.UIAction;
/** /**
* *
@ -35,6 +40,57 @@ public class TileMap extends ArrayList<ArrayList<Tile>> implements Serializable
loadFromMap(m); loadFromMap(m);
} }
public static final double SATURATION = 0.5;
public static final double VALUE = 1.0;
public static double HUE = 0;
private java.util.Map<Integer, List<Script>> locationScripts = new HashMap<>();
private java.util.Map<Script, Color> scriptColors = new HashMap<>();
public Color getScriptColor(Script s) {
return scriptColors.get(s);
}
public List<Script> getLocationScripts(int x, int y) {
List<Script> list = locationScripts.get(getMortonNumber(x, y));
if (list != null) {
return list;
} else {
return Collections.EMPTY_LIST;
}
}
public void putLocationScript(int x, int y, Script s) {
LocationTrigger trigger = new Script.LocationTrigger();
trigger.setX(x);
trigger.setY(y);
s.getLocationTrigger().add(trigger);
registerLocationScript(x, y, s);
}
private void registerLocationScript(int x, int y, Script s) {
if (!scriptColors.containsKey(s)) {
scriptColors.put(s, Color.hsb(HUE, SATURATION, VALUE));
HUE = (HUE + 20) % 360;
}
int loc = getMortonNumber(x, y);
List<Script> list = locationScripts.get(loc);
if (list == null) {
list = new ArrayList<>();
locationScripts.put(loc, list);
}
list.add(s);
}
private int getMortonNumber(int x, int y) {
int morton = 0;
for (int i = 0; i < 16; i++) {
int mask = 1 << (i);
morton += (x & mask) << (i + 1);
morton += (y & mask) << i;
}
return morton;
}
public Tile get(int x, int y) { public Tile get(int x, int y) {
if (size() <= y || get(y) == null) { if (size() <= y || get(y) == null) {
return null; return null;
@ -52,7 +108,7 @@ public class TileMap extends ArrayList<ArrayList<Tile>> implements Serializable
add(null); add(null);
} }
if (get(y) == null) { if (get(y) == null) {
set(y, new ArrayList<Tile>()); set(y, new ArrayList<>());
} }
List<Tile> row = get(y); List<Tile> row = get(y);
for (int i = row.size(); i <= x; i++) { for (int i = row.size(); i <= x; i++) {
@ -93,7 +149,12 @@ public class TileMap extends ArrayList<ArrayList<Tile>> implements Serializable
width = 0; width = 0;
height = 0; height = 0;
Set<Tile> unknownTiles = new HashSet<>(); Set<Tile> unknownTiles = new HashSet<>();
for (Chunk c : m.getChunk()) { m.getScripts().getScript().forEach(
s -> s.getLocationTrigger().forEach(
l -> registerLocationScript(l.getX(), l.getY(), s)
)
);
m.getChunk().forEach( c-> {
int y = c.getY(); int y = c.getY();
for (JAXBElement<List<String>> row : c.getRow()) { for (JAXBElement<List<String>> row : c.getRow()) {
int x = c.getX(); int x = c.getX();
@ -114,7 +175,7 @@ public class TileMap extends ArrayList<ArrayList<Tile>> implements Serializable
} }
y++; y++;
} }
} });
if (!unknownTiles.isEmpty()) { if (!unknownTiles.isEmpty()) {
int numMissing = unknownTiles.size(); int numMissing = unknownTiles.size();
JOptionPane.showMessageDialog(null, (numMissing > 1 JOptionPane.showMessageDialog(null, (numMissing > 1

@ -31,25 +31,21 @@
<xs:element name="name" type="xs:string"/> <xs:element name="name" type="xs:string"/>
<xs:element name="description" type="xs:string" minOccurs="0"/> <xs:element name="description" type="xs:string" minOccurs="0"/>
<xs:element name="block" type="tns:block"/> <xs:element name="block" type="tns:block"/>
</xs:sequence> <xs:element name="locationTrigger" minOccurs="0" maxOccurs="unbounded">
</xs:complexType> <xs:complexType>
<xs:complexType name="locationScript"> <xs:attribute name="x" type="xs:int"/>
<xs:complexContent> <xs:attribute name="y" type="xs:int"/>
<xs:extension base="tns:script"> </xs:complexType>
<xs:attribute name="x" type="xs:int"/> </xs:element>
<xs:attribute name="y" type="xs:int"/> <xs:element name="intervalTrigger" minOccurs="0" maxOccurs="unbounded">
</xs:extension> <xs:complexType>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="intervalScript">
<xs:complexContent>
<xs:extension base="tns:script">
<xs:attribute name="start" type="xs:int" use="optional"/> <xs:attribute name="start" type="xs:int" use="optional"/>
<xs:attribute name="end" type="xs:int" use="optional"/> <xs:attribute name="end" type="xs:int" use="optional"/>
<xs:attribute name="period" type="xs:int" use="optional"/> <xs:attribute name="period" type="xs:int" use="optional"/>
<xs:attribute name="ifTrue" type="xs:string" use="optional"/> <xs:attribute name="ifTrue" type="xs:string" use="optional"/>
</xs:extension> </xs:complexType>
</xs:complexContent> </xs:element>
</xs:sequence>
</xs:complexType> </xs:complexType>
<xs:complexType name="map"> <xs:complexType name="map">
<xs:sequence> <xs:sequence>

@ -80,9 +80,12 @@ is divided into following sections:
</and> </and>
</condition> </condition>
<condition property="do.archive"> <condition property="do.archive">
<not> <or>
<istrue value="${jar.archive.disabled}"/> <not>
</not> <istrue value="${jar.archive.disabled}"/>
</not>
<istrue value="${not.archive.disabled}"/>
</or>
</condition> </condition>
<condition property="do.mkdist"> <condition property="do.mkdist">
<and> <and>
@ -170,7 +173,12 @@ is divided into following sections:
</condition> </condition>
<path id="endorsed.classpath.path" path="${endorsed.classpath}"/> <path id="endorsed.classpath.path" path="${endorsed.classpath}"/>
<condition else="" property="endorsed.classpath.cmd.line.arg" value="-Xbootclasspath/p:'${toString:endorsed.classpath.path}'"> <condition else="" property="endorsed.classpath.cmd.line.arg" value="-Xbootclasspath/p:'${toString:endorsed.classpath.path}'">
<length length="0" string="${endorsed.classpath}" when="greater"/> <and>
<isset property="endorsed.classpath"/>
<not>
<equals arg1="${endorsed.classpath}" arg2="" trim="true"/>
</not>
</and>
</condition> </condition>
<condition else="" property="javac.profile.cmd.line.arg" value="-profile ${javac.profile}"> <condition else="" property="javac.profile.cmd.line.arg" value="-profile ${javac.profile}">
<isset property="profile.available"/> <isset property="profile.available"/>
@ -827,7 +835,7 @@ is divided into following sections:
</pathconvert> </pathconvert>
<taskdef classname="org.netbeans.modules.java.j2seproject.copylibstask.CopyLibs" classpath="${libs.CopyLibs.classpath}" name="copylibs"/> <taskdef classname="org.netbeans.modules.java.j2seproject.copylibstask.CopyLibs" classpath="${libs.CopyLibs.classpath}" name="copylibs"/>
<copylibs compress="${jar.compress}" excludeFromCopy="${copylibs.excludes}" index="${jar.index}" indexMetaInf="${jar.index.metainf}" jarfile="${dist.jar}" manifest="@{manifest}" rebase="${copylibs.rebase}" runtimeclasspath="${run.classpath.without.build.classes.dir}"> <copylibs compress="${jar.compress}" excludeFromCopy="${copylibs.excludes}" index="${jar.index}" indexMetaInf="${jar.index.metainf}" jarfile="${dist.jar}" manifest="@{manifest}" rebase="${copylibs.rebase}" runtimeclasspath="${run.classpath.without.build.classes.dir}">
<fileset dir="${build.classes.dir}"/> <fileset dir="${build.classes.dir}" excludes="${dist.archive.excludes}"/>
<manifest> <manifest>
<attribute name="Class-Path" value="${jar.classpath}"/> <attribute name="Class-Path" value="${jar.classpath}"/>
<customize/> <customize/>
@ -839,7 +847,7 @@ is divided into following sections:
<target name="-init-presetdef-jar"> <target name="-init-presetdef-jar">
<presetdef name="jar" uri="http://www.netbeans.org/ns/j2se-project/1"> <presetdef name="jar" uri="http://www.netbeans.org/ns/j2se-project/1">
<jar compress="${jar.compress}" index="${jar.index}" jarfile="${dist.jar}"> <jar compress="${jar.compress}" index="${jar.index}" jarfile="${dist.jar}">
<j2seproject1:fileset dir="${build.classes.dir}"/> <j2seproject1:fileset dir="${build.classes.dir}" excludes="${dist.archive.excludes}"/>
</jar> </jar>
</presetdef> </presetdef>
</target> </target>
@ -1194,11 +1202,14 @@ is divided into following sections:
</not> </not>
</and> </and>
</condition> </condition>
<javadoc additionalparam="${javadoc.additionalparam}" author="${javadoc.author}" charset="UTF-8" destdir="${dist.javadoc.dir}" docencoding="UTF-8" encoding="${javadoc.encoding.used}" failonerror="true" noindex="${javadoc.noindex}" nonavbar="${javadoc.nonavbar}" notree="${javadoc.notree}" private="${javadoc.private}" source="${javac.source}" splitindex="${javadoc.splitindex}" use="${javadoc.use}" useexternalfile="true" version="${javadoc.version}" windowtitle="${javadoc.windowtitle}"> <condition else="" property="bug5101868workaround" value="*.java">
<matches pattern="1\.[56](\..*)?" string="${java.version}"/>
</condition>
<javadoc additionalparam="-J-Dfile.encoding=${file.encoding} ${javadoc.additionalparam}" author="${javadoc.author}" charset="UTF-8" destdir="${dist.javadoc.dir}" docencoding="UTF-8" encoding="${javadoc.encoding.used}" failonerror="true" noindex="${javadoc.noindex}" nonavbar="${javadoc.nonavbar}" notree="${javadoc.notree}" private="${javadoc.private}" source="${javac.source}" splitindex="${javadoc.splitindex}" use="${javadoc.use}" useexternalfile="true" version="${javadoc.version}" windowtitle="${javadoc.windowtitle}">
<classpath> <classpath>
<path path="${javac.classpath}"/> <path path="${javac.classpath}"/>
</classpath> </classpath>
<fileset dir="${src.dir}" excludes="*.java,${excludes}" includes="${includes}"> <fileset dir="${src.dir}" excludes="${bug5101868workaround},${excludes}" includes="${includes}">
<filename name="**/*.java"/> <filename name="**/*.java"/>
</fileset> </fileset>
<fileset dir="${build.generated.sources.dir}" erroronmissingdir="false"> <fileset dir="${build.generated.sources.dir}" erroronmissingdir="false">
@ -1272,7 +1283,7 @@ is divided into following sections:
<mkdir dir="${build.test.results.dir}"/> <mkdir dir="${build.test.results.dir}"/>
</target> </target>
<target depends="init,compile-test,-pre-test-run" if="have.tests" name="-do-test-run"> <target depends="init,compile-test,-pre-test-run" if="have.tests" name="-do-test-run">
<j2seproject3:test testincludes="**/*Test.java"/> <j2seproject3:test includes="${includes}" testincludes="**/*Test.java"/>
</target> </target>
<target depends="init,compile-test,-pre-test-run,-do-test-run" if="have.tests" name="-post-test-run"> <target depends="init,compile-test,-pre-test-run,-do-test-run" if="have.tests" name="-post-test-run">
<fail if="tests.failed" unless="ignore.failing.tests">Some tests failed; see details above.</fail> <fail if="tests.failed" unless="ignore.failing.tests">Some tests failed; see details above.</fail>

@ -4,5 +4,5 @@ build.xml.stylesheet.CRC32=8064a381@1.68.1.46
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
nbproject/build-impl.xml.data.CRC32=5246bcd2 nbproject/build-impl.xml.data.CRC32=5246bcd2
nbproject/build-impl.xml.script.CRC32=ca8bcaaf nbproject/build-impl.xml.script.CRC32=0f1cf190
nbproject/build-impl.xml.stylesheet.CRC32=cdba79fa@1.68.1.46 nbproject/build-impl.xml.stylesheet.CRC32=876e7a8f@1.74.1.48