-
Notifications
You must be signed in to change notification settings - Fork 19
/
tileset.h
128 lines (92 loc) · 3.46 KB
/
tileset.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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/*
Copyright 2015 StapleButter
This file is part of CoinKiller.
CoinKiller is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation, either version 3 of the License, or (at your option)
any later version.
CoinKiller is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with CoinKiller. If not, see http://www.gnu.org/licenses/.
*/
#ifndef TILESET_H
#define TILESET_H
#include "filesystem/filesystem.h"
#include "ctpk.h"
#include <QPainter>
#include <QList>
typedef QHash<quint32,quint8> TileGrid;
class Game;
struct ObjectRow
{
quint8 slopeFlags;
quint8 xRepeatStart, xRepeatEnd;
QList<quint8> data;
};
struct ObjectDef
{
quint8 width, height;
quint8 randomisation;
quint8 unkFlag; // whatever this is
quint8 slopeY; // where the second slope block starts
quint8 yRepeatStart, yRepeatEnd;
QList<ObjectRow> rows;
};
class Tileset
{
public:
Tileset(Game* game, QString name);
~Tileset();
QString getName() const { return name; }
int getSlot() { return slot; }
void drawTile(QPainter& painter, TileGrid& grid, int num, int x, int y, float zoom, int item);
void drawObject(QPainter& painter, TileGrid& grid, int num, int x, int y, int w, int h, float zoom);
quint8 getBehaviorByte(int tile, int byte);
void setBehaviorByte(int tile, int byte, quint8 value);
int getNumObjects() { return objectDefs.size(); }
ObjectDef* getObjectDef(int i) { return objectDefs[i]; }
quint8 getData(int objNbr, int x, int y, int byte);
void setData(int objNbr, int x, int y, int byte, int value);
void addObject(int objNbr);
void removeObject(int objNbr);
void moveObjectUp(int objNbr);
void moveObjectDown(int objNbr);
void resizeObject(int objNubr, int width, int height);
void setSlot(int slot);
void setInternalName(QString name);
quint16 getOverlayTile(int selTile);
quint16 getOverlayTileSlot(int selTile);
void setOverlayTile(int selTile, int ovTile, int slot);
bool getRandomizeH(int tile);
void setRandomizeH(int tile, bool value);
bool getRandomizeV(int tile);
void setRandomizeV(int tile, bool value);
quint8 getRandomizeTiles(int tile);
void setRandomizeTiles(int tile, quint8 value);
void setObjectBehavior(int selObj, int type, int hStart, int hEnd, int vStart, int vEnd);
void Render2DTiles(bool toggle) { draw2D = toggle; }
void Render3DOverlay(bool toggle) { draw3D = toggle; }
Game* game;
QImage& getImage();
void setImage(QImage& img, uint quality = 1, bool dither = false);
void save();
// temp function
void replaceCTPK(QString filename);
static QImage padTilesetImage(const QImage& img, quint32 outWidth = 512, quint32 outHeight = 512);
private:
QString name;
bool drawOverrides = false;
int slot;
SarcFilesystem* archive;
Ctpk* ctpk;
QImage texImage;
QList<ObjectDef*> objectDefs;
void drawRow(QPainter& painter, TileGrid& grid, ObjectDef& def, ObjectRow& row, int x, int y, int w, float zoom);
quint8 behaviors[441][8];
quint16 overlays3D[441];
bool draw3D;
bool draw2D;
};
#endif // TILESET_H