diff options
author | Kelly Rauchenberger <fefferburbia@gmail.com> | 2015-03-15 19:27:55 -0400 |
---|---|---|
committer | Kelly Rauchenberger <fefferburbia@gmail.com> | 2015-03-15 19:27:55 -0400 |
commit | dca2aea57957c6af1af535f23ae392e7517ebd51 (patch) | |
tree | 170d7e471d3872c07e508998320a3a5e537454fe /tools/mapedit/src | |
parent | c125c1acc0b20c3e405dddb5c835d9734aa0472c (diff) | |
download | therapy-dca2aea57957c6af1af535f23ae392e7517ebd51.tar.gz therapy-dca2aea57957c6af1af535f23ae392e7517ebd51.tar.bz2 therapy-dca2aea57957c6af1af535f23ae392e7517ebd51.zip |
Fixed functionality of quit menu item in map editor
Diffstat (limited to 'tools/mapedit/src')
-rw-r--r-- | tools/mapedit/src/frame.cpp | 37 | ||||
-rw-r--r-- | tools/mapedit/src/frame.h | 10 | ||||
-rw-r--r-- | tools/mapedit/src/main.cpp | 4 |
3 files changed, 41 insertions, 10 deletions
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 @@ | |||
3 | #include "tile_widget.h" | 3 | #include "tile_widget.h" |
4 | #include <wx/splitter.h> | 4 | #include <wx/splitter.h> |
5 | #include "panel.h" | 5 | #include "panel.h" |
6 | #include <list> | ||
7 | |||
8 | static std::list<wxWindow*> openWindows; | ||
6 | 9 | ||
7 | enum { | 10 | enum { |
8 | MENU_VIEW_ZOOM_IN, | 11 | MENU_VIEW_ZOOM_IN, |
@@ -102,6 +105,8 @@ void MapeditFrame::OnExit(wxCloseEvent& event) | |||
102 | } | 105 | } |
103 | } | 106 | } |
104 | 107 | ||
108 | *closer = nullptr; | ||
109 | |||
105 | event.Skip(); | 110 | event.Skip(); |
106 | } | 111 | } |
107 | 112 | ||
@@ -122,8 +127,7 @@ void MapeditFrame::ZoomOut(wxCommandEvent& event) | |||
122 | 127 | ||
123 | void MapeditFrame::OnNew(wxCommandEvent& event) | 128 | void MapeditFrame::OnNew(wxCommandEvent& event) |
124 | { | 129 | { |
125 | MapeditFrame* frame = new MapeditFrame(); | 130 | NewMap(); |
126 | frame->Show(true); | ||
127 | } | 131 | } |
128 | 132 | ||
129 | void MapeditFrame::OnOpen(wxCommandEvent& event) | 133 | void MapeditFrame::OnOpen(wxCommandEvent& event) |
@@ -134,9 +138,7 @@ void MapeditFrame::OnOpen(wxCommandEvent& event) | |||
134 | return; | 138 | return; |
135 | } | 139 | } |
136 | 140 | ||
137 | std::string filename = openFileDialog.GetPath().ToStdString(); | 141 | OpenMap(openFileDialog.GetPath().c_str()); |
138 | MapeditFrame* frame = new MapeditFrame(Map(filename), filename); | ||
139 | frame->Show(true); | ||
140 | } | 142 | } |
141 | 143 | ||
142 | void MapeditFrame::OnSave(wxCommandEvent& event) | 144 | void MapeditFrame::OnSave(wxCommandEvent& event) |
@@ -162,10 +164,33 @@ void MapeditFrame::OnClose(wxCommandEvent& event) | |||
162 | 164 | ||
163 | void MapeditFrame::OnQuit(wxCommandEvent& event) | 165 | void MapeditFrame::OnQuit(wxCommandEvent& event) |
164 | { | 166 | { |
165 | // TODO | 167 | for (auto window : openWindows) |
168 | { | ||
169 | if (window != nullptr) | ||
170 | { | ||
171 | window->Close(false); | ||
172 | } | ||
173 | } | ||
166 | } | 174 | } |
167 | 175 | ||
168 | void MapeditFrame::OnTitleChange(wxCommandEvent& event) | 176 | void MapeditFrame::OnTitleChange(wxCommandEvent& event) |
169 | { | 177 | { |
170 | map.setTitle(titleBox->GetLineText(0).ToStdString()); | 178 | map.setTitle(titleBox->GetLineText(0).ToStdString()); |
171 | } | 179 | } |
180 | |||
181 | void MapeditFrame::NewMap() | ||
182 | { | ||
183 | LaunchWindow(Map(), ""); | ||
184 | } | ||
185 | |||
186 | void MapeditFrame::OpenMap(const char* filename) | ||
187 | { | ||
188 | LaunchWindow(Map(filename), filename); | ||
189 | } | ||
190 | |||
191 | void MapeditFrame::LaunchWindow(Map map, const char* filename) | ||
192 | { | ||
193 | MapeditFrame* frame = new MapeditFrame(map, filename); | ||
194 | frame->closer = openWindows.insert(end(openWindows), frame); | ||
195 | frame->Show(true); | ||
196 | } | ||
diff --git a/tools/mapedit/src/frame.h b/tools/mapedit/src/frame.h index 11990b1..5e119f3 100644 --- a/tools/mapedit/src/frame.h +++ b/tools/mapedit/src/frame.h | |||
@@ -10,15 +10,23 @@ | |||
10 | #include "map.h" | 10 | #include "map.h" |
11 | #include "widget.h" | 11 | #include "widget.h" |
12 | #include "tile_widget.h" | 12 | #include "tile_widget.h" |
13 | #include <list> | ||
13 | 14 | ||
14 | class MapeditFrame : public wxFrame { | 15 | class MapeditFrame : public wxFrame { |
15 | public: | 16 | public: |
16 | MapeditFrame() : MapeditFrame(Map(), "") {} | 17 | MapeditFrame() {} |
17 | MapeditFrame(Map map, std::string filename); | 18 | MapeditFrame(Map map, std::string filename); |
18 | 19 | ||
19 | MapeditWidget* GetMapEditor(); | 20 | MapeditWidget* GetMapEditor(); |
21 | |||
22 | static void NewMap(); | ||
23 | static void OpenMap(const char* filename); | ||
24 | |||
25 | std::list<wxWindow*>::iterator closer; | ||
20 | 26 | ||
21 | private: | 27 | private: |
28 | static void LaunchWindow(Map map, const char* filename); | ||
29 | |||
22 | void ZoomIn(wxCommandEvent& event); | 30 | void ZoomIn(wxCommandEvent& event); |
23 | void ZoomOut(wxCommandEvent& event); | 31 | void ZoomOut(wxCommandEvent& event); |
24 | void OnNew(wxCommandEvent& event); | 32 | void OnNew(wxCommandEvent& event); |
diff --git a/tools/mapedit/src/main.cpp b/tools/mapedit/src/main.cpp index cfc5a46..91dd98f 100644 --- a/tools/mapedit/src/main.cpp +++ b/tools/mapedit/src/main.cpp | |||
@@ -18,9 +18,7 @@ bool MapeditApp::OnInit() | |||
18 | { | 18 | { |
19 | wxInitAllImageHandlers(); | 19 | wxInitAllImageHandlers(); |
20 | 20 | ||
21 | MapeditFrame* frame = new MapeditFrame(); | 21 | MapeditFrame::NewMap(); |
22 | SetTopWindow(frame); | ||
23 | frame->Show(true); | ||
24 | 22 | ||
25 | return true; | 23 | return true; |
26 | } | 24 | } |