mirror of
https://github.com/badvision/lawless-legends.git
synced 2025-03-31 16:31:27 +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 WritableImage redrawSprite(byte[] spriteData, WritableImage image);
|
||||
public abstract WritableImage redrawSprite(byte[] spriteData, WritableImage image, boolean useBleedOver);
|
||||
|
||||
public abstract int getWidth();
|
||||
|
||||
|
@ -14,7 +14,7 @@ public class AppleTileRenderer extends TileRenderer {
|
||||
public static boolean useSolidPalette = true;
|
||||
|
||||
@Override
|
||||
public WritableImage redrawSprite(byte[] spriteData, WritableImage img) {
|
||||
public WritableImage redrawSprite(byte[] spriteData, WritableImage img, boolean useBleedOver) {
|
||||
if (img == null) {
|
||||
img = new WritableImage(28, 32);
|
||||
}
|
||||
@ -23,12 +23,14 @@ public class AppleTileRenderer extends TileRenderer {
|
||||
}
|
||||
int[][] palette = useSolidPalette ? solidPalette : textPalette;
|
||||
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 last = (scan >> 26) & 3;
|
||||
int keep = scan & 0xff;
|
||||
scan <<= 2;
|
||||
scan |= last;
|
||||
if (useBleedOver) {
|
||||
scan |= last;
|
||||
}
|
||||
for (int x = 0; x < 14; x++) {
|
||||
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 javafx.scene.image.WritableImage;
|
||||
import javafx.scene.paint.Color;
|
||||
import org.badvision.outlaweditor.TileRenderer;
|
||||
import static org.badvision.outlaweditor.apple.AppleNTSCGraphics.*;
|
||||
|
||||
/**
|
||||
@ -12,7 +11,7 @@ import static org.badvision.outlaweditor.apple.AppleNTSCGraphics.*;
|
||||
*/
|
||||
public class AppleDHGRTileRenderer extends AppleTileRenderer {
|
||||
@Override
|
||||
public WritableImage redrawSprite(byte[] spriteData, WritableImage img) {
|
||||
public WritableImage redrawSprite(byte[] spriteData, WritableImage img, boolean useBleedOver) {
|
||||
if (img == null) {
|
||||
img = new WritableImage(28, 32);
|
||||
}
|
||||
@ -30,7 +29,9 @@ public class AppleDHGRTileRenderer extends AppleTileRenderer {
|
||||
int last = (scan >> 26) & 3;
|
||||
int keep = scan & 0xff;
|
||||
scan <<= 2;
|
||||
scan |= last;
|
||||
if (useBleedOver) {
|
||||
scan |= last;
|
||||
}
|
||||
for (int x = 0; x < 14; x++) {
|
||||
boolean isHiBit = ((spriteData[y * 2 + x / 7] & 128) != 0);
|
||||
|
||||
|
@ -168,6 +168,6 @@ public enum FillPattern {
|
||||
for (int i=0; i < pattern.length; 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.data.xml.Field;
|
||||
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.Scope;
|
||||
import org.badvision.outlaweditor.data.xml.Script;
|
||||
import org.badvision.outlaweditor.data.xml.Scripts;
|
||||
|
||||
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) {
|
||||
if (entities == null) {
|
||||
return;
|
||||
|
@ -60,7 +60,7 @@ public class TileUtils {
|
||||
System.err.println("Unable to find any platform support for '" + d.getPlatform() + "'");
|
||||
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);
|
||||
}
|
||||
@ -79,7 +79,7 @@ public class TileUtils {
|
||||
public static WritableImage getImage(Tile t, Platform p) {
|
||||
Map<Platform, WritableImage> displays = getDisplay(t);
|
||||
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) {
|
||||
|
@ -6,11 +6,9 @@ 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.Tooltip;
|
||||
import javafx.scene.text.Font;
|
||||
import javafx.scene.text.FontWeight;
|
||||
import javafx.util.Callback;
|
||||
import javax.xml.bind.JAXBException;
|
||||
import org.badvision.outlaweditor.Application;
|
||||
import org.badvision.outlaweditor.TransferHelper;
|
||||
@ -27,57 +25,46 @@ public class GlobalEditorTabControllerImpl extends GlobalEditorTabController {
|
||||
@Override
|
||||
public void initialize() {
|
||||
super.initialize();
|
||||
variableList.setOnEditStart((ListView.EditEvent<Variable> event) -> {
|
||||
UIAction.editVariable(event.getSource().getItems().get(event.getIndex()), Application.gameData.getGlobal());
|
||||
variableList.getSelectionModel().clearSelection();
|
||||
});
|
||||
variableList.setCellFactory(new Callback<ListView<Variable>, ListCell<Variable>>() {
|
||||
variableList.setCellFactory((listView) -> new ListCell<Variable>() {
|
||||
@Override
|
||||
public ListCell<Variable> call(ListView<Variable> param) {
|
||||
final ListCell<Variable> cell = new ListCell<Variable>() {
|
||||
@Override
|
||||
protected void updateItem(Variable item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
if (empty || item == null) {
|
||||
setText("");
|
||||
} else {
|
||||
setText(item.getName());
|
||||
if (item.getComment() != null && !(item.getComment().isEmpty())) {
|
||||
setTooltip(new Tooltip(item.getComment()));
|
||||
}
|
||||
setFont(Font.font(null, FontWeight.BOLD, 12.0));
|
||||
}
|
||||
protected void updateItem(Variable item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
if (empty || item == null) {
|
||||
setText("");
|
||||
} else {
|
||||
setText(item.getName());
|
||||
if (item.getComment() != null && !(item.getComment().isEmpty())) {
|
||||
setTooltip(new Tooltip(item.getComment()));
|
||||
}
|
||||
};
|
||||
return cell;
|
||||
setFont(Font.font(null, FontWeight.BOLD, 12.0));
|
||||
}
|
||||
}
|
||||
});
|
||||
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
|
||||
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));
|
||||
}
|
||||
}
|
||||
};
|
||||
return cell;
|
||||
@Override
|
||||
public void startEdit() {
|
||||
UIAction.editVariable(getItem(), Application.gameData.getGlobal());
|
||||
cancelEdit();
|
||||
updateItem(getItem(), false);
|
||||
}
|
||||
});
|
||||
dataTypeList.setOnEditStart((ListView.EditEvent<UserType> event) -> {
|
||||
UIAction.editUserType(event.getSource().getItems().get(event.getIndex()));
|
||||
dataTypeList.getSelectionModel().clearSelection();
|
||||
globalScriptList.setCellFactory((listView) -> new ListCell<Script>() {
|
||||
@Override
|
||||
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>() {
|
||||
@Override
|
||||
@ -93,6 +80,13 @@ public class GlobalEditorTabControllerImpl extends GlobalEditorTabController {
|
||||
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
|
||||
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
|
||||
|
@ -28,7 +28,6 @@ import static org.badvision.outlaweditor.data.PropertyHelper.stringProp;
|
||||
import org.badvision.outlaweditor.data.TileUtils;
|
||||
import org.badvision.outlaweditor.data.xml.Map;
|
||||
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.ui.EntitySelectorCell;
|
||||
import org.badvision.outlaweditor.ui.MapEditorTabController;
|
||||
@ -206,7 +205,7 @@ public class MapEditorTabControllerImpl extends MapEditorTabController {
|
||||
redrawMapScripts();
|
||||
},
|
||||
null);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -282,7 +281,7 @@ public class MapEditorTabControllerImpl extends MapEditorTabController {
|
||||
} else {
|
||||
if (m.getScripts() != null) {
|
||||
DataUtilities.sortNamedEntities(m.getScripts().getScript());
|
||||
};
|
||||
}
|
||||
if (m.getHeight() == null) {
|
||||
m.setHeight(512);
|
||||
}
|
||||
@ -321,6 +320,7 @@ public class MapEditorTabControllerImpl extends MapEditorTabController {
|
||||
@Override
|
||||
public void rebuildMapSelectors() {
|
||||
mapSelect.getItems().clear();
|
||||
DataUtilities.sortMaps(Application.gameData.getMap());
|
||||
mapSelect.getItems().addAll(Application.gameData.getMap());
|
||||
mapSelect.getSelectionModel().select(getCurrentMap());
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user