1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  *
21  */
22 
23 #ifndef NUVIE_FILES_TMX_MAP_H
24 #define NUVIE_FILES_TMX_MAP_H
25 
26 #include "ultima/nuvie/core/nuvie_defs.h"
27 #include "ultima/nuvie/files/nuvie_io_file.h"
28 
29 namespace Ultima {
30 namespace Nuvie {
31 
32 class Map;
33 class ObjManager;
34 class TileManager;
35 class NuvieIOFileWrite;
36 
37 class TMXMap {
38 private:
39 	unsigned char *mapdata;
40 	NuvieIOFileWrite file;
41 	TileManager *tile_manager;
42 	Map *map;
43 	ObjManager *obj_manager;
44 	Std::string savedir;
45 	Std::string savename;
46 	nuvie_game_t game_type;
47 
48 public:
49 	TMXMap(TileManager *tm, Map *m, ObjManager *om);
50 	virtual ~TMXMap();
51 	bool exportTmxMapFiles(Std::string dir, nuvie_game_t type);
52 private:
53 	bool exportMapLevel(uint8 level);
54 	void writeRoofTileset(uint8 level);
55 	void writeLayer(NuvieIOFileWrite *tmx, uint16 width, Std::string layerName,
56 		uint16 gidOffset, uint16 bitsPerTile, const unsigned char *data);
57 	void writeObjectLayer(NuvieIOFileWrite *tmx, uint8 level);
58 	void writeObjects(NuvieIOFileWrite *tmx, uint8 level, bool forceLower, bool toptiles);
59 	Std::string writeObjectTile(Obj *obj, Std::string nameSuffix, uint16 tile_num, uint16 x, uint16 y, bool forceLower, bool toptile);
60 	Std::string sint32ToString(sint32 value);
61 	Std::string boolToString(bool value);
62 	bool canDrawTile(Tile *t, bool forceLower, bool toptile);
63 };
64 
65 } // End of namespace Nuvie
66 } // End of namespace Ultima
67 
68 #endif
69