Skip to content

Commit

Permalink
Updating mapformat to new path system
Browse files Browse the repository at this point in the history
  • Loading branch information
ZILtoid1991 committed Feb 7, 2024
1 parent 219c060 commit 8ad7577
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
16 changes: 11 additions & 5 deletions pixelperfectengine/src/pixelperfectengine/map/mapformat.d
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public class MapFormat {
Tag[] tileSource = getAllTileSources(key);
foreach (t0; tileSource) {
string path = t0.getValue!string();
Image i = loadImage(File(path, "rb"));
Image i = loadImage(File(getPathToAsset(path), "rb"));
void helperFunc(T)(T[] bitmaps, Tag source) {
TileLayer tl = cast(TileLayer)layeroutput[key];
Tag tileInfo = source.getTag("Embed:TileInfo", null);
Expand Down Expand Up @@ -187,7 +187,7 @@ public class MapFormat {
case "File:SpriteSource":
string filename = t0.expectValue!string();
if (imageBuffer.get(filename, null) is null) {
imageBuffer[filename] = loadImage(File(filename));
imageBuffer[filename] = loadImage(File(getPathToAsset(filename)));
}
const int id = t0.expectValue!int();
/+if ("horizOffset" in t0.attributes && "vertOffset" in t0.attributes && "width" in t0.attributes &&
Expand Down Expand Up @@ -356,7 +356,7 @@ public class MapFormat {
if (t0 !is null) {
TileLayer tl = cast(TileLayer)layeroutput[key];
MapDataHeader mdf;
File mapfile = File(t0.expectValue!string());
File mapfile = File(getPathToAsset(t0.expectValue!string()));
tl.loadMapping(value.values[4].get!int(), value.values[5].get!int(), loadMapFile(mapfile, mdf));
}
}
Expand Down Expand Up @@ -444,7 +444,8 @@ public class MapFormat {
ushort palShift = cast(ushort)t0.getAttribute!int("palShift", 0);
if (t1 !is null) {
foreach (Tag t2 ; t1.tags) {
result ~= TileInfo(cast(wchar)t2.values[0].get!int(), palShift, t2.values[1].get!int(), t2.values[2].get!string());
result ~= TileInfo(cast(wchar)t2.values[0].get!int(), palShift, t2.values[1].get!int(),
t2.values[2].get!string());
}
}
}
Expand Down Expand Up @@ -621,7 +622,8 @@ public class MapFormat {
public void addNewTileLayer(int pri, int tX, int tY, int mX, int mY, string name, TileLayer l) @trusted {
layeroutput[pri] = l;
l.setRasterizer(getHorizontalResolution, getVerticalResolution);
layerData[pri] = new Tag(root, "Layer", "Tile", [Value(name), Value(pri), Value(tX), Value(tY), Value(mX), Value(mY)]);
layerData[pri] = new Tag(root, "Layer", "Tile", [Value(name), Value(pri), Value(tX), Value(tY), Value(mX),
Value(mY)]);
new Tag(layerData[pri], null, "RenderingMode", [Value("Copy")]);
}
/**
Expand Down Expand Up @@ -1036,6 +1038,10 @@ abstract class MapObject {
public bool opEquals (MapObject rhs) @nogc @safe nothrow pure const {
return pID == rhs.pID && gID == rhs.gID;
}
override size_t toHash() const @nogc @safe pure nothrow {
static if (size_t.sizeof == 8) return pID | (cast(ulong)gID<<32L);
else return pID ^ (gID<<16) ^ (gID>>>16);
}
}
/**
* Implements a Box object. Adds a single Coordinate property to the default MapObject
Expand Down
2 changes: 1 addition & 1 deletion test2/app.d
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public class MapFormatTester : SystemEventListener, InputListener {
output = new OutputScreen("TileLayer test", 424 * 4, 240 * 4);
r = new Raster(424,240,output,0);
output.setMainRaster(r);
Image fontSource = loadImage(File("../system/codepage_8_8.png"));
Image fontSource = loadImage(File(getPathToAsset("/system/codepage_8_8.png")));
ih = new InputHandler();
ih.systemEventListener = this;
ih.inputListener = this;
Expand Down

0 comments on commit 8ad7577

Please sign in to comment.