table_brush.h

main 87 lines · 2.2 KB Raw
Alex Alex Commit Map Editor 18/10/2026 23:40
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_TABLE_BRUSH_H
19#define RME_TABLE_BRUSH_H
20
21#include "brush.h"
22
23//=============================================================================
24// Tablebrush, for tables, and some things that behave like tables
25// and with tables I really mean counters.
26
27class TableBrush : public Brush {
28public:
29 static void init();
30
31 TableBrush();
32 virtual ~TableBrush();
33
34 bool isTable() const {
35 return true;
36 }
37 TableBrush* asTable() {
38 return static_cast<TableBrush*>(this);
39 }
40
41 virtual bool load(pugi::xml_node node, wxArrayString& warnings);
42
43 virtual bool canDraw(BaseMap* map, const Position& position) const;
44 virtual void draw(BaseMap* map, Tile* tile, void* parameter);
45 virtual void undraw(BaseMap* map, Tile* tile);
46
47 static void doTables(BaseMap* map, Tile* tile);
48
49 virtual int getLookID() const {
50 return look_id;
51 }
52
53 virtual std::string getName() const {
54 return name;
55 }
56 virtual void setName(const std::string& newName) {
57 name = newName;
58 }
59
60 virtual bool needBorders() const {
61 return true;
62 }
63
64protected:
65 struct TableType {
66 TableType() :
67 chance(0), item_id(0) { }
68 int chance;
69 uint16_t item_id;
70 };
71
72 struct TableNode {
73 TableNode() :
74 total_chance(0) { }
75 int total_chance;
76 std::vector<TableType> items;
77 };
78
79 std::string name;
80 uint16_t look_id;
81 TableNode table_items[7];
82
83 static uint32_t table_types[256];
84};
85
86#endif
87
Top