mirror of
https://github.com/badvision/lawless-legends.git
synced 2024-07-05 01:28:57 +00:00
Scripts assigned to the map are now visible. Still needs some UX to be fully useful but it's sufficient for basic stuff.
This commit is contained in:
parent
c4d6742aec
commit
6c1a1c18af
@ -12,6 +12,7 @@ import javafx.scene.ImageCursor;
|
|||||||
import javafx.scene.Scene;
|
import javafx.scene.Scene;
|
||||||
import javafx.scene.canvas.Canvas;
|
import javafx.scene.canvas.Canvas;
|
||||||
import javafx.scene.canvas.GraphicsContext;
|
import javafx.scene.canvas.GraphicsContext;
|
||||||
|
import javafx.scene.effect.DropShadow;
|
||||||
import javafx.scene.image.ImageView;
|
import javafx.scene.image.ImageView;
|
||||||
import javafx.scene.image.WritableImage;
|
import javafx.scene.image.WritableImage;
|
||||||
import javafx.scene.input.Clipboard;
|
import javafx.scene.input.Clipboard;
|
||||||
@ -237,41 +238,57 @@ public class MapEditor extends Editor<Map, MapEditor.DrawMode> implements EventH
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final int dashLength=3;
|
||||||
|
|
||||||
private void highlightScripts(int x, int y, List<Script> scripts) {
|
private void highlightScripts(int x, int y, List<Script> scripts) {
|
||||||
if (scripts == null || scripts.isEmpty()) {
|
if (scripts == null || scripts.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
GraphicsContext gc = drawCanvas.getGraphicsContext2D();
|
GraphicsContext gc = drawCanvas.getGraphicsContext2D();
|
||||||
int idx = 0;
|
int idx = 0;
|
||||||
int xx = (int) (x * tileWidth);
|
double xx = x * tileWidth;
|
||||||
int yy = (int) (y * tileHeight);
|
double yy = y * tileHeight;
|
||||||
gc.setLineWidth(2.5);
|
gc.setLineWidth(4);
|
||||||
gc.setStroke(currentMap.getScriptColor(scripts.get(0)));
|
for (int i = 0; i < tileWidth-2; i += dashLength) {
|
||||||
gc.rect(xx, yy, tileWidth, tileHeight);
|
idx = (idx + 1) % scripts.size();
|
||||||
// gc.beginPath();
|
gc.beginPath();
|
||||||
// gc.moveTo(xx,yy);
|
gc.moveTo(xx,yy);
|
||||||
// for (int i = 0; i < tileWidth; i += 2, xx += 2) {
|
gc.setStroke(currentMap.getScriptColor(scripts.get(idx)));
|
||||||
// idx = (idx + 1) % scripts.size();
|
xx += dashLength;
|
||||||
// gc.setStroke(currentMap.getScriptColor(scripts.get(idx)));
|
gc.lineTo(xx, yy);
|
||||||
// gc.lineTo(xx, yy);
|
gc.setEffect(new DropShadow(2, Color.BLACK));
|
||||||
// }
|
gc.stroke();
|
||||||
// for (int i = 0; i < tileHeight; i += 2, yy += 2) {
|
}
|
||||||
// idx = (idx + 1) % scripts.size();
|
for (int i = 0; i < tileHeight-2; i += dashLength) {
|
||||||
// gc.setStroke(currentMap.getScriptColor(scripts.get(idx)));
|
idx = (idx + 1) % scripts.size();
|
||||||
// gc.lineTo(xx, yy);
|
gc.beginPath();
|
||||||
// }
|
gc.moveTo(xx,yy);
|
||||||
// for (int i = 0; i < tileWidth; i += 2, xx -= 2) {
|
gc.setStroke(currentMap.getScriptColor(scripts.get(idx)));
|
||||||
// idx = (idx + 1) % scripts.size();
|
yy += dashLength;
|
||||||
// gc.setStroke(currentMap.getScriptColor(scripts.get(idx)));
|
gc.lineTo(xx, yy);
|
||||||
// gc.lineTo(xx, yy);
|
gc.setEffect(new DropShadow(2, Color.BLACK));
|
||||||
// }
|
gc.stroke();
|
||||||
// for (int i = 0; i < tileHeight; i += 2, yy -= 2) {
|
}
|
||||||
// idx = (idx + 1) % scripts.size();
|
for (int i = 0; i < tileWidth-2; i += dashLength) {
|
||||||
// gc.setStroke(currentMap.getScriptColor(scripts.get(idx)));
|
idx = (idx + 1) % scripts.size();
|
||||||
// gc.lineTo(xx, yy);
|
gc.beginPath();
|
||||||
// }
|
gc.moveTo(xx,yy);
|
||||||
// gc.closePath();
|
gc.setStroke(currentMap.getScriptColor(scripts.get(idx)));
|
||||||
|
xx -= dashLength;
|
||||||
|
gc.lineTo(xx, yy);
|
||||||
|
gc.setEffect(new DropShadow(2, Color.BLACK));
|
||||||
|
gc.stroke();
|
||||||
|
}
|
||||||
|
for (int i = 0; i < tileHeight-2; i += dashLength) {
|
||||||
|
idx = (idx + 1) % scripts.size();
|
||||||
|
gc.beginPath();
|
||||||
|
gc.moveTo(xx,yy);
|
||||||
|
gc.setStroke(currentMap.getScriptColor(scripts.get(idx)));
|
||||||
|
yy -= dashLength;
|
||||||
|
gc.lineTo(xx, yy);
|
||||||
|
gc.setEffect(new DropShadow(2, Color.BLACK));
|
||||||
|
gc.stroke();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setupDragDrop(TransferHelper<Script> scriptHelper) {
|
public void setupDragDrop(TransferHelper<Script> scriptHelper) {
|
||||||
|
@ -40,9 +40,9 @@ public class TileMap extends ArrayList<ArrayList<Tile>> implements Serializable
|
|||||||
loadFromMap(m);
|
loadFromMap(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final double SATURATION = 0.5;
|
public static final double SATURATION = 0.75;
|
||||||
public static final double VALUE = 1.0;
|
public static final double VALUE = 1.0;
|
||||||
public static double HUE = 0;
|
public static double HUE = 180;
|
||||||
private final java.util.Map<Integer, List<Script>> locationScripts = new HashMap<>();
|
private final java.util.Map<Integer, List<Script>> locationScripts = new HashMap<>();
|
||||||
private final java.util.Map<Script, Color> scriptColors = new HashMap<>();
|
private final java.util.Map<Script, Color> scriptColors = new HashMap<>();
|
||||||
|
|
||||||
@ -70,7 +70,7 @@ public class TileMap extends ArrayList<ArrayList<Tile>> implements Serializable
|
|||||||
private void registerLocationScript(int x, int y, Script s) {
|
private void registerLocationScript(int x, int y, Script s) {
|
||||||
if (!scriptColors.containsKey(s)) {
|
if (!scriptColors.containsKey(s)) {
|
||||||
scriptColors.put(s, Color.hsb(HUE, SATURATION, VALUE));
|
scriptColors.put(s, Color.hsb(HUE, SATURATION, VALUE));
|
||||||
HUE = (HUE + 20) % 360;
|
HUE = (HUE + 35) % 360;
|
||||||
}
|
}
|
||||||
int loc = getMortonNumber(x, y);
|
int loc = getMortonNumber(x, y);
|
||||||
List<Script> list = locationScripts.get(loc);
|
List<Script> list = locationScripts.get(loc);
|
||||||
|
Loading…
Reference in New Issue
Block a user