Item inventoryIcon supports other drawable kinds now
This commit is contained in:
parent
9665048a9e
commit
b7cddf4f0e
@ -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 {
|
||||||
|
Loading…
Reference in New Issue
Block a user