mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-19 08:16:41 +08:00
[cpp] Replaced all usages of std::string (except in RTTI) with custom String. Fixed a bunch of unnecessary copies/pass by values.
This commit is contained in:
parent
ba90852ad6
commit
895407b69d
@ -29,7 +29,7 @@ Spine::SpineExtension::setInstance(Spine::DefaultSpineExtension::getInstance());
|
||||
|
||||
class MyTextureLoader : public TextureLoader
|
||||
{
|
||||
virtual void load(AtlasPage& page, std::string path) { // TODO }
|
||||
virtual void load(AtlasPage& page, const String& path) { // TODO }
|
||||
|
||||
virtual void unload(void* texture) { // TODO }
|
||||
};
|
||||
|
||||
@ -98,8 +98,8 @@ void reproduceIssue_776() {
|
||||
loadJson(R_JSON, R_ATLAS, atlas, skeletonData, stateData, skeleton, state);
|
||||
dispose(atlas, skeletonData, stateData, skeleton, state);
|
||||
|
||||
loadBinary(R_BINARY, R_ATLAS, atlas, skeletonData, stateData, skeleton, state);
|
||||
dispose(atlas, skeletonData, stateData, skeleton, state);
|
||||
// loadBinary(R_BINARY, R_ATLAS, atlas, skeletonData, stateData, skeleton, state);
|
||||
// dispose(atlas, skeletonData, stateData, skeleton, state);
|
||||
}
|
||||
|
||||
int main (int argc, char** argv) {
|
||||
|
||||
@ -35,8 +35,7 @@
|
||||
#include <spine/MixPose.h>
|
||||
#include <spine/MixDirection.h>
|
||||
#include <spine/SpineObject.h>
|
||||
|
||||
#include <string>
|
||||
#include <spine/String.h>
|
||||
|
||||
namespace Spine {
|
||||
class Timeline;
|
||||
@ -65,7 +64,7 @@ namespace Spine {
|
||||
friend class TwoColorTimeline;
|
||||
|
||||
public:
|
||||
Animation(std::string name, Vector<Timeline*>& timelines, float duration);
|
||||
Animation(const String& name, Vector<Timeline*>& timelines, float duration);
|
||||
|
||||
~Animation();
|
||||
|
||||
@ -73,7 +72,7 @@ namespace Spine {
|
||||
/// See also Timeline::apply(Skeleton&, float, float, Vector, float, MixPose, MixDirection)
|
||||
void apply(Skeleton& skeleton, float lastTime, float time, bool loop, Vector<Event*>* pEvents, float alpha, MixPose pose, MixDirection direction);
|
||||
|
||||
std::string getName();
|
||||
const String& getName();
|
||||
|
||||
Vector<Timeline*> getTimelines();
|
||||
|
||||
@ -86,7 +85,7 @@ namespace Spine {
|
||||
private:
|
||||
Vector<Timeline*> _timelines;
|
||||
float _duration;
|
||||
std::string _name;
|
||||
String _name;
|
||||
|
||||
/// @param target After the first and before the last entry.
|
||||
static int binarySearch(Vector<float>& values, float target, int step);
|
||||
|
||||
@ -35,6 +35,7 @@
|
||||
#include <spine/Pool.h>
|
||||
#include <spine/MixPose.h>
|
||||
#include <spine/SpineObject.h>
|
||||
#include <spine/String.h>
|
||||
|
||||
namespace Spine {
|
||||
enum EventType {
|
||||
@ -315,7 +316,7 @@ namespace Spine {
|
||||
void clearTrack(int trackIndex);
|
||||
|
||||
/// Sets an animation by name. setAnimation(int, Animation, bool)
|
||||
TrackEntry* setAnimation(int trackIndex, std::string animationName, bool loop);
|
||||
TrackEntry* setAnimation(int trackIndex, const String& animationName, bool loop);
|
||||
|
||||
/// Sets the current animation for a track, discarding any queued animations.
|
||||
/// @param loop If true, the animation will repeat.
|
||||
@ -328,7 +329,7 @@ namespace Spine {
|
||||
|
||||
/// Queues an animation by name.
|
||||
/// addAnimation(int, Animation, bool, float)
|
||||
TrackEntry* addAnimation(int trackIndex, std::string animationName, bool loop, float delay);
|
||||
TrackEntry* addAnimation(int trackIndex, const String& animationName, bool loop, float delay);
|
||||
|
||||
/// Adds an animation to be played delay seconds after the current or last queued animation
|
||||
/// for a track. If the track is empty, it is equivalent to calling setAnimation.
|
||||
|
||||
@ -33,9 +33,9 @@
|
||||
|
||||
#include <spine/HashMap.h>
|
||||
#include <spine/SpineObject.h>
|
||||
#include <spine/String.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <string>
|
||||
|
||||
namespace Spine {
|
||||
class SkeletonData;
|
||||
@ -56,7 +56,7 @@ namespace Spine {
|
||||
AnimationStateData(SkeletonData* skeletonData);
|
||||
|
||||
/// Sets a mix duration by animation names.
|
||||
void setMix(std::string fromName, std::string toName, float duration);
|
||||
void setMix(const String& fromName, const String& toName, float duration);
|
||||
|
||||
/// Sets a mix duration when changing from the specified animation to the other.
|
||||
/// See TrackEntry.MixDuration.
|
||||
|
||||
@ -34,8 +34,7 @@
|
||||
#include <spine/Vector.h>
|
||||
#include <spine/Extension.h>
|
||||
#include <spine/SpineObject.h>
|
||||
|
||||
#include <string>
|
||||
#include <spine/String.h>
|
||||
|
||||
namespace Spine {
|
||||
enum Format {
|
||||
@ -66,7 +65,7 @@ namespace Spine {
|
||||
|
||||
class AtlasPage : public SpineObject {
|
||||
public:
|
||||
std::string name;
|
||||
String name;
|
||||
Format format;
|
||||
TextureFilter minFilter;
|
||||
TextureFilter magFilter;
|
||||
@ -75,13 +74,13 @@ namespace Spine {
|
||||
void* rendererObject;
|
||||
int width, height;
|
||||
|
||||
AtlasPage(std::string inName) : name(inName) {}
|
||||
AtlasPage(const String& inName) : name(inName) {}
|
||||
};
|
||||
|
||||
class AtlasRegion : public SpineObject {
|
||||
public:
|
||||
AtlasPage* page;
|
||||
std::string name;
|
||||
String name;
|
||||
int x, y, width, height;
|
||||
float u, v, u2, v2;
|
||||
float offsetX, offsetY;
|
||||
@ -104,10 +103,10 @@ namespace Spine {
|
||||
|
||||
void flipV();
|
||||
|
||||
/// Returns the first region found with the specified name. This method uses std::string comparison to find the region, so the result
|
||||
/// Returns the first region found with the specified name. This method uses String comparison to find the region, so the result
|
||||
/// should be cached rather than calling this method multiple times.
|
||||
/// @return The region, or NULL.
|
||||
AtlasRegion* findRegion(std::string name);
|
||||
AtlasRegion* findRegion(const String& name);
|
||||
|
||||
void dispose();
|
||||
|
||||
|
||||
@ -33,6 +33,7 @@
|
||||
|
||||
#include <spine/AttachmentLoader.h>
|
||||
#include <spine/Vector.h>
|
||||
#include <spine/String.h>
|
||||
|
||||
|
||||
namespace Spine {
|
||||
@ -49,19 +50,19 @@ namespace Spine {
|
||||
public:
|
||||
AtlasAttachmentLoader(Atlas* atlas);
|
||||
|
||||
virtual RegionAttachment* newRegionAttachment(Skin& skin, std::string name, std::string path);
|
||||
virtual RegionAttachment* newRegionAttachment(Skin& skin, const String& name, const String& path);
|
||||
|
||||
virtual MeshAttachment* newMeshAttachment(Skin& skin, std::string name, std::string path);
|
||||
virtual MeshAttachment* newMeshAttachment(Skin& skin, const String& name, const String& path);
|
||||
|
||||
virtual BoundingBoxAttachment* newBoundingBoxAttachment(Skin& skin, std::string name);
|
||||
virtual BoundingBoxAttachment* newBoundingBoxAttachment(Skin& skin, const String& name);
|
||||
|
||||
virtual PathAttachment* newPathAttachment(Skin& skin, std::string name);
|
||||
virtual PathAttachment* newPathAttachment(Skin& skin, const String& name);
|
||||
|
||||
virtual PointAttachment* newPointAttachment(Skin& skin, std::string name);
|
||||
virtual PointAttachment* newPointAttachment(Skin& skin, const String& name);
|
||||
|
||||
virtual ClippingAttachment* newClippingAttachment(Skin& skin, std::string name);
|
||||
virtual ClippingAttachment* newClippingAttachment(Skin& skin, const String& name);
|
||||
|
||||
AtlasRegion* findRegion(std::string name);
|
||||
AtlasRegion* findRegion(const String& name);
|
||||
|
||||
private:
|
||||
Atlas* _atlas;
|
||||
|
||||
@ -33,20 +33,20 @@
|
||||
|
||||
#include <spine/RTTI.h>
|
||||
#include <spine/SpineObject.h>
|
||||
#include <string>
|
||||
#include <spine/String.h>
|
||||
|
||||
namespace Spine {
|
||||
class Attachment : public SpineObject {
|
||||
RTTI_DECL
|
||||
|
||||
public:
|
||||
Attachment(std::string name);
|
||||
Attachment(const String& name);
|
||||
virtual ~Attachment();
|
||||
|
||||
const std::string& getName();
|
||||
|
||||
const String& getName();
|
||||
|
||||
private:
|
||||
const std::string _name;
|
||||
const String _name;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -33,7 +33,7 @@
|
||||
|
||||
#include <spine/RTTI.h>
|
||||
#include <spine/SpineObject.h>
|
||||
#include <string>
|
||||
#include <spine/String.h>
|
||||
|
||||
namespace Spine {
|
||||
class Skin;
|
||||
@ -52,20 +52,20 @@ namespace Spine {
|
||||
virtual ~AttachmentLoader();
|
||||
|
||||
/// @return May be NULL to not load any attachment.
|
||||
virtual RegionAttachment* newRegionAttachment(Skin& skin, std::string name, std::string path) = 0;
|
||||
virtual RegionAttachment* newRegionAttachment(Skin& skin, const String& name, const String& path) = 0;
|
||||
|
||||
/// @return May be NULL to not load any attachment.
|
||||
virtual MeshAttachment* newMeshAttachment(Skin& skin, std::string name, std::string path) = 0;
|
||||
virtual MeshAttachment* newMeshAttachment(Skin& skin, const String& name, const String& path) = 0;
|
||||
|
||||
/// @return May be NULL to not load any attachment.
|
||||
virtual BoundingBoxAttachment* newBoundingBoxAttachment(Skin& skin, std::string name) = 0;
|
||||
virtual BoundingBoxAttachment* newBoundingBoxAttachment(Skin& skin, const String& name) = 0;
|
||||
|
||||
/// @return May be NULL to not load any attachment
|
||||
virtual PathAttachment* newPathAttachment(Skin& skin, std::string name) = 0;
|
||||
virtual PathAttachment* newPathAttachment(Skin& skin, const String& name) = 0;
|
||||
|
||||
virtual PointAttachment* newPointAttachment(Skin& skin, std::string name) = 0;
|
||||
virtual PointAttachment* newPointAttachment(Skin& skin, const String& name) = 0;
|
||||
|
||||
virtual ClippingAttachment* newClippingAttachment(Skin& skin, std::string name) = 0;
|
||||
virtual ClippingAttachment* newClippingAttachment(Skin& skin, const String& name) = 0;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -36,8 +36,8 @@
|
||||
#include <spine/Vector.h>
|
||||
#include <spine/MixPose.h>
|
||||
#include <spine/MixDirection.h>
|
||||
#include <spine/String.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace Spine {
|
||||
class Skeleton;
|
||||
@ -57,20 +57,20 @@ namespace Spine {
|
||||
virtual int getPropertyId();
|
||||
|
||||
/// Sets the time and value of the specified keyframe.
|
||||
void setFrame(int frameIndex, float time, std::string attachmentName);
|
||||
void setFrame(int frameIndex, float time, const String& attachmentName);
|
||||
|
||||
int getSlotIndex();
|
||||
void setSlotIndex(int inValue);
|
||||
Vector<float>& getFrames();
|
||||
const Vector<float>& getFrames();
|
||||
void setFrames(Vector<float>& inValue); // time, ...
|
||||
Vector<std::string> getAttachmentNames();
|
||||
void setAttachmentNames(Vector<std::string>& inValue);
|
||||
const Vector<String>& getAttachmentNames();
|
||||
void setAttachmentNames(Vector<String>& inValue);
|
||||
int getFrameCount();
|
||||
|
||||
private:
|
||||
int _slotIndex;
|
||||
Vector<float> _frames;
|
||||
Vector<std::string> _attachmentNames;
|
||||
Vector<String> _attachmentNames;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -33,7 +33,7 @@
|
||||
|
||||
#include <spine/TransformMode.h>
|
||||
#include <spine/SpineObject.h>
|
||||
#include <string>
|
||||
#include <spine/String.h>
|
||||
|
||||
namespace Spine {
|
||||
class BoneData : public SpineObject {
|
||||
@ -48,13 +48,13 @@ namespace Spine {
|
||||
friend class TranslateTimeline;
|
||||
|
||||
public:
|
||||
BoneData(int index, std::string name, BoneData* parent = NULL);
|
||||
BoneData(int index, const String& name, BoneData* parent = NULL);
|
||||
|
||||
/// The index of the bone in Skeleton.Bones
|
||||
const int getIndex();
|
||||
int getIndex();
|
||||
|
||||
/// The name of the bone, which is unique within the skeleton.
|
||||
const std::string& getName();
|
||||
const String& getName();
|
||||
|
||||
/// May be NULL.
|
||||
BoneData* getParent();
|
||||
@ -96,7 +96,7 @@ namespace Spine {
|
||||
|
||||
private:
|
||||
const int _index;
|
||||
const std::string _name;
|
||||
const String _name;
|
||||
BoneData* _parent;
|
||||
float _length;
|
||||
float _x, _y, _rotation, _scaleX, _scaleY, _shearX, _shearY;
|
||||
|
||||
@ -39,7 +39,7 @@ namespace Spine {
|
||||
class BoundingBoxAttachment : public VertexAttachment {
|
||||
RTTI_DECL
|
||||
|
||||
BoundingBoxAttachment(std::string name);
|
||||
BoundingBoxAttachment(const String& name);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -45,7 +45,7 @@ namespace Spine {
|
||||
RTTI_DECL
|
||||
|
||||
public:
|
||||
ClippingAttachment(std::string name);
|
||||
ClippingAttachment(const String& name);
|
||||
|
||||
SlotData* getEndSlot();
|
||||
void setEndSlot(SlotData* inValue);
|
||||
|
||||
@ -35,8 +35,8 @@
|
||||
#include <spine/Vector.h>
|
||||
#include <spine/HashMap.h>
|
||||
#include <spine/SpineObject.h>
|
||||
#include <spine/String.h>
|
||||
|
||||
#include <string>
|
||||
#include <assert.h>
|
||||
|
||||
namespace Spine {
|
||||
@ -46,7 +46,7 @@ namespace Spine {
|
||||
/// It is more efficient to cache the results of this method than to call it multiple times.
|
||||
/// @return May be NULL.
|
||||
template<typename T>
|
||||
static T* findWithName(Vector<T*>& items, std::string name) {
|
||||
static T* findWithName(Vector<T*>& items, const String& name) {
|
||||
assert(name.length() > 0);
|
||||
|
||||
for (T** i = items.begin(); i != items.end(); ++i) {
|
||||
@ -61,7 +61,7 @@ namespace Spine {
|
||||
|
||||
/// @return -1 if the item was not found.
|
||||
template<typename T>
|
||||
static int findIndexWithName(Vector<T*>& items, std::string name) {
|
||||
static int findIndexWithName(Vector<T*>& items, const String& name) {
|
||||
assert(name.length() > 0);
|
||||
|
||||
for (size_t i = 0, len = items.size(); i < len; ++i) {
|
||||
@ -78,7 +78,7 @@ namespace Spine {
|
||||
/// It is more efficient to cache the results of this method than to call it multiple times.
|
||||
/// @return May be NULL.
|
||||
template<typename T>
|
||||
static T* findWithDataName(Vector<T*>& items, std::string name) {
|
||||
static T* findWithDataName(Vector<T*>& items, const String& name) {
|
||||
assert(name.length() > 0);
|
||||
|
||||
for (T** i = items.begin(); i != items.end(); ++i) {
|
||||
@ -93,7 +93,7 @@ namespace Spine {
|
||||
|
||||
/// @return -1 if the item was not found.
|
||||
template<typename T>
|
||||
static int findIndexWithDataName(Vector<T*>& items, std::string name) {
|
||||
static int findIndexWithDataName(Vector<T*>& items, const String& name) {
|
||||
assert(name.length() > 0);
|
||||
|
||||
for (size_t i = 0, len = items.size(); i < len; ++i) {
|
||||
|
||||
@ -32,8 +32,7 @@
|
||||
#define Spine_Event_h
|
||||
|
||||
#include <spine/SpineObject.h>
|
||||
|
||||
#include <string>
|
||||
#include <spine/String.h>
|
||||
|
||||
namespace Spine {
|
||||
class EventData;
|
||||
@ -57,16 +56,16 @@ namespace Spine {
|
||||
|
||||
float getFloatValue();
|
||||
void setFloatValue(int inValue);
|
||||
|
||||
std::string getStringValue();
|
||||
void setStringValue(std::string inValue);
|
||||
|
||||
const String& getStringValue();
|
||||
void setStringValue(const String& inValue);
|
||||
|
||||
private:
|
||||
const EventData& _data;
|
||||
const float _time;
|
||||
int _intValue;
|
||||
float _floatValue;
|
||||
std::string _stringValue;
|
||||
String _stringValue;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -32,8 +32,7 @@
|
||||
#define Spine_EventData_h
|
||||
|
||||
#include <spine/SpineObject.h>
|
||||
|
||||
#include <string>
|
||||
#include <spine/String.h>
|
||||
|
||||
namespace Spine {
|
||||
/// Stores the setup pose values for an Event.
|
||||
@ -43,10 +42,10 @@ namespace Spine {
|
||||
friend class Event;
|
||||
|
||||
public:
|
||||
EventData(std::string name);
|
||||
EventData(const String& name);
|
||||
|
||||
/// The name of the event, which is unique within the skeleton.
|
||||
const std::string& getName();
|
||||
const String& getName();
|
||||
|
||||
int getIntValue();
|
||||
void setIntValue(int inValue);
|
||||
@ -54,14 +53,14 @@ namespace Spine {
|
||||
float getFloatValue();
|
||||
void setFloatValue(float inValue);
|
||||
|
||||
std::string getStringValue();
|
||||
void setStringValue(std::string inValue);
|
||||
const String& getStringValue();
|
||||
void setStringValue(const String& inValue);
|
||||
|
||||
private:
|
||||
const std::string _name;
|
||||
const String _name;
|
||||
int _intValue;
|
||||
float _floatValue;
|
||||
std::string _stringValue;
|
||||
String _stringValue;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -33,8 +33,7 @@
|
||||
|
||||
#include <spine/Vector.h>
|
||||
#include <spine/SpineObject.h>
|
||||
|
||||
#include <string>
|
||||
#include <spine/String.h>
|
||||
|
||||
namespace Spine {
|
||||
class BoneData;
|
||||
@ -47,10 +46,10 @@ namespace Spine {
|
||||
friend class IkConstraintTimeline;
|
||||
|
||||
public:
|
||||
IkConstraintData(std::string name);
|
||||
IkConstraintData(const String& name);
|
||||
|
||||
/// The IK constraint's name, which is unique within the skeleton.
|
||||
const std::string& getName();
|
||||
const String& getName();
|
||||
|
||||
int getOrder();
|
||||
void setOrder(int inValue);
|
||||
@ -70,7 +69,7 @@ namespace Spine {
|
||||
void setMix(float inValue);
|
||||
|
||||
private:
|
||||
const std::string _name;
|
||||
const String _name;
|
||||
int _order;
|
||||
Vector<BoneData*> _bones;
|
||||
BoneData* _target;
|
||||
|
||||
@ -32,8 +32,7 @@
|
||||
#define Spine_LinkedMesh_h
|
||||
|
||||
#include <spine/SpineObject.h>
|
||||
|
||||
#include <string>
|
||||
#include <spine/String.h>
|
||||
|
||||
namespace Spine {
|
||||
class MeshAttachment;
|
||||
@ -43,13 +42,13 @@ namespace Spine {
|
||||
friend class SkeletonJson;
|
||||
|
||||
public:
|
||||
LinkedMesh(MeshAttachment* mesh, std::string skin, int slotIndex, std::string parent);
|
||||
LinkedMesh(MeshAttachment* mesh, const String& skin, int slotIndex, const String& parent);
|
||||
|
||||
private:
|
||||
MeshAttachment* _mesh;
|
||||
std::string _skin;
|
||||
String _skin;
|
||||
int _slotIndex;
|
||||
std::string _parent;
|
||||
String _parent;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -32,10 +32,8 @@
|
||||
#define Spine_MeshAttachment_h
|
||||
|
||||
#include <spine/VertexAttachment.h>
|
||||
|
||||
#include <spine/Vector.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace Spine {
|
||||
/// Attachment that displays a texture region using a mesh.
|
||||
@ -47,7 +45,7 @@ namespace Spine {
|
||||
RTTI_DECL
|
||||
|
||||
public:
|
||||
MeshAttachment(std::string name);
|
||||
MeshAttachment(const String& name);
|
||||
|
||||
void updateUVs();
|
||||
|
||||
@ -75,8 +73,8 @@ namespace Spine {
|
||||
float getA();
|
||||
void setA(float inValue);
|
||||
|
||||
std::string getPath();
|
||||
void setPath(std::string inValue);
|
||||
const String& getPath();
|
||||
void setPath(const String& inValue);
|
||||
void* getRendererObject();
|
||||
void setRendererObject(void* inValue);
|
||||
|
||||
@ -138,7 +136,7 @@ namespace Spine {
|
||||
Vector<short> _triangles;
|
||||
Vector<short> _edges;
|
||||
void* _rendererObject;
|
||||
std::string _path;
|
||||
String _path;
|
||||
float _regionU;
|
||||
float _regionV;
|
||||
float _regionU2;
|
||||
|
||||
@ -41,7 +41,7 @@ namespace Spine {
|
||||
RTTI_DECL
|
||||
|
||||
public:
|
||||
PathAttachment(std::string name);
|
||||
PathAttachment(const String& name);
|
||||
|
||||
/// The length in the setup pose from the start of the path to the end of each curve.
|
||||
Vector<float>& getLengths();
|
||||
|
||||
@ -36,8 +36,7 @@
|
||||
#include <spine/RotateMode.h>
|
||||
#include <spine/Vector.h>
|
||||
#include <spine/SpineObject.h>
|
||||
|
||||
#include <string>
|
||||
#include <spine/String.h>
|
||||
|
||||
namespace Spine {
|
||||
class BoneData;
|
||||
@ -54,9 +53,9 @@ namespace Spine {
|
||||
friend class PathConstraintSpacingTimeline;
|
||||
|
||||
public:
|
||||
PathConstraintData(std::string name);
|
||||
|
||||
const std::string& getName();
|
||||
PathConstraintData(const String& name);
|
||||
|
||||
const String& getName();
|
||||
|
||||
int getOrder();
|
||||
void setOrder(int inValue);
|
||||
@ -91,7 +90,7 @@ namespace Spine {
|
||||
void setTranslateMix(float inValue);
|
||||
|
||||
private:
|
||||
const std::string _name;
|
||||
const String _name;
|
||||
int _order;
|
||||
Vector<BoneData*> _bones;
|
||||
SlotData* _target;
|
||||
|
||||
@ -50,7 +50,7 @@ namespace Spine {
|
||||
RTTI_DECL
|
||||
|
||||
public:
|
||||
PointAttachment(std::string name);
|
||||
PointAttachment(const String& name);
|
||||
|
||||
void computeWorldPosition(Bone& bone, float& ox, float& oy);
|
||||
|
||||
|
||||
@ -32,6 +32,7 @@
|
||||
#define Spine_RTTI_h
|
||||
|
||||
#include <spine/SpineObject.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace Spine {
|
||||
@ -52,8 +53,8 @@ namespace Spine {
|
||||
RTTI(const RTTI& obj);
|
||||
RTTI& operator=(const RTTI& obj);
|
||||
|
||||
const std::string m_className;
|
||||
const RTTI *m_pBaseRTTI;
|
||||
const std::string& _className;
|
||||
const RTTI *_pBaseRTTI;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -51,7 +51,7 @@ namespace Spine {
|
||||
RTTI_DECL
|
||||
|
||||
public:
|
||||
RegionAttachment(std::string name);
|
||||
RegionAttachment(const String& name);
|
||||
|
||||
void updateOffset();
|
||||
|
||||
@ -87,9 +87,9 @@ namespace Spine {
|
||||
void setB(float inValue);
|
||||
float getA();
|
||||
void setA(float inValue);
|
||||
|
||||
std::string getPath();
|
||||
void setPath(std::string inValue);
|
||||
|
||||
const String& getPath();
|
||||
void setPath(const String& inValue);
|
||||
void* getRendererObject();
|
||||
void setRendererObject(void* inValue);
|
||||
float getRegionOffsetX();
|
||||
@ -129,7 +129,7 @@ namespace Spine {
|
||||
Vector<float> _offset;
|
||||
Vector<float> _uvs;
|
||||
void* _rendererObject;
|
||||
std::string _path;
|
||||
String _path;
|
||||
float _regionU;
|
||||
float _regionV;
|
||||
float _regionU2;
|
||||
|
||||
@ -34,8 +34,8 @@
|
||||
#include <spine/Vector.h>
|
||||
#include <spine/MathUtil.h>
|
||||
#include <spine/SpineObject.h>
|
||||
#include <spine/String.h>
|
||||
|
||||
#include <string>
|
||||
#include <limits> // std::numeric_limits
|
||||
|
||||
namespace Spine {
|
||||
@ -90,19 +90,19 @@ namespace Spine {
|
||||
void setSlotsToSetupPose();
|
||||
|
||||
/// @return May be NULL.
|
||||
Bone* findBone(std::string boneName);
|
||||
Bone* findBone(const String& boneName);
|
||||
|
||||
/// @return -1 if the bone was not found.
|
||||
int findBoneIndex(std::string boneName);
|
||||
int findBoneIndex(const String& boneName);
|
||||
|
||||
/// @return May be NULL.
|
||||
Slot* findSlot(std::string slotName);
|
||||
Slot* findSlot(const String& slotName);
|
||||
|
||||
/// @return -1 if the bone was not found.
|
||||
int findSlotIndex(std::string slotName);
|
||||
int findSlotIndex(const String& slotName);
|
||||
|
||||
/// Sets a skin by name (see setSkin).
|
||||
void setSkin(std::string skinName);
|
||||
void setSkin(const String& skinName);
|
||||
|
||||
/// Attachments from the new skin are attached if the corresponding attachment from the old skin was attached.
|
||||
/// If there was no old skin, each slot's setup mode attachment is attached from the new skin.
|
||||
@ -115,22 +115,22 @@ namespace Spine {
|
||||
void setSkin(Skin* newSkin);
|
||||
|
||||
/// @return May be NULL.
|
||||
Attachment* getAttachment(std::string slotName, std::string attachmentName);
|
||||
Attachment* getAttachment(const String& slotName, const String& attachmentName);
|
||||
|
||||
/// @return May be NULL.
|
||||
Attachment* getAttachment(int slotIndex, std::string attachmentName);
|
||||
Attachment* getAttachment(int slotIndex, const String& attachmentName);
|
||||
|
||||
/// @param attachmentName May be empty.
|
||||
void setAttachment(std::string slotName, std::string attachmentName);
|
||||
void setAttachment(const String& slotName, const String& attachmentName);
|
||||
|
||||
/// @return May be NULL.
|
||||
IkConstraint* findIkConstraint(std::string constraintName);
|
||||
IkConstraint* findIkConstraint(const String& constraintName);
|
||||
|
||||
/// @return May be NULL.
|
||||
TransformConstraint* findTransformConstraint(std::string constraintName);
|
||||
TransformConstraint* findTransformConstraint(const String& constraintName);
|
||||
|
||||
/// @return May be NULL.
|
||||
PathConstraint* findPathConstraint(std::string constraintName);
|
||||
PathConstraint* findPathConstraint(const String& constraintName);
|
||||
|
||||
void update(float delta);
|
||||
|
||||
|
||||
@ -34,8 +34,7 @@
|
||||
#include <spine/TransformMode.h>
|
||||
#include <spine/Vector.h>
|
||||
#include <spine/SpineObject.h>
|
||||
|
||||
#include <string>
|
||||
#include <spine/String.h>
|
||||
|
||||
namespace Spine {
|
||||
class SkeletonData;
|
||||
@ -87,7 +86,7 @@ namespace Spine {
|
||||
|
||||
AttachmentLoader* _attachmentLoader;
|
||||
Vector<LinkedMesh*> _linkedMeshes;
|
||||
std::string _error;
|
||||
String _error;
|
||||
float _scale;
|
||||
const bool _ownsLoader;
|
||||
|
||||
|
||||
@ -32,8 +32,7 @@
|
||||
#define Spine_SkeletonData_h
|
||||
|
||||
#include <spine/Vector.h>
|
||||
|
||||
#include <string>
|
||||
#include <spine/String.h>
|
||||
|
||||
namespace Spine {
|
||||
class BoneData;
|
||||
@ -59,40 +58,40 @@ namespace Spine {
|
||||
/// Finds a bone by comparing each bone's name.
|
||||
/// It is more efficient to cache the results of this method than to call it multiple times.
|
||||
/// @return May be NULL.
|
||||
BoneData* findBone(std::string boneName);
|
||||
BoneData* findBone(const String& boneName);
|
||||
|
||||
/// @return -1 if the bone was not found.
|
||||
int findBoneIndex(std::string boneName);
|
||||
int findBoneIndex(const String& boneName);
|
||||
|
||||
/// @return May be NULL.
|
||||
SlotData* findSlot(std::string slotName);
|
||||
SlotData* findSlot(const String& slotName);
|
||||
|
||||
/// @return -1 if the slot was not found.
|
||||
int findSlotIndex(std::string slotName);
|
||||
int findSlotIndex(const String& slotName);
|
||||
|
||||
/// @return May be NULL.
|
||||
Skin* findSkin(std::string skinName);
|
||||
Skin* findSkin(const String& skinName);
|
||||
|
||||
/// @return May be NULL.
|
||||
EventData* findEvent(std::string eventDataName);
|
||||
EventData* findEvent(const String& eventDataName);
|
||||
|
||||
/// @return May be NULL.
|
||||
Animation* findAnimation(std::string animationName);
|
||||
Animation* findAnimation(const String& animationName);
|
||||
|
||||
/// @return May be NULL.
|
||||
IkConstraintData* findIkConstraint(std::string constraintName);
|
||||
IkConstraintData* findIkConstraint(const String& constraintName);
|
||||
|
||||
/// @return May be NULL.
|
||||
TransformConstraintData* findTransformConstraint(std::string constraintName);
|
||||
TransformConstraintData* findTransformConstraint(const String& constraintName);
|
||||
|
||||
/// @return May be NULL.
|
||||
PathConstraintData* findPathConstraint(std::string constraintName);
|
||||
PathConstraintData* findPathConstraint(const String& constraintName);
|
||||
|
||||
/// @return -1 if the path constraint was not found.
|
||||
int findPathConstraintIndex(std::string pathConstraintName);
|
||||
|
||||
std::string getName();
|
||||
void setName(std::string inValue);
|
||||
int findPathConstraintIndex(const String& pathConstraintName);
|
||||
|
||||
const String& getName();
|
||||
void setName(const String& inValue);
|
||||
|
||||
/// The skeleton's bones, sorted parent first. The root bone is always the first bone.
|
||||
Vector<BoneData*>& getBones();
|
||||
@ -112,12 +111,16 @@ namespace Spine {
|
||||
|
||||
Vector<EventData*>& getEvents();
|
||||
void setEvents(Vector<EventData*>& inValue);
|
||||
|
||||
Vector<Animation*>& getAnimations();
|
||||
void setAnimations(Vector<Animation*>& inValue);
|
||||
|
||||
Vector<IkConstraintData*>& getIkConstraints();
|
||||
void setIkConstraints(Vector<IkConstraintData*>& inValue);
|
||||
|
||||
Vector<TransformConstraintData*>& getTransformConstraints();
|
||||
void setTransformConstraints(Vector<TransformConstraintData*>& inValue);
|
||||
|
||||
Vector<PathConstraintData*>& getPathConstraints();
|
||||
void setPathConstraints(Vector<PathConstraintData*>& inValue);
|
||||
|
||||
@ -127,19 +130,19 @@ namespace Spine {
|
||||
void setHeight(float inValue);
|
||||
|
||||
/// The Spine version used to export this data, or NULL.
|
||||
std::string getVersion();
|
||||
void setVersion(std::string inValue);
|
||||
std::string getHash();
|
||||
void setHash(std::string inValue);
|
||||
std::string getImagesPath();
|
||||
void setImagesPath(std::string inValue);
|
||||
const String& getVersion();
|
||||
void setVersion(const String& inValue);
|
||||
const String& getHash();
|
||||
void setHash(const String& inValue);
|
||||
const String& getImagesPath();
|
||||
void setImagesPath(const String& inValue);
|
||||
|
||||
/// The dopesheet FPS in Spine. Available only when nonessential data was exported.
|
||||
float getFps();
|
||||
void setFps(float inValue);
|
||||
|
||||
private:
|
||||
std::string _name;
|
||||
String _name;
|
||||
Vector<BoneData*> _bones; // Ordered parents first
|
||||
Vector<SlotData*> _slots; // Setup pose draw order.
|
||||
Vector<Skin*> _skins;
|
||||
@ -150,12 +153,12 @@ namespace Spine {
|
||||
Vector<TransformConstraintData*> _transformConstraints;
|
||||
Vector<PathConstraintData*> _pathConstraints;
|
||||
float _width, _height;
|
||||
std::string _version;
|
||||
std::string _hash;
|
||||
String _version;
|
||||
String _hash;
|
||||
|
||||
// Nonessential.
|
||||
float _fps;
|
||||
std::string _imagesPath;
|
||||
String _imagesPath;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -33,8 +33,7 @@
|
||||
|
||||
#include <spine/Vector.h>
|
||||
#include <spine/SpineObject.h>
|
||||
|
||||
#include <string>
|
||||
#include <spine/String.h>
|
||||
|
||||
namespace Spine {
|
||||
class CurveTimeline;
|
||||
@ -63,7 +62,7 @@ namespace Spine {
|
||||
Vector<LinkedMesh*> _linkedMeshes;
|
||||
float _scale;
|
||||
const bool _ownsLoader;
|
||||
std::string _error;
|
||||
String _error;
|
||||
|
||||
static float toColor(const char* value, int index);
|
||||
|
||||
|
||||
@ -31,9 +31,9 @@
|
||||
#ifndef Spine_Skin_h
|
||||
#define Spine_Skin_h
|
||||
|
||||
#include <string>
|
||||
#include <spine/HashMap.h>
|
||||
#include <spine/Vector.h>
|
||||
#include <spine/String.h>
|
||||
|
||||
namespace Spine {
|
||||
class Attachment;
|
||||
@ -49,9 +49,9 @@ namespace Spine {
|
||||
class AttachmentKey {
|
||||
public:
|
||||
int _slotIndex;
|
||||
std::string _name;
|
||||
String _name;
|
||||
|
||||
AttachmentKey(int slotIndex = 0, std::string name = "");
|
||||
AttachmentKey(int slotIndex = 0, const String& name = "");
|
||||
|
||||
AttachmentKey(const AttachmentKey &other) {
|
||||
this->_slotIndex = other._slotIndex;
|
||||
@ -65,31 +65,31 @@ namespace Spine {
|
||||
std::size_t operator()(const Spine::Skin::AttachmentKey& val) const;
|
||||
};
|
||||
|
||||
Skin(std::string name);
|
||||
Skin(const String& name);
|
||||
~Skin();
|
||||
|
||||
/// Adds an attachment to the skin for the specified slot index and name.
|
||||
/// If the name already exists for the slot, the previous value is replaced.
|
||||
void addAttachment(int slotIndex, std::string name, Attachment* attachment);
|
||||
void addAttachment(int slotIndex, const String& name, Attachment* attachment);
|
||||
|
||||
/// Returns the attachment for the specified slot index and name, or NULL.
|
||||
Attachment* getAttachment(int slotIndex, std::string name);
|
||||
Attachment* getAttachment(int slotIndex, const String& name);
|
||||
|
||||
/// Finds the skin keys for a given slot. The results are added to the passed array of names.
|
||||
/// @param slotIndex The target slotIndex. To find the slot index, use Skeleton::findSlotIndex or SkeletonData::findSlotIndex
|
||||
/// @param names Found skin key names will be added to this array.
|
||||
void findNamesForSlot(int slotIndex, Vector<std::string>& names);
|
||||
void findNamesForSlot(int slotIndex, Vector<String>& names);
|
||||
|
||||
/// Finds the attachments for a given slot. The results are added to the passed array of Attachments.
|
||||
/// @param slotIndex The target slotIndex. To find the slot index, use Skeleton::findSlotIndex or SkeletonData::findSlotIndex
|
||||
/// @param attachments Found Attachments will be added to this array.
|
||||
void findAttachmentsForSlot(int slotIndex, Vector<Attachment*>& attachments);
|
||||
|
||||
const std::string& getName();
|
||||
|
||||
const String& getName();
|
||||
HashMap<AttachmentKey, Attachment*, HashAttachmentKey>& getAttachments();
|
||||
|
||||
private:
|
||||
const std::string _name;
|
||||
const String _name;
|
||||
HashMap<AttachmentKey, Attachment*, HashAttachmentKey> _attachments;
|
||||
|
||||
/// Attach all attachments from this skin if the corresponding attachment from the old skin is currently attached.
|
||||
|
||||
@ -33,8 +33,7 @@
|
||||
|
||||
#include <spine/BlendMode.h>
|
||||
#include <spine/SpineObject.h>
|
||||
|
||||
#include <string>
|
||||
#include <spine/String.h>
|
||||
|
||||
namespace Spine {
|
||||
class BoneData;
|
||||
@ -59,11 +58,11 @@ namespace Spine {
|
||||
friend class TwoColorTimeline;
|
||||
|
||||
public:
|
||||
SlotData(int index, std::string name, BoneData& boneData);
|
||||
SlotData(int index, const String& name, BoneData& boneData);
|
||||
|
||||
const int getIndex();
|
||||
|
||||
const std::string& getName();
|
||||
const String& getName();
|
||||
|
||||
BoneData& getBoneData();
|
||||
|
||||
@ -86,20 +85,20 @@ namespace Spine {
|
||||
void setHasSecondColor(bool inValue);
|
||||
|
||||
/// May be empty.
|
||||
std::string getAttachmentName();
|
||||
void setAttachmentName(std::string inValue);
|
||||
const String& getAttachmentName();
|
||||
void setAttachmentName(const String& inValue);
|
||||
|
||||
BlendMode getBlendMode();
|
||||
void setBlendMode(BlendMode inValue);
|
||||
|
||||
private:
|
||||
const int _index;
|
||||
const std::string _name;
|
||||
String _name;
|
||||
BoneData& _boneData;
|
||||
float _r, _g, _b, _a;
|
||||
float _r2, _g2, _b2, _a2;
|
||||
bool _hasSecondColor;
|
||||
std::string _attachmentName;
|
||||
String _attachmentName;
|
||||
BlendMode _blendMode;
|
||||
};
|
||||
}
|
||||
|
||||
163
spine-cpp/spine-cpp/include/spine/String.h
Normal file
163
spine-cpp/spine-cpp/include/spine/String.h
Normal file
@ -0,0 +1,163 @@
|
||||
/******************************************************************************
|
||||
* Spine Runtimes Software License v2.5
|
||||
*
|
||||
* Copyright (c) 2013-2016, Esoteric Software
|
||||
* All rights reserved.
|
||||
*
|
||||
* You are granted a perpetual, non-exclusive, non-sublicensable, and
|
||||
* non-transferable license to use, install, execute, and perform the Spine
|
||||
* Runtimes software and derivative works solely for personal or internal
|
||||
* use. Without the written permission of Esoteric Software (see Section 2 of
|
||||
* the Spine Software License Agreement), you may not (a) modify, translate,
|
||||
* adapt, or develop new applications using the Spine Runtimes or otherwise
|
||||
* create derivative works or improvements of the Spine Runtimes or (b) remove,
|
||||
* delete, alter, or obscure any trademarks or any copyright, trademark, patent,
|
||||
* or other intellectual property or proprietary rights notices on or in the
|
||||
* Software, including any copy thereof. Redistributions in binary or source
|
||||
* form must include this license and terms.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||
* EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF
|
||||
* USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef SPINE_STRING_H
|
||||
#define SPINE_STRING_H
|
||||
|
||||
#include <spine/SpineObject.h>
|
||||
#include <spine/Extension.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
namespace Spine {
|
||||
class String : public SpineObject {
|
||||
public:
|
||||
String (): _length(0), _buffer(NULL) {
|
||||
}
|
||||
|
||||
String (const char* chars, bool own = false) {
|
||||
if (!chars) {
|
||||
_length = 0;
|
||||
_buffer = NULL;
|
||||
} else {
|
||||
_length = strlen(chars);
|
||||
if (!own) {
|
||||
_buffer = SpineExtension::alloc<char>(_length + 1, __FILE__, __LINE__);
|
||||
memcpy((void *) _buffer, chars, _length + 1);
|
||||
} else {
|
||||
_buffer = chars;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String (const String& other) {
|
||||
if (!other._buffer) {
|
||||
_length = 0;
|
||||
_buffer = NULL;
|
||||
} else {
|
||||
_length = other._length;
|
||||
_buffer = SpineExtension::alloc<char>(other._length + 1, __FILE__, __LINE__);
|
||||
memcpy((void*)_buffer, other._buffer, other._length + 1);
|
||||
}
|
||||
}
|
||||
|
||||
size_t length () const {
|
||||
return _length;
|
||||
}
|
||||
|
||||
const char* buffer () const {
|
||||
return _buffer;
|
||||
}
|
||||
|
||||
void own (const String& other) {
|
||||
if (this == &other) return;
|
||||
if (_buffer) {
|
||||
SpineExtension::free(_buffer, __FILE__, __LINE__);
|
||||
}
|
||||
_length = other._length;
|
||||
_buffer = other._buffer;
|
||||
other._length = 0;
|
||||
other._buffer = NULL;
|
||||
}
|
||||
|
||||
void own (const char* chars) {
|
||||
if (_buffer == chars) return;
|
||||
if (_buffer) {
|
||||
SpineExtension::free(_buffer, __FILE__, __LINE__);
|
||||
}
|
||||
|
||||
if (!chars) {
|
||||
_length = 0;
|
||||
_buffer = 0;
|
||||
} else {
|
||||
_length = strlen(chars);
|
||||
_buffer = chars;
|
||||
}
|
||||
}
|
||||
|
||||
String& operator= (const String& other) {
|
||||
if (this == &other) return *this;
|
||||
if (_buffer) {
|
||||
SpineExtension::free(_buffer, __FILE__, __LINE__);
|
||||
}
|
||||
if (!other._buffer) {
|
||||
_length = 0;
|
||||
_buffer = NULL;
|
||||
} else {
|
||||
_length = other._length;
|
||||
_buffer = SpineExtension::alloc<char>(other._length + 1, __FILE__, __LINE__);
|
||||
memcpy((void*)_buffer, other._buffer, other._length + 1);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
String& operator= (const char* chars) {
|
||||
if (_buffer == chars) return *this;
|
||||
if (_buffer) {
|
||||
SpineExtension::free(_buffer, __FILE__, __LINE__);
|
||||
}
|
||||
if (!chars) {
|
||||
_length = 0;
|
||||
_buffer = NULL;
|
||||
} else {
|
||||
_length = strlen(chars);
|
||||
_buffer = SpineExtension::alloc<char>(_length + 1, __FILE__, __LINE__);
|
||||
memcpy((void*)_buffer, chars, _length + 1);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
friend bool operator== (const String& a, const String& b) {
|
||||
if (a._buffer == b._buffer) return true;
|
||||
if (a._length != b._length) return false;
|
||||
if (a._buffer && b._buffer) {
|
||||
return strcmp(a._buffer, b._buffer) == 0;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
friend bool operator!= (const String& a, const String& b) {
|
||||
return !(a == b);
|
||||
}
|
||||
|
||||
~String () {
|
||||
if (_buffer) {
|
||||
SpineExtension::free(_buffer, __FILE__, __LINE__);
|
||||
}
|
||||
}
|
||||
private:
|
||||
mutable size_t _length;
|
||||
mutable const char* _buffer;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
#endif //SPINE_STRING_H
|
||||
@ -32,8 +32,7 @@
|
||||
#define Spine_TextureLoader_h
|
||||
|
||||
#include <spine/SpineObject.h>
|
||||
|
||||
#include <string>
|
||||
#include <spine/String.h>
|
||||
|
||||
namespace Spine {
|
||||
class AtlasPage;
|
||||
@ -44,7 +43,7 @@ namespace Spine {
|
||||
|
||||
virtual ~TextureLoader();
|
||||
|
||||
virtual void load(AtlasPage& page, std::string path) = 0;
|
||||
virtual void load(AtlasPage& page, const String& path) = 0;
|
||||
|
||||
virtual void unload(void* texture) = 0;
|
||||
};
|
||||
|
||||
@ -33,8 +33,7 @@
|
||||
|
||||
#include <spine/Vector.h>
|
||||
#include <spine/SpineObject.h>
|
||||
|
||||
#include <string>
|
||||
#include <spine/String.h>
|
||||
|
||||
namespace Spine {
|
||||
class BoneData;
|
||||
@ -48,9 +47,9 @@ namespace Spine {
|
||||
friend class TransformConstraintTimeline;
|
||||
|
||||
public:
|
||||
TransformConstraintData(std::string name);
|
||||
|
||||
const std::string& getName();
|
||||
TransformConstraintData(const String& name);
|
||||
|
||||
const String& getName();
|
||||
int getOrder();
|
||||
Vector<BoneData*>& getBones();
|
||||
BoneData* getTarget();
|
||||
@ -70,7 +69,7 @@ namespace Spine {
|
||||
bool isLocal();
|
||||
|
||||
private:
|
||||
const std::string _name;
|
||||
const String _name;
|
||||
int _order;
|
||||
Vector<BoneData*> _bones;
|
||||
BoneData* _target;
|
||||
|
||||
@ -47,7 +47,7 @@ namespace Spine {
|
||||
RTTI_DECL
|
||||
|
||||
public:
|
||||
VertexAttachment(std::string name);
|
||||
VertexAttachment(const String& name);
|
||||
|
||||
virtual ~VertexAttachment();
|
||||
|
||||
|
||||
@ -88,6 +88,7 @@
|
||||
#include <spine/SkeletonJson.h>
|
||||
#include <spine/Skin.h>
|
||||
#include <spine/SpineObject.h>
|
||||
#include <spine/String.h>
|
||||
#include <spine/TextureLoader.h>
|
||||
#include <spine/Timeline.h>
|
||||
#include <spine/TimelineType.h>
|
||||
|
||||
@ -40,7 +40,7 @@
|
||||
#include <math.h> /* fmod */
|
||||
|
||||
namespace Spine {
|
||||
Animation::Animation(std::string name, Vector<Timeline*>& timelines, float duration) :
|
||||
Animation::Animation(const String& name, Vector<Timeline*>& timelines, float duration) :
|
||||
_timelines(timelines),
|
||||
_duration(duration),
|
||||
_name(name) {
|
||||
@ -64,7 +64,7 @@ namespace Spine {
|
||||
}
|
||||
}
|
||||
|
||||
std::string Animation::getName() {
|
||||
const String& Animation::getName() {
|
||||
return _name;
|
||||
}
|
||||
|
||||
|
||||
@ -500,7 +500,7 @@ namespace Spine {
|
||||
_queue->drain();
|
||||
}
|
||||
|
||||
TrackEntry* AnimationState::setAnimation(int trackIndex, std::string animationName, bool loop) {
|
||||
TrackEntry* AnimationState::setAnimation(int trackIndex, const String& animationName, bool loop) {
|
||||
Animation* animation = _data->_skeletonData->findAnimation(animationName);
|
||||
assert(animation != NULL);
|
||||
|
||||
@ -534,7 +534,7 @@ namespace Spine {
|
||||
return entry;
|
||||
}
|
||||
|
||||
TrackEntry* AnimationState::addAnimation(int trackIndex, std::string animationName, bool loop, float delay) {
|
||||
TrackEntry* AnimationState::addAnimation(int trackIndex, const String& animationName, bool loop, float delay) {
|
||||
Animation* animation = _data->_skeletonData->findAnimation(animationName);
|
||||
assert(animation != NULL);
|
||||
|
||||
@ -643,7 +643,7 @@ namespace Spine {
|
||||
|
||||
Animation* AnimationState::getEmptyAnimation() {
|
||||
static Vector<Timeline*> timelines;
|
||||
static Animation ret(std::string("<empty>"), timelines, 0);
|
||||
static Animation ret(String("<empty>"), timelines, 0);
|
||||
return &ret;
|
||||
}
|
||||
|
||||
|
||||
@ -38,7 +38,7 @@ namespace Spine {
|
||||
// Empty
|
||||
}
|
||||
|
||||
void AnimationStateData::setMix(std::string fromName, std::string toName, float duration) {
|
||||
void AnimationStateData::setMix(const String& fromName, const String& toName, float duration) {
|
||||
Animation* from = _skeletonData->findAnimation(fromName);
|
||||
Animation* to = _skeletonData->findAnimation(toName);
|
||||
|
||||
@ -94,13 +94,13 @@ namespace Spine {
|
||||
std::size_t h1 = 7;
|
||||
size_t strlen = val._a1->_name.length();
|
||||
for (int i = 0; i < strlen; ++i) {
|
||||
h1 = h1 * 31 + val._a1->_name.at(i);
|
||||
h1 = h1 * 31 + val._a1->_name.buffer()[i];
|
||||
}
|
||||
|
||||
std::size_t h2 = 7;
|
||||
strlen = val._a2->_name.length();
|
||||
for (int i = 0; i < strlen; ++i) {
|
||||
h2 = h2 * 31 + val._a2->_name.at(i);
|
||||
h2 = h2 * 31 + val._a2->_name.buffer()[i];
|
||||
}
|
||||
|
||||
return (((h1 << 5) + h1) ^ h2);
|
||||
|
||||
@ -80,7 +80,7 @@ namespace Spine {
|
||||
}
|
||||
}
|
||||
|
||||
AtlasRegion* Atlas::findRegion(std::string name) {
|
||||
AtlasRegion* Atlas::findRegion(const String& name) {
|
||||
for (size_t i = 0, n = _regions.size(); i < n; ++i) {
|
||||
if (_regions[i]->name == name) {
|
||||
return _regions[i];
|
||||
@ -124,9 +124,7 @@ namespace Spine {
|
||||
}
|
||||
strcpy(path + dirLength + needsSlash, name);
|
||||
|
||||
page = new (__FILE__, __LINE__) AtlasPage(std::string(name));
|
||||
|
||||
SpineExtension::free(name, __FILE__, __LINE__);
|
||||
page = new (__FILE__, __LINE__) AtlasPage(String(name, true));
|
||||
|
||||
int tupleVal = readTuple(&begin, end, tuple);
|
||||
assert(tupleVal == 2);
|
||||
@ -161,7 +159,7 @@ namespace Spine {
|
||||
}
|
||||
}
|
||||
|
||||
if (_textureLoader) _textureLoader->load(*page, std::string(path));
|
||||
if (_textureLoader) _textureLoader->load(*page, String(path));
|
||||
|
||||
SpineExtension::free(path, __FILE__, __LINE__);
|
||||
|
||||
@ -171,10 +169,7 @@ namespace Spine {
|
||||
AtlasRegion* region = new (__FILE__, __LINE__) AtlasRegion();
|
||||
|
||||
region->page = page;
|
||||
|
||||
char* name = mallocString(&str);
|
||||
region->name = std::string(name);
|
||||
SpineExtension::free(name, __FILE__, __LINE__);
|
||||
region->name = String(mallocString(&str), true);
|
||||
|
||||
assert(readValue(&begin, end, &str));
|
||||
region->rotate = equals(&str, "true");
|
||||
|
||||
@ -47,7 +47,7 @@ namespace Spine {
|
||||
// Empty
|
||||
}
|
||||
|
||||
RegionAttachment* AtlasAttachmentLoader::newRegionAttachment(Skin& skin, std::string name, std::string path) {
|
||||
RegionAttachment* AtlasAttachmentLoader::newRegionAttachment(Skin& skin, const String& name, const String& path) {
|
||||
AtlasRegion* regionP = findRegion(path);
|
||||
assert(regionP != NULL);
|
||||
|
||||
@ -67,7 +67,7 @@ namespace Spine {
|
||||
return attachmentP;
|
||||
}
|
||||
|
||||
MeshAttachment* AtlasAttachmentLoader::newMeshAttachment(Skin& skin, std::string name, std::string path) {
|
||||
MeshAttachment* AtlasAttachmentLoader::newMeshAttachment(Skin& skin, const String& name, const String& path) {
|
||||
AtlasRegion* regionP = findRegion(path);
|
||||
assert(regionP != NULL);
|
||||
|
||||
@ -92,23 +92,23 @@ namespace Spine {
|
||||
return attachmentP;
|
||||
}
|
||||
|
||||
BoundingBoxAttachment* AtlasAttachmentLoader::newBoundingBoxAttachment(Skin& skin, std::string name) {
|
||||
BoundingBoxAttachment* AtlasAttachmentLoader::newBoundingBoxAttachment(Skin& skin, const String& name) {
|
||||
return new (__FILE__, __LINE__) BoundingBoxAttachment(name);
|
||||
}
|
||||
|
||||
PathAttachment* AtlasAttachmentLoader::newPathAttachment(Skin& skin, std::string name) {
|
||||
PathAttachment* AtlasAttachmentLoader::newPathAttachment(Skin& skin, const String& name) {
|
||||
return new (__FILE__, __LINE__) PathAttachment(name);
|
||||
}
|
||||
|
||||
PointAttachment* AtlasAttachmentLoader::newPointAttachment(Skin& skin, std::string name) {
|
||||
PointAttachment* AtlasAttachmentLoader::newPointAttachment(Skin& skin, const String& name) {
|
||||
return new (__FILE__, __LINE__) PointAttachment(name);
|
||||
}
|
||||
|
||||
ClippingAttachment* AtlasAttachmentLoader::newClippingAttachment(Skin& skin, std::string name) {
|
||||
ClippingAttachment* AtlasAttachmentLoader::newClippingAttachment(Skin& skin, const String& name) {
|
||||
return new (__FILE__, __LINE__) ClippingAttachment(name);
|
||||
}
|
||||
|
||||
AtlasRegion* AtlasAttachmentLoader::findRegion(std::string name) {
|
||||
AtlasRegion* AtlasAttachmentLoader::findRegion(const String& name) {
|
||||
AtlasRegion* ret;
|
||||
return _atlas->findRegion(name);
|
||||
}
|
||||
|
||||
@ -35,14 +35,14 @@
|
||||
namespace Spine {
|
||||
RTTI_IMPL_NOPARENT(Attachment);
|
||||
|
||||
Attachment::Attachment(std::string name) : _name(name) {
|
||||
Attachment::Attachment(const String& name) : _name(name) {
|
||||
assert(_name.length() > 0);
|
||||
}
|
||||
|
||||
Attachment::~Attachment() {
|
||||
}
|
||||
|
||||
const std::string& Attachment::getName() {
|
||||
|
||||
const String& Attachment::getName() {
|
||||
return _name;
|
||||
}
|
||||
}
|
||||
|
||||
@ -48,27 +48,27 @@ namespace Spine {
|
||||
_frames.setSize(frameCount);
|
||||
|
||||
for (int i = 0; i < frameCount; ++i) {
|
||||
_attachmentNames.push_back(std::string(""));
|
||||
_attachmentNames.push_back(String());
|
||||
}
|
||||
}
|
||||
|
||||
void AttachmentTimeline::apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>* pEvents, float alpha, MixPose pose, MixDirection direction) {
|
||||
assert(_slotIndex < skeleton._slots.size());
|
||||
|
||||
std::string attachmentName;
|
||||
|
||||
String* attachmentName;
|
||||
Slot* slotP = skeleton._slots[_slotIndex];
|
||||
Slot& slot = *slotP;
|
||||
if (direction == MixDirection_Out && pose == MixPose_Setup) {
|
||||
attachmentName = slot._data._attachmentName;
|
||||
slot._attachment = attachmentName.length() == 0 ? NULL : skeleton.getAttachment(_slotIndex, attachmentName);
|
||||
attachmentName = &slot._data._attachmentName;
|
||||
slot._attachment = attachmentName->length() == 0 ? NULL : skeleton.getAttachment(_slotIndex, *attachmentName);
|
||||
return;
|
||||
}
|
||||
|
||||
if (time < _frames[0]) {
|
||||
// Time is before first frame.
|
||||
if (pose == MixPose_Setup) {
|
||||
attachmentName = slot._data._attachmentName;
|
||||
slot._attachment = attachmentName.length() == 0 ? NULL : skeleton.getAttachment(_slotIndex, attachmentName);
|
||||
attachmentName = &slot._data._attachmentName;
|
||||
slot._attachment = attachmentName->length() == 0 ? NULL : skeleton.getAttachment(_slotIndex, *attachmentName);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -82,15 +82,15 @@ namespace Spine {
|
||||
frameIndex = Animation::binarySearch(_frames, time, 1) - 1;
|
||||
}
|
||||
|
||||
attachmentName = _attachmentNames[frameIndex];
|
||||
slot._attachment = attachmentName.length() == 0 ? NULL : skeleton.getAttachment(_slotIndex, attachmentName);
|
||||
attachmentName = &_attachmentNames[frameIndex];
|
||||
slot._attachment = attachmentName->length() == 0 ? NULL : skeleton.getAttachment(_slotIndex, *attachmentName);
|
||||
}
|
||||
|
||||
int AttachmentTimeline::getPropertyId() {
|
||||
return ((int)TimelineType_Attachment << 24) + _slotIndex;
|
||||
}
|
||||
|
||||
void AttachmentTimeline::setFrame(int frameIndex, float time, std::string attachmentName) {
|
||||
void AttachmentTimeline::setFrame(int frameIndex, float time, const String& attachmentName) {
|
||||
_frames[frameIndex] = time;
|
||||
_attachmentNames[frameIndex] = attachmentName;
|
||||
}
|
||||
@ -103,7 +103,7 @@ namespace Spine {
|
||||
_slotIndex = inValue;
|
||||
}
|
||||
|
||||
Vector<float>& AttachmentTimeline::getFrames() {
|
||||
const Vector<float>& AttachmentTimeline::getFrames() {
|
||||
return _frames;
|
||||
}
|
||||
|
||||
@ -111,11 +111,11 @@ namespace Spine {
|
||||
_frames = inValue;
|
||||
}
|
||||
|
||||
Vector<std::string> AttachmentTimeline::getAttachmentNames() {
|
||||
const Vector<String>& AttachmentTimeline::getAttachmentNames() {
|
||||
return _attachmentNames;
|
||||
}
|
||||
|
||||
void AttachmentTimeline::setAttachmentNames(Vector<std::string>& inValue) {
|
||||
void AttachmentTimeline::setAttachmentNames(Vector<String>& inValue) {
|
||||
_attachmentNames = inValue;
|
||||
}
|
||||
|
||||
|
||||
@ -33,7 +33,7 @@
|
||||
#include <assert.h>
|
||||
|
||||
namespace Spine {
|
||||
BoneData::BoneData(int index, std::string name, BoneData* parent) :
|
||||
BoneData::BoneData(int index, const String& name, BoneData* parent) :
|
||||
_index(index),
|
||||
_name(name),
|
||||
_parent(parent),
|
||||
@ -50,11 +50,11 @@ namespace Spine {
|
||||
assert(_name.length() > 0);
|
||||
}
|
||||
|
||||
const int BoneData::getIndex() {
|
||||
int BoneData::getIndex() {
|
||||
return _index;
|
||||
}
|
||||
|
||||
const std::string& BoneData::getName() {
|
||||
const String& BoneData::getName() {
|
||||
return _name;
|
||||
}
|
||||
|
||||
|
||||
@ -33,7 +33,7 @@
|
||||
namespace Spine {
|
||||
RTTI_IMPL(BoundingBoxAttachment, VertexAttachment);
|
||||
|
||||
BoundingBoxAttachment::BoundingBoxAttachment(std::string name) : VertexAttachment(name) {
|
||||
BoundingBoxAttachment::BoundingBoxAttachment(const String& name) : VertexAttachment(name) {
|
||||
// Empty
|
||||
}
|
||||
}
|
||||
|
||||
@ -35,7 +35,7 @@
|
||||
namespace Spine {
|
||||
RTTI_IMPL(ClippingAttachment, VertexAttachment);
|
||||
|
||||
ClippingAttachment::ClippingAttachment(std::string name) : VertexAttachment(name), _endSlot(NULL) {
|
||||
ClippingAttachment::ClippingAttachment(const String& name) : VertexAttachment(name), _endSlot(NULL) {
|
||||
// Empty
|
||||
}
|
||||
|
||||
|
||||
@ -65,12 +65,12 @@ namespace Spine {
|
||||
void Event::setFloatValue(int inValue) {
|
||||
_floatValue = inValue;
|
||||
}
|
||||
|
||||
std::string Event::getStringValue() {
|
||||
|
||||
const String& Event::getStringValue() {
|
||||
return _stringValue;
|
||||
}
|
||||
|
||||
void Event::setStringValue(std::string inValue) {
|
||||
void Event::setStringValue(const String& inValue) {
|
||||
_stringValue = inValue;
|
||||
}
|
||||
}
|
||||
|
||||
@ -33,7 +33,7 @@
|
||||
#include <assert.h>
|
||||
|
||||
namespace Spine {
|
||||
EventData::EventData(std::string name) :
|
||||
EventData::EventData(const String& name) :
|
||||
_name(name),
|
||||
_intValue(0),
|
||||
_floatValue(0),
|
||||
@ -42,7 +42,7 @@ namespace Spine {
|
||||
}
|
||||
|
||||
/// The name of the event, which is unique within the skeleton.
|
||||
const std::string& EventData::getName() {
|
||||
const String& EventData::getName() {
|
||||
return _name;
|
||||
}
|
||||
|
||||
@ -62,11 +62,11 @@ namespace Spine {
|
||||
_floatValue = inValue;
|
||||
}
|
||||
|
||||
std::string EventData::getStringValue() {
|
||||
const String& EventData::getStringValue() {
|
||||
return _stringValue;
|
||||
}
|
||||
|
||||
void EventData::setStringValue(std::string inValue) {
|
||||
void EventData::setStringValue(const String& inValue) {
|
||||
_stringValue = inValue;
|
||||
}
|
||||
}
|
||||
|
||||
@ -33,7 +33,7 @@
|
||||
#include <spine/BoneData.h>
|
||||
|
||||
namespace Spine {
|
||||
IkConstraintData::IkConstraintData(std::string name) :
|
||||
IkConstraintData::IkConstraintData(const String& name) :
|
||||
_name(name),
|
||||
_order(0),
|
||||
_target(NULL),
|
||||
@ -42,7 +42,7 @@ namespace Spine {
|
||||
// Empty
|
||||
}
|
||||
|
||||
const std::string& IkConstraintData::getName() {
|
||||
const String& IkConstraintData::getName() {
|
||||
return _name;
|
||||
}
|
||||
|
||||
|
||||
@ -33,7 +33,7 @@
|
||||
#include <spine/MeshAttachment.h>
|
||||
|
||||
namespace Spine {
|
||||
LinkedMesh::LinkedMesh(MeshAttachment* mesh, std::string skin, int slotIndex, std::string parent) :
|
||||
LinkedMesh::LinkedMesh(MeshAttachment* mesh, const String& skin, int slotIndex, const String& parent) :
|
||||
_mesh(mesh),
|
||||
_skin(skin),
|
||||
_slotIndex(slotIndex),
|
||||
|
||||
@ -33,7 +33,7 @@
|
||||
namespace Spine {
|
||||
RTTI_IMPL(MeshAttachment, VertexAttachment);
|
||||
|
||||
MeshAttachment::MeshAttachment(std::string name) : VertexAttachment(name),
|
||||
MeshAttachment::MeshAttachment(const String& name) : VertexAttachment(name),
|
||||
_regionOffsetX(0),
|
||||
_regionOffsetY(0),
|
||||
_regionWidth(0),
|
||||
@ -148,11 +148,11 @@ namespace Spine {
|
||||
_a = inValue;
|
||||
}
|
||||
|
||||
std::string MeshAttachment::getPath() {
|
||||
const String& MeshAttachment::getPath() {
|
||||
return _path;
|
||||
}
|
||||
|
||||
void MeshAttachment::setPath(std::string inValue) {
|
||||
void MeshAttachment::setPath(const String& inValue) {
|
||||
_path = inValue;
|
||||
}
|
||||
|
||||
|
||||
@ -33,7 +33,7 @@
|
||||
namespace Spine {
|
||||
RTTI_IMPL(PathAttachment, VertexAttachment);
|
||||
|
||||
PathAttachment::PathAttachment(std::string name) : VertexAttachment(name), _closed(false), _constantSpeed(false) {
|
||||
PathAttachment::PathAttachment(const String& name) : VertexAttachment(name), _closed(false), _constantSpeed(false) {
|
||||
// Empty
|
||||
}
|
||||
|
||||
|
||||
@ -36,7 +36,7 @@
|
||||
#include <assert.h>
|
||||
|
||||
namespace Spine {
|
||||
PathConstraintData::PathConstraintData(std::string name) :
|
||||
PathConstraintData::PathConstraintData(const String& name) :
|
||||
_name(name),
|
||||
_order(0),
|
||||
_target(NULL),
|
||||
@ -50,8 +50,8 @@ namespace Spine {
|
||||
_translateMix(0) {
|
||||
assert(_name.length() > 0);
|
||||
}
|
||||
|
||||
const std::string& PathConstraintData::getName() {
|
||||
|
||||
const String& PathConstraintData::getName() {
|
||||
return _name;
|
||||
}
|
||||
|
||||
|
||||
@ -37,7 +37,7 @@
|
||||
namespace Spine {
|
||||
RTTI_IMPL(PointAttachment, Attachment);
|
||||
|
||||
PointAttachment::PointAttachment(std::string name) : Attachment(name), _x(0), _y(0), _rotation(0) {
|
||||
PointAttachment::PointAttachment(const String& name) : Attachment(name), _x(0), _y(0), _rotation(0) {
|
||||
// Empty
|
||||
}
|
||||
|
||||
|
||||
@ -29,18 +29,19 @@
|
||||
*****************************************************************************/
|
||||
|
||||
#include <spine/RTTI.h>
|
||||
#include <spine/String.h>
|
||||
|
||||
namespace Spine {
|
||||
RTTI::RTTI(const std::string& className) : m_className(className), m_pBaseRTTI(NULL) {
|
||||
RTTI::RTTI(const std::string& className) : _className(className), _pBaseRTTI(NULL) {
|
||||
// Empty
|
||||
}
|
||||
|
||||
RTTI::RTTI(const std::string& className, const RTTI& baseRTTI) : m_className(className), m_pBaseRTTI(&baseRTTI) {
|
||||
RTTI::RTTI(const std::string& className, const RTTI& baseRTTI) : _className(className), _pBaseRTTI(&baseRTTI) {
|
||||
// Empty
|
||||
}
|
||||
|
||||
const std::string& RTTI::getClassName() const {
|
||||
return m_className;
|
||||
return _className;
|
||||
}
|
||||
|
||||
bool RTTI::isExactly(const RTTI& rtti) const {
|
||||
@ -55,7 +56,7 @@ namespace Spine {
|
||||
return true;
|
||||
}
|
||||
|
||||
pCompare = pCompare->m_pBaseRTTI;
|
||||
pCompare = pCompare->_pBaseRTTI;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
@ -48,7 +48,7 @@ namespace Spine {
|
||||
const int RegionAttachment::BRX = 6;
|
||||
const int RegionAttachment::BRY = 7;
|
||||
|
||||
RegionAttachment::RegionAttachment(std::string name) : Attachment(name),
|
||||
RegionAttachment::RegionAttachment(const String& name) : Attachment(name),
|
||||
_x(0),
|
||||
_y(0),
|
||||
_rotation(0),
|
||||
@ -249,11 +249,11 @@ namespace Spine {
|
||||
_a = inValue;
|
||||
}
|
||||
|
||||
std::string RegionAttachment::getPath() {
|
||||
const String& RegionAttachment::getPath() {
|
||||
return _path;
|
||||
}
|
||||
|
||||
void RegionAttachment::setPath(std::string inValue) {
|
||||
void RegionAttachment::setPath(const String& inValue) {
|
||||
_path = inValue;
|
||||
}
|
||||
|
||||
|
||||
@ -269,23 +269,23 @@ namespace Spine {
|
||||
}
|
||||
}
|
||||
|
||||
Bone* Skeleton::findBone(std::string boneName) {
|
||||
Bone* Skeleton::findBone(const String& boneName) {
|
||||
return ContainerUtil::findWithDataName(_bones, boneName);
|
||||
}
|
||||
|
||||
int Skeleton::findBoneIndex(std::string boneName) {
|
||||
int Skeleton::findBoneIndex(const String& boneName) {
|
||||
return ContainerUtil::findIndexWithDataName(_bones, boneName);
|
||||
}
|
||||
|
||||
Slot* Skeleton::findSlot(std::string slotName) {
|
||||
Slot* Skeleton::findSlot(const String& slotName) {
|
||||
return ContainerUtil::findWithDataName(_slots, slotName);
|
||||
}
|
||||
|
||||
int Skeleton::findSlotIndex(std::string slotName) {
|
||||
int Skeleton::findSlotIndex(const String& slotName) {
|
||||
return ContainerUtil::findIndexWithDataName(_slots, slotName);
|
||||
}
|
||||
|
||||
void Skeleton::setSkin(std::string skinName) {
|
||||
void Skeleton::setSkin(const String& skinName) {
|
||||
Skin* foundSkin = _data->findSkin(skinName);
|
||||
|
||||
assert(foundSkin != NULL);
|
||||
@ -303,7 +303,7 @@ namespace Spine {
|
||||
for (int i = 0, n = static_cast<int>(_slots.size()); i < n; ++i) {
|
||||
Slot* slotP = _slots[i];
|
||||
Slot& slot = *slotP;
|
||||
std::string name = slot._data.getAttachmentName();
|
||||
const String& name = slot._data.getAttachmentName();
|
||||
if (name.length() > 0) {
|
||||
Attachment* attachment = newSkin->getAttachment(i, name);
|
||||
if (attachment != NULL) {
|
||||
@ -317,11 +317,11 @@ namespace Spine {
|
||||
_skin = newSkin;
|
||||
}
|
||||
|
||||
Attachment* Skeleton::getAttachment(std::string slotName, std::string attachmentName) {
|
||||
Attachment* Skeleton::getAttachment(const String& slotName, const String& attachmentName) {
|
||||
return getAttachment(_data->findSlotIndex(slotName), attachmentName);
|
||||
}
|
||||
|
||||
Attachment* Skeleton::getAttachment(int slotIndex, std::string attachmentName) {
|
||||
Attachment* Skeleton::getAttachment(int slotIndex, const String& attachmentName) {
|
||||
assert(attachmentName.length() > 0);
|
||||
|
||||
if (_skin != NULL) {
|
||||
@ -334,7 +334,7 @@ namespace Spine {
|
||||
return _data->getDefaultSkin() != NULL ? _data->getDefaultSkin()->getAttachment(slotIndex, attachmentName) : NULL;
|
||||
}
|
||||
|
||||
void Skeleton::setAttachment(std::string slotName, std::string attachmentName) {
|
||||
void Skeleton::setAttachment(const String& slotName, const String& attachmentName) {
|
||||
assert(slotName.length() > 0);
|
||||
|
||||
for (int i = 0, n = static_cast<int>(_slots.size()); i < n; ++i) {
|
||||
@ -353,12 +353,12 @@ namespace Spine {
|
||||
}
|
||||
}
|
||||
|
||||
printf("Slot not found: %s", slotName.c_str());
|
||||
printf("Slot not found: %s", slotName.buffer());
|
||||
|
||||
assert(false);
|
||||
}
|
||||
|
||||
IkConstraint* Skeleton::findIkConstraint(std::string constraintName) {
|
||||
IkConstraint* Skeleton::findIkConstraint(const String& constraintName) {
|
||||
assert(constraintName.length() > 0);
|
||||
|
||||
for (int i = 0, n = static_cast<int>(_ikConstraints.size()); i < n; ++i) {
|
||||
@ -370,7 +370,7 @@ namespace Spine {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
TransformConstraint* Skeleton::findTransformConstraint(std::string constraintName) {
|
||||
TransformConstraint* Skeleton::findTransformConstraint(const String& constraintName) {
|
||||
assert(constraintName.length() > 0);
|
||||
|
||||
for (int i = 0, n = static_cast<int>(_transformConstraints.size()); i < n; ++i) {
|
||||
@ -383,7 +383,7 @@ namespace Spine {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
PathConstraint* Skeleton::findPathConstraint(std::string constraintName) {
|
||||
PathConstraint* Skeleton::findPathConstraint(const String& constraintName) {
|
||||
assert(constraintName.length() > 0);
|
||||
|
||||
for (int i = 0, n = static_cast<int>(_pathConstraints.size()); i < n; ++i) {
|
||||
|
||||
@ -135,12 +135,10 @@ namespace Spine {
|
||||
skeletonData = new (__FILE__, __LINE__) SkeletonData();
|
||||
|
||||
char* skeletonData_hash = readString(input);
|
||||
skeletonData->_hash = std::string(skeletonData_hash);
|
||||
SpineExtension::free(skeletonData_hash, __FILE__, __LINE__);
|
||||
skeletonData->_hash.own(skeletonData_hash);
|
||||
|
||||
char* skeletonData_version = readString(input);
|
||||
skeletonData->_version = std::string(skeletonData_version);
|
||||
SpineExtension::free(skeletonData_version, __FILE__, __LINE__);
|
||||
skeletonData->_version.own(skeletonData_version);
|
||||
|
||||
skeletonData->_width = readFloat(input);
|
||||
skeletonData->_height = readFloat(input);
|
||||
@ -164,10 +162,7 @@ namespace Spine {
|
||||
const char* name = readString(input);
|
||||
BoneData* parent = i == 0 ? 0 : skeletonData->_bones[readVarint(input, 1)];
|
||||
|
||||
data = new (__FILE__, __LINE__) BoneData(i, std::string(name), parent);
|
||||
|
||||
SpineExtension::free(name, __FILE__, __LINE__);
|
||||
|
||||
data = new (__FILE__, __LINE__) BoneData(i, String(name, true), parent);
|
||||
data->_rotation = readFloat(input);
|
||||
data->_x = readFloat(input) * _scale;
|
||||
data->_y = readFloat(input) * _scale;
|
||||
@ -213,9 +208,8 @@ namespace Spine {
|
||||
const char* slotName = readString(input);
|
||||
BoneData* boneData = skeletonData->_bones[readVarint(input, 1)];
|
||||
|
||||
SlotData* slotData = new (__FILE__, __LINE__) SlotData(i, std::string(slotName), *boneData);
|
||||
SlotData* slotData = new (__FILE__, __LINE__) SlotData(i, String(slotName, true), *boneData);
|
||||
|
||||
SpineExtension::free(slotName, __FILE__, __LINE__);
|
||||
readColor(input, &slotData->_r, &slotData->_g, &slotData->_b, &slotData->_a);
|
||||
r = readByte(input);
|
||||
g = readByte(input);
|
||||
@ -226,9 +220,7 @@ namespace Spine {
|
||||
slotData->_g2 = g / 255.0f;
|
||||
slotData->_b2 = b / 255.0f;
|
||||
}
|
||||
char* slotData_attachmentName = readString(input);
|
||||
slotData->_attachmentName = std::string(slotData_attachmentName);
|
||||
SpineExtension::free(slotData_attachmentName, __FILE__, __LINE__);
|
||||
slotData->_attachmentName.own(readString(input));
|
||||
slotData->_blendMode = static_cast<BlendMode>(readVarint(input, 1));
|
||||
|
||||
skeletonData->_slots[i] = slotData;
|
||||
@ -241,11 +233,10 @@ namespace Spine {
|
||||
for (i = 0; i < ikConstraintsCount; ++i) {
|
||||
const char* name = readString(input);
|
||||
|
||||
IkConstraintData* data = new (__FILE__, __LINE__) IkConstraintData(std::string(name));
|
||||
IkConstraintData* data = new (__FILE__, __LINE__) IkConstraintData(String(name, true));
|
||||
|
||||
data->_order = readVarint(input, 1);
|
||||
|
||||
SpineExtension::free(name, __FILE__, __LINE__);
|
||||
int bonesCount = readVarint(input, 1);
|
||||
data->_bones.reserve(bonesCount);
|
||||
data->_bones.setSize(bonesCount);
|
||||
@ -266,10 +257,9 @@ namespace Spine {
|
||||
for (i = 0; i < transformConstraintsCount; ++i) {
|
||||
const char* name = readString(input);
|
||||
|
||||
TransformConstraintData* data = new (__FILE__, __LINE__) TransformConstraintData(std::string(name));
|
||||
TransformConstraintData* data = new (__FILE__, __LINE__) TransformConstraintData(String(name, true));
|
||||
|
||||
data->_order = readVarint(input, 1);
|
||||
SpineExtension::free(name, __FILE__, __LINE__);
|
||||
int bonesCount = readVarint(input, 1);
|
||||
data->_bones.reserve(bonesCount);
|
||||
data->_bones.setSize(bonesCount);
|
||||
@ -300,10 +290,9 @@ namespace Spine {
|
||||
for (i = 0; i < pathConstraintsCount; ++i) {
|
||||
const char* name = readString(input);
|
||||
|
||||
PathConstraintData* data = new (__FILE__, __LINE__) PathConstraintData(std::string(name));
|
||||
PathConstraintData* data = new (__FILE__, __LINE__) PathConstraintData(String(name, true));
|
||||
|
||||
data->_order = readVarint(input, 1);
|
||||
SpineExtension::free(name, __FILE__, __LINE__);
|
||||
|
||||
int bonesCount = readVarint(input, 1);
|
||||
data->_bones.reserve(bonesCount);
|
||||
@ -360,14 +349,14 @@ namespace Spine {
|
||||
if (skin == NULL) {
|
||||
delete input;
|
||||
delete skeletonData;
|
||||
setError("Skin not found: ", linkedMesh->_skin.c_str());
|
||||
setError("Skin not found: ", linkedMesh->_skin.buffer());
|
||||
return NULL;
|
||||
}
|
||||
Attachment* parent = skin->getAttachment(linkedMesh->_slotIndex, linkedMesh->_parent);
|
||||
if (parent == NULL) {
|
||||
delete input;
|
||||
delete skeletonData;
|
||||
setError("Parent mesh not found: ", linkedMesh->_parent.c_str());
|
||||
setError("Parent mesh not found: ", linkedMesh->_parent.buffer());
|
||||
return NULL;
|
||||
}
|
||||
linkedMesh->_mesh->_parentMesh = static_cast<MeshAttachment*>(parent);
|
||||
@ -381,13 +370,10 @@ namespace Spine {
|
||||
skeletonData->_events.setSize(eventsCount);
|
||||
for (i = 0; i < eventsCount; ++i) {
|
||||
const char* name = readString(input);
|
||||
EventData* eventData = new (__FILE__, __LINE__) EventData(std::string(name));
|
||||
SpineExtension::free(name, __FILE__, __LINE__);
|
||||
EventData* eventData = new (__FILE__, __LINE__) EventData(String(name, true));
|
||||
eventData->_intValue = readVarint(input, 0);
|
||||
eventData->_floatValue = readFloat(input);
|
||||
const char* eventData_stringValue = readString(input);
|
||||
eventData->_stringValue = std::string(eventData_stringValue);
|
||||
SpineExtension::free(eventData_stringValue, __FILE__, __LINE__);
|
||||
eventData->_stringValue.own(readString(input));
|
||||
SpineExtension::free(readString(input), __FILE__, __LINE__); // skip audio path
|
||||
skeletonData->_events[i] = eventData;
|
||||
}
|
||||
@ -435,7 +421,7 @@ namespace Spine {
|
||||
strncat(message + length, value2, 255 - length);
|
||||
}
|
||||
|
||||
_error = std::string(message);
|
||||
_error = message;
|
||||
}
|
||||
|
||||
char* SkeletonBinary::readString(DataInput* input) {
|
||||
@ -524,7 +510,7 @@ namespace Spine {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
skin = new (__FILE__, __LINE__) Skin(std::string(skinName));
|
||||
skin = new (__FILE__, __LINE__) Skin(String(skinName));
|
||||
|
||||
for (i = 0; i < slotCount; ++i) {
|
||||
int slotIndex = readVarint(input, 1);
|
||||
@ -532,7 +518,7 @@ namespace Spine {
|
||||
const char* name = readString(input);
|
||||
Attachment* attachment = readAttachment(input, skin, slotIndex, name, skeletonData, nonessential);
|
||||
if (attachment) {
|
||||
skin->addAttachment(slotIndex, std::string(name), attachment);
|
||||
skin->addAttachment(slotIndex, String(name), attachment);
|
||||
}
|
||||
SpineExtension::free(name, __FILE__, __LINE__);
|
||||
}
|
||||
@ -560,8 +546,8 @@ namespace Spine {
|
||||
if (!path) {
|
||||
path = name;
|
||||
}
|
||||
region = _attachmentLoader->newRegionAttachment(*skin, std::string(name), std::string(path));
|
||||
region->_path = std::string(path);
|
||||
region = _attachmentLoader->newRegionAttachment(*skin, String(name), String(path));
|
||||
region->_path = String(path);
|
||||
region->_rotation = readFloat(input);
|
||||
region->_x = readFloat(input) * _scale;
|
||||
region->_y = readFloat(input) * _scale;
|
||||
@ -580,7 +566,7 @@ namespace Spine {
|
||||
}
|
||||
case AttachmentType_Boundingbox: {
|
||||
int vertexCount = readVarint(input, 1);
|
||||
BoundingBoxAttachment* box = _attachmentLoader->newBoundingBoxAttachment(*skin, std::string(name));
|
||||
BoundingBoxAttachment* box = _attachmentLoader->newBoundingBoxAttachment(*skin, String(name));
|
||||
readVertices(input, static_cast<VertexAttachment*>(box), vertexCount);
|
||||
if (nonessential) {
|
||||
/* Skip color. */
|
||||
@ -599,8 +585,8 @@ namespace Spine {
|
||||
if (!path) {
|
||||
path = name;
|
||||
}
|
||||
mesh = _attachmentLoader->newMeshAttachment(*skin, std::string(name), std::string(path));
|
||||
mesh->_path = std::string(path);
|
||||
mesh = _attachmentLoader->newMeshAttachment(*skin, String(name), String(path));
|
||||
mesh->_path = String(path);
|
||||
readColor(input, &mesh->_r, &mesh->_g, &mesh->_b, &mesh->_a);
|
||||
vertexCount = readVarint(input, 1);
|
||||
Vector<float> float_array = readFloatArray(input, vertexCount << 1, 1);
|
||||
@ -636,7 +622,7 @@ namespace Spine {
|
||||
path = name;
|
||||
}
|
||||
|
||||
mesh = _attachmentLoader->newMeshAttachment(*skin, std::string(name), std::string(path));
|
||||
mesh = _attachmentLoader->newMeshAttachment(*skin, String(name), String(path));
|
||||
mesh->_path = path;
|
||||
readColor(input, &mesh->_r, &mesh->_g, &mesh->_b, &mesh->_a);
|
||||
skinName = readString(input);
|
||||
@ -647,7 +633,7 @@ namespace Spine {
|
||||
mesh->_height = readFloat(input) * _scale;
|
||||
}
|
||||
|
||||
LinkedMesh* linkedMesh = new (__FILE__, __LINE__) LinkedMesh(mesh, std::string(skinName), slotIndex, std::string(parent));
|
||||
LinkedMesh* linkedMesh = new (__FILE__, __LINE__) LinkedMesh(mesh, String(skinName), slotIndex, String(parent));
|
||||
_linkedMeshes.push_back(linkedMesh);
|
||||
|
||||
if (freeName) {
|
||||
@ -660,7 +646,7 @@ namespace Spine {
|
||||
return mesh;
|
||||
}
|
||||
case AttachmentType_Path: {
|
||||
PathAttachment* path = _attachmentLoader->newPathAttachment(*skin, std::string(name));
|
||||
PathAttachment* path = _attachmentLoader->newPathAttachment(*skin, String(name));
|
||||
int vertexCount = 0;
|
||||
path->_closed = readBoolean(input);
|
||||
path->_constantSpeed = readBoolean(input);
|
||||
@ -685,7 +671,7 @@ namespace Spine {
|
||||
return path;
|
||||
}
|
||||
case AttachmentType_Point: {
|
||||
PointAttachment* point = _attachmentLoader->newPointAttachment(*skin, std::string(name));
|
||||
PointAttachment* point = _attachmentLoader->newPointAttachment(*skin, String(name));
|
||||
point->_rotation = readFloat(input);
|
||||
point->_x = readFloat(input) * _scale;
|
||||
point->_y = readFloat(input) * _scale;
|
||||
@ -806,8 +792,7 @@ namespace Spine {
|
||||
timeline->_slotIndex = slotIndex;
|
||||
for (int frameIndex = 0; frameIndex < frameCount; ++frameIndex) {
|
||||
const char* attachmentName = readString(input);
|
||||
timeline->setFrame(frameIndex, readFloat(input), std::string(attachmentName));
|
||||
SpineExtension::free(attachmentName, __FILE__, __LINE__);
|
||||
timeline->setFrame(frameIndex, readFloat(input), String(attachmentName, true));
|
||||
}
|
||||
timelines.push_back(timeline);
|
||||
duration = MAX(duration, timeline->_frames[frameCount - 1]);
|
||||
@ -858,7 +843,7 @@ namespace Spine {
|
||||
}
|
||||
default: {
|
||||
ContainerUtil::cleanUpVectorOfPointers(timelines);
|
||||
setError("Invalid timeline type for a slot: ", skeletonData->_slots[slotIndex]->_name.c_str());
|
||||
setError("Invalid timeline type for a slot: ", skeletonData->_slots[slotIndex]->_name.buffer());
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
@ -913,7 +898,7 @@ namespace Spine {
|
||||
}
|
||||
default: {
|
||||
ContainerUtil::cleanUpVectorOfPointers(timelines);
|
||||
setError("Invalid timeline type for a bone: ", skeletonData->_bones[boneIndex]->_name.c_str());
|
||||
setError("Invalid timeline type for a bone: ", skeletonData->_bones[boneIndex]->_name.buffer());
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
@ -1014,17 +999,14 @@ namespace Spine {
|
||||
int slotIndex = readVarint(input, true);
|
||||
for (int iii = 0, nnn = readVarint(input, true); iii < nnn; iii++) {
|
||||
const char* attachmentName = readString(input);
|
||||
Attachment* baseAttachment = skin->getAttachment(slotIndex, std::string(attachmentName));
|
||||
Attachment* baseAttachment = skin->getAttachment(slotIndex, String(attachmentName, true));
|
||||
|
||||
if (!baseAttachment) {
|
||||
ContainerUtil::cleanUpVectorOfPointers(timelines);
|
||||
setError("Attachment not found: ", attachmentName);
|
||||
SpineExtension::free(attachmentName, __FILE__, __LINE__);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SpineExtension::free(attachmentName, __FILE__, __LINE__);
|
||||
|
||||
VertexAttachment* attachment = static_cast<VertexAttachment*>(baseAttachment);
|
||||
|
||||
bool weighted = attachment->_bones.size() > 0;
|
||||
@ -1147,8 +1129,8 @@ namespace Spine {
|
||||
event->_intValue = readVarint(input, false);
|
||||
event->_floatValue = readFloat(input);
|
||||
bool freeString = readBoolean(input);
|
||||
const char* event_stringValue = freeString ? readString(input) : eventData->_stringValue.c_str();
|
||||
event->_stringValue = std::string(event_stringValue);
|
||||
const char* event_stringValue = freeString ? readString(input) : eventData->_stringValue.buffer();
|
||||
event->_stringValue = String(event_stringValue);
|
||||
if (freeString) {
|
||||
SpineExtension::free(event_stringValue, __FILE__, __LINE__);
|
||||
}
|
||||
@ -1159,7 +1141,7 @@ namespace Spine {
|
||||
duration = MAX(duration, timeline->_frames[eventCount - 1]);
|
||||
}
|
||||
|
||||
return new (__FILE__, __LINE__) Animation(std::string(name), timelines, duration);
|
||||
return new (__FILE__, __LINE__) Animation(String(name), timelines, duration);
|
||||
}
|
||||
|
||||
void SkeletonBinary::readCurve(DataInput* input, int frameIndex, CurveTimeline* timeline) {
|
||||
|
||||
@ -70,55 +70,55 @@ namespace Spine {
|
||||
ContainerUtil::cleanUpVectorOfPointers(_pathConstraints);
|
||||
}
|
||||
|
||||
BoneData* SkeletonData::findBone(std::string boneName) {
|
||||
BoneData* SkeletonData::findBone(const String& boneName) {
|
||||
return ContainerUtil::findWithName(_bones, boneName);
|
||||
}
|
||||
|
||||
int SkeletonData::findBoneIndex(std::string boneName) {
|
||||
int SkeletonData::findBoneIndex(const String& boneName) {
|
||||
return ContainerUtil::findIndexWithName(_bones, boneName);
|
||||
}
|
||||
|
||||
SlotData* SkeletonData::findSlot(std::string slotName) {
|
||||
SlotData* SkeletonData::findSlot(const String& slotName) {
|
||||
return ContainerUtil::findWithName(_slots, slotName);
|
||||
}
|
||||
|
||||
int SkeletonData::findSlotIndex(std::string slotName) {
|
||||
int SkeletonData::findSlotIndex(const String& slotName) {
|
||||
return ContainerUtil::findIndexWithName(_slots, slotName);
|
||||
}
|
||||
|
||||
Skin* SkeletonData::findSkin(std::string skinName) {
|
||||
Skin* SkeletonData::findSkin(const String& skinName) {
|
||||
return ContainerUtil::findWithName(_skins, skinName);
|
||||
}
|
||||
|
||||
EventData* SkeletonData::findEvent(std::string eventDataName) {
|
||||
EventData* SkeletonData::findEvent(const String& eventDataName) {
|
||||
return ContainerUtil::findWithName(_events, eventDataName);
|
||||
}
|
||||
|
||||
Animation* SkeletonData::findAnimation(std::string animationName) {
|
||||
Animation* SkeletonData::findAnimation(const String& animationName) {
|
||||
return ContainerUtil::findWithName(_animations, animationName);
|
||||
}
|
||||
|
||||
IkConstraintData* SkeletonData::findIkConstraint(std::string constraintName) {
|
||||
IkConstraintData* SkeletonData::findIkConstraint(const String& constraintName) {
|
||||
return ContainerUtil::findWithName(_ikConstraints, constraintName);
|
||||
}
|
||||
|
||||
TransformConstraintData* SkeletonData::findTransformConstraint(std::string constraintName) {
|
||||
TransformConstraintData* SkeletonData::findTransformConstraint(const String& constraintName) {
|
||||
return ContainerUtil::findWithName(_transformConstraints, constraintName);
|
||||
}
|
||||
|
||||
PathConstraintData* SkeletonData::findPathConstraint(std::string constraintName) {
|
||||
PathConstraintData* SkeletonData::findPathConstraint(const String& constraintName) {
|
||||
return ContainerUtil::findWithName(_pathConstraints, constraintName);
|
||||
}
|
||||
|
||||
int SkeletonData::findPathConstraintIndex(std::string pathConstraintName) {
|
||||
int SkeletonData::findPathConstraintIndex(const String& pathConstraintName) {
|
||||
return ContainerUtil::findIndexWithName(_pathConstraints, pathConstraintName);
|
||||
}
|
||||
|
||||
std::string SkeletonData::getName() {
|
||||
const String& SkeletonData::getName() {
|
||||
return _name;
|
||||
}
|
||||
|
||||
void SkeletonData::setName(std::string inValue) {
|
||||
void SkeletonData::setName(const String& inValue) {
|
||||
_name = inValue;
|
||||
}
|
||||
|
||||
@ -202,27 +202,27 @@ namespace Spine {
|
||||
_height = inValue;
|
||||
}
|
||||
|
||||
std::string SkeletonData::getVersion() {
|
||||
const String& SkeletonData::getVersion() {
|
||||
return _version;
|
||||
}
|
||||
|
||||
void SkeletonData::setVersion(std::string inValue) {
|
||||
void SkeletonData::setVersion(const String& inValue) {
|
||||
_version = inValue;
|
||||
}
|
||||
|
||||
std::string SkeletonData::getHash() {
|
||||
const String& SkeletonData::getHash() {
|
||||
return _hash;
|
||||
}
|
||||
|
||||
void SkeletonData::setHash(std::string inValue) {
|
||||
void SkeletonData::setHash(const String& inValue) {
|
||||
_hash = inValue;
|
||||
}
|
||||
|
||||
std::string SkeletonData::getImagesPath() {
|
||||
const String& SkeletonData::getImagesPath() {
|
||||
return _imagesPath;
|
||||
}
|
||||
|
||||
void SkeletonData::setImagesPath(std::string inValue) {
|
||||
void SkeletonData::setImagesPath(const String& inValue) {
|
||||
_imagesPath = inValue;
|
||||
}
|
||||
|
||||
|
||||
@ -122,7 +122,7 @@ namespace Spine {
|
||||
SkeletonData* skeletonData;
|
||||
Json *root, *skeleton, *bones, *boneMap, *ik, *transform, *path, *slots, *skins, *animations, *events;
|
||||
|
||||
_error.clear();
|
||||
_error = "";
|
||||
_linkedMeshes.clear();
|
||||
|
||||
root = new (__FILE__, __LINE__) Json(json);
|
||||
@ -567,7 +567,7 @@ namespace Spine {
|
||||
}
|
||||
else {
|
||||
mesh->_inheritDeform = Json::getInt(attachmentMap, "deform", 1);
|
||||
LinkedMesh* linkedMesh = new (__FILE__, __LINE__) LinkedMesh(mesh, std::string(Json::getString(attachmentMap, "skin", 0)), slotIndex, std::string(entry->_valueString));
|
||||
LinkedMesh* linkedMesh = new (__FILE__, __LINE__) LinkedMesh(mesh, String(Json::getString(attachmentMap, "skin", 0)), slotIndex, String(entry->_valueString));
|
||||
_linkedMeshes.push_back(linkedMesh);
|
||||
}
|
||||
break;
|
||||
@ -640,13 +640,13 @@ namespace Spine {
|
||||
Skin* skin = linkedMesh->_skin.length() == 0 ? skeletonData->getDefaultSkin() : skeletonData->findSkin(linkedMesh->_skin);
|
||||
if (skin == NULL) {
|
||||
delete skeletonData;
|
||||
setError(root, "Skin not found: ", linkedMesh->_skin.c_str());
|
||||
setError(root, "Skin not found: ", linkedMesh->_skin.buffer());
|
||||
return NULL;
|
||||
}
|
||||
Attachment* parent = skin->getAttachment(linkedMesh->_slotIndex, linkedMesh->_parent);
|
||||
if (parent == NULL) {
|
||||
delete skeletonData;
|
||||
setError(root, "Parent mesh not found: ", linkedMesh->_parent.c_str());
|
||||
setError(root, "Parent mesh not found: ", linkedMesh->_parent.buffer());
|
||||
return NULL;
|
||||
}
|
||||
linkedMesh->_mesh->_parentMesh = static_cast<MeshAttachment*>(parent);
|
||||
@ -661,12 +661,12 @@ namespace Spine {
|
||||
skeletonData->_events.reserve(events->_size);
|
||||
skeletonData->_events.setSize(events->_size);
|
||||
for (eventMap = events->_child, i = 0; eventMap; eventMap = eventMap->_next, ++i) {
|
||||
EventData* eventData = new (__FILE__, __LINE__) EventData(std::string(eventMap->_name));
|
||||
EventData* eventData = new (__FILE__, __LINE__) EventData(String(eventMap->_name));
|
||||
|
||||
eventData->_intValue = Json::getInt(eventMap, "int", 0);
|
||||
eventData->_floatValue = Json::getFloat(eventMap, "float", 0);
|
||||
const char* stringValue = Json::getString(eventMap, "string", 0);
|
||||
eventData->_stringValue = std::string(stringValue ? stringValue : "");
|
||||
eventData->_stringValue = stringValue;
|
||||
skeletonData->_events[i] = eventData;
|
||||
}
|
||||
}
|
||||
@ -802,7 +802,7 @@ namespace Spine {
|
||||
|
||||
for (valueMap = timelineMap->_child, frameIndex = 0; valueMap; valueMap = valueMap->_next, ++frameIndex) {
|
||||
Json* name = Json::getItem(valueMap, "name");
|
||||
std::string attachmentName = name->_type == Json::JSON_NULL ? std::string("") : std::string(name->_valueString);
|
||||
String attachmentName = name->_type == Json::JSON_NULL ? "" : name->_valueString;
|
||||
timeline->setFrame(frameIndex, Json::getFloat(valueMap, "time", 0), attachmentName);
|
||||
}
|
||||
timelines.push_back(timeline);
|
||||
@ -1159,7 +1159,7 @@ namespace Spine {
|
||||
event = new (__FILE__, __LINE__) Event(Json::getFloat(valueMap, "time", 0), *eventData);
|
||||
event->_intValue = Json::getInt(valueMap, "int", eventData->_intValue);
|
||||
event->_floatValue = Json::getFloat(valueMap, "float", eventData->_floatValue);
|
||||
event->_stringValue = Json::getString(valueMap, "string", eventData->_stringValue.c_str());
|
||||
event->_stringValue = Json::getString(valueMap, "string", eventData->_stringValue.buffer());
|
||||
timeline->setFrame(frameIndex, event);
|
||||
}
|
||||
timelines.push_back(timeline);
|
||||
@ -1167,7 +1167,7 @@ namespace Spine {
|
||||
duration = MAX(duration, timeline->_frames[events->_size - 1]);
|
||||
}
|
||||
|
||||
return new (__FILE__, __LINE__) Animation(std::string(root->_name), timelines, duration);
|
||||
return new (__FILE__, __LINE__) Animation(String(root->_name), timelines, duration);
|
||||
}
|
||||
|
||||
void SkeletonJson::readVertices(Json* attachmentMap, VertexAttachment* attachment, int verticesLength) {
|
||||
@ -1224,7 +1224,7 @@ namespace Spine {
|
||||
strncat(message + length, value2, 255 - length);
|
||||
}
|
||||
|
||||
_error = std::string(message);
|
||||
_error = String(message);
|
||||
|
||||
if (root) {
|
||||
delete root;
|
||||
|
||||
@ -38,7 +38,7 @@
|
||||
#include <assert.h>
|
||||
|
||||
namespace Spine {
|
||||
Skin::AttachmentKey::AttachmentKey(int slotIndex, std::string name) :
|
||||
Skin::AttachmentKey::AttachmentKey(int slotIndex, const String& name) :
|
||||
_slotIndex(slotIndex),
|
||||
_name(name) {
|
||||
// Empty
|
||||
@ -54,7 +54,7 @@ namespace Spine {
|
||||
return h1;
|
||||
}
|
||||
|
||||
Skin::Skin(std::string name) : _name(name) {
|
||||
Skin::Skin(const String& name) : _name(name) {
|
||||
assert(_name.length() > 0);
|
||||
}
|
||||
|
||||
@ -65,13 +65,13 @@ namespace Spine {
|
||||
}
|
||||
}
|
||||
|
||||
void Skin::addAttachment(int slotIndex, std::string name, Attachment* attachment) {
|
||||
void Skin::addAttachment(int slotIndex, const String& name, Attachment* attachment) {
|
||||
assert(attachment);
|
||||
|
||||
_attachments.insert(AttachmentKey(slotIndex, name), attachment);
|
||||
}
|
||||
|
||||
Attachment* Skin::getAttachment(int slotIndex, std::string name) {
|
||||
Attachment* Skin::getAttachment(int slotIndex, const String& name) {
|
||||
HashMap<AttachmentKey, Attachment*, HashAttachmentKey>::Iterator i = _attachments.find(AttachmentKey(slotIndex, name));
|
||||
|
||||
Attachment* ret = NULL;
|
||||
@ -83,7 +83,7 @@ namespace Spine {
|
||||
return ret;
|
||||
}
|
||||
|
||||
void Skin::findNamesForSlot(int slotIndex, Vector<std::string>& names) {
|
||||
void Skin::findNamesForSlot(int slotIndex, Vector<String>& names) {
|
||||
for (HashMap<AttachmentKey, Attachment*, HashAttachmentKey>::Iterator i = _attachments.begin(); i != _attachments.end(); ++i) {
|
||||
if (i.key()._slotIndex == slotIndex) {
|
||||
names.push_back(i.key()._name);
|
||||
@ -98,8 +98,8 @@ namespace Spine {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const std::string& Skin::getName() {
|
||||
|
||||
const String& Skin::getName() {
|
||||
return _name;
|
||||
}
|
||||
|
||||
|
||||
@ -59,7 +59,7 @@ namespace Spine {
|
||||
_b = _data.getB();
|
||||
_a = _data.getA();
|
||||
|
||||
std::string attachmentName = _data.getAttachmentName();
|
||||
const String& attachmentName = _data.getAttachmentName();
|
||||
if (attachmentName.length() > 0) {
|
||||
_attachment = NULL;
|
||||
setAttachment(_skeleton.getAttachment(_data.getIndex(), attachmentName));
|
||||
|
||||
@ -33,7 +33,7 @@
|
||||
#include <assert.h>
|
||||
|
||||
namespace Spine {
|
||||
SlotData::SlotData(int index, std::string name, BoneData& boneData) :
|
||||
SlotData::SlotData(int index, const String& name, BoneData& boneData) :
|
||||
_index(index),
|
||||
_name(name),
|
||||
_boneData(boneData),
|
||||
@ -56,7 +56,7 @@ namespace Spine {
|
||||
return _index;
|
||||
}
|
||||
|
||||
const std::string& SlotData::getName() {
|
||||
const String& SlotData::getName() {
|
||||
return _name;
|
||||
}
|
||||
|
||||
@ -128,11 +128,11 @@ namespace Spine {
|
||||
_hasSecondColor = inValue;
|
||||
}
|
||||
|
||||
std::string SlotData::getAttachmentName() {
|
||||
const String& SlotData::getAttachmentName() {
|
||||
return _attachmentName;
|
||||
}
|
||||
|
||||
void SlotData::setAttachmentName(std::string inValue) {
|
||||
void SlotData::setAttachmentName(const String& inValue) {
|
||||
_attachmentName = inValue;
|
||||
}
|
||||
|
||||
|
||||
@ -35,7 +35,7 @@
|
||||
#include <assert.h>
|
||||
|
||||
namespace Spine {
|
||||
TransformConstraintData::TransformConstraintData(std::string name) :
|
||||
TransformConstraintData::TransformConstraintData(const String& name) :
|
||||
_name(name),
|
||||
_order(0),
|
||||
_target(NULL),
|
||||
@ -54,7 +54,7 @@ namespace Spine {
|
||||
assert(_name.length() > 0);
|
||||
}
|
||||
|
||||
const std::string& TransformConstraintData::getName() {
|
||||
const String& TransformConstraintData::getName() {
|
||||
return _name;
|
||||
}
|
||||
|
||||
|
||||
@ -38,7 +38,7 @@
|
||||
namespace Spine {
|
||||
RTTI_IMPL(VertexAttachment, Attachment);
|
||||
|
||||
VertexAttachment::VertexAttachment(std::string name) : Attachment(name), _worldVerticesLength(0), _id(getNextID()) {
|
||||
VertexAttachment::VertexAttachment(const String& name) : Attachment(name), _worldVerticesLength(0), _id(getNextID()) {
|
||||
// Empty
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user