Blame view

ios/cocos2d/cocos/editor-support/spine/Skin.h 5.42 KB
520389e3   xiaoyu   接入cocos源码,编译未通过,继续修改
1
  /******************************************************************************
5daad4bc   xiaoyu   游戏源码添加编译(现存问题:游戏内...
2
3
   * Spine Runtimes License Agreement
   * Last updated May 1, 2019. Replaces all prior versions.
520389e3   xiaoyu   接入cocos源码,编译未通过,继续修改
4
   *
5daad4bc   xiaoyu   游戏源码添加编译(现存问题:游戏内...
5
   * Copyright (c) 2013-2019, Esoteric Software LLC
520389e3   xiaoyu   接入cocos源码,编译未通过,继续修改
6
   *
5daad4bc   xiaoyu   游戏源码添加编译(现存问题:游戏内...
7
8
9
10
   * Integration of the Spine Runtimes into software or otherwise creating
   * derivative works of the Spine Runtimes is permitted under the terms and
   * conditions of Section 2 of the Spine Editor License Agreement:
   * http://esotericsoftware.com/spine-editor-license
520389e3   xiaoyu   接入cocos源码,编译未通过,继续修改
11
   *
5daad4bc   xiaoyu   游戏源码添加编译(现存问题:游戏内...
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
   * Otherwise, it is permitted to integrate the Spine Runtimes into software
   * or otherwise create derivative works of the Spine Runtimes (collectively,
   * "Products"), provided that each user of the Products must obtain their own
   * Spine Editor license and redistribution of the Products in any form must
   * include this license and copyright notice.
   *
   * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE LLC "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 LLC 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.
520389e3   xiaoyu   接入cocos源码,编译未通过,继续修改
28
29
   *****************************************************************************/
  
