Item inventoryIcon supports other drawable kinds now

This commit is contained in:
Kae 2023-08-19 15:44:16 +10:00
parent 9665048a9e
commit b7cddf4f0e

View File

@ -25,9 +25,13 @@ Item::Item(Json config, String directory, Json parameters) {
if (inventoryIcon.type() == Json::Type::Array) { if (inventoryIcon.type() == Json::Type::Array) {
List<Drawable> iconDrawables; List<Drawable> iconDrawables;
for (auto const& drawable : inventoryIcon.toArray()) { for (auto const& drawable : inventoryIcon.toArray()) {
auto image = AssetPath::relativeTo(m_directory, drawable.getString("image")); if (auto image = drawable.optString("image")) {
Vec2F position = jsonToVec2F(drawable.getArray("position", {0, 0})); auto changed = drawable.set("image", AssetPath::relativeTo(m_directory, *image));
iconDrawables.append(Drawable::makeImage(image, 1.0f, true, position)); iconDrawables.emplaceAppend(changed);
}
else {
iconDrawables.emplaceAppend(drawable);
}
} }
setIconDrawables(move(iconDrawables)); setIconDrawables(move(iconDrawables));
} else { } else {