mirror of
https://github.com/badvision/lawless-legends.git
synced 2024-07-17 19:28:55 +00:00
Merge branch 'master' of https://github.com/badvision/lawless-legends
This commit is contained in:
commit
7ebf23f4f0
@ -8,7 +8,7 @@ import javafx.scene.image.WritableImage;
|
|||||||
*/
|
*/
|
||||||
public abstract class TileRenderer {
|
public abstract class TileRenderer {
|
||||||
|
|
||||||
public abstract WritableImage redrawSprite(byte[] spriteData, WritableImage image);
|
public abstract WritableImage redrawSprite(byte[] spriteData, WritableImage image, boolean useBleedOver);
|
||||||
|
|
||||||
public abstract int getWidth();
|
public abstract int getWidth();
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ public class AppleTileRenderer extends TileRenderer {
|
|||||||
public static boolean useSolidPalette = true;
|
public static boolean useSolidPalette = true;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public WritableImage redrawSprite(byte[] spriteData, WritableImage img) {
|
public WritableImage redrawSprite(byte[] spriteData, WritableImage img, boolean useBleedOver) {
|
||||||
if (img == null) {
|
if (img == null) {
|
||||||
img = new WritableImage(28, 32);
|
img = new WritableImage(28, 32);
|
||||||
}
|
}
|
||||||
@ -23,12 +23,14 @@ public class AppleTileRenderer extends TileRenderer {
|
|||||||
}
|
}
|
||||||
int[][] palette = useSolidPalette ? solidPalette : textPalette;
|
int[][] palette = useSolidPalette ? solidPalette : textPalette;
|
||||||
for (int y = 0; y < 16; y++) {
|
for (int y = 0; y < 16; y++) {
|
||||||
int bleedOver = (spriteData[y * 2 + 1] & 192) == 192 ? 256 : 0;
|
int bleedOver = useBleedOver ? (spriteData[y * 2 + 1] & 192) == 192 ? 256 : 0 : 0;
|
||||||
int scan = hgrToDhgr[bleedOver | (spriteData[y * 2] & 255)][spriteData[y * 2 + 1] & 255];
|
int scan = hgrToDhgr[bleedOver | (spriteData[y * 2] & 255)][spriteData[y * 2 + 1] & 255];
|
||||||
int last = (scan >> 26) & 3;
|
int last = (scan >> 26) & 3;
|
||||||
int keep = scan & 0xff;
|
int keep = scan & 0xff;
|
||||||
scan <<= 2;
|
scan <<= 2;
|
||||||
scan |= last;
|
if (useBleedOver) {
|
||||||
|
scan |= last;
|
||||||
|
}
|
||||||
for (int x = 0; x < 14; x++) {
|
for (int x = 0; x < 14; x++) {
|
||||||
boolean isHiBit = ((spriteData[y * 2 + x / 7] & 128) != 0);
|
boolean isHiBit = ((spriteData[y * 2 + x / 7] & 128) != 0);
|
||||||
|
|
||||||
|
@ -3,7 +3,6 @@ package org.badvision.outlaweditor.apple.dhgr;
|
|||||||
import org.badvision.outlaweditor.apple.*;
|
import org.badvision.outlaweditor.apple.*;
|
||||||
import javafx.scene.image.WritableImage;
|
import javafx.scene.image.WritableImage;
|
||||||
import javafx.scene.paint.Color;
|
import javafx.scene.paint.Color;
|
||||||
import org.badvision.outlaweditor.TileRenderer;
|
|
||||||
import static org.badvision.outlaweditor.apple.AppleNTSCGraphics.*;
|
import static org.badvision.outlaweditor.apple.AppleNTSCGraphics.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -12,7 +11,7 @@ import static org.badvision.outlaweditor.apple.AppleNTSCGraphics.*;
|
|||||||
*/
|
*/
|
||||||
public class AppleDHGRTileRenderer extends AppleTileRenderer {
|
public class AppleDHGRTileRenderer extends AppleTileRenderer {
|
||||||
@Override
|
@Override
|
||||||
public WritableImage redrawSprite(byte[] spriteData, WritableImage img) {
|
public WritableImage redrawSprite(byte[] spriteData, WritableImage img, boolean useBleedOver) {
|
||||||
if (img == null) {
|
if (img == null) {
|
||||||
img = new WritableImage(28, 32);
|
img = new WritableImage(28, 32);
|
||||||
}
|
}
|
||||||
@ -30,7 +29,9 @@ public class AppleDHGRTileRenderer extends AppleTileRenderer {
|
|||||||
int last = (scan >> 26) & 3;
|
int last = (scan >> 26) & 3;
|
||||||
int keep = scan & 0xff;
|
int keep = scan & 0xff;
|
||||||
scan <<= 2;
|
scan <<= 2;
|
||||||
scan |= last;
|
if (useBleedOver) {
|
||||||
|
scan |= last;
|
||||||
|
}
|
||||||
for (int x = 0; x < 14; x++) {
|
for (int x = 0; x < 14; x++) {
|
||||||
boolean isHiBit = ((spriteData[y * 2 + x / 7] & 128) != 0);
|
boolean isHiBit = ((spriteData[y * 2 + x / 7] & 128) != 0);
|
||||||
|
|
||||||
|
@ -168,6 +168,6 @@ public enum FillPattern {
|
|||||||
for (int i=0; i < pattern.length; i++) {
|
for (int i=0; i < pattern.length; i++) {
|
||||||
b[i]=(byte) pattern[i];
|
b[i]=(byte) pattern[i];
|
||||||
}
|
}
|
||||||
return Platform.AppleII_DHGR.tileRenderer.redrawSprite(b, null);
|
return Platform.AppleII_DHGR.tileRenderer.redrawSprite(b, null, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,10 +4,10 @@ import java.util.List;
|
|||||||
import org.badvision.outlaweditor.Application;
|
import org.badvision.outlaweditor.Application;
|
||||||
import org.badvision.outlaweditor.data.xml.Field;
|
import org.badvision.outlaweditor.data.xml.Field;
|
||||||
import org.badvision.outlaweditor.data.xml.Global;
|
import org.badvision.outlaweditor.data.xml.Global;
|
||||||
|
import org.badvision.outlaweditor.data.xml.Map;
|
||||||
import org.badvision.outlaweditor.data.xml.NamedEntity;
|
import org.badvision.outlaweditor.data.xml.NamedEntity;
|
||||||
import org.badvision.outlaweditor.data.xml.Scope;
|
import org.badvision.outlaweditor.data.xml.Scope;
|
||||||
import org.badvision.outlaweditor.data.xml.Script;
|
import org.badvision.outlaweditor.data.xml.Script;
|
||||||
import org.badvision.outlaweditor.data.xml.Scripts;
|
|
||||||
|
|
||||||
public class DataUtilities {
|
public class DataUtilities {
|
||||||
|
|
||||||
@ -17,6 +17,23 @@ public class DataUtilities {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void sortMaps(List<? extends Map> entities) {
|
||||||
|
if (entities == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
entities.sort((a, b) -> {
|
||||||
|
String nameA = a == null ? "" : nullSafe(a.getName());
|
||||||
|
String nameB = b == null ? "" : nullSafe(b.getName());
|
||||||
|
if (nameA.equalsIgnoreCase("init")) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (nameB.equalsIgnoreCase("init")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return nameA.compareTo(nameB);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public static void sortNamedEntities(List<? extends NamedEntity> entities) {
|
public static void sortNamedEntities(List<? extends NamedEntity> entities) {
|
||||||
if (entities == null) {
|
if (entities == null) {
|
||||||
return;
|
return;
|
||||||
|
@ -60,7 +60,7 @@ public class TileUtils {
|
|||||||
System.err.println("Unable to find any platform support for '" + d.getPlatform() + "'");
|
System.err.println("Unable to find any platform support for '" + d.getPlatform() + "'");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
displays.put(p, p.tileRenderer.redrawSprite(d.getValue(), displays.get(p)));
|
displays.put(p, p.tileRenderer.redrawSprite(d.getValue(), displays.get(p), false));
|
||||||
}
|
}
|
||||||
DataProducer.notifyObservers(t);
|
DataProducer.notifyObservers(t);
|
||||||
}
|
}
|
||||||
@ -79,7 +79,7 @@ public class TileUtils {
|
|||||||
public static WritableImage getImage(Tile t, Platform p) {
|
public static WritableImage getImage(Tile t, Platform p) {
|
||||||
Map<Platform, WritableImage> displays = getDisplay(t);
|
Map<Platform, WritableImage> displays = getDisplay(t);
|
||||||
byte[] data = getPlatformData(t, p);
|
byte[] data = getPlatformData(t, p);
|
||||||
return displays.put(p, p.tileRenderer.redrawSprite(data, displays.get(p)));
|
return displays.put(p, p.tileRenderer.redrawSprite(data, displays.get(p), false));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setImage(Tile t, Platform p, WritableImage img) {
|
public static void setImage(Tile t, Platform p, WritableImage img) {
|
||||||
|
@ -6,11 +6,9 @@ import java.util.logging.Level;
|
|||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import javafx.event.ActionEvent;
|
import javafx.event.ActionEvent;
|
||||||
import javafx.scene.control.ListCell;
|
import javafx.scene.control.ListCell;
|
||||||
import javafx.scene.control.ListView;
|
|
||||||
import javafx.scene.control.Tooltip;
|
import javafx.scene.control.Tooltip;
|
||||||
import javafx.scene.text.Font;
|
import javafx.scene.text.Font;
|
||||||
import javafx.scene.text.FontWeight;
|
import javafx.scene.text.FontWeight;
|
||||||
import javafx.util.Callback;
|
|
||||||
import javax.xml.bind.JAXBException;
|
import javax.xml.bind.JAXBException;
|
||||||
import org.badvision.outlaweditor.Application;
|
import org.badvision.outlaweditor.Application;
|
||||||
import org.badvision.outlaweditor.TransferHelper;
|
import org.badvision.outlaweditor.TransferHelper;
|
||||||
@ -27,57 +25,46 @@ public class GlobalEditorTabControllerImpl extends GlobalEditorTabController {
|
|||||||
@Override
|
@Override
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
super.initialize();
|
super.initialize();
|
||||||
variableList.setOnEditStart((ListView.EditEvent<Variable> event) -> {
|
variableList.setCellFactory((listView) -> new ListCell<Variable>() {
|
||||||
UIAction.editVariable(event.getSource().getItems().get(event.getIndex()), Application.gameData.getGlobal());
|
|
||||||
variableList.getSelectionModel().clearSelection();
|
|
||||||
});
|
|
||||||
variableList.setCellFactory(new Callback<ListView<Variable>, ListCell<Variable>>() {
|
|
||||||
@Override
|
@Override
|
||||||
public ListCell<Variable> call(ListView<Variable> param) {
|
protected void updateItem(Variable item, boolean empty) {
|
||||||
final ListCell<Variable> cell = new ListCell<Variable>() {
|
super.updateItem(item, empty);
|
||||||
@Override
|
if (empty || item == null) {
|
||||||
protected void updateItem(Variable item, boolean empty) {
|
setText("");
|
||||||
super.updateItem(item, empty);
|
} else {
|
||||||
if (empty || item == null) {
|
setText(item.getName());
|
||||||
setText("");
|
if (item.getComment() != null && !(item.getComment().isEmpty())) {
|
||||||
} else {
|
setTooltip(new Tooltip(item.getComment()));
|
||||||
setText(item.getName());
|
|
||||||
if (item.getComment() != null && !(item.getComment().isEmpty())) {
|
|
||||||
setTooltip(new Tooltip(item.getComment()));
|
|
||||||
}
|
|
||||||
setFont(Font.font(null, FontWeight.BOLD, 12.0));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
setFont(Font.font(null, FontWeight.BOLD, 12.0));
|
||||||
return cell;
|
}
|
||||||
}
|
}
|
||||||
});
|
|
||||||
globalScriptList.setOnEditStart((ListView.EditEvent<Script> event) -> {
|
|
||||||
UIAction.editScript(event.getSource().getItems().get(event.getIndex()), Application.gameData.getGlobal());
|
|
||||||
globalScriptList.getSelectionModel().clearSelection();
|
|
||||||
});
|
|
||||||
globalScriptList.setCellFactory(new Callback<ListView<Script>, ListCell<Script>>() {
|
|
||||||
@Override
|
|
||||||
public ListCell<Script> call(ListView<Script> param) {
|
|
||||||
final ListCell<Script> cell = new ListCell<Script>() {
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void updateItem(Script item, boolean empty) {
|
public void startEdit() {
|
||||||
super.updateItem(item, empty);
|
UIAction.editVariable(getItem(), Application.gameData.getGlobal());
|
||||||
if (empty || item == null) {
|
cancelEdit();
|
||||||
setText("");
|
updateItem(getItem(), false);
|
||||||
} else {
|
|
||||||
setText(item.getName());
|
|
||||||
setFont(Font.font(null, FontWeight.BOLD, 12.0));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
return cell;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
dataTypeList.setOnEditStart((ListView.EditEvent<UserType> event) -> {
|
globalScriptList.setCellFactory((listView) -> new ListCell<Script>() {
|
||||||
UIAction.editUserType(event.getSource().getItems().get(event.getIndex()));
|
@Override
|
||||||
dataTypeList.getSelectionModel().clearSelection();
|
protected void updateItem(Script item, boolean empty) {
|
||||||
|
super.updateItem(item, empty);
|
||||||
|
if (empty || item == null) {
|
||||||
|
setText("");
|
||||||
|
} else {
|
||||||
|
setText(item.getName());
|
||||||
|
setFont(Font.font(null, FontWeight.BOLD, 12.0));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void startEdit() {
|
||||||
|
UIAction.editScript(getItem(), Application.gameData.getGlobal());
|
||||||
|
cancelEdit();
|
||||||
|
updateItem(getItem(), false);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
dataTypeList.setCellFactory((listView) -> new ListCell<UserType>() {
|
dataTypeList.setCellFactory((listView) -> new ListCell<UserType>() {
|
||||||
@Override
|
@Override
|
||||||
@ -93,6 +80,13 @@ public class GlobalEditorTabControllerImpl extends GlobalEditorTabController {
|
|||||||
setFont(Font.font(null, FontWeight.BOLD, 12.0));
|
setFont(Font.font(null, FontWeight.BOLD, 12.0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void startEdit() {
|
||||||
|
UIAction.editUserType(getItem());
|
||||||
|
cancelEdit();
|
||||||
|
updateItem(getItem(), false);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -162,6 +156,25 @@ public class GlobalEditorTabControllerImpl extends GlobalEditorTabController {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onDataTypeClonePressed(ActionEvent event) {
|
protected void onDataTypeClonePressed(ActionEvent event) {
|
||||||
|
UserType source = dataTypeList.getSelectionModel().getSelectedItem();
|
||||||
|
if (source == null) {
|
||||||
|
String message = "First select a data type and then press Clone";
|
||||||
|
UIAction.alert(message);
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
UserType newType = TransferHelper.cloneObject(source, UserType.class, "userType");
|
||||||
|
newType.setName(source.getName() + " CLONE");
|
||||||
|
if (UIAction.editAndGetUserType(newType) != null) {
|
||||||
|
Application.gameData.getGlobal().getUserTypes().getUserType().add(newType);
|
||||||
|
redrawGlobalDataTypes();
|
||||||
|
}
|
||||||
|
} catch (JAXBException ex) {
|
||||||
|
Logger.getLogger(MapEditorTabControllerImpl.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
|
UIAction.alert("Error occured when attempting clone operation:\n" + ex.getMessage());
|
||||||
|
} catch (IntrospectionException ex) {
|
||||||
|
Logger.getLogger(GlobalEditorTabControllerImpl.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -28,7 +28,6 @@ import static org.badvision.outlaweditor.data.PropertyHelper.stringProp;
|
|||||||
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;
|
||||||
import org.badvision.outlaweditor.data.xml.Script;
|
import org.badvision.outlaweditor.data.xml.Script;
|
||||||
import org.badvision.outlaweditor.data.xml.Scripts;
|
|
||||||
import org.badvision.outlaweditor.data.xml.Tile;
|
import org.badvision.outlaweditor.data.xml.Tile;
|
||||||
import org.badvision.outlaweditor.ui.EntitySelectorCell;
|
import org.badvision.outlaweditor.ui.EntitySelectorCell;
|
||||||
import org.badvision.outlaweditor.ui.MapEditorTabController;
|
import org.badvision.outlaweditor.ui.MapEditorTabController;
|
||||||
@ -206,7 +205,7 @@ public class MapEditorTabControllerImpl extends MapEditorTabController {
|
|||||||
redrawMapScripts();
|
redrawMapScripts();
|
||||||
},
|
},
|
||||||
null);
|
null);
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -282,7 +281,7 @@ public class MapEditorTabControllerImpl extends MapEditorTabController {
|
|||||||
} else {
|
} else {
|
||||||
if (m.getScripts() != null) {
|
if (m.getScripts() != null) {
|
||||||
DataUtilities.sortNamedEntities(m.getScripts().getScript());
|
DataUtilities.sortNamedEntities(m.getScripts().getScript());
|
||||||
};
|
}
|
||||||
if (m.getHeight() == null) {
|
if (m.getHeight() == null) {
|
||||||
m.setHeight(512);
|
m.setHeight(512);
|
||||||
}
|
}
|
||||||
@ -321,6 +320,7 @@ public class MapEditorTabControllerImpl extends MapEditorTabController {
|
|||||||
@Override
|
@Override
|
||||||
public void rebuildMapSelectors() {
|
public void rebuildMapSelectors() {
|
||||||
mapSelect.getItems().clear();
|
mapSelect.getItems().clear();
|
||||||
|
DataUtilities.sortMaps(Application.gameData.getMap());
|
||||||
mapSelect.getItems().addAll(Application.gameData.getMap());
|
mapSelect.getItems().addAll(Application.gameData.getMap());
|
||||||
mapSelect.getSelectionModel().select(getCurrentMap());
|
mapSelect.getSelectionModel().select(getCurrentMap());
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user