From 2e369a81307a4c864f0e46d7bf207e900b8688e4 Mon Sep 17 00:00:00 2001 From: Mario Zechner Date: Wed, 11 Jun 2025 12:51:03 +0200 Subject: [PATCH] [cpp] 4.3 porting WIP --- spine-cpp/spine-cpp/include/spine/SlotData.h | 70 ++++++-------------- spine-cpp/spine-cpp/src/spine/SlotData.cpp | 61 ++++++----------- 2 files changed, 42 insertions(+), 89 deletions(-) diff --git a/spine-cpp/spine-cpp/include/spine/SlotData.h b/spine-cpp/spine-cpp/include/spine/SlotData.h index 8e16ea9d0..9a1fd4d39 100644 --- a/spine-cpp/spine-cpp/include/spine/SlotData.h +++ b/spine-cpp/spine-cpp/include/spine/SlotData.h @@ -31,95 +31,67 @@ #define Spine_SlotData_h #include -#include +#include #include -#include +#include namespace spine { class BoneData; + class SlotPose; + + /// Stores the setup pose for a Slot. + class SP_API SlotData : public PosedData { + RTTI_DECL - class SP_API SlotData : public SpineObject { friend class SkeletonBinary; - friend class SkeletonJson; - friend class AttachmentTimeline; - friend class RGBATimeline; - friend class RGBTimeline; - friend class AlphaTimeline; - friend class RGBA2Timeline; - friend class RGB2Timeline; - friend class DeformTimeline; - friend class DrawOrderTimeline; - friend class EventTimeline; - friend class IkConstraintTimeline; - friend class PathConstraintMixTimeline; - friend class PathConstraintPositionTimeline; - friend class PathConstraintSpacingTimeline; - friend class ScaleTimeline; - friend class ShearTimeline; - friend class TransformConstraintTimeline; - friend class TranslateTimeline; - friend class TwoColorTimeline; public: - SlotData(int index, const String &name, BoneData &boneData); + SlotData(int index, const String& name, BoneData& boneData); + /// The index of the slot in Skeleton::getSlots(). int getIndex(); - const String &getName(); + /// The bone this slot belongs to. + BoneData& getBoneData(); - BoneData &getBoneData(); + void setAttachmentName(const String& attachmentName); - Color &getColor(); - - Color &getDarkColor(); - - bool hasDarkColor(); - - void setHasDarkColor(bool inValue); - - /// May be empty. - const String &getAttachmentName(); - - void setAttachmentName(const String &inValue); + /// The name of the attachment that is visible for this slot in the setup pose, or empty if no attachment is visible. + const String& getAttachmentName(); + /// The blend mode for drawing the slot's attachment. BlendMode getBlendMode(); + void setBlendMode(BlendMode blendMode); - void setBlendMode(BlendMode inValue); - - bool isVisible(); - - void setVisible(bool inValue); + /// False if the slot was hidden in Spine and nonessential data was exported. Does not affect runtime rendering. + bool isVisible(); + void setVisible(bool visible); private: const int _index; - String _name; - BoneData &_boneData; - Color _color; - Color _darkColor; - - bool _hasDarkColor; + BoneData& _boneData; String _attachmentName; BlendMode _blendMode; - bool _visible; + bool _visible; }; } diff --git a/spine-cpp/spine-cpp/src/spine/SlotData.cpp b/spine-cpp/spine-cpp/src/spine/SlotData.cpp index bc9694a28..01468bcf7 100644 --- a/spine-cpp/spine-cpp/src/spine/SlotData.cpp +++ b/spine-cpp/spine-cpp/src/spine/SlotData.cpp @@ -28,72 +28,53 @@ *****************************************************************************/ #include +#include +#include #include using namespace spine; -SlotData::SlotData(int index, const String &name, BoneData &boneData) : _index(index), - _name(name), - _boneData(boneData), - _color(1, 1, 1, 1), - _darkColor(0, 0, 0, 0), - _hasDarkColor(false), - _attachmentName(), - _blendMode(BlendMode_Normal), - _visible(true) { - assert(_index >= 0); - assert(_name.length() > 0); +RTTI_IMPL_NOPARENT(SlotData) + +SlotData::SlotData(int index, const String& name, BoneData& boneData) : + PosedData(name, new (__FILE__, __LINE__) SlotPose()), + _index(index), + _boneData(boneData), + _attachmentName(), + _blendMode(BlendMode_Normal), + _visible(true) { + assert(index >= 0); } int SlotData::getIndex() { return _index; } -const String &SlotData::getName() { - return _name; -} - -BoneData &SlotData::getBoneData() { +BoneData& SlotData::getBoneData() { return _boneData; } -Color &SlotData::getColor() { - return _color; +void SlotData::setAttachmentName(const String& attachmentName) { + _attachmentName = attachmentName; } -Color &SlotData::getDarkColor() { - return _darkColor; -} - -bool SlotData::hasDarkColor() { - return _hasDarkColor; -} - -void SlotData::setHasDarkColor(bool inValue) { - _hasDarkColor = inValue; -} - -const String &SlotData::getAttachmentName() { +const String& SlotData::getAttachmentName() { return _attachmentName; } -void SlotData::setAttachmentName(const String &inValue) { - _attachmentName = inValue; -} - BlendMode SlotData::getBlendMode() { return _blendMode; } -void SlotData::setBlendMode(BlendMode inValue) { - _blendMode = inValue; +void SlotData::setBlendMode(BlendMode blendMode) { + _blendMode = blendMode; } bool SlotData::isVisible() { return _visible; } -void SlotData::setVisible(bool inValue) { - this->_visible = inValue; -} +void SlotData::setVisible(bool visible) { + _visible = visible; +} \ No newline at end of file