diff options
Diffstat (limited to 'tools/mapedit/src/map.cpp')
-rw-r--r-- | tools/mapedit/src/map.cpp | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/tools/mapedit/src/map.cpp b/tools/mapedit/src/map.cpp index 2799a4e..f9c07fc 100644 --- a/tools/mapedit/src/map.cpp +++ b/tools/mapedit/src/map.cpp | |||
@@ -2,6 +2,7 @@ | |||
2 | #include <libxml/parser.h> | 2 | #include <libxml/parser.h> |
3 | #include <libxml/xmlwriter.h> | 3 | #include <libxml/xmlwriter.h> |
4 | #include <sstream> | 4 | #include <sstream> |
5 | #include "frame.h" | ||
5 | 6 | ||
6 | Map::Map() | 7 | Map::Map() |
7 | { | 8 | { |
@@ -96,6 +97,7 @@ Map::Map(const Map& map) | |||
96 | rightmap = map.rightmap; | 97 | rightmap = map.rightmap; |
97 | dirty = map.dirty; | 98 | dirty = map.dirty; |
98 | objects = map.objects; | 99 | objects = map.objects; |
100 | frame = map.frame; | ||
99 | } | 101 | } |
100 | 102 | ||
101 | Map::Map(Map&& map) : Map() | 103 | Map::Map(Map&& map) : Map() |
@@ -123,6 +125,7 @@ void swap(Map& first, Map& second) | |||
123 | std::swap(first.rightmap, second.rightmap); | 125 | std::swap(first.rightmap, second.rightmap); |
124 | std::swap(first.dirty, second.dirty); | 126 | std::swap(first.dirty, second.dirty); |
125 | std::swap(first.objects, second.objects); | 127 | std::swap(first.objects, second.objects); |
128 | std::swap(first.frame, second.frame); | ||
126 | } | 129 | } |
127 | 130 | ||
128 | #define MY_ENCODING "ISO-8859-1" | 131 | #define MY_ENCODING "ISO-8859-1" |
@@ -197,7 +200,7 @@ void Map::save(std::string name) | |||
197 | 200 | ||
198 | xmlFreeTextWriter(writer); | 201 | xmlFreeTextWriter(writer); |
199 | 202 | ||
200 | dirty = false; | 203 | setDirty(false); |
201 | } | 204 | } |
202 | 205 | ||
203 | bool Map::hasUnsavedChanges() const | 206 | bool Map::hasUnsavedChanges() const |
@@ -207,7 +210,7 @@ bool Map::hasUnsavedChanges() const | |||
207 | 210 | ||
208 | void Map::setTileAt(int x, int y, int tile) | 211 | void Map::setTileAt(int x, int y, int tile) |
209 | { | 212 | { |
210 | dirty = true; | 213 | setDirty(true); |
211 | mapdata[x+y*MAP_WIDTH] = tile; | 214 | mapdata[x+y*MAP_WIDTH] = tile; |
212 | } | 215 | } |
213 | 216 | ||
@@ -223,7 +226,7 @@ std::string Map::getTitle() const | |||
223 | 226 | ||
224 | void Map::setTitle(std::string title) | 227 | void Map::setTitle(std::string title) |
225 | { | 228 | { |
226 | dirty = true; | 229 | setDirty(true); |
227 | this->title = title; | 230 | this->title = title; |
228 | } | 231 | } |
229 | 232 | ||
@@ -234,12 +237,27 @@ const std::list<std::shared_ptr<MapObjectEntry>>& Map::getObjects() const | |||
234 | 237 | ||
235 | void Map::addObject(std::shared_ptr<MapObjectEntry>& obj) | 238 | void Map::addObject(std::shared_ptr<MapObjectEntry>& obj) |
236 | { | 239 | { |
237 | dirty = true; | 240 | setDirty(true); |
238 | objects.push_back(obj); | 241 | objects.push_back(obj); |
239 | } | 242 | } |
240 | 243 | ||
241 | void Map::removeObject(std::shared_ptr<MapObjectEntry>& obj) | 244 | void Map::removeObject(std::shared_ptr<MapObjectEntry>& obj) |
242 | { | 245 | { |
243 | dirty = true; | 246 | setDirty(true); |
244 | objects.remove(obj); | 247 | objects.remove(obj); |
245 | } | 248 | } |
249 | |||
250 | bool Map::getDirty() const | ||
251 | { | ||
252 | return dirty; | ||
253 | } | ||
254 | |||
255 | void Map::setDirty(bool dirty) | ||
256 | { | ||
257 | this->dirty = dirty; | ||
258 | |||
259 | if (frame != nullptr) | ||
260 | { | ||
261 | frame->MapDirtyDidChange(dirty); | ||
262 | } | ||
263 | } | ||