diff options
Diffstat (limited to 'tools/mapedit/src/map.cpp')
-rw-r--r-- | tools/mapedit/src/map.cpp | 216 |
1 files changed, 180 insertions, 36 deletions
diff --git a/tools/mapedit/src/map.cpp b/tools/mapedit/src/map.cpp index 0db7031..fb675e8 100644 --- a/tools/mapedit/src/map.cpp +++ b/tools/mapedit/src/map.cpp | |||
@@ -1,5 +1,8 @@ | |||
1 | #include "map.h" | 1 | #include "map.h" |
2 | #include "frame.h" | 2 | #include "frame.h" |
3 | #include "object.h" | ||
4 | #include "world.h" | ||
5 | #include "consts.h" | ||
3 | 6 | ||
4 | Map::Map(int id, World* world) : id(id), world(world) | 7 | Map::Map(int id, World* world) : id(id), world(world) |
5 | { | 8 | { |
@@ -13,13 +16,19 @@ Map::Map(const Map& map) | |||
13 | 16 | ||
14 | id = map.id; | 17 | id = map.id; |
15 | title = map.title; | 18 | title = map.title; |
16 | leftmap = map.leftmap; | ||
17 | rightmap = map.rightmap; | ||
18 | objects = map.objects; | 19 | objects = map.objects; |
19 | world = map.world; | 20 | world = map.world; |
20 | treeItemId = map.treeItemId; | 21 | treeItemId = map.treeItemId; |
21 | children = map.children; | 22 | children = map.children; |
22 | hidden = map.hidden; | 23 | hidden = map.hidden; |
24 | leftType = map.leftType; | ||
25 | rightType = map.rightType; | ||
26 | upType = map.upType; | ||
27 | downType = map.downType; | ||
28 | leftMap = map.leftMap; | ||
29 | rightMap = map.rightMap; | ||
30 | downMap = map.downMap; | ||
31 | upMap = map.upMap; | ||
23 | } | 32 | } |
24 | 33 | ||
25 | Map::Map(Map&& map) : Map(-1, map.world) | 34 | Map::Map(Map&& map) : Map(-1, map.world) |
@@ -43,14 +52,67 @@ void swap(Map& first, Map& second) | |||
43 | { | 52 | { |
44 | std::swap(first.mapdata, second.mapdata); | 53 | std::swap(first.mapdata, second.mapdata); |
45 | std::swap(first.title, second.title); | 54 | std::swap(first.title, second.title); |
46 | std::swap(first.leftmap, second.leftmap); | ||
47 | std::swap(first.rightmap, second.rightmap); | ||
48 | std::swap(first.objects, second.objects); | 55 | std::swap(first.objects, second.objects); |
49 | std::swap(first.id, second.id); | 56 | std::swap(first.id, second.id); |
50 | std::swap(first.world, second.world); | 57 | std::swap(first.world, second.world); |
51 | std::swap(first.treeItemId, second.treeItemId); | 58 | std::swap(first.treeItemId, second.treeItemId); |
52 | std::swap(first.children, second.children); | 59 | std::swap(first.children, second.children); |
53 | std::swap(first.hidden, second.hidden); | 60 | std::swap(first.hidden, second.hidden); |
61 | std::swap(first.leftType, second.leftType); | ||
62 | std::swap(first.rightType, second.rightType); | ||
63 | std::swap(first.upType, second.upType); | ||
64 | std::swap(first.downType, second.downType); | ||
65 | std::swap(first.leftMap, second.leftMap); | ||
66 | std::swap(first.rightMap, second.rightMap); | ||
67 | std::swap(first.downMap, second.downMap); | ||
68 | std::swap(first.upMap, second.upMap); | ||
69 | } | ||
70 | |||
71 | std::list<Map::MoveType> Map::listMoveTypes() | ||
72 | { | ||
73 | return {MoveType::Wall, MoveType::Wrap, MoveType::Warp, MoveType::ReverseWarp}; | ||
74 | } | ||
75 | |||
76 | std::string Map::stringForMoveType(MoveType type) | ||
77 | { | ||
78 | switch (type) | ||
79 | { | ||
80 | case MoveType::Wall: return "Wall"; | ||
81 | case MoveType::Warp: return "Warp"; | ||
82 | case MoveType::Wrap: return "Wrap"; | ||
83 | case MoveType::ReverseWarp: return "Reverse Warp"; | ||
84 | } | ||
85 | } | ||
86 | |||
87 | bool Map::moveTypeTakesMap(MoveType type) | ||
88 | { | ||
89 | switch (type) | ||
90 | { | ||
91 | case MoveType::Wall: return false; | ||
92 | case MoveType::Wrap: return false; | ||
93 | case MoveType::Warp: return true; | ||
94 | case MoveType::ReverseWarp: return true; | ||
95 | } | ||
96 | } | ||
97 | |||
98 | std::string Map::shortForMoveType(MoveType type) | ||
99 | { | ||
100 | switch (type) | ||
101 | { | ||
102 | case MoveType::Wall: return "wall"; | ||
103 | case MoveType::Wrap: return "wrap"; | ||
104 | case MoveType::Warp: return "warp"; | ||
105 | case MoveType::ReverseWarp: return "reverseWarp"; | ||
106 | } | ||
107 | } | ||
108 | |||
109 | Map::MoveType Map::moveTypeForShort(std::string str) | ||
110 | { | ||
111 | if (str == "wrap") return MoveType::Wrap; | ||
112 | if (str == "warp") return MoveType::Warp; | ||
113 | if (str == "reverseWarp") return MoveType::ReverseWarp; | ||
114 | |||
115 | return MoveType::Wall; | ||
54 | } | 116 | } |
55 | 117 | ||
56 | int Map::getID() const | 118 | int Map::getID() const |
@@ -73,26 +135,6 @@ const std::list<std::shared_ptr<MapObjectEntry>>& Map::getObjects() const | |||
73 | return objects; | 135 | return objects; |
74 | } | 136 | } |
75 | 137 | ||
76 | std::shared_ptr<Map> Map::getLeftmap() const | ||
77 | { | ||
78 | if (leftmap == -1) | ||
79 | { | ||
80 | return std::shared_ptr<Map>(); | ||
81 | } else { | ||
82 | return world->getMap(leftmap); | ||
83 | } | ||
84 | } | ||
85 | |||
86 | std::shared_ptr<Map> Map::getRightmap() const | ||
87 | { | ||
88 | if (rightmap == -1) | ||
89 | { | ||
90 | return std::shared_ptr<Map>(); | ||
91 | } else { | ||
92 | return world->getMap(rightmap); | ||
93 | } | ||
94 | } | ||
95 | |||
96 | wxTreeItemId Map::getTreeItemId() const | 138 | wxTreeItemId Map::getTreeItemId() const |
97 | { | 139 | { |
98 | return treeItemId; | 140 | return treeItemId; |
@@ -125,6 +167,47 @@ bool Map::getHidden() const | |||
125 | return hidden; | 167 | return hidden; |
126 | } | 168 | } |
127 | 169 | ||
170 | Map::MoveType Map::getLeftMoveType() const | ||
171 | { | ||
172 | return leftType; | ||
173 | } | ||
174 | |||
175 | Map::MoveType Map::getRightMoveType() const | ||
176 | { | ||
177 | return rightType; | ||
178 | } | ||
179 | |||
180 | Map::MoveType Map::getUpMoveType() const | ||
181 | { | ||
182 | return upType; | ||
183 | } | ||
184 | |||
185 | Map::MoveType Map::getDownMoveType() const | ||
186 | { | ||
187 | return downType; | ||
188 | } | ||
189 | |||
190 | int Map::getLeftMoveMapID() const | ||
191 | { | ||
192 | return leftMap; | ||
193 | } | ||
194 | |||
195 | int Map::getRightMoveMapID() const | ||
196 | { | ||
197 | return rightMap; | ||
198 | } | ||
199 | |||
200 | int Map::getUpMoveMapID() const | ||
201 | { | ||
202 | return upMap; | ||
203 | } | ||
204 | |||
205 | int Map::getDownMoveMapID() const | ||
206 | { | ||
207 | return downMap; | ||
208 | } | ||
209 | |||
210 | |||
128 | void Map::setTitle(std::string title, bool dirty) | 211 | void Map::setTitle(std::string title, bool dirty) |
129 | { | 212 | { |
130 | this->title = title; | 213 | this->title = title; |
@@ -176,9 +259,39 @@ void Map::removeObject(std::shared_ptr<MapObjectEntry> obj, bool dirty) | |||
176 | } | 259 | } |
177 | } | 260 | } |
178 | 261 | ||
179 | void Map::setLeftmap(int id, bool dirty) | 262 | void Map::setTreeItemId(wxTreeItemId id) |
263 | { | ||
264 | this->treeItemId = id; | ||
265 | } | ||
266 | |||
267 | void Map::addChild(int id) | ||
268 | { | ||
269 | children.push_back(id); | ||
270 | } | ||
271 | |||
272 | void Map::setExpanded(bool exp) | ||
273 | { | ||
274 | expanded = exp; | ||
275 | } | ||
276 | |||
277 | void Map::setHidden(bool hid) | ||
278 | { | ||
279 | hidden = hid; | ||
280 | } | ||
281 | |||
282 | void Map::setLeftMoveType(Map::MoveType move, bool dirty) | ||
283 | { | ||
284 | leftType = move; | ||
285 | |||
286 | if (dirty) | ||
287 | { | ||
288 | world->setDirty(true); | ||
289 | } | ||
290 | } | ||
291 | |||
292 | void Map::setRightMoveType(Map::MoveType move, bool dirty) | ||
180 | { | 293 | { |
181 | leftmap = id; | 294 | rightType = move; |
182 | 295 | ||
183 | if (dirty) | 296 | if (dirty) |
184 | { | 297 | { |
@@ -186,9 +299,9 @@ void Map::setLeftmap(int id, bool dirty) | |||
186 | } | 299 | } |
187 | } | 300 | } |
188 | 301 | ||
189 | void Map::setRightmap(int id, bool dirty) | 302 | void Map::setUpMoveType(Map::MoveType move, bool dirty) |
190 | { | 303 | { |
191 | rightmap = id; | 304 | upType = move; |
192 | 305 | ||
193 | if (dirty) | 306 | if (dirty) |
194 | { | 307 | { |
@@ -196,22 +309,53 @@ void Map::setRightmap(int id, bool dirty) | |||
196 | } | 309 | } |
197 | } | 310 | } |
198 | 311 | ||
199 | void Map::setTreeItemId(wxTreeItemId id) | 312 | void Map::setDownMoveType(Map::MoveType move, bool dirty) |
200 | { | 313 | { |
201 | this->treeItemId = id; | 314 | downType = move; |
315 | |||
316 | if (dirty) | ||
317 | { | ||
318 | world->setDirty(true); | ||
319 | } | ||
202 | } | 320 | } |
203 | 321 | ||
204 | void Map::addChild(int id) | 322 | void Map::setLeftMoveMapID(int id, bool dirty) |
205 | { | 323 | { |
206 | children.push_back(id); | 324 | leftMap = id; |
325 | |||
326 | if (dirty) | ||
327 | { | ||
328 | world->setDirty(true); | ||
329 | } | ||
207 | } | 330 | } |
208 | 331 | ||
209 | void Map::setExpanded(bool exp) | 332 | void Map::setRightMoveMapID(int id, bool dirty) |
210 | { | 333 | { |
211 | expanded = exp; | 334 | rightMap = id; |
335 | |||
336 | if (dirty) | ||
337 | { | ||
338 | world->setDirty(true); | ||
339 | } | ||
212 | } | 340 | } |
213 | 341 | ||
214 | void Map::setHidden(bool hid) | 342 | void Map::setUpMoveMapID(int id, bool dirty) |
215 | { | 343 | { |
216 | hidden = hid; | 344 | upMap = id; |
345 | |||
346 | if (dirty) | ||
347 | { | ||
348 | world->setDirty(true); | ||
349 | } | ||
217 | } | 350 | } |
351 | |||
352 | void Map::setDownMoveMapID(int id, bool dirty) | ||
353 | { | ||
354 | downMap = id; | ||
355 | |||
356 | if (dirty) | ||
357 | { | ||
358 | world->setDirty(true); | ||
359 | } | ||
360 | } | ||
361 | |||