diff --git a/assets/README.md b/assets/README.md index a6efc6e..f7b10c8 100644 --- a/assets/README.md +++ b/assets/README.md @@ -1,4 +1,4 @@ # Assets -* [Atlas](atlas.png): By [Kapendev](https://kapendev.itch.io), CC0 -* [Monogram](monogram.png): By [DATAGOBLIN](https://datagoblin.itch.io/monogram), CC0 +* [Atlas](parin_atlas.png): By [Kapendev](https://kapendev.itch.io), CC0 +* [Monogram](parin_monogram.png): By [DATAGOBLIN](https://datagoblin.itch.io/monogram), CC0 diff --git a/assets/atlas.png b/assets/parin_atlas.png similarity index 100% rename from assets/atlas.png rename to assets/parin_atlas.png diff --git a/assets/monogram.png b/assets/parin_monogram.png similarity index 100% rename from assets/monogram.png rename to assets/parin_monogram.png diff --git a/examples/intro/map.d b/examples/intro/map.d index aa2f9b0..1858f64 100644 --- a/examples/intro/map.d +++ b/examples/intro/map.d @@ -10,7 +10,7 @@ auto tileFlip = Flip.none; void ready() { lockResolution(320, 180); - atlas = loadTexture("atlas.png"); + atlas = loadTexture("parin_atlas.png"); // Parse a CSV string representing a tile map, where each tile is 16x16 pixels in size. map.parse("-1,-1,-1\n21,22,23\n37,38,39\n53,54,55", 16, 16); } diff --git a/examples/intro/patch.d b/examples/intro/patch.d index 8d8e9e7..89199d8 100644 --- a/examples/intro/patch.d +++ b/examples/intro/patch.d @@ -7,7 +7,7 @@ auto patchAtlasArea = Rect(5 * 16, 1 * 16, Vec2(16 * 3)); void ready() { lockResolution(320, 180); - atlas = loadTexture("atlas.png"); + atlas = loadTexture("parin_atlas.png"); } bool update(float dt) { diff --git a/examples/intro/sprite.d b/examples/intro/sprite.d index 4bc6328..0fcfa17 100644 --- a/examples/intro/sprite.d +++ b/examples/intro/sprite.d @@ -11,7 +11,7 @@ auto walkAnimation = SpriteAnimation(0, 2, 6); void ready() { lockResolution(320, 180); - atlas = loadTexture("atlas.png"); + atlas = loadTexture("parin_atlas.png"); } bool update(float dt) { diff --git a/examples/ui/custom.d b/examples/ui/custom.d index fa74848..2518cb7 100644 --- a/examples/ui/custom.d +++ b/examples/ui/custom.d @@ -21,7 +21,7 @@ bool myButton(Rect area, IStr text) { void ready() { lockResolution(320, 180); - atlas = loadTexture("atlas.png"); + atlas = loadTexture("parin_atlas.png"); } bool update(float dt) { diff --git a/source/parin/engine.d b/source/parin/engine.d index cf2085d..6d551d2 100644 --- a/source/parin/engine.d +++ b/source/parin/engine.d @@ -301,6 +301,16 @@ struct TextureId { return getOr().size; } + /// Sets the filter mode of the texture associated with the resource identifier. + void setFilter(Filter value) { + getOr().setFilter(value); + } + + /// Sets the wrap mode of the texture associated with the resource identifier. + void setWrap(Wrap value) { + getOr().setWrap(value); + } + /// Checks if the resource identifier is valid. It becomes automatically invalid when the resource is freed. bool isValid() { return data && engineState.textures.has(data); @@ -392,6 +402,16 @@ struct FontId { return getOr().size; } + /// Sets the filter mode of the font associated with the resource identifier. + void setFilter(Filter value) { + getOr().setFilter(value); + } + + /// Sets the wrap mode of the font associated with the resource identifier. + void setWrap(Wrap value) { + getOr().setWrap(value); + } + /// Checks if the resource identifier is valid. It becomes automatically invalid when the resource is freed. bool isValid() { return data && engineState.fonts.has(data); @@ -519,6 +539,11 @@ struct SoundId { @safe @nogc nothrow: + /// Returns true if the sound associated with the resource identifier is playing. + bool isPlaying() { + return getOr().isPlaying; + } + /// Returns the current playback time of the sound associated with the resource identifier. float time() { return getOr().time; @@ -533,6 +558,21 @@ struct SoundId { return getOr().progress; } + /// Sets the volume level for the sound associated with the resource identifier. + void setVolume(float value) { + getOr().setVolume(value); + } + + /// Sets the pitch for the sound associated with the resource identifier. + void setPitch(float value) { + getOr().setPitch(value); + } + + /// Sets the stereo panning for the sound associated with the resource identifier. + void setPan(float value) { + getOr().setPan(value); + } + /// Checks if the resource identifier is valid. It becomes automatically invalid when the resource is freed. bool isValid() { return data && engineState.sounds.has(data); @@ -1299,7 +1339,7 @@ void openWindow(int width, int height, const(IStr)[] args, IStr title = "Parin") engineState.saveTextBuffer.reserve(8192); if (args.length) engineState.assetsPath.append(pathConcat(args[0].pathDir, "assets")); // Load debug font. - auto monogramData = cast(const(ubyte)[]) import("monogram.png"); + auto monogramData = cast(const(ubyte)[]) import("parin_monogram.png"); auto monogramImage = rl.LoadImageFromMemory(".png", monogramData.ptr, cast(int) monogramData.length); auto monogramTexture = rl.LoadTextureFromImage(monogramImage); engineState.debugFont = monogramTexture.toParin().toFont(6, 12); diff --git a/source/parin/map.d b/source/parin/map.d index 137e937..474523d 100644 --- a/source/parin/map.d +++ b/source/parin/map.d @@ -284,23 +284,6 @@ struct TileMap { } } -Result!TileMap toTileMap(IStr csv, int tileWidth, int tileHeight) { - auto value = TileMap(); - auto fault = value.parse(csv, tileWidth, tileHeight); - if (fault) { - value.free(); - } - return Result!TileMap(value, fault); -} - -Result!TileMap loadRawTileMap(IStr path, int tileWidth, int tileHeight) { - auto temp = loadTempText(path); - if (temp.isNone) { - return Result!TileMap(temp.fault); - } - return toTileMap(temp.get(), tileWidth, tileHeight); -} - Fault saveTileMap(IStr path, TileMap map) { auto csv = prepareTempText(); foreach (row; 0 .. map.rowCount) {