summary refs log tree commit diff stats
path: root/tools/mapedit/src/map.h
diff options
context:
space:
mode:
Diffstat (limited to 'tools/mapedit/src/map.h')
-rw-r--r--tools/mapedit/src/map.h72
1 files changed, 53 insertions, 19 deletions
diff --git a/tools/mapedit/src/map.h b/tools/mapedit/src/map.h index 34dcb33..46e5790 100644 --- a/tools/mapedit/src/map.h +++ b/tools/mapedit/src/map.h
@@ -1,28 +1,17 @@
1#ifndef MAP_H 1#ifndef MAP_H
2#define MAP_H 2#define MAP_H
3 3
4class Map;
5
6#include <string> 4#include <string>
7#include <exception> 5#include <exception>
8#include <utility> 6#include <utility>
9#include <list> 7#include <list>
10#include "object.h"
11#include <memory> 8#include <memory>
12#include "world.h"
13#include <wx/treectrl.h> 9#include <wx/treectrl.h>
14 10
11class MapObject;
12class World;
15class MapeditFrame; 13class MapeditFrame;
16 14
17const int TILE_WIDTH = 8;
18const int TILE_HEIGHT = 8;
19const int GAME_WIDTH = 320;
20const int GAME_HEIGHT = 200;
21const int MAP_WIDTH = GAME_WIDTH/TILE_WIDTH;
22const int MAP_HEIGHT = GAME_HEIGHT/TILE_HEIGHT - 1;
23const int PLAYER_WIDTH[5] = {10, 0, 0, 0, 0};
24const int PLAYER_HEIGHT[5] = {12, 0, 0, 0, 0};
25
26class MapLoadException: public std::exception 15class MapLoadException: public std::exception
27{ 16{
28 public: 17 public:
@@ -75,29 +64,54 @@ class Map {
75 Map& operator= (Map other); 64 Map& operator= (Map other);
76 friend void swap(Map& first, Map& second); 65 friend void swap(Map& first, Map& second);
77 66
67 enum class MoveType {
68 Wall,
69 Wrap,
70 Warp,
71 ReverseWarp
72 };
73
74 static std::list<MoveType> listMoveTypes();
75 static std::string stringForMoveType(MoveType type);
76 static bool moveTypeTakesMap(MoveType type);
77 static std::string shortForMoveType(MoveType type);
78 static MoveType moveTypeForShort(std::string str);
79
78 int getID() const; 80 int getID() const;
79 std::string getTitle() const; 81 std::string getTitle() const;
80 int getTileAt(int x, int y) const; 82 int getTileAt(int x, int y) const;
81 const std::list<std::shared_ptr<MapObjectEntry>>& getObjects() const; 83 const std::list<std::shared_ptr<MapObjectEntry>>& getObjects() const;
82 std::shared_ptr<Map> getLeftmap() const;
83 std::shared_ptr<Map> getRightmap() const;
84 wxTreeItemId getTreeItemId() const; 84 wxTreeItemId getTreeItemId() const;
85 std::list<std::shared_ptr<Map>> getChildren() const; 85 std::list<std::shared_ptr<Map>> getChildren() const;
86 bool getExpanded() const; 86 bool getExpanded() const;
87 World* getWorld() const; 87 World* getWorld() const;
88 bool getHidden() const; 88 bool getHidden() const;
89 MoveType getLeftMoveType() const;
90 MoveType getRightMoveType() const;
91 MoveType getUpMoveType() const;
92 MoveType getDownMoveType() const;
93 int getLeftMoveMapID() const;
94 int getRightMoveMapID() const;
95 int getUpMoveMapID() const;
96 int getDownMoveMapID() const;
89 97
90 void setTitle(std::string title, bool dirty = true); 98 void setTitle(std::string title, bool dirty = true);
91 void setTileAt(int x, int y, int tile, bool dirty = true); 99 void setTileAt(int x, int y, int tile, bool dirty = true);
92 void setMapdata(int* mapdata, bool dirty = true); 100 void setMapdata(int* mapdata, bool dirty = true);
93 void addObject(std::shared_ptr<MapObjectEntry> obj, bool dirty = true); 101 void addObject(std::shared_ptr<MapObjectEntry> obj, bool dirty = true);
94 void removeObject(std::shared_ptr<MapObjectEntry> obj, bool dirty = true); 102 void removeObject(std::shared_ptr<MapObjectEntry> obj, bool dirty = true);
95 void setLeftmap(int id, bool dirty = true);
96 void setRightmap(int id, bool dirty = true);
97 void setTreeItemId(wxTreeItemId id); 103 void setTreeItemId(wxTreeItemId id);
98 void addChild(int id); 104 void addChild(int id);
99 void setExpanded(bool exp); 105 void setExpanded(bool exp);
100 void setHidden(bool hid); 106 void setHidden(bool hid);
107 void setLeftMoveType(MoveType move, bool dirty = true);
108 void setRightMoveType(MoveType move, bool dirty = true);
109 void setUpMoveType(MoveType move, bool dirty = true);
110 void setDownMoveType(MoveType move, bool dirty = true);
111 void setLeftMoveMapID(int id, bool dirty = true);
112 void setRightMoveMapID(int id, bool dirty = true);
113 void setUpMoveMapID(int id, bool dirty = true);
114 void setDownMoveMapID(int id, bool dirty = true);
101 115
102 private: 116 private:
103 int id; 117 int id;
@@ -106,11 +120,31 @@ class Map {
106 int* mapdata; 120 int* mapdata;
107 std::string title {"Untitled Map"}; 121 std::string title {"Untitled Map"};
108 std::list<int> children; 122 std::list<int> children;
109 int leftmap = -1;
110 int rightmap = -1;
111 wxTreeItemId treeItemId; 123 wxTreeItemId treeItemId;
112 bool expanded = false; 124 bool expanded = false;
113 bool hidden = false; 125 bool hidden = false;
126 MoveType leftType = MoveType::Wall;
127 MoveType rightType = MoveType::Wall;
128 MoveType upType = MoveType::Wall;
129 MoveType downType = MoveType::Wall;
130 int leftMap = 0;
131 int rightMap = 0;
132 int upMap = 0;
133 int downMap = 0;
134};
135
136class MapPtrCtr : public wxTreeItemData {
137 public:
138 Map* map;
139
140 MapPtrCtr(Map* map) : map(map) {}
141};
142
143class MoveTypeCtr {
144 public:
145 Map::MoveType type;
146
147 MoveTypeCtr(Map::MoveType type) : type(type) {}
114}; 148};
115 149
116#endif 150#endif