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:
@@ -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 };
|
||||
|
||||
@@ -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()
|
||||
{
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user