-
Notifications
You must be signed in to change notification settings - Fork 1
/
jsonsprite.h
105 lines (96 loc) · 2.4 KB
/
jsonsprite.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
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
105
#ifndef JSONSPRITE_H
#define JSONSPRITE_H
#include <QJsonDocument>
#include <QFile>
#include <QJsonObject>
#include <QJsonArray>
#include <QTableView>
#include <QFileDialog>
#include <QMessageBox>
#include "tweak_bytes.h"
enum DisplayType {
XY,
ExtraByte
};
struct SingleGFXFile {
bool separate{false};
int value{0x7f};
SingleGFXFile() = default;
SingleGFXFile(bool separate, int value);
SingleGFXFile(const QJsonObject& g);
QJsonObject toJson() const;
};
struct GFXInfo {
SingleGFXFile sp0{};
SingleGFXFile sp1{};
SingleGFXFile sp2{};
SingleGFXFile sp3{};
GFXInfo() = default;
GFXInfo(SingleGFXFile s0, SingleGFXFile s1, SingleGFXFile s2, SingleGFXFile s3);
GFXInfo(const QJsonObject& g);
QJsonObject toJson() const;
};
struct Tile {
int xoff;
int yoff;
int tilenumber;
Tile(int x, int y, int tileno);
Tile(const QJsonObject& d);
QJsonObject toJson() const;
};
struct JSONDisplay {
QString description;
QVector<Tile> tiles;
bool extrabit;
int x_or_index;
int y_or_value;
bool useText;
QString displaytext;
GFXInfo gfxinfo{};
JSONDisplay(const QJsonObject& t, DisplayType type);
JSONDisplay(const QString& d, const QVector<Tile>& ts, bool bit, int xx, int yy, bool text, const QString& disp, const GFXInfo& info);
QJsonObject toJson(DisplayType type) const;
};
struct Collection {
QString name;
bool extrabit;
uint8_t prop[12];
Collection(const QJsonObject& c);
QJsonObject toJson() const;
};
class JsonSprite {
public:
JsonSprite();
void reset();
void from_file(const QString& name);
void deserialize();
void deserialize_cfg(QFile& file);
void serialize();
QByteArray serialize_cfg();
void addCollections(QTableView* view);
void addDisplay(const JSONDisplay& display);
void setMap16(const QString& mapdata);
QByteArray to_text(const QString& filename);
void to_file(QString name = "");
QString& name();
J1656 t1656;
J1662 t1662;
J166E t166e;
J167A t167a;
J1686 t1686;
J190F t190f;
QString asmfile;
uint8_t actlike;
uint8_t type;
uint8_t extraProp1;
uint8_t extraProp2;
int addbcountclear;
int addbcountset;
QString map16;
QVector<JSONDisplay> displays;
QVector<Collection> collections;
QString m_name;
QJsonObject obj;
DisplayType dispType;
};
#endif // JSONSPRITE_H