1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-18 12:33:17 +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 };

View File

@@ -13,6 +13,7 @@
#include "../peep/PeepAnimations.h"
#include "Object.h"
#include <string_view>
#include <vector>
class PeepAnimationsObject final : public Object
@@ -41,6 +42,7 @@ public:
OpenRCT2::AnimationPeepType GetPeepType() const;
size_t GetNumAnimationGroups() const;
PeepAnimationGroup GetLegacyPosition(PeepAnimationGroup animGroup) const;
std::string_view GetScriptName(PeepAnimationGroup animGroup) const;
bool IsSlowWalking()
{

View File

@@ -14,6 +14,7 @@
#include "../drawing/ImageIndexType.h"
#include "../entity/Peep.h"
#include <string>
#include <vector>
class PeepAnimationsObject;
@@ -51,6 +52,7 @@ namespace OpenRCT2
public:
// TODO: move type to RCT12?
PeepAnimationGroup legacyPosition = PeepAnimationGroup::Invalid;
std::string scriptName{};
constexpr PeepAnimation& operator[](PeepAnimationType n)
{