-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathclasstilemaps.cpp
64 lines (54 loc) · 1.85 KB
/
classtilemaps.cpp
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
/*
This file is part of Retro Graphics Toolkit
Retro Graphics Toolkit 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 any later version.
Retro Graphics Toolkit 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 Retro Graphics Toolkit. If not, see <http://www.gnu.org/licenses/>.
Copyright Sega16 (or whatever you wish to call me) (2012-2018)
*/
#include "classtilemaps.h"
tilemaps::tilemaps(Project*prj) {
this->prj = prj;
maps.emplace_back(prj);
maps[0].planeName.assign("0");
}
tilemaps::tilemaps(const tilemaps&other, Project*prj) {
this->prj = prj;
unsigned cnt = other.maps.size();
maps.reserve(cnt);
for (unsigned i = 0; i < cnt; ++i)
maps.emplace_back(other.maps[i], prj);
}
void tilemaps::setPlaneCnt(unsigned cnt) {
unsigned oldCnt = maps.size();
if (cnt > oldCnt) {
maps.reserve(cnt);
for (unsigned i = oldCnt; i < cnt; ++i) {
char tmp[16];
snprintf(tmp, 16, "%u", i);
maps.emplace_back(tileMap(prj));
maps[i].planeName.assign(tmp);
}
} else if (cnt < oldCnt) {
for (int i = oldCnt; i > (int)cnt; --i)
maps.pop_back();
}
}
void tilemaps::changePrjPtr(Project*prj) {
this->prj = prj;
for (unsigned i = 0; i < maps.size(); ++i)
maps[i].prj = prj;
}
void tilemaps::swapTile(unsigned oldTile, unsigned newTile) {
for (unsigned i = 0; i < maps.size(); ++i)
maps[i].swapTile(oldTile, newTile);
}
void tilemaps::fixPaletteRows(unsigned num, unsigned dom) {
for (unsigned i = 0; i < maps.size(); ++i)
maps[i].fixPaletteRows(num, dom);
}