mirror of
https://github.com/badvision/lawless-legends.git
synced 2024-12-27 10:29:40 +00:00
Merge branch 'master' of https://github.com/badvision/lawless-legends
This commit is contained in:
commit
f0a53623b5
@ -79,7 +79,7 @@
|
||||
<dependency>
|
||||
<groupId>javafx-packager</groupId>
|
||||
<artifactId>javafx-packager</artifactId>
|
||||
<version>1.7</version>
|
||||
<version>1.8</version>
|
||||
<systemPath>${java.home}/../lib/ant-javafx.jar</systemPath>
|
||||
<scope>system</scope>
|
||||
</dependency>
|
||||
|
@ -1,9 +1,12 @@
|
||||
package org.badvision.outlaweditor;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.stream.Collectors;
|
||||
import javafx.application.Platform;
|
||||
import javafx.beans.value.ObservableValue;
|
||||
import javafx.event.EventHandler;
|
||||
@ -247,50 +250,75 @@ public class MapEditor extends Editor<Map, MapEditor.DrawMode> implements EventH
|
||||
|
||||
private static final int dashLength = 3;
|
||||
|
||||
private final Set<Script> invisibleScripts = new HashSet<>();
|
||||
|
||||
public boolean isScriptVisible(Script script) {
|
||||
return !invisibleScripts.contains(script);
|
||||
}
|
||||
|
||||
public void setScriptVisible(Script script, boolean visible) {
|
||||
setScriptVisible(script, visible, true);
|
||||
}
|
||||
|
||||
public void setScriptVisible(Script script, boolean visible, boolean redraw) {
|
||||
if (visible) {
|
||||
invisibleScripts.remove(script);
|
||||
} else {
|
||||
invisibleScripts.add(script);
|
||||
}
|
||||
if (redraw) {
|
||||
redraw();
|
||||
}
|
||||
}
|
||||
|
||||
private void highlightScripts(int x, int y, List<Script> scripts) {
|
||||
if (scripts == null || scripts.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
List<Script> visibleScripts = scripts.stream().filter(this::isScriptVisible).collect(Collectors.toList());
|
||||
if (visibleScripts.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
GraphicsContext gc = drawCanvas.getGraphicsContext2D();
|
||||
int idx = 0;
|
||||
double xx = x * tileWidth;
|
||||
double yy = y * tileHeight;
|
||||
gc.setLineWidth(4);
|
||||
for (int i = 0; i < tileWidth - 2; i += dashLength) {
|
||||
idx = (idx + 1) % scripts.size();
|
||||
idx = (idx + 1) % visibleScripts.size();
|
||||
gc.beginPath();
|
||||
gc.moveTo(xx, yy);
|
||||
currentMap.getScriptColor(scripts.get(idx)).ifPresent(gc::setStroke);
|
||||
currentMap.getScriptColor(visibleScripts.get(idx)).ifPresent(gc::setStroke);
|
||||
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();
|
||||
idx = (idx + 1) % visibleScripts.size();
|
||||
gc.beginPath();
|
||||
gc.moveTo(xx, yy);
|
||||
currentMap.getScriptColor(scripts.get(idx)).ifPresent(gc::setStroke);
|
||||
currentMap.getScriptColor(visibleScripts.get(idx)).ifPresent(gc::setStroke);
|
||||
yy += dashLength;
|
||||
gc.lineTo(xx, yy);
|
||||
gc.setEffect(new DropShadow(2, Color.BLACK));
|
||||
gc.stroke();
|
||||
}
|
||||
for (int i = 0; i < tileWidth - 2; i += dashLength) {
|
||||
idx = (idx + 1) % scripts.size();
|
||||
idx = (idx + 1) % visibleScripts.size();
|
||||
gc.beginPath();
|
||||
gc.moveTo(xx, yy);
|
||||
currentMap.getScriptColor(scripts.get(idx)).ifPresent(gc::setStroke);
|
||||
currentMap.getScriptColor(visibleScripts.get(idx)).ifPresent(gc::setStroke);
|
||||
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();
|
||||
idx = (idx + 1) % visibleScripts.size();
|
||||
gc.beginPath();
|
||||
gc.moveTo(xx, yy);
|
||||
currentMap.getScriptColor(scripts.get(idx)).ifPresent(gc::setStroke);
|
||||
currentMap.getScriptColor(visibleScripts.get(idx)).ifPresent(gc::setStroke);
|
||||
yy -= dashLength;
|
||||
gc.lineTo(xx, yy);
|
||||
gc.setEffect(new DropShadow(2, Color.BLACK));
|
||||
|
@ -150,7 +150,7 @@ public class UIAction {
|
||||
|
||||
public static WritableImage getBadImage(int width, int height) {
|
||||
if (badImage == null) {
|
||||
badImage = new Image("/images/icon_brokenLink.png");
|
||||
badImage = new Image("images/icon_brokenLink.png");
|
||||
}
|
||||
WritableImage img = new WritableImage(width, height);
|
||||
img.getPixelWriter().setPixels(0, 0, (int) badImage.getWidth(), (int) badImage.getHeight(), badImage.getPixelReader(), 0, 0);
|
||||
|
@ -1,12 +1,16 @@
|
||||
package org.badvision.outlaweditor.ui.impl;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.scene.control.ListCell;
|
||||
import javafx.scene.control.ListView;
|
||||
import javafx.scene.control.MenuItem;
|
||||
import javafx.scene.control.Menu;
|
||||
import javafx.scene.control.RadioMenuItem;
|
||||
import javafx.scene.control.ToggleGroup;
|
||||
import javafx.scene.control.cell.ComboBoxListCell;
|
||||
import javafx.scene.image.Image;
|
||||
import javafx.scene.image.ImageView;
|
||||
import javafx.scene.image.WritableImage;
|
||||
import javafx.util.Callback;
|
||||
@ -197,8 +201,10 @@ public class MapEditorTabControllerImpl extends MapEditorTabController {
|
||||
if (getCurrentMap() != null && getCurrentMap().equals(m)) {
|
||||
return;
|
||||
}
|
||||
Tile currentTile = null;
|
||||
// mapEditorAnchorPane.getChildren().clear();
|
||||
if (getCurrentEditor() != null) {
|
||||
currentTile = getCurrentEditor().getCurrentTile();
|
||||
getCurrentEditor().unregister();
|
||||
}
|
||||
if (m == null) {
|
||||
@ -238,6 +244,9 @@ public class MapEditorTabControllerImpl extends MapEditorTabController {
|
||||
e.buildEditorUI(mapEditorAnchorPane);
|
||||
setCurrentEditor(e);
|
||||
e.setupDragDrop(scriptDragDrop, toolDragDrop);
|
||||
if (currentTile != null) {
|
||||
e.setCurrentTile(currentTile);
|
||||
}
|
||||
}
|
||||
redrawMapScripts();
|
||||
}
|
||||
@ -279,19 +288,40 @@ public class MapEditorTabControllerImpl extends MapEditorTabController {
|
||||
@Override
|
||||
public void rebuildTileSelectors() {
|
||||
mapSelectTile.getItems().clear();
|
||||
Application.gameData.getTile().stream().map((Tile t) -> {
|
||||
|
||||
ToggleGroup tileGroup = new ToggleGroup();
|
||||
HashMap<String,Menu> submenus = new HashMap<>();
|
||||
Application.gameData.getTile().stream().forEach((Tile t) -> {
|
||||
WritableImage img = TileUtils.getImage(t, currentPlatform);
|
||||
ImageView iv = new ImageView(img);
|
||||
MenuItem mapSelectItem = new MenuItem(String.valueOf(t.getCategory())+"/"+String.valueOf(t.getName()), iv);
|
||||
mapSelectItem.setGraphic(new ImageView(TileUtils.getImage(t, currentPlatform)));
|
||||
mapSelectItem.setOnAction((event) -> {
|
||||
String category = String.valueOf(t.getCategory());
|
||||
Menu categoryMenu = submenus.get(category);
|
||||
if (categoryMenu == null) {
|
||||
categoryMenu = new Menu(category);
|
||||
submenus.put(category, categoryMenu);
|
||||
}
|
||||
final Menu theMenu = categoryMenu;
|
||||
RadioMenuItem tileSelection = new RadioMenuItem(String.valueOf(t.getName()), iv);
|
||||
tileSelection.setToggleGroup(tileGroup);
|
||||
if (getCurrentEditor() != null && getCurrentEditor().getCurrentTile() == t) {
|
||||
tileGroup.selectToggle(tileSelection);
|
||||
theMenu.setStyle("-fx-font-weight:bold; -fx-text-fill:blue");
|
||||
}
|
||||
tileSelection.setGraphic(new ImageView(TileUtils.getImage(t, currentPlatform)));
|
||||
tileSelection.setOnAction((event) -> {
|
||||
if (getCurrentEditor() != null) {
|
||||
getCurrentEditor().setCurrentTile(t);
|
||||
}
|
||||
tileGroup.selectToggle(tileSelection);
|
||||
submenus.values().stream().forEach((menu) -> {
|
||||
menu.setStyle(null);
|
||||
});
|
||||
return mapSelectItem;
|
||||
}).forEach((mapSelectItem) -> {
|
||||
mapSelectTile.getItems().add(mapSelectItem);
|
||||
theMenu.setStyle("-fx-font-weight:bold; -fx-text-fill:blue");
|
||||
});
|
||||
categoryMenu.getItems().add(tileSelection);
|
||||
});
|
||||
submenus.values().stream().forEach((menu) -> {
|
||||
mapSelectTile.getItems().add(menu);
|
||||
});
|
||||
}
|
||||
|
||||
@ -310,9 +340,16 @@ public class MapEditorTabControllerImpl extends MapEditorTabController {
|
||||
if (empty || item == null) {
|
||||
setText("");
|
||||
} else {
|
||||
ImageView visibleIcon = getVisibleIcon(item);
|
||||
visibleIcon.setOnMouseClicked((e)->{
|
||||
toggleVisibility(visibleIcon, item);
|
||||
mapScriptsList.getSelectionModel().clearSelection();
|
||||
});
|
||||
setGraphic(visibleIcon);
|
||||
getCurrentEditor().getCurrentMap().getScriptColor(item).ifPresent(this::setTextFill);
|
||||
setText(item.getName());
|
||||
scriptDragDrop.registerDragSupport(this, item);
|
||||
visibleIcon.setMouseTransparent(false);
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -329,4 +366,26 @@ public class MapEditorTabControllerImpl extends MapEditorTabController {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static final Image VISIBLE_IMAGE = new Image("images/visible.png");
|
||||
public static final Image INVISIBLE_IMAGE = new Image("images/not_visible.png");
|
||||
|
||||
private ImageView getVisibleIcon(Script script) {
|
||||
if (getCurrentEditor().isScriptVisible(script)) {
|
||||
return new ImageView(VISIBLE_IMAGE);
|
||||
} else {
|
||||
return new ImageView(INVISIBLE_IMAGE);
|
||||
}
|
||||
}
|
||||
|
||||
private void toggleVisibility(ImageView visibilityIcon, Script script) {
|
||||
if (script.getName() == null) return;
|
||||
if (getCurrentEditor().isScriptVisible(script)) {
|
||||
getCurrentEditor().setScriptVisible(script, false);
|
||||
visibilityIcon.setImage(INVISIBLE_IMAGE);
|
||||
} else {
|
||||
getCurrentEditor().setScriptVisible(script, true);
|
||||
visibilityIcon.setImage(VISIBLE_IMAGE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -229,6 +229,7 @@ public class TileEditorTabControllerImpl extends TileEditorTabController {
|
||||
|
||||
@Override
|
||||
public void rebuildTileSelectors() {
|
||||
Tile t = getCurrentTile();
|
||||
tileSelector.getItems().clear();
|
||||
List<Tile> allTiles = Application.gameData.getTile();
|
||||
allTiles.sort((Tile o1, Tile o2) -> {
|
||||
@ -240,5 +241,6 @@ public class TileEditorTabControllerImpl extends TileEditorTabController {
|
||||
});
|
||||
tileSelector.getItems().addAll(allTiles);
|
||||
tileSelector.getSelectionModel().select(allTiles.indexOf(getCurrentTile()));
|
||||
setCurrentTile(t);
|
||||
}
|
||||
}
|
||||
|
BIN
OutlawEditor/src/main/resources/images/not_visible.png
Normal file
BIN
OutlawEditor/src/main/resources/images/not_visible.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 890 B |
BIN
OutlawEditor/src/main/resources/images/visible.png
Normal file
BIN
OutlawEditor/src/main/resources/images/visible.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 659 B |
Loading…
Reference in New Issue
Block a user