forked from FranciscoBiaso/TileMapEditorRealmz
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathImgPack.h
76 lines (63 loc) · 1.75 KB
/
ImgPack.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#pragma once
#include "ImgObj.h"
#include "TextureAtlas.h"
#include <gdk/gdk.h>
#include <string>
#include <list>
namespace data {
/*!
ImgPack class data structure
============================
This class represents a data structure capable of storing ImgObj objects and also managing memory sharing of real images (32x32, 32x64,64x32,64x64).
*/
class ImgPack
{
private:
std::list<data::ImgObj> _imgs;
data::TextureAtlas* textureAtlas;
/**
* @brief This method is used to increase memory when needed.
*/
void resizeTextureAtlas();
public:
/**
* constructor.
*/
ImgPack();
/**
* @brief This method add ImgObj into this data structure.
* @param name key of the ImgObj to be added.
* @param srcImg pixel buffer region with pixels to fill textureAtlas.
* @param size ImgSize to be copied (32x32, 32x64, 64x32, 64x64).
*/
void addImgObj(std::string name, const GdkPixbuf* srcImg, const def::IMG_SIZE size);
void addImgObjFromJson(ImgObj);
/**
* @brief This method delete ImgObj from this data strcture.
* @param name key of the ImgObj to be deleted.
*/
void delImgObj(std::string name);
/**
* @brief This method gets data::TextureAtlas*.
*/
data::TextureAtlas* getTextureAtlas() const;
/**
* @brief This method gets vector<data::ImgObj>&.
*/
std::list<data::ImgObj>& getStrucutre() { return _imgs; }
/**
* @brief This method gets count of ImgObj.
*/
int getCountImgs() { return _imgs.size(); }
/**
* @brief This method find img by name. If dont exists return nullpointer.
*/
std::list<data::ImgObj>::iterator find(std::string imgName);
/**
* @brief This method
*/
std::list<data::ImgObj>& getImgVec();
void saveImgPackAsJsonFile();
void sort();
};
}