From 8b61d93fc869ea39a78cdc134002ef11bf3e69d3 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Mon, 16 Mar 2015 17:20:03 -0400 Subject: Opening a file in the map editor closes the current window if the current window is a blank slate --- tools/mapedit/src/frame.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'tools/mapedit/src/frame.cpp') 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&) return; } - OpenWorld(openFileDialog.GetPath().ToStdString()); + if (OpenWorld(openFileDialog.GetPath().ToStdString())) + { + if (world->getEmpty()) + { + Close(true); + } + } } void MapeditFrame::OnSave(wxCommandEvent&) @@ -429,17 +435,21 @@ void MapeditFrame::NewWorld() LaunchWindow(std::unique_ptr(new World())); } -void MapeditFrame::OpenWorld(std::string filename) +bool MapeditFrame::OpenWorld(std::string filename) { try { auto world = std::unique_ptr(new World(filename)); LaunchWindow(std::move(world)); + + return true; } catch (std::exception& ex) { wxMessageBox(ex.what(), "Error loading world", wxOK | wxCENTRE | wxICON_ERROR); } + + return false; } void MapeditFrame::LaunchWindow(std::unique_ptr world) -- cgit 1.4.1