diff options
author | Kae <80987908+Novaenia@users.noreply.github.com> | 2024-03-17 01:53:46 +1100 |
---|---|---|
committer | Kae <80987908+Novaenia@users.noreply.github.com> | 2024-03-17 01:53:46 +1100 |
commit | 53c7c3775fae0810b0831297b50aab1b0a1ef4e0 (patch) | |
tree | ee8153e55810085d6ed07a64efb6a17c1fa87a2f /source/base | |
parent | 463205c09cc393e92ae2f51b9bc8f61c4e368dea (diff) |
Lua: new Image userdata (& cursor mod fix)
Diffstat (limited to 'source/base')
-rw-r--r-- | source/base/StarAssets.cpp | 14 | ||||
-rw-r--r-- | source/base/StarMemoryAssetSource.cpp | 2 |
2 files changed, 14 insertions, 2 deletions
diff --git a/source/base/StarAssets.cpp b/source/base/StarAssets.cpp index 784d686..6593d3d 100644 --- a/source/base/StarAssets.cpp +++ b/source/base/StarAssets.cpp @@ -19,6 +19,7 @@ #include "StarSha256.hpp" #include "StarDataStreamDevices.hpp" #include "StarLua.hpp" +#include "StarImageLuaBindings.hpp" #include "StarUtilityLuaBindings.hpp" namespace Star { @@ -120,6 +121,14 @@ Assets::Assets(Settings settings, StringList assetSources) { return String(assetBytes->ptr(), assetBytes->size()); }); + callbacks.registerCallback("image", [this](String const& path) -> Image { + auto assetImage = image(path); + if (assetImage->bytesPerPixel() == 3) + return assetImage->convert(PixelFormat::RGBA32); + else + return *assetImage; + }); + callbacks.registerCallback("scan", [this](Maybe<String> const& a, Maybe<String> const& b) -> StringList { return b ? scan(a.value(), *b) : scan(a.value()); }); @@ -211,6 +220,9 @@ Assets::Assets(Settings settings, StringList assetSources) { addSource(strf("{}::{}", sourcePath, groupName), memoryAssets); } } + // clear any caching that may have been trigered by load scripts as they may no longer be valid + m_framesSpecifications.clear(); + m_assetsCache.clear(); }; List<pair<String, AssetSourcePtr>> sources; @@ -884,7 +896,7 @@ Json Assets::readJson(String const& path) const { } } else if (patchJson.isType(Json::Type::Object)) { //Kae: Do a good ol' json merge instead if the .patch file is a Json object auto patchData = patchJson.toObject(); - result = jsonMerge(result, patchData); + result = jsonMergeNulling(result, patchData); } } return result; diff --git a/source/base/StarMemoryAssetSource.cpp b/source/base/StarMemoryAssetSource.cpp index 1176f5a..17e3749 100644 --- a/source/base/StarMemoryAssetSource.cpp +++ b/source/base/StarMemoryAssetSource.cpp @@ -52,7 +52,7 @@ IODevicePtr MemoryAssetSource::open(String const& path) { } ByteArrayPtr assetData; - StreamOffset assetPos; + StreamOffset assetPos = 0; String name; }; |