Веб-сайт самохостера Lotigara

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKae <80987908+Novaenia@users.noreply.github.com>2023-08-19 15:44:16 +1000
committerKae <80987908+Novaenia@users.noreply.github.com>2023-08-19 15:44:16 +1000
commitb7cddf4f0e3ea7e852782b4200d24b0407797bc0 (patch)
tree258d98d1361d8967aed6c2b195707c47af80d31a
parent9665048a9e3663b03e9094f7c41791f86911d405 (diff)
Item inventoryIcon supports other drawable kinds now
-rw-r--r--source/game/StarItem.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/source/game/StarItem.cpp b/source/game/StarItem.cpp
index 3658bb0..f920a64 100644
--- a/source/game/StarItem.cpp
+++ b/source/game/StarItem.cpp
@@ -25,9 +25,13 @@ Item::Item(Json config, String directory, Json parameters) {
if (inventoryIcon.type() == Json::Type::Array) {
List<Drawable> iconDrawables;
for (auto const& drawable : inventoryIcon.toArray()) {
- auto image = AssetPath::relativeTo(m_directory, drawable.getString("image"));
- Vec2F position = jsonToVec2F(drawable.getArray("position", {0, 0}));
- iconDrawables.append(Drawable::makeImage(image, 1.0f, true, position));
+ if (auto image = drawable.optString("image")) {
+ auto changed = drawable.set("image", AssetPath::relativeTo(m_directory, *image));
+ iconDrawables.emplaceAppend(changed);
+ }
+ else {
+ iconDrawables.emplaceAppend(drawable);
+ }
}
setIconDrawables(move(iconDrawables));
} else {