1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-02-03 18:07:53 +01:00

Read scriptName property from JSON

Use object identifier if no scriptName is provided
This commit is contained in:
Aaron van Geffen
2024-12-08 12:31:34 +01:00
parent 7efe73f6ac
commit e3c6fe22a6
3 changed files with 20 additions and 0 deletions

View File

@@ -104,6 +104,17 @@ void PeepAnimationsObject::ReadJson(IReadObjectContext* context, json_t& root)
}
}
// Do we have a preferred way of addressing this object in scripts?
if (groupJson.contains("scriptName"))
{
group.scriptName = Json::GetString(groupJson["scriptName"]);
}
// If not, just use the object identifier.
else
{
group.scriptName = GetIdentifier();
}
_animationGroups.push_back(group);
}
}
@@ -143,6 +154,11 @@ PeepAnimationGroup PeepAnimationsObject::GetLegacyPosition(PeepAnimationGroup an
return _animationGroups[EnumValue(animGroup)].legacyPosition;
}
std::string_view PeepAnimationsObject::GetScriptName(PeepAnimationGroup animGroup) const
{
return _animationGroups[EnumValue(animGroup)].scriptName;
}
void PeepAnimationsObject::DrawPreview(DrawPixelInfo& dpi, int32_t width, int32_t height) const
{
auto centre = ScreenCoordsXY{ width / 2, height / 2 };