JugiMap Framework
jmSourceGraphics.h
1 #ifndef JUGIMAP_SOURCE_GRAPHICS_H
2 #define JUGIMAP_SOURCE_GRAPHICS_H
3 
4 
5 #include "jmCommon.h"
6 #include "jmGlobal.h"
7 
8 
9 
10 namespace jugimap {
11 
12 
13 class VectorShape;
14 class GraphicFile;
15 class SourceSprite;
16 class FrameAnimation;
17 class TimelineAnimation;
18 class StandardSprite;
19 class ComposedSprite;
20 class SkeletonSprite;
21 class SourceGraphics;
22 class SpriteLayer;
23 class VectorLayer;
24 class Administrator;
25 class JugiMapBinaryLoader;
26 class ObjectFactory;
27 
28 
29 
35 {
36 public:
37  friend class JugiMapBinaryLoader;
38  friend class ObjectFactory;
39  friend class Administrator;
40  friend class GraphicFile;
41  friend class SourceSprite;
42  friend class GraphicFile;
43  friend class StandardSprite;
44  friend class SkeletonSprite;
45 
46 
47 
51  virtual void Init();
52 
53 
55  GraphicFile* GetFile() {return graphicFile;}
56 
57 
59  std::string GetName() {return name;}
60 
61 
63  Vec2i GetPos() {return rect.min;}
64 
65 
67  int GetWidth() {return rect.GetWidth();}
68 
69 
71  int GetHeight() {return rect.GetHeight();}
72 
73 
75  Vec2i GetSize() {return rect.GetSize();}
76 
77 
79  Vec2f GetHandle() {return handle;}
80 
81 
83  float GetSpineScale() {return spineScale;}
84 
85 
87  std::vector<VectorShape*>& GetSpriteShapes() {return spriteShapes;}
88 
89 
91  std::vector<VectorShape*>& GetExtraShapes() {return extraShapes;}
92 
93 
95  std::string GetLabel(){ return label; }
96 
97 
99  int GetFontStyleId(){ return fontStyleId; }
100 
102  int GetColorStyleId(){ return colorStyleId; }
103 
104 
106  TextHandleVariant GetTextHandleVariant(){ return textHandleVariant; }
107 
108 
109 protected:
110 
113 
114  GraphicItem(const GraphicItem &gi) = delete;
115  GraphicItem & operator=(const GraphicItem &gi) = delete;
116 
118  virtual ~GraphicItem();
119 
120 
121 private:
122  GraphicFile *graphicFile = nullptr; //LINK pointer to parent file.
123  std::string name;
124 
125  // (sub)image rectangle
126  Recti rect;
127 
128  float spineScale = 1.0;
129  Vec2f handle;
130  std::vector<VectorShape*>spriteShapes; // OWNED
131  std::vector<VectorShape*>extraShapes; // OWNED
132 
133  // text label
134  std::string label;
135  int fontStyleId = 0;
136  int colorStyleId = 0;
137  TextHandleVariant textHandleVariant = TextHandleVariant::CENTER;
138 
139 };
140 
141 
142 //=======================================================================================
143 
149 {
150 public:
151  friend class ObjectFactory;
152  friend class JugiMapBinaryLoader;
153  friend class Administrator;
154  friend class GraphicItem;
155  friend class StandardSprite;
156  friend class SkeletonSprite;
157  friend class SourceGraphics;
158 
159  static std::string pathPrefix;
160 
161 
162 
163 
167  virtual void Init(){}
168 
169 
171  FileKind GetKind() {return kind;}
172 
173 
175  std::string GetRelativeFilePath() {return pathPrefix + relativeFilePath;}
176 
177 
179  Vec2i GetSize() {return size;}
180 
181 
183  std::vector<GraphicItem*>& GetItems() {return items;}
184 
185 
187  std::string GetSpineAtlasRelativeFilePath() {return pathPrefix + spineAtlasRelativeFilePath;}
188 
189 
190 protected:
191 
194  GraphicFile(const GraphicFile &gf) = delete;
195  GraphicFile & operator=(const GraphicFile &gf) = delete;
196 
198  virtual ~GraphicFile();
199 
200 private:
202  std::string relativeFilePath;
203  Vec2i size;
204  std::vector<GraphicItem*>items; // OWNED objects
205  std::string spineAtlasRelativeFilePath;
206 
207 };
208 
209 
210 //=======================================================================================
211 
212 
213 
214 
215 
222 {
223 public:
224  friend class ObjectFactory;
225  friend class JugiMapBinaryLoader;
226  friend class Administrator;
227  friend class JMSprite;
228  friend class StandardSprite;
229  friend class ComposedSprite;
230  friend class SkeletonSprite;
231  friend class SourceGraphics;
232 
233 
235  enum Status{
240  };
241 
242 
246  void Init();
247 
248 
250  SpriteKind GetKind() {return kind;}
251 
252 
254  std::string GetName() {return name;}
255 
256 
258  std::vector<Parameter>& GetConstantParameters(){return constantParameters;}
259 
260 
262  std::vector<GraphicItem*>& GetGraphicItems(){return graphicItems;}
263 
264 
266  std::vector<FrameAnimation*>& GetFrameAnimations(){return frameAnimations;}
267 
268 
270  std::vector<TimelineAnimation*>& GetTimelineAnimations(){return timelineAnimations;}
271 
272 
274  int GetStatusFlags() {return statusFlags;}
275 
276 
278  ComposedSprite* GetSourceComposedSprite(){return sourceComposedSprite;}
279 
280 
281 private:
283  std::string name;
284  std::vector<Parameter> constantParameters;
285  std::vector<GraphicItem*>graphicItems; // LINKs
286  std::vector<FrameAnimation*>frameAnimations; // OWNED
287  std::vector<TimelineAnimation*>timelineAnimations; // OWNED
288 
289  std::vector<Parameter> parametersTMP;
290 
291  int statusFlags = 0;
292  bool initialized = false;
293 
294  ComposedSprite * sourceComposedSprite = nullptr; // OWNED
295 
296 
298  SourceSprite(){}
299  SourceSprite(SpriteKind _kind) : kind(_kind){}
300 
301  SourceSprite(const SourceSprite &ss) = delete;
302  SourceSprite & operator=(const SourceSprite &ss) = delete;
303 
305  ~SourceSprite();
306 
307 };
308 
309 
310 
311 
312 
313 struct SourceSpriteReplacement
314 {
315  SourceSprite * sourceSprite = nullptr; // LINK
316  std::string childSpriteName;
317 
318 
319  SourceSpriteReplacement(SourceSprite * _sourceSprite, const std::string &_childSpriteName) :
320  sourceSprite(_sourceSprite),
321  childSpriteName(_childSpriteName)
322  {}
323 };
324 
325 
326 
327 struct SourceSpriteReplacements
328 {
329 
330  std::vector<SourceSpriteReplacement>replacements;
331  SourceSprite * originalSourceSprite = nullptr; // LINK
332 
333  SourceSpriteReplacements(SourceSprite * _sourceSprite, const std::string &_childSpriteName, SourceSprite * _originalSourceSprite)
334  :originalSourceSprite(_originalSourceSprite)
335  {
336  replacements.push_back(SourceSpriteReplacement(_sourceSprite, _childSpriteName));
337  }
338 
339  SourceSprite * FindSourceSpriteForChild(const std::string &_childSpriteName);
340 
341 
342 };
343 
344 
345 //=======================================================================================
346 
352 {
353 public:
354  friend class JugiMapBinaryLoader;
355 
356  static SourceSprite* dummyTextSourceSprite;
357 
360 
361 
363  ~SourceGraphics();
364 
365 
367  void DeleteContent();
368 
369 
371  std::vector<GraphicFile*>& GetFiles(){return files;}
372 
373 
375  std::vector<SourceSprite*>& GetSourceSprites(){return sourceSprites;}
376 
377 
378  static void DeleteGlobalData();
379 
380 
381 
382 private:
383  std::vector<GraphicFile*>files; //OWNED
384  std::vector<SourceSprite*>sourceSprites; //OWNED
385 
386 };
387 
388 
389 /*
408 */
409 
410 }
411 
412 
413 
414 
415 
416 
417 #endif
jugimap::FileKind::NOT_DEFINED
The file kind not defined.
jugimap::SourceSprite::GetSourceComposedSprite
ComposedSprite * GetSourceComposedSprite()
Returns a pointer to the owned source composed sprite or nullptr if there is none.
Definition: jmSourceGraphics.h:278
jugimap::SourceGraphics::GetFiles
std::vector< GraphicFile * > & GetFiles()
Returns a reference to the vector of stored graphic files.
Definition: jmSourceGraphics.h:371
jugimap::GraphicFile::~GraphicFile
virtual ~GraphicFile()
Destructor.
Definition: jmSourceGraphics.cpp:40
jugimap::GraphicItem::~GraphicItem
virtual ~GraphicItem()
Destructor.
Definition: jmSourceGraphics.cpp:23
jugimap::SourceSprite::HAS_MULTIPLE_SPRITE_SHAPES_IN_IMAGE
The source sprite has image(s) with multiple sprite shapes.
Definition: jmSourceGraphics.h:239
jugimap::GraphicFile::GetRelativeFilePath
std::string GetRelativeFilePath()
Returns the relative file path of this file.
Definition: jmSourceGraphics.h:175
jugimap::Rect< int >
jugimap::GraphicItem::GetTextHandleVariant
TextHandleVariant GetTextHandleVariant()
Returns the text handle variant if this graphic item belong to text sprite.
Definition: jmSourceGraphics.h:106
jugimap::SpriteKind
SpriteKind
The kinds of sprite. Used as identifier for Sprite objects.
Definition: jmGlobal.h:30
jugimap::GraphicItem::GetSize
Vec2i GetSize()
Returns the size of sub-image if this graphic item belongs to an image file.
Definition: jmSourceGraphics.h:75
jugimap::GraphicFile::GetItems
std::vector< GraphicItem * > & GetItems()
Returns a reference to the vector of stored graphic items in this file.
Definition: jmSourceGraphics.h:183
jugimap::GraphicFile::GetKind
FileKind GetKind()
Returns the kind of this file.
Definition: jmSourceGraphics.h:171
jugimap::GraphicItem::GetHeight
int GetHeight()
Returns the height of sub-image if this graphic item belongs to an image file.
Definition: jmSourceGraphics.h:71
jugimap::GraphicItem::GetSpineScale
float GetSpineScale()
Returns the spine scale if this graphic item belongs to a Spine file.
Definition: jmSourceGraphics.h:83
jugimap::GraphicItem::GetPos
Vec2i GetPos()
Returns the position of sub-image if this graphic item belong to an image file.
Definition: jmSourceGraphics.h:63
jugimap::GraphicItem::GetWidth
int GetWidth()
Returns the width of sub-image if this graphic item belongs to an image file.
Definition: jmSourceGraphics.h:67
jugimap::SourceGraphics::~SourceGraphics
~SourceGraphics()
Destructor.
Definition: jmSourceGraphics.cpp:152
jugimap::SourceSprite::Status
Status
The status flags for standard source sprites (SpriteKind::STANDARD).
Definition: jmSourceGraphics.h:235
jugimap::GraphicItem::Init
virtual void Init()
Initialize this graphic item.
Definition: jmSourceGraphics.cpp:16
jugimap::GraphicFile::GetSpineAtlasRelativeFilePath
std::string GetSpineAtlasRelativeFilePath()
Returns the relative file path of the spine atlas if this file is a Spine file.
Definition: jmSourceGraphics.h:187
jugimap::GraphicItem::GetName
std::string GetName()
Returns the name of this graphic item.
Definition: jmSourceGraphics.h:59
jugimap::GraphicItem::GetColorStyleId
int GetColorStyleId()
Returns the color style id if this graphic item belong to text sprite.
Definition: jmSourceGraphics.h:102
jugimap::SourceGraphics::SourceGraphics
SourceGraphics()
Constructor.
Definition: jmSourceGraphics.h:359
jugimap::GraphicItem
The GraphicItem class defines the equivalent object from JugiMap Editor.
Definition: jmSourceGraphics.h:34
jugimap::SourceGraphics::GetSourceSprites
std::vector< SourceSprite * > & GetSourceSprites()
Returns a reference to the vector of stored source sprites.
Definition: jmSourceGraphics.h:375
jugimap::StandardSprite
The StandardSprite class defines the sprite from JugiMap Editor.
Definition: jmSprites.h:787
jugimap::GraphicItem::GetFontStyleId
int GetFontStyleId()
Returns the font style id if this graphic item belong to text sprite.
Definition: jmSourceGraphics.h:99
jugimap::SourceSprite::GetConstantParameters
std::vector< Parameter > & GetConstantParameters()
Returns a reference to the vector of stored constant parameters in this source sprite.
Definition: jmSourceGraphics.h:258
jugimap::SourceGraphics
The SourceGraphics class represents source graphics elements from JugiMap Editor.
Definition: jmSourceGraphics.h:351
jugimap::GraphicItem::GetSpriteShapes
std::vector< VectorShape * > & GetSpriteShapes()
Returns a reference to sprite shapes if this graphic item belong to an image file.
Definition: jmSourceGraphics.h:87
jugimap::SpriteKind::NOT_DEFINED
The sprite kind not defined.
jugimap::FileKind
FileKind
The kinds of file.
Definition: jmGlobal.h:17
jugimap::Rect::min
Vec2< T > min
The minimum coordinate (the left-top corner when y coordinate points downward).
Definition: jmCommon.h:177
jugimap::GraphicFile
The GraphicFile class defines the equivalent object from JugiMap Editor.
Definition: jmSourceGraphics.h:148
jugimap::GraphicItem::GetExtraShapes
std::vector< VectorShape * > & GetExtraShapes()
Returns a reference to probe shapes if this graphic item belong to an image file.
Definition: jmSourceGraphics.h:91
jugimap::Rect::GetHeight
T GetHeight() const
Returns the height of this rectangle.
Definition: jmCommon.h:204
jugimap::GraphicItem::GetLabel
std::string GetLabel()
Returns the text if this graphic item belong to text sprite.
Definition: jmSourceGraphics.h:95
jugimap::SourceSprite::GetKind
SpriteKind GetKind()
Returns the kind of this source sprite.
Definition: jmSourceGraphics.h:250
jugimap::SkeletonSprite
The SkeletonSprite class defines the skeleton sprite from JugiMap Editor.
Definition: jmSprites.h:1011
jugimap::GraphicFile::GraphicFile
GraphicFile()
Constructor.
Definition: jmSourceGraphics.h:193
jugimap::GraphicItem::GetHandle
Vec2f GetHandle()
Returns the handle of sub-image if this graphic item belongs to an image file.
Definition: jmSourceGraphics.h:79
jugimap::GraphicFile::Init
virtual void Init()
Initialize this GraphicFile.
Definition: jmSourceGraphics.h:167
jugimap::Rect::GetWidth
T GetWidth() const
Returns the width of this rectangle.
Definition: jmCommon.h:201
jugimap::Rect::GetSize
Vec2< T > GetSize() const
Returns a vector storing the size of this rectangle; the width is stored in x and the height is store...
Definition: jmCommon.h:227
jugimap::GraphicFile::GetSize
Vec2i GetSize()
Returns the size of image if this file is an image.
Definition: jmSourceGraphics.h:179
jugimap::SourceSprite::Init
void Init()
Initialize this source sprite.
Definition: jmSourceGraphics.cpp:63
jugimap::SourceSprite::GetGraphicItems
std::vector< GraphicItem * > & GetGraphicItems()
Returns a reference to the vector of graphic items in this source sprite.
Definition: jmSourceGraphics.h:262
jugimap::SourceSprite::GetName
std::string GetName()
Returns the name of this source sprite.
Definition: jmSourceGraphics.h:254
jugimap::SourceSprite::GetFrameAnimations
std::vector< FrameAnimation * > & GetFrameAnimations()
Returns a reference to the vector of stored frame animations in this source sprite.
Definition: jmSourceGraphics.h:266
jugimap::SourceSprite::HAS_IMAGES_WITH_SPRITE_SHAPES
Has image(s) with defined sprite shapes.
Definition: jmSourceGraphics.h:237
jugimap::GraphicItem::GraphicItem
GraphicItem()
Constructor.
Definition: jmSourceGraphics.h:112
jugimap::ObjectFactory
The ObjectFactory is the base class for engine specific object factories.
Definition: jmObjectFactory.h:48
jugimap::ComposedSprite
The ComposedSprite class defines the composed sprite from JugiMap Editor.
Definition: jmSprites.h:682
jugimap::GraphicFile::pathPrefix
static std::string pathPrefix
An optional string attached to stored file paths. It must end with slash '/'!
Definition: jmSourceGraphics.h:159
jugimap::SourceSprite::GetTimelineAnimations
std::vector< TimelineAnimation * > & GetTimelineAnimations()
Returns a reference to the vector of stored timeline animations in this source sprite.
Definition: jmSourceGraphics.h:270
jugimap::SourceSprite::HAS_IMAGES_WITH_DIFFERENT_SPRITE_SHAPES
Has more images and they do not have all the same sprite shapes.
Definition: jmSourceGraphics.h:238
jugimap::SourceGraphics::DeleteContent
void DeleteContent()
Delete stored SourceGraphics objects and GraphicFile objects.
Definition: jmSourceGraphics.cpp:159
jugimap::Vec2< int >
jugimap::SourceSprite
The SourceSprite class defines the source sprite from JugiMap Editor.
Definition: jmSourceGraphics.h:221
jugimap::SourceSprite::GetStatusFlags
int GetStatusFlags()
Returns the status flags.
Definition: jmSourceGraphics.h:274
jugimap::GraphicItem::GetFile
GraphicFile * GetFile()
Returns the graphic file of this graphic item.
Definition: jmSourceGraphics.h:55
jugimap::TextHandleVariant
TextHandleVariant
Predefined handles for TextSprite objects.
Definition: jmGlobal.h:229
jugimap::SourceSprite::HAS_IMAGES_OF_DIFFERENT_SIZE
Has images of different size.
Definition: jmSourceGraphics.h:236
jugimap::JugiMapBinaryLoader
The JugiMapBinaryLoader class loads data from jugimap binary files (.jmb).
Definition: jmMapBinaryLoader.h:37