From 76a64738d521d69f214654638615387fdc1423c0 Mon Sep 17 00:00:00 2001 From: Bottinator22 Date: Sun, 2 Mar 2025 15:29:52 -0800 Subject: allow persistently preloading assets --- source/base/StarAssets.hpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'source/base/StarAssets.hpp') diff --git a/source/base/StarAssets.hpp b/source/base/StarAssets.hpp index 6ffcb05..e848410 100644 --- a/source/base/StarAssets.hpp +++ b/source/base/StarAssets.hpp @@ -38,6 +38,15 @@ struct FramesSpecification { StringMap aliases; }; +enum class AssetType { + Json, + Image, + Audio, + Font, + Bytes +}; +extern EnumMap const AssetTypeNames; + // The assets system can load image, font, json, and data assets from a set of // sources. Each source is either a directory on the filesystem or a single // packed asset file. @@ -71,14 +80,6 @@ public: StringList digestIgnore; }; - enum class AssetType { - Json, - Image, - Audio, - Font, - Bytes - }; - enum class QueuePriority { None, Working, @@ -107,6 +108,7 @@ public: double time = 0.0; bool needsPostProcessing = false; + bool forcePersist = false; }; struct JsonData : AssetData { -- cgit v1.2.3 From 1af60db5b25143a8dd937b512c3ddfd2e275a4ab Mon Sep 17 00:00:00 2001 From: Bottinator22 Date: Sun, 2 Mar 2025 20:18:31 -0800 Subject: minor improvements --- source/base/StarAssets.cpp | 2 +- source/base/StarAssets.hpp | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) (limited to 'source/base/StarAssets.hpp') diff --git a/source/base/StarAssets.cpp b/source/base/StarAssets.cpp index 7fad6be..8622b87 100644 --- a/source/base/StarAssets.cpp +++ b/source/base/StarAssets.cpp @@ -369,7 +369,7 @@ Assets::Assets(Settings settings, StringList assetSources) { auto type = AssetTypeNames.getLeft(script.getString("type")); auto path = script.getString("path"); auto components = AssetPath::split(path); - validatePath(components, type == AssetType::Json, type == AssetType::Image); + validatePath(components, type == AssetType::Json || type == AssetType::Image, type == AssetType::Image); auto asset = getAsset(AssetId{type, std::move(components)}); // make this asset never unload diff --git a/source/base/StarAssets.hpp b/source/base/StarAssets.hpp index e848410..203214a 100644 --- a/source/base/StarAssets.hpp +++ b/source/base/StarAssets.hpp @@ -45,7 +45,6 @@ enum class AssetType { Font, Bytes }; -extern EnumMap const AssetTypeNames; // The assets system can load image, font, json, and data assets from a set of // sources. Each source is either a directory on the filesystem or a single -- cgit v1.2.3 From 33bb286cfb2a99ee785827c0f92e02acd2ec0cfd Mon Sep 17 00:00:00 2001 From: Bottinator22 Date: Sun, 2 Mar 2025 20:25:08 -0800 Subject: improvement --- source/base/StarAssets.cpp | 8 -------- source/base/StarAssets.hpp | 24 ++++++++++++++++-------- 2 files changed, 16 insertions(+), 16 deletions(-) (limited to 'source/base/StarAssets.hpp') diff --git a/source/base/StarAssets.cpp b/source/base/StarAssets.cpp index 8622b87..5bb752e 100644 --- a/source/base/StarAssets.cpp +++ b/source/base/StarAssets.cpp @@ -23,14 +23,6 @@ #include "StarUtilityLuaBindings.hpp" namespace Star { - -EnumMap const AssetTypeNames{ - {AssetType::Json, "json"}, - {AssetType::Image, "image"}, - {AssetType::Audio, "audio"}, - {AssetType::Font, "font"}, - {AssetType::Bytes, "bytes"} -}; static void validateBasePath(std::string_view const& basePath) { if (basePath.empty() || basePath[0] != '/') diff --git a/source/base/StarAssets.hpp b/source/base/StarAssets.hpp index 203214a..a8e4480 100644 --- a/source/base/StarAssets.hpp +++ b/source/base/StarAssets.hpp @@ -38,14 +38,6 @@ struct FramesSpecification { StringMap aliases; }; -enum class AssetType { - Json, - Image, - Audio, - Font, - Bytes -}; - // The assets system can load image, font, json, and data assets from a set of // sources. Each source is either a directory on the filesystem or a single // packed asset file. @@ -85,6 +77,14 @@ public: PostProcess, Load }; + + enum class AssetType { + Json, + Image, + Audio, + Font, + Bytes + }; struct AssetId { AssetType type; @@ -256,6 +256,14 @@ public: void cleanup(); private: + EnumMap const AssetTypeNames{ + {AssetType::Json, "json"}, + {AssetType::Image, "image"}, + {AssetType::Audio, "audio"}, + {AssetType::Font, "font"}, + {AssetType::Bytes, "bytes"} + }; + static FramesSpecification parseFramesSpecification(Json const& frameConfig, String path); void queueAssets(List const& assetIds) const; -- cgit v1.2.3