Added script coloring in the scripts list -- makes it possible to tell what script is associated on the map (yay!)

This commit is contained in:
Brendan Robert
2014-07-04 16:52:14 -05:00
parent f0c628016e
commit 41265e8f59
3 changed files with 9 additions and 6 deletions

View File

@@ -253,7 +253,7 @@ public class MapEditor extends Editor<Map, MapEditor.DrawMode> implements EventH
idx = (idx + 1) % scripts.size(); idx = (idx + 1) % scripts.size();
gc.beginPath(); gc.beginPath();
gc.moveTo(xx,yy); gc.moveTo(xx,yy);
gc.setStroke(currentMap.getScriptColor(scripts.get(idx))); currentMap.getScriptColor(scripts.get(idx)).ifPresent(gc::setStroke);
xx += dashLength; xx += dashLength;
gc.lineTo(xx, yy); gc.lineTo(xx, yy);
gc.setEffect(new DropShadow(2, Color.BLACK)); gc.setEffect(new DropShadow(2, Color.BLACK));
@@ -263,7 +263,7 @@ public class MapEditor extends Editor<Map, MapEditor.DrawMode> implements EventH
idx = (idx + 1) % scripts.size(); idx = (idx + 1) % scripts.size();
gc.beginPath(); gc.beginPath();
gc.moveTo(xx,yy); gc.moveTo(xx,yy);
gc.setStroke(currentMap.getScriptColor(scripts.get(idx))); currentMap.getScriptColor(scripts.get(idx)).ifPresent(gc::setStroke);
yy += dashLength; yy += dashLength;
gc.lineTo(xx, yy); gc.lineTo(xx, yy);
gc.setEffect(new DropShadow(2, Color.BLACK)); gc.setEffect(new DropShadow(2, Color.BLACK));
@@ -273,7 +273,7 @@ public class MapEditor extends Editor<Map, MapEditor.DrawMode> implements EventH
idx = (idx + 1) % scripts.size(); idx = (idx + 1) % scripts.size();
gc.beginPath(); gc.beginPath();
gc.moveTo(xx,yy); gc.moveTo(xx,yy);
gc.setStroke(currentMap.getScriptColor(scripts.get(idx))); currentMap.getScriptColor(scripts.get(idx)).ifPresent(gc::setStroke);
xx -= dashLength; xx -= dashLength;
gc.lineTo(xx, yy); gc.lineTo(xx, yy);
gc.setEffect(new DropShadow(2, Color.BLACK)); gc.setEffect(new DropShadow(2, Color.BLACK));
@@ -283,7 +283,7 @@ public class MapEditor extends Editor<Map, MapEditor.DrawMode> implements EventH
idx = (idx + 1) % scripts.size(); idx = (idx + 1) % scripts.size();
gc.beginPath(); gc.beginPath();
gc.moveTo(xx,yy); gc.moveTo(xx,yy);
gc.setStroke(currentMap.getScriptColor(scripts.get(idx))); currentMap.getScriptColor(scripts.get(idx)).ifPresent(gc::setStroke);
yy -= dashLength; yy -= dashLength;
gc.lineTo(xx, yy); gc.lineTo(xx, yy);
gc.setEffect(new DropShadow(2, Color.BLACK)); gc.setEffect(new DropShadow(2, Color.BLACK));

View File

@@ -6,6 +6,7 @@ import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Optional;
import java.util.Set; import java.util.Set;
import javafx.scene.image.WritableImage; import javafx.scene.image.WritableImage;
import javafx.scene.paint.Color; import javafx.scene.paint.Color;
@@ -46,8 +47,8 @@ public class TileMap extends ArrayList<ArrayList<Tile>> implements Serializable
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<>();
public Color getScriptColor(Script s) { public Optional<Color> getScriptColor(Script s) {
return scriptColors.get(s); return Optional.ofNullable(scriptColors.get(s));
} }
public List<Script> getLocationScripts(int x, int y) { public List<Script> getLocationScripts(int x, int y) {
@@ -79,6 +80,7 @@ public class TileMap extends ArrayList<ArrayList<Tile>> implements Serializable
locationScripts.put(loc, list); locationScripts.put(loc, list);
} }
list.add(s); list.add(s);
Application.getInstance().getController().redrawScripts();
} }
private int getMortonNumber(int x, int y) { private int getMortonNumber(int x, int y) {

View File

@@ -306,6 +306,7 @@ public class MapEditorTabControllerImpl extends MapEditorTabController {
if (empty || item == null) { if (empty || item == null) {
setText(""); setText("");
} else { } else {
getCurrentEditor().getCurrentMap().getScriptColor(item).ifPresent(this::setTextFill);
setText(item.getName()); setText(item.getName());
scriptDragDrop.registerDragSupport(this, item); scriptDragDrop.registerDragSupport(this, item);
} }