1//////////////////////////////////////////////////////////////////////
2// This file is part of Remere's Map Editor
3//////////////////////////////////////////////////////////////////////
4// Remere's Map Editor is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8//
9// Remere's Map Editor is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with this program. If not, see <http://www.gnu.org/licenses/>.
16//////////////////////////////////////////////////////////////////////
17
18#ifndef RME_WALL_BRUSH_H
19#define RME_WALL_BRUSH_H
20
21#include "brush.h"
22
23//=============================================================================
24// Wallbrush, for drawing walls
25
26class WallBrush : public TerrainBrush {
27public:
28 static void init();
29
30 WallBrush();
31 virtual ~WallBrush();
32
33 bool isWall() const {
34 return true;
35 }
36 WallBrush* asWall() {
37 return static_cast<WallBrush*>(this);
38 }
39
40 virtual bool load(pugi::xml_node node, wxArrayString& warnings);
41
42 virtual bool canDraw(BaseMap* map, const Position& position) const {
43 return true;
44 }
45
46 // Draw to the target tile
47 // Note that this actually only puts the first WALL_NORMAL item on the tile.
48 // It's up to the doWalls function to change it to the correct alignment
49 virtual void draw(BaseMap* map, Tile* tile, void* parameter);
50 virtual void undraw(BaseMap* map, Tile* tile);
51 // Creates walls on the target tile (does not depend on brush in any way)
52 static void doWalls(BaseMap* map, Tile* tile);
53
54 // If the specified wall item is part of this wall
55 bool hasWall(Item* item);
56 ::DoorType getDoorTypeFromID(uint16_t id);
57
58 virtual bool canSmear() const {
59 return false;
60 }
61 virtual bool canDrag() const {
62 return true;
63 }
64
65 static uint32_t full_border_types[16];
66 static uint32_t half_border_types[16];
67
68protected:
69 struct WallType {
70 int chance;
71 uint16_t id;
72 };
73 struct WallNode {
74 WallNode() :
75 total_chance(0) { }
76 int total_chance;
77 std::vector<WallType> items;
78 };
79 struct DoorType {
80 ::DoorType type;
81 uint16_t id;
82 bool locked;
83 };
84 WallNode wall_items[17];
85 std::vector<DoorType> door_items[17];
86
87 WallBrush* redirect_to;
88
89 friend class DoorBrush;
90};
91
92//=============================================================================
93// Wall decoration brush, for drawing decoration on walls
94
95class WallDecorationBrush : public WallBrush {
96public:
97 WallDecorationBrush();
98 virtual ~WallDecorationBrush();
99
100 bool isWallDecoration() const {
101 return true;
102 }
103 WallDecorationBrush* asWallDecoration() {
104 return static_cast<WallDecorationBrush*>(this);
105 }
106
107 // We use the exact same loading algorithm as normal walls
108
109 virtual void draw(BaseMap* map, Tile* tile, void* parameter);
110};
111
112#endif
113