5daad4bc   xiaoyu   游戏源码添加编译(现存问题:游戏内...
30
31
  #ifndef Spine_Skin_h
  #define Spine_Skin_h
520389e3   xiaoyu   接入cocos源码,编译未通过,继续修改
32
  
5daad4bc   xiaoyu   游戏源码添加编译(现存问题:游戏内...
33
34
  #include <spine/Vector.h>
  #include <spine/SpineString.h>
520389e3   xiaoyu   接入cocos源码,编译未通过,继续修改
35
  
5daad4bc   xiaoyu   游戏源码添加编译(现存问题:游戏内...
36
37
  namespace spine {
  class Attachment;
520389e3   xiaoyu   接入cocos源码,编译未通过,继续修改
38
  
5daad4bc   xiaoyu   游戏源码添加编译(现存问题:游戏内...
39
40
41
  class Skeleton;
  class BoneData;
  class ConstraintData;
520389e3   xiaoyu   接入cocos源码,编译未通过,继续修改
42
  
5daad4bc   xiaoyu   游戏源码添加编译(现存问题:游戏内...
43
44
45
46
47
  /// Stores attachments by slot index and attachment name.
  /// See SkeletonData::getDefaultSkin, Skeleton::getSkin, and
  /// http://esotericsoftware.com/spine-runtime-skins in the Spine Runtimes Guide.
  class SP_API Skin : public SpineObject {
  	friend class Skeleton;
520389e3   xiaoyu   接入cocos源码,编译未通过,继续修改
48
  
5daad4bc   xiaoyu   游戏源码添加编译(现存问题:游戏内...
49
50
51
  public:
  	class SP_API AttachmentMap : public SpineObject {
  		friend class Skin;
520389e3   xiaoyu   接入cocos源码,编译未通过,继续修改
52
  
5daad4bc   xiaoyu   游戏源码添加编译(现存问题:游戏内...
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
  	public:
  		struct SP_API Entry {
  			size_t _slotIndex;
  			String _name;
  			Attachment *_attachment;
  
  			Entry(size_t slotIndex, const String &name, Attachment *attachment) :
  					_slotIndex(slotIndex),
  					_name(name),
  					_attachment(attachment) {
  			}
  		};
  
  		class SP_API Entries {
  			friend class AttachmentMap;
  
  		public:
  			bool hasNext() {
  				while(true) {
  					if (_slotIndex >= _buckets.size()) return false;
  					if (_bucketIndex >= _buckets[_slotIndex].size()) {
  						_bucketIndex = 0;
  						++_slotIndex;
  						continue;
  					};
  					return true;
  				}
  			}
  
  			Entry &next() {
  				Entry &result = _buckets[_slotIndex][_bucketIndex];
  				++_bucketIndex;
  				return result;
  			}
  
  		protected:
  			Entries(Vector< Vector<Entry> > &buckets) : _buckets(buckets), _slotIndex(0), _bucketIndex(0) {
  			}
  
  		private:
  			Vector< Vector<Entry> > &_buckets;
  			size_t _slotIndex;
  			size_t _bucketIndex;
  		};
  
  		void put(size_t slotIndex, const String &attachmentName, Attachment *attachment);
  
  		Attachment *get(size_t slotIndex, const String &attachmentName);
  
  		void remove(size_t slotIndex, const String &attachmentName);
  
  		Entries getEntries();
520389e3   xiaoyu   接入cocos源码,编译未通过,继续修改
105
  
5daad4bc   xiaoyu   游戏源码添加编译(现存问题:游戏内...
106
107
  	protected:
  		AttachmentMap();
520389e3   xiaoyu   接入cocos源码,编译未通过,继续修改
108
  
5daad4bc   xiaoyu   游戏源码添加编译(现存问题:游戏内...
109
  	private:
520389e3   xiaoyu   接入cocos源码,编译未通过,继续修改
110
  
5daad4bc   xiaoyu   游戏源码添加编译(现存问题:游戏内...
111
  		int findInBucket(Vector <Entry> &, const String &attachmentName);
520389e3   xiaoyu   接入cocos源码,编译未通过,继续修改
112
  
5daad4bc   xiaoyu   游戏源码添加编译(现存问题:游戏内...
113
114
  		Vector <Vector<Entry> > _buckets;
  	};
520389e3   xiaoyu   接入cocos源码,编译未通过,继续修改
115
  
5daad4bc   xiaoyu   游戏源码添加编译(现存问题:游戏内...
116
  	explicit Skin(const String &name);
520389e3   xiaoyu   接入cocos源码,编译未通过,继续修改
117
  
5daad4bc   xiaoyu   游戏源码添加编译(现存问题:游戏内...
118
  	~Skin();
520389e3   xiaoyu   接入cocos源码,编译未通过,继续修改
119
  
5daad4bc   xiaoyu   游戏源码添加编译(现存问题:游戏内...
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
  	/// 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 setAttachment(size_t slotIndex, const String &name, Attachment *attachment);
  
  	/// Returns the attachment for the specified slot index and name, or NULL.
  	Attachment *getAttachment(size_t slotIndex, const String &name);
  
  	// Removes the attachment from the skin.
  	void removeAttachment(size_t 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(size_t 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(size_t slotIndex, Vector<Attachment *> &attachments);
  
  	const String &getName();
  
  	/// Adds all attachments, bones, and constraints from the specified skin to this skin.
  	void addSkin(Skin* other);
  
  	/// Adds all attachments, bones, and constraints from the specified skin to this skin. Attachments are deep copied.
  	void copySkin(Skin* other);
  
  	AttachmentMap::Entries getAttachments();
  
  	Vector<BoneData*>& getBones();
  
  	Vector<ConstraintData*>& getConstraints();
  private:
  	const String _name;
  	AttachmentMap _attachments;
  	Vector<BoneData*> _bones;
  	Vector<ConstraintData*> _constraints;
  
  	/// Attach all attachments from this skin if the corresponding attachment from the old skin is currently attached.
  	void attachAll(Skeleton &skeleton, Skin &oldSkin);
  };
520389e3   xiaoyu   接入cocos源码,编译未通过,继续修改
162
  }
520389e3   xiaoyu   接入cocos源码,编译未通过,继续修改
163
  
5daad4bc   xiaoyu   游戏源码添加编译(现存问题:游戏内...
164
  #endif /* Spine_Skin_h */