mirror of
https://github.com/badvision/lawless-legends.git
synced 2024-08-10 07:28:58 +00:00
Merge branch 'master' of https://github.com/badvision/lawless-legends
This commit is contained in:
commit
cdafd665fa
@ -845,7 +845,7 @@ public class ApplicationUIControllerImpl extends ApplicationUIController {
|
||||
UIAction.editScript(event.getSource().getItems().get(event.getIndex()));
|
||||
}
|
||||
});
|
||||
final DragDropHelper<Script> scriptDragDrop = new DragDropHelper<>(Script.class);
|
||||
final TransferHelper<Script> scriptDragDrop = new TransferHelper<>(Script.class);
|
||||
mapScriptsList.setCellFactory(new Callback<ListView<Script>, ListCell<Script>>() {
|
||||
@Override
|
||||
public ListCell<Script> call(ListView<Script> param) {
|
||||
|
@ -0,0 +1,96 @@
|
||||
package org.badvision.outlaweditor;
|
||||
|
||||
import javafx.scene.shape.Rectangle;
|
||||
import org.badvision.outlaweditor.data.xml.Image;
|
||||
|
||||
/**
|
||||
* Details about part of an image
|
||||
* @author blurry
|
||||
* @param <T> Represents the image renderer that can produce this image
|
||||
*/
|
||||
public class ImageClip<T extends ImageRenderer> {
|
||||
private final int clipId;
|
||||
private Rectangle bounds;
|
||||
private Image source;
|
||||
private ImageRenderer renderer;
|
||||
private Platform platform;
|
||||
private boolean allSelected;
|
||||
public ImageClip(Image src, boolean all, ImageRenderer r, Platform p) {
|
||||
source = src;
|
||||
renderer = r;
|
||||
platform = p;
|
||||
clipId = (int) (Math.random() * (double) Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
public ImageClip(Image src, int x1, int y1, int x2, int y2, ImageRenderer r, Platform p) {
|
||||
this(src, false, r, p);
|
||||
bounds = new Rectangle(
|
||||
Math.min(x1,x2),
|
||||
Math.min(y1,y2),
|
||||
Math.abs(x2-x1),
|
||||
Math.abs(y2-y1));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the clipId
|
||||
*/
|
||||
public int getClipId() {
|
||||
return clipId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the bounds
|
||||
*/
|
||||
public Rectangle getBounds() {
|
||||
return bounds;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bounds the bounds to set
|
||||
*/
|
||||
public void setBounds(Rectangle bounds) {
|
||||
this.bounds = bounds;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the source
|
||||
*/
|
||||
public Image getSource() {
|
||||
return source;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param source the source to set
|
||||
*/
|
||||
public void setSource(Image source) {
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the renderer
|
||||
*/
|
||||
public ImageRenderer getRenderer() {
|
||||
return renderer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param renderer the renderer to set
|
||||
*/
|
||||
public void setRenderer(ImageRenderer renderer) {
|
||||
this.renderer = renderer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the platform
|
||||
*/
|
||||
public Platform getPlatform() {
|
||||
return platform;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param platform the platform to set
|
||||
*/
|
||||
public void setPlatform(Platform platform) {
|
||||
this.platform = platform;
|
||||
}
|
||||
}
|
@ -30,7 +30,7 @@ import javafx.scene.paint.Color;
|
||||
import javafx.scene.shape.Rectangle;
|
||||
import javafx.stage.Stage;
|
||||
import static org.badvision.outlaweditor.Application.currentPlatform;
|
||||
import org.badvision.outlaweditor.DragDropHelper.DropEventHandler;
|
||||
import org.badvision.outlaweditor.TransferHelper.DropEventHandler;
|
||||
import org.badvision.outlaweditor.data.TileMap;
|
||||
import org.badvision.outlaweditor.data.TileUtils;
|
||||
import org.badvision.outlaweditor.data.xml.Map;
|
||||
@ -53,7 +53,7 @@ public class MapEditor extends Editor<Map, MapEditor.DrawMode> implements EventH
|
||||
TileMap currentMap;
|
||||
double tileWidth = currentPlatform.tileRenderer.getWidth() * zoom;
|
||||
double tileHeight = currentPlatform.tileRenderer.getHeight() * zoom;
|
||||
public static DragDropHelper<Script> scriptDragDrop = new DragDropHelper<>(Script.class);
|
||||
public static TransferHelper<Script> scriptDragDrop = new TransferHelper<>(Script.class);
|
||||
|
||||
@Override
|
||||
public void setEntity(Map t) {
|
||||
|
@ -18,7 +18,7 @@ import javafx.scene.input.TransferMode;
|
||||
* @author blurry
|
||||
* @param <T> Type of object being passed
|
||||
*/
|
||||
public class DragDropHelper<T> {
|
||||
public class TransferHelper<T> {
|
||||
|
||||
Class type;
|
||||
DataFormat format;
|
||||
@ -30,15 +30,19 @@ public class DragDropHelper<T> {
|
||||
public void handle(T object, double x, double y);
|
||||
}
|
||||
|
||||
private DragDropHelper() {
|
||||
private TransferHelper() {
|
||||
}
|
||||
|
||||
public DragDropHelper(Class<T> clazz) {
|
||||
public TransferHelper(Class<T> clazz) {
|
||||
type = clazz;
|
||||
format = getDataFormat(clazz);
|
||||
}
|
||||
|
||||
public static DataFormat getDataFormat(Class clazz) {
|
||||
if (!dataFormats.containsKey(clazz.getName())) {
|
||||
dataFormats.put(clazz.getName(), new DataFormat(clazz.getName()));
|
||||
}
|
||||
format = dataFormats.get(clazz.getName());
|
||||
return dataFormats.get(clazz.getName());
|
||||
}
|
||||
|
||||
public void registerDragSupport(final Node source, final T object) {
|
Loading…
Reference in New Issue
Block a user