diff options
-rw-r--r-- | tools/mapedit/src/frame.cpp | 14 | ||||
-rw-r--r-- | tools/mapedit/src/frame.h | 2 | ||||
-rw-r--r-- | tools/mapedit/src/world.cpp | 7 | ||||
-rw-r--r-- | tools/mapedit/src/world.h | 2 |
4 files changed, 22 insertions, 3 deletions
diff --git a/tools/mapedit/src/frame.cpp b/tools/mapedit/src/frame.cpp index 934e0f8..94be15e 100644 --- a/tools/mapedit/src/frame.cpp +++ b/tools/mapedit/src/frame.cpp | |||
@@ -265,7 +265,13 @@ void MapeditFrame::OnOpen(wxCommandEvent&) | |||
265 | return; | 265 | return; |
266 | } | 266 | } |
267 | 267 | ||
268 | OpenWorld(openFileDialog.GetPath().ToStdString()); | 268 | if (OpenWorld(openFileDialog.GetPath().ToStdString())) |
269 | { | ||
270 | if (world->getEmpty()) | ||
271 | { | ||
272 | Close(true); | ||
273 | } | ||
274 | } | ||
269 | } | 275 | } |
270 | 276 | ||
271 | void MapeditFrame::OnSave(wxCommandEvent&) | 277 | void MapeditFrame::OnSave(wxCommandEvent&) |
@@ -429,17 +435,21 @@ void MapeditFrame::NewWorld() | |||
429 | LaunchWindow(std::unique_ptr<World>(new World())); | 435 | LaunchWindow(std::unique_ptr<World>(new World())); |
430 | } | 436 | } |
431 | 437 | ||
432 | void MapeditFrame::OpenWorld(std::string filename) | 438 | bool MapeditFrame::OpenWorld(std::string filename) |
433 | { | 439 | { |
434 | try | 440 | try |
435 | { | 441 | { |
436 | auto world = std::unique_ptr<World>(new World(filename)); | 442 | auto world = std::unique_ptr<World>(new World(filename)); |
437 | 443 | ||
438 | LaunchWindow(std::move(world)); | 444 | LaunchWindow(std::move(world)); |
445 | |||
446 | return true; | ||
439 | } catch (std::exception& ex) | 447 | } catch (std::exception& ex) |
440 | { | 448 | { |
441 | wxMessageBox(ex.what(), "Error loading world", wxOK | wxCENTRE | wxICON_ERROR); | 449 | wxMessageBox(ex.what(), "Error loading world", wxOK | wxCENTRE | wxICON_ERROR); |
442 | } | 450 | } |
451 | |||
452 | return false; | ||
443 | } | 453 | } |
444 | 454 | ||
445 | void MapeditFrame::LaunchWindow(std::unique_ptr<World> world) | 455 | void MapeditFrame::LaunchWindow(std::unique_ptr<World> world) |
diff --git a/tools/mapedit/src/frame.h b/tools/mapedit/src/frame.h index 4844485..6085eb2 100644 --- a/tools/mapedit/src/frame.h +++ b/tools/mapedit/src/frame.h | |||
@@ -33,7 +33,7 @@ class MapeditFrame : public wxFrame { | |||
33 | void MapDirtyDidChange(bool dirty); | 33 | void MapDirtyDidChange(bool dirty); |
34 | 34 | ||
35 | static void NewWorld(); | 35 | static void NewWorld(); |
36 | static void OpenWorld(std::string filename); | 36 | static bool OpenWorld(std::string filename); |
37 | 37 | ||
38 | std::list<wxWindow*>::iterator closer; | 38 | std::list<wxWindow*>::iterator closer; |
39 | 39 | ||
diff --git a/tools/mapedit/src/world.cpp b/tools/mapedit/src/world.cpp index f7b541d..c30f76c 100644 --- a/tools/mapedit/src/world.cpp +++ b/tools/mapedit/src/world.cpp | |||
@@ -9,6 +9,7 @@ World::World() | |||
9 | newMap(); | 9 | newMap(); |
10 | 10 | ||
11 | rootChildren.push_back(0); | 11 | rootChildren.push_back(0); |
12 | empty = true; | ||
12 | } | 13 | } |
13 | 14 | ||
14 | World::World(std::string filename) | 15 | World::World(std::string filename) |
@@ -170,6 +171,7 @@ std::shared_ptr<Map> World::getMap(int id) const | |||
170 | 171 | ||
171 | void World::setDirty(bool dirty) | 172 | void World::setDirty(bool dirty) |
172 | { | 173 | { |
174 | if (dirty) empty = false; | ||
173 | this->dirty = dirty; | 175 | this->dirty = dirty; |
174 | parent->MapDirtyDidChange(dirty); | 176 | parent->MapDirtyDidChange(dirty); |
175 | } | 177 | } |
@@ -372,3 +374,8 @@ void World::setLastMap(Map* map) | |||
372 | { | 374 | { |
373 | lastmap = map->getID(); | 375 | lastmap = map->getID(); |
374 | } | 376 | } |
377 | |||
378 | bool World::getEmpty() const | ||
379 | { | ||
380 | return empty; | ||
381 | } | ||
diff --git a/tools/mapedit/src/world.h b/tools/mapedit/src/world.h index c30f4b4..a2b5235 100644 --- a/tools/mapedit/src/world.h +++ b/tools/mapedit/src/world.h | |||
@@ -32,6 +32,7 @@ class World { | |||
32 | void setLastMap(Map* map); | 32 | void setLastMap(Map* map); |
33 | std::list<std::shared_ptr<Map>> getRootMaps() const; | 33 | std::list<std::shared_ptr<Map>> getRootMaps() const; |
34 | const std::map<int, std::shared_ptr<Map>> getMaps() const; | 34 | const std::map<int, std::shared_ptr<Map>> getMaps() const; |
35 | bool getEmpty() const; | ||
35 | 36 | ||
36 | private: | 37 | private: |
37 | MapeditFrame* parent; | 38 | MapeditFrame* parent; |
@@ -41,6 +42,7 @@ class World { | |||
41 | std::string filename; | 42 | std::string filename; |
42 | int lastmap = 0; | 43 | int lastmap = 0; |
43 | std::list<int> rootChildren; | 44 | std::list<int> rootChildren; |
45 | bool empty = false; | ||
44 | }; | 46 | }; |
45 | 47 | ||
46 | #endif | 48 | #endif |