diff options
author | Kae <80987908+Novaenia@users.noreply.github.com> | 2024-09-22 15:59:45 +1000 |
---|---|---|
committer | Kae <80987908+Novaenia@users.noreply.github.com> | 2024-09-22 15:59:45 +1000 |
commit | ca48a137ec25f1002af4a1ab6e6e5047b5684ca6 (patch) | |
tree | 965c441c4a8675abe89598036c4339b5f167699a /source/base | |
parent | 764751a82545a80688612b643ba8031f10b6c048 (diff) |
root.assetFrames & assets.frames
Diffstat (limited to 'source/base')
-rw-r--r-- | source/base/StarAssets.cpp | 14 | ||||
-rw-r--r-- | source/base/StarAssets.hpp | 3 |
2 files changed, 16 insertions, 1 deletions
diff --git a/source/base/StarAssets.cpp b/source/base/StarAssets.cpp index 4a10aab..ecd2068 100644 --- a/source/base/StarAssets.cpp +++ b/source/base/StarAssets.cpp @@ -102,6 +102,14 @@ Maybe<RectU> FramesSpecification::getRect(String const& frame) const { } } +Json FramesSpecification::toJson() const { + return JsonObject{ + {"aliases", jsonFromMap(aliases)}, + {"frames", jsonFromMapV(frames, jsonFromRectU)}, + {"file", framesFile} + }; +} + Assets::Assets(Settings settings, StringList assetSources) { const char* AssetsPatchSuffix = ".patch"; const char* AssetsPatchListSuffix = ".patchlist"; @@ -139,6 +147,12 @@ Assets::Assets(Settings settings, StringList assetSources) { return *assetImage; }); + callbacks.registerCallback("frames", [this](String const& path) -> Json { + if (auto frames = imageFrames(path)) + return frames->toJson(); + return Json(); + }); + callbacks.registerCallback("scan", [this](Maybe<String> const& a, Maybe<String> const& b) -> StringList { return b ? scan(a.value(), *b) : scan(a.value()); }); diff --git a/source/base/StarAssets.hpp b/source/base/StarAssets.hpp index 6b454e8..e7b8611 100644 --- a/source/base/StarAssets.hpp +++ b/source/base/StarAssets.hpp @@ -27,7 +27,8 @@ struct FramesSpecification { // Get the target sub-rect of a given frame name (which can be an alias). // Returns nothing if the frame name is not found. Maybe<RectU> getRect(String const& frame) const; - + // Converts to Json. + Json toJson() const; // The full path to the .frames file from which this was loaded. String framesFile; // Named sub-frames |