From dca2aea57957c6af1af535f23ae392e7517ebd51 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Sun, 15 Mar 2015 19:27:55 -0400 Subject: Fixed functionality of quit menu item in map editor --- tools/mapedit/src/frame.cpp | 37 +++++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-) (limited to 'tools/mapedit/src/frame.cpp') diff --git a/tools/mapedit/src/frame.cpp b/tools/mapedit/src/frame.cpp index b3808e2..e0df030 100644 --- a/tools/mapedit/src/frame.cpp +++ b/tools/mapedit/src/frame.cpp @@ -3,6 +3,9 @@ #include "tile_widget.h" #include #include "panel.h" +#include + +static std::list openWindows; enum { MENU_VIEW_ZOOM_IN, @@ -102,6 +105,8 @@ void MapeditFrame::OnExit(wxCloseEvent& event) } } + *closer = nullptr; + event.Skip(); } @@ -122,8 +127,7 @@ void MapeditFrame::ZoomOut(wxCommandEvent& event) void MapeditFrame::OnNew(wxCommandEvent& event) { - MapeditFrame* frame = new MapeditFrame(); - frame->Show(true); + NewMap(); } void MapeditFrame::OnOpen(wxCommandEvent& event) @@ -134,9 +138,7 @@ void MapeditFrame::OnOpen(wxCommandEvent& event) return; } - std::string filename = openFileDialog.GetPath().ToStdString(); - MapeditFrame* frame = new MapeditFrame(Map(filename), filename); - frame->Show(true); + OpenMap(openFileDialog.GetPath().c_str()); } void MapeditFrame::OnSave(wxCommandEvent& event) @@ -162,10 +164,33 @@ void MapeditFrame::OnClose(wxCommandEvent& event) void MapeditFrame::OnQuit(wxCommandEvent& event) { - // TODO + for (auto window : openWindows) + { + if (window != nullptr) + { + window->Close(false); + } + } } void MapeditFrame::OnTitleChange(wxCommandEvent& event) { map.setTitle(titleBox->GetLineText(0).ToStdString()); } + +void MapeditFrame::NewMap() +{ + LaunchWindow(Map(), ""); +} + +void MapeditFrame::OpenMap(const char* filename) +{ + LaunchWindow(Map(filename), filename); +} + +void MapeditFrame::LaunchWindow(Map map, const char* filename) +{ + MapeditFrame* frame = new MapeditFrame(map, filename); + frame->closer = openWindows.insert(end(openWindows), frame); + frame->Show(true); +} -- cgit 1.4.1