Skip to content

Commit

Permalink
0.9.4 release
Browse files Browse the repository at this point in the history
  • Loading branch information
ZILtoid1991 committed Jan 5, 2020
1 parent 06cb3c8 commit 5603594
Show file tree
Hide file tree
Showing 14 changed files with 346 additions and 148 deletions.
Binary file removed assets/_system/sysdef.xmp
Binary file not shown.
Binary file removed assets/_system/sysfont.xmp
Binary file not shown.
47 changes: 29 additions & 18 deletions pixelperfecteditor/src/PixelPerfectEditor/app.d
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,14 @@ public Editor prg;
int main(string[] args){
initialzeSDL();

if(args.length > 1){
if(args[1] == "--test"){
TileLayerTest prg = new TileLayerTest();
prg.whereTheMagicHappens;
if (args.length > 1) {
if (args[1] == "--test") {
bool testTransformableTileLayer;
if (args.length > 2)
if (args[2] == "transform")
testTransformableTileLayer = true;
TileLayerTest lprg = new TileLayerTest(testTransformableTileLayer);
lprg.whereTheMagicHappens;
//writeln(prg.isRunning);
return 0;
}
Expand Down Expand Up @@ -88,7 +92,7 @@ class TileLayerTest : SystemEventListener, InputListener{
InputHandler ih;
float theta;
//CollisionDetector c;
this(){
this(bool testTransformableTileLayer = false){
theta = 0;
isRunning = true;
Image tileSource = loadImage(File("../assets/sci-fi-tileset.tga"));
Expand All @@ -115,13 +119,16 @@ class TileLayerTest : SystemEventListener, InputListener{
//tiles.length = tileSource.bitmapID.length;
tiles = loadBitmapSheetFromImage!Bitmap8Bit(tileSource, 16, 16);//loadBitmapSheetFromFile!Bitmap8Bit("../assets/sci-fi-tileset.png",16,16);
//tiles = loadBitmapSheetFromFile!(Bitmap8Bit)("../assets/sci-fi-tileset.png", 16, 16);
for(int i; i < tiles.length; i++){
//string hex = tileSource.bitmapID[i];
//writeln(hex[hex.length-4..hex.length]);
//ABitmap ab = loadBitmapFromXMP!Bitmap16Bit(tileSource, hex);
//tiles[i] = ab;
t.addTile(tiles[i], cast(wchar)i);
if (testTransformableTileLayer) {
for (int i; i < tiles.length; i++) {
tt.addTile(tiles[i], cast(wchar)i);
}
} else {
for (int i; i < tiles.length; i++) {
t.addTile(tiles[i], cast(wchar)i);
}
}

//wchar[] mapping;
MappingElement[] mapping;
mapping.length = 64*64;
Expand Down Expand Up @@ -164,10 +171,13 @@ class TileLayerTest : SystemEventListener, InputListener{
ih.kb ~= KeyBinding(0, ScanCode.n4,0, "sH-", Devicetype.KEYBOARD, KeyModifier.ANY);
ih.kb ~= KeyBinding(0, ScanCode.Q,0, "HM", Devicetype.KEYBOARD, KeyModifier.ANY);
ih.kb ~= KeyBinding(0, ScanCode.W,0, "VM", Devicetype.KEYBOARD, KeyModifier.ANY);

t.loadMapping(64,64,mapping);
t.setWarpMode(false);

if (testTransformableTileLayer) {
tt.loadMapping(64,64,mapping);
tt.setWarpMode(false);
} else {
t.loadMapping(64,64,mapping);
t.setWarpMode(false);
}
//t.setWrapMode(true);
//tt.D = -256;
output = new OutputScreen("TileLayer test", 1280,960);
Expand All @@ -180,14 +190,15 @@ class TileLayerTest : SystemEventListener, InputListener{
writeln('[',x,',',y,"] : ", t.transformFunc([x,y]));
}
}*/
r.addLayer(t, 0);
if (testTransformableTileLayer) r.addLayer(tt, 0);
else r.addLayer(t, 0);
r.addLayer(s, 1);
Color[] localPal = loadPaletteFromImage(tileSource);
localPal.length = 256;
r.palette ~= localPal;
r.palette = r.palette ~ localPal;
localPal = loadPaletteFromImage(spriteSource);
localPal.length = 256;
r.palette ~= localPal;
r.palette = r.palette ~ localPal;
//r.palette[0].alpha = 255;
r.palette[256].raw = 0;
//writeln(tt);
Expand Down
23 changes: 10 additions & 13 deletions pixelperfecteditor/src/PixelPerfectEditor/document.d
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class MapDocument {
* Loads the document from disk.
*/
public this(string filename) @trusted {
mainDoc = new MapFormat(filename);
mainDoc = new MapFormat(File(filename));
events = new UndoableStack(20);
}
///New from scratch
Expand All @@ -53,14 +53,11 @@ public class MapDocument {
///Returns the next available layer number.
public int nextLayerNumber() @safe {
int result = selectedLayer;
bool found;
do {
if (mainDoc[result] is null)
found = true;
else
result++;
} while (!found);
return result;
return result;
result++;
} while (true);
}
///Puts the loaded tiles onto a TileLayer
public void addTileSet(int layer, ABitmap[ushort] tiles) @trusted {
Expand Down Expand Up @@ -108,8 +105,8 @@ public class MapDocument {
} else {

ITileLayer target = cast(ITileLayer)(mainDoc[selectedLayer]);
x = (x - mainDoc[selectedLayer].getSX) / target.getTileWidth;
y = (y - mainDoc[selectedLayer].getSY) / target.getTileHeight;
x = (x + mainDoc[selectedLayer].getSX) / target.getTileWidth;
y = (y + mainDoc[selectedLayer].getSY) / target.getTileHeight;
prevMouseX = (prevMouseX - mainDoc[selectedLayer].getSX) / target.getTileWidth;
prevMouseY = (prevMouseY - mainDoc[selectedLayer].getSY) / target.getTileHeight;
Coordinate c;
Expand Down Expand Up @@ -244,11 +241,11 @@ public class MapDocument {
updateLayerList;
updateMaterialList;
}
public void tileMaterial_FlipHorizontal() {
selectedMappingElement.attributes.horizMirror = !selectedMappingElement.attributes.horizMirror;
public void tileMaterial_FlipHorizontal(bool pos) {
selectedMappingElement.attributes.horizMirror = pos;
}
public void tileMaterial_FlipVertical() {
selectedMappingElement.attributes.vertMirror = !selectedMappingElement.attributes.vertMirror;
public void tileMaterial_FlipVertical(bool pos) {
selectedMappingElement.attributes.vertMirror = pos;
}
public void tileMaterial_Select(wchar id) {
selectedMappingElement.tileID = id;
Expand Down
90 changes: 48 additions & 42 deletions pixelperfecteditor/src/PixelPerfectEditor/editor.d
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public interface IEditor{
//public void newLayer();
public void xmpToolkit();
public void passActionEvent(Event e);
public void createNewDocument(dstring name, int rX, int rY, int pal);
public void createNewDocument(dstring name, int rX, int rY);
//public void createNewLayer(string name, int type, int tX, int tY, int mX, int mY, int priority);
}

Expand All @@ -69,7 +69,7 @@ public class NewDocumentDialog : Window{
textBoxes ~= new TextBox("","name",Coordinate(81,20,200,39));
textBoxes ~= new TextBox("","rX",Coordinate(121,40,200,59));
textBoxes ~= new TextBox("","rY",Coordinate(121,60,200,79));
textBoxes ~= new TextBox("","pal",Coordinate(121,80,200,99));
//textBoxes ~= new TextBox("","pal",Coordinate(121,80,200,99));
addElement(buttons[0], EventProperties.MOUSE);
foreach(WindowElement we; labels){
addElement(we, EventProperties.MOUSE);
Expand All @@ -82,7 +82,7 @@ public class NewDocumentDialog : Window{
}

public void buttonOn_onMouseLClickRel(Event event){
ie.createNewDocument(textBoxes[0].getText(), to!int(textBoxes[1].getText()), to!int(textBoxes[2].getText()), to!int(textBoxes[3].getText()));
ie.createNewDocument(textBoxes[0].getText(), to!int(textBoxes[1].getText()), to!int(textBoxes[2].getText()));

parent.closeWindow(this);
}
Expand Down Expand Up @@ -229,7 +229,6 @@ public class EditorWindowHandler : WindowHandler, ElementContainer{
ie.newDocument;
break;
case "xmpTool":
ie.xmpToolkit();
break;
case "about":
Window w = new AboutWindow();
Expand Down Expand Up @@ -290,10 +289,6 @@ public class Editor : InputListener, MouseListener, IEditor, SystemEventListener
public OutputScreen[] ow;
public Raster rasters;
public InputHandler input;
public TileLayer[int] backgroundLayers;
//public TileLayer8Bit[int] backgroundLayers8;
//public TileLayer32Bit[int] backgroundLayers32;
public Layer[int] layers;
public wchar selectedTile;
public BitmapAttrib selectedTileAttrib;
public int selectedLayer;
Expand Down Expand Up @@ -362,7 +357,7 @@ public class Editor : InputListener, MouseListener, IEditor, SystemEventListener
case "save":
onSave();
break;
case "saveas":
case "saveAs":
onSaveAs();
break;
case "load":
Expand All @@ -385,7 +380,24 @@ public class Editor : InputListener, MouseListener, IEditor, SystemEventListener
wh.addWindow(fd);
}
public void onLoadDialog (Event event) {
selDoc = new MapDocument(event.getFullPath);
import std.utf : toUTF32;
try {
selDoc = new MapDocument(event.getFullPath);
dstring name = toUTF32(selDoc.mainDoc.getName);
RasterWindow w = new RasterWindow(selDoc.mainDoc.getHorizontalResolution, selDoc.mainDoc.getVerticalResolution,
rasters.palette.ptr, name, selDoc);
selDoc.outputWindow = w;
wh.addWindow(w);
documents[name] = selDoc;
selDoc.updateLayerList();
selDoc.updateMaterialList();
selDoc.mainDoc.loadTiles(w);
selDoc.mainDoc.loadMappingData();
w.loadLayers();
w.updateRaster();
} catch (Exception e) {
debug writeln(e);
}

}
public void onSave () {
Expand All @@ -401,7 +413,12 @@ public class Editor : InputListener, MouseListener, IEditor, SystemEventListener
wh.addWindow(fd);
}
public void onSaveDialog (Event event) {
import std.path : extension;
import std.ascii : toLower;
selDoc.filename = event.getFullPath();
if(extension(selDoc.filename) != ".xmf"){
selDoc.filename ~= ".xmf";
}
selDoc.mainDoc.save(selDoc.filename);
}
public void actionEvent(Event event) {
Expand Down Expand Up @@ -434,18 +451,7 @@ public class Editor : InputListener, MouseListener, IEditor, SystemEventListener
public void xmpToolkit(){
//wh.addWindow(new ConverterDialog(input,bitmapPreview));
}
/*public void placeObject(int x, int y){
if(backgroundLayers.get(selectedLayer, null) !is null){
int sX = backgroundLayers[selectedLayer].getSX(), sY = backgroundLayers[selectedLayer].getSY();
sX += x;
sY += y;
sX /= backgroundLayers[selectedLayer].getTileWidth();
sY /= backgroundLayers[selectedLayer].getTileHeight();
if(sX >= 0 && sY >= 0){
backgroundLayers[selectedLayer].writeMapping(sX, sY, selectedTile);
}
}
}*/

public this(string[] args){
pm = PlacementMode.OVERWRITE;
ConfigurationProfile.setVaultPath("ZILtoid1991","PixelPerfectEditor");
Expand Down Expand Up @@ -479,25 +485,25 @@ public class Editor : InputListener, MouseListener, IEditor, SystemEventListener
WindowElement.styleSheet.setImage(customGUIElems[14], "blankButtonA");
WindowElement.styleSheet.setImage(customGUIElems[15], "blankButtonB");
}
/+{
Bitmap8Bit[] customGUIElems = loadBitmapSheetFromFile!Bitmap8Bit("../system/concreteGUIE2.tga");
WindowElement.styleSheet.setImage(customGUIElems[0], "");
WindowElement.styleSheet.setImage(customGUIElems[1], "");
WindowElement.styleSheet.setImage(customGUIElems[2], "");
WindowElement.styleSheet.setImage(customGUIElems[3], "");
WindowElement.styleSheet.setImage(customGUIElems[4], "");
WindowElement.styleSheet.setImage(customGUIElems[5], "");
WindowElement.styleSheet.setImage(customGUIElems[6], "");
WindowElement.styleSheet.setImage(customGUIElems[7], "");
WindowElement.styleSheet.setImage(customGUIElems[8], "");
WindowElement.styleSheet.setImage(customGUIElems[9], "");
WindowElement.styleSheet.setImage(customGUIElems[10], "");
WindowElement.styleSheet.setImage(customGUIElems[11], "");
WindowElement.styleSheet.setImage(customGUIElems[12], "");
WindowElement.styleSheet.setImage(customGUIElems[13], "");
WindowElement.styleSheet.setImage(customGUIElems[14], "");
WindowElement.styleSheet.setImage(customGUIElems[15], "");
}+/
{
Bitmap8Bit[] customGUIElems = loadBitmapSheetFromFile!Bitmap8Bit("../system/concreteGUIE4.tga", 16, 16);
WindowElement.styleSheet.setImage(customGUIElems[0], "addMaterialA");
WindowElement.styleSheet.setImage(customGUIElems[1], "addMaterialB");
WindowElement.styleSheet.setImage(customGUIElems[2], "removeMaterialA");
WindowElement.styleSheet.setImage(customGUIElems[3], "removeMaterialB");
WindowElement.styleSheet.setImage(customGUIElems[4], "horizMirrorA");
WindowElement.styleSheet.setImage(customGUIElems[5], "horizMirrorB");
WindowElement.styleSheet.setImage(customGUIElems[6], "vertMirrorA");
WindowElement.styleSheet.setImage(customGUIElems[7], "vertMirrorB");
//WindowElement.styleSheet.setImage(customGUIElems[8], "");
//WindowElement.styleSheet.setImage(customGUIElems[9], "");
//WindowElement.styleSheet.setImage(customGUIElems[10], "");
//WindowElement.styleSheet.setImage(customGUIElems[11], "");
WindowElement.styleSheet.setImage(customGUIElems[12], "paletteDownA");
WindowElement.styleSheet.setImage(customGUIElems[13], "paletteDownB");
WindowElement.styleSheet.setImage(customGUIElems[14], "paletteUpA");
WindowElement.styleSheet.setImage(customGUIElems[15], "paletteUpB");
}
{
Bitmap8Bit[] customGUIElems = loadBitmapSheetFromFile!Bitmap8Bit("../system/concreteGUIE3.tga", 16, 16);
WindowElement.styleSheet.setImage(customGUIElems[0], "trashButtonA");
Expand Down Expand Up @@ -594,7 +600,7 @@ public class Editor : InputListener, MouseListener, IEditor, SystemEventListener
ndd.ie = this;
wh.addWindow(ndd);
}
public void createNewDocument(dstring name, int rX, int rY, int pal){
public void createNewDocument(dstring name, int rX, int rY){
import std.utf : toUTF8;
MapDocument md = new MapDocument(toUTF8(name), rX, rY);
RasterWindow w = new RasterWindow(rX, rY, rasters.palette.ptr, name, md);
Expand Down
2 changes: 1 addition & 1 deletion pixelperfecteditor/src/PixelPerfectEditor/editorEvents.d
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ public class CreateTileLayerEvent : UndoableEvent {
//handle the following instances for materials:
//res == image file
//TODO: check if material resource file has any embedded resource data
//TODO: enable importing from SDLang map files (*.ppm)
//TODO: enable importing from SDLang map files (*.xmf)
//TODO: generate dummy tiles for nonexistent material
if (exists(res)) {
//load the resource file and test if it's the correct size (through an exception)
Expand Down
48 changes: 42 additions & 6 deletions pixelperfecteditor/src/PixelPerfectEditor/materialList.d
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,32 @@ public class MaterialList : Window {
listBox_materials.onItemSelect = &onItemSelect;
addElement(listBox_materials);
{
SmallButton sb = new SmallButton("trashButtonB", "trashButtonA", "trash", Coordinate(113, 234, 129, 250));
SmallButton sb = new SmallButton("removeMaterialB", "removeMaterialA", "rem", Coordinate(113, 234, 129, 250));
//sb.onMouseLClickRel = &button_trash_onClick;
buttons ~= sb;
}
{
SmallButton sb = new SmallButton("blankButtonB", "blankButtonA", "horizMirror", Coordinate(1, 218, 17, 234));
SmallButton sb = new SmallButton("addMaterialB", "addMaterialA", "add", Coordinate(113, 218, 129, 234));
//sb.onMouseLClickRel = &button_trash_onClick;
buttons ~= sb;
}
{
SmallButton sb = new SmallButton("blankButtonB", "blankButtonA", "vertMirror", Coordinate(17, 218, 33, 234));
SmallButton sb = new SmallButton("horizMirrorB", "horizMirrorA", "horizMirror", Coordinate(1, 218, 17, 234));
sb.onMouseLClickRel = &horizMirror_onClick;
buttons ~= sb;
}
{
SmallButton sb = new SmallButton("vertMirrorB", "vertMirrorA", "vertMirror", Coordinate(17, 218, 33, 234));
sb.onMouseLClickRel = &vertMirror_onClick;
buttons ~= sb;
}
{
SmallButton sb = new SmallButton("paletteUpB", "paletteUpA", "palUp", Coordinate(1, 234, 17, 250));
//sb.onMouseLClickRel = &button_trash_onClick;
buttons ~= sb;
}
{
SmallButton sb = new SmallButton("blankButtonB", "blankButtonA", "addMat", Coordinate(1, 234, 17, 250));
SmallButton sb = new SmallButton("paletteDownB", "paletteDownA", "palDown", Coordinate(17, 234, 33, 250));
//sb.onMouseLClickRel = &button_trash_onClick;
buttons ~= sb;
}
Expand All @@ -64,10 +74,36 @@ public class MaterialList : Window {
listBox_materials.updateColumns(output, new ListBoxHeader(tileListHeaderS.dup, tileListHeaderW.dup));
}
private void vertMirror_onClick(Event ev) {
prg.selDoc.tileMaterial_FlipVertical();
SmallButton sender = cast(SmallButton)ev.sender;
if(sender.iconPressed == "vertMirrorB") {
prg.selDoc.tileMaterial_FlipVertical(true);
sender.iconPressed = "vertMirrorA";
sender.iconUnpressed = "vertMirrorB";
} else {
prg.selDoc.tileMaterial_FlipVertical(false);
sender.iconPressed = "vertMirrorB";
sender.iconUnpressed = "vertMirrorA";
}
sender.draw();
}
private void horizMirror_onClick(Event ev) {
prg.selDoc.tileMaterial_FlipHorizontal();
SmallButton sender = cast(SmallButton)ev.sender;
if(sender.iconPressed == "horizMirrorB") {
prg.selDoc.tileMaterial_FlipHorizontal(true);
sender.iconPressed = "horizMirrorA";
sender.iconUnpressed = "horizMirrorB";
} else {
prg.selDoc.tileMaterial_FlipHorizontal(false);
sender.iconPressed = "horizMirrorB";
sender.iconUnpressed = "horizMirrorA";
}
sender.draw();
}
private void palUp_onClick(Event ev) {

}
private void palDown_onClick(Event ev) {

}
private void onItemSelect(Event ev) {
prg.selDoc.tileMaterial_Select(tiles[ev.value].id);
Expand Down
Loading

0 comments on commit 5603594

Please sign in to comment.