Эх сурвалжийг харах

Docs, accept empty string for std::string refs that can be null in the C API.

NathanSweet 10 жил өмнө
parent
commit
fae952d73c

+ 2 - 1
spine-c/include/spine/Skeleton.h

@@ -117,7 +117,8 @@ int spSkeleton_setSkinByName (spSkeleton* self, const char* skinName);
 spAttachment* spSkeleton_getAttachmentForSlotName (const spSkeleton* self, const char* slotName, const char* attachmentName);
 /* Returns 0 if the slot or attachment was not found. */
 spAttachment* spSkeleton_getAttachmentForSlotIndex (const spSkeleton* self, int slotIndex, const char* attachmentName);
-/* Returns 0 if the slot or attachment was not found. */
+/* Returns 0 if the slot or attachment was not found.
+ * @param attachmentName May be 0. */
 int spSkeleton_setAttachment (spSkeleton* self, const char* slotName, const char* attachmentName);
 
 /* Returns 0 if the IK constraint was not found. */

+ 2 - 2
spine-cocos2dx/3/src/spine/SkeletonRenderer.cpp

@@ -346,14 +346,14 @@ spSlot* SkeletonRenderer::findSlot (const std::string& slotName) const {
 }
 
 bool SkeletonRenderer::setSkin (const std::string& skinName) {
-	return spSkeleton_setSkinByName(_skeleton, skinName.c_str()) ? true : false;
+	return spSkeleton_setSkinByName(_skeleton, skinName.empty() ? 0 : skinName.c_str()) ? true : false;
 }
 
 spAttachment* SkeletonRenderer::getAttachment (const std::string& slotName, const std::string& attachmentName) const {
 	return spSkeleton_getAttachmentForSlotName(_skeleton, slotName.c_str(), attachmentName.c_str());
 }
 bool SkeletonRenderer::setAttachment (const std::string& slotName, const std::string& attachmentName) {
-	return spSkeleton_setAttachment(_skeleton, slotName.c_str(), attachmentName.c_str()) ? true : false;
+	return spSkeleton_setAttachment(_skeleton, slotName.c_str(), attachmentName.empty() ? 0 : attachmentName.c_str()) ? true : false;
 }
 
 spSkeleton* SkeletonRenderer::getSkeleton () {

+ 3 - 2
spine-cocos2dx/3/src/spine/SkeletonRenderer.h

@@ -77,12 +77,13 @@ public:
 	
 	/* Sets the skin used to look up attachments not found in the SkeletonData defaultSkin. Attachments from the new skin are
 	 * attached if the corresponding attachment from the old skin was attached. Returns false if the skin was not found.
-	 * @param skin May be 0.*/
+	 * @param skin May be empty string ("") for no skin.*/
 	bool setSkin (const std::string& skinName);
 	
 	/* Returns 0 if the slot or attachment was not found. */
 	spAttachment* getAttachment (const std::string& slotName, const std::string& attachmentName) const;
-	/* Returns false if the slot or attachment was not found. */
+	/* Returns false if the slot or attachment was not found.
+	 * @param attachmentName May be empty string ("") for no attachment. */
 	bool setAttachment (const std::string& slotName, const std::string& attachmentName);
 
 	// --- BlendProtocol