diff options
Diffstat (limited to 'tools/mapedit/src/frame.cpp')
-rw-r--r-- | tools/mapedit/src/frame.cpp | 287 |
1 files changed, 275 insertions, 12 deletions
diff --git a/tools/mapedit/src/frame.cpp b/tools/mapedit/src/frame.cpp index 2f85905..b8b4326 100644 --- a/tools/mapedit/src/frame.cpp +++ b/tools/mapedit/src/frame.cpp | |||
@@ -1,11 +1,15 @@ | |||
1 | #include "frame.h" | 1 | #include "frame.h" |
2 | #include "widget.h" | 2 | #include "mapselect_combo.h" |
3 | #include "tile_widget.h" | ||
4 | #include <wx/statline.h> | 3 | #include <wx/statline.h> |
5 | #include "panel.h" | ||
6 | #include <list> | 4 | #include <list> |
7 | #include <exception> | 5 | #include <exception> |
8 | #include <sstream> | 6 | #include <sstream> |
7 | #include "widget.h" | ||
8 | #include "tile_widget.h" | ||
9 | #include "panel.h" | ||
10 | #include "map.h" | ||
11 | #include "undo.h" | ||
12 | #include "object.h" | ||
9 | 13 | ||
10 | static std::list<wxWindow*> openWindows; | 14 | static std::list<wxWindow*> openWindows; |
11 | 15 | ||
@@ -33,7 +37,15 @@ enum { | |||
33 | SET_STARTPOS_BUTTON, | 37 | SET_STARTPOS_BUTTON, |
34 | CANCEL_STARTPOS_BUTTON, | 38 | CANCEL_STARTPOS_BUTTON, |
35 | LAYOUT_ONE_SPLITTER, | 39 | LAYOUT_ONE_SPLITTER, |
36 | LAYOUT_THREE_SPLITTER | 40 | LAYOUT_THREE_SPLITTER, |
41 | LEFTMAP_TYPE_CHOICE, | ||
42 | LEFTMAP_MAP_CHOICE, | ||
43 | RIGHTMAP_TYPE_CHOICE, | ||
44 | RIGHTMAP_MAP_CHOICE, | ||
45 | UPMAP_TYPE_CHOICE, | ||
46 | UPMAP_MAP_CHOICE, | ||
47 | DOWNMAP_TYPE_CHOICE, | ||
48 | DOWNMAP_MAP_CHOICE | ||
37 | }; | 49 | }; |
38 | 50 | ||
39 | wxBEGIN_EVENT_TABLE(MapeditFrame, wxFrame) | 51 | wxBEGIN_EVENT_TABLE(MapeditFrame, wxFrame) |
@@ -67,9 +79,17 @@ wxBEGIN_EVENT_TABLE(MapeditFrame, wxFrame) | |||
67 | EVT_BUTTON(CANCEL_STARTPOS_BUTTON, MapeditFrame::OnCancelSetStartpos) | 79 | EVT_BUTTON(CANCEL_STARTPOS_BUTTON, MapeditFrame::OnCancelSetStartpos) |
68 | EVT_SPLITTER_SASH_POS_CHANGING(LAYOUT_ONE_SPLITTER, MapeditFrame::OnOneMovingSash) | 80 | EVT_SPLITTER_SASH_POS_CHANGING(LAYOUT_ONE_SPLITTER, MapeditFrame::OnOneMovingSash) |
69 | EVT_SPLITTER_SASH_POS_CHANGING(LAYOUT_THREE_SPLITTER, MapeditFrame::OnThreeMovingSash) | 81 | EVT_SPLITTER_SASH_POS_CHANGING(LAYOUT_THREE_SPLITTER, MapeditFrame::OnThreeMovingSash) |
82 | EVT_CHOICE(LEFTMAP_TYPE_CHOICE, MapeditFrame::OnSetLeftmapType) | ||
83 | EVT_CHOICE(RIGHTMAP_TYPE_CHOICE, MapeditFrame::OnSetRightmapType) | ||
84 | EVT_CHOICE(UPMAP_TYPE_CHOICE, MapeditFrame::OnSetUpmapType) | ||
85 | EVT_CHOICE(DOWNMAP_TYPE_CHOICE, MapeditFrame::OnSetDownmapType) | ||
86 | EVT_COMBOBOX_CLOSEUP(LEFTMAP_MAP_CHOICE, MapeditFrame::OnSetLeftmapMap) | ||
87 | EVT_COMBOBOX_CLOSEUP(RIGHTMAP_MAP_CHOICE, MapeditFrame::OnSetRightmapMap) | ||
88 | EVT_COMBOBOX_CLOSEUP(UPMAP_MAP_CHOICE, MapeditFrame::OnSetUpmapMap) | ||
89 | EVT_COMBOBOX_CLOSEUP(DOWNMAP_MAP_CHOICE, MapeditFrame::OnSetDownmapMap) | ||
70 | wxEND_EVENT_TABLE() | 90 | wxEND_EVENT_TABLE() |
71 | 91 | ||
72 | MapeditFrame::MapeditFrame(std::unique_ptr<World> world) : wxFrame(NULL, wxID_ANY, "Map Editor") | 92 | MapeditFrame::MapeditFrame(World* world) : wxFrame(NULL, wxID_ANY, "Map Editor") |
73 | { | 93 | { |
74 | int screenWidth = wxSystemSettings::GetMetric(wxSYS_SCREEN_X); | 94 | int screenWidth = wxSystemSettings::GetMetric(wxSYS_SCREEN_X); |
75 | int screenHeight = wxSystemSettings::GetMetric(wxSYS_SCREEN_Y); | 95 | int screenHeight = wxSystemSettings::GetMetric(wxSYS_SCREEN_Y); |
@@ -97,7 +117,7 @@ MapeditFrame::MapeditFrame(std::unique_ptr<World> world) : wxFrame(NULL, wxID_AN | |||
97 | Maximize(); | 117 | Maximize(); |
98 | } | 118 | } |
99 | 119 | ||
100 | this->world = std::move(world); | 120 | this->world = world; |
101 | this->world->setParent(this); | 121 | this->world->setParent(this); |
102 | currentMap = this->world->getLastMap(); | 122 | currentMap = this->world->getLastMap(); |
103 | 123 | ||
@@ -167,6 +187,34 @@ MapeditFrame::MapeditFrame(std::unique_ptr<World> world) : wxFrame(NULL, wxID_AN | |||
167 | cancelStartposButton = new wxButton(propertyEditor, CANCEL_STARTPOS_BUTTON, "Cancel"); | 187 | cancelStartposButton = new wxButton(propertyEditor, CANCEL_STARTPOS_BUTTON, "Cancel"); |
168 | cancelStartposButton->Disable(); | 188 | cancelStartposButton->Disable(); |
169 | 189 | ||
190 | wxStaticText* leftmapLabel = new wxStaticText(propertyEditor, wxID_ANY, "Leftmap Action:"); | ||
191 | wxChoice* leftmapChoice = new wxChoice(propertyEditor, LEFTMAP_TYPE_CHOICE); | ||
192 | wxComboCtrl* leftmapCombo = new wxComboCtrl(propertyEditor, LEFTMAP_MAP_CHOICE, "", wxDefaultPosition, wxDefaultSize, wxCB_READONLY); | ||
193 | leftmapCombo->SetPopupControl(new MapSelectComboPopup(mapTree, currentMap->getLeftMoveMapID())); | ||
194 | |||
195 | wxStaticText* rightmapLabel = new wxStaticText(propertyEditor, wxID_ANY, "Rightmap Action:"); | ||
196 | wxChoice* rightmapChoice = new wxChoice(propertyEditor, RIGHTMAP_TYPE_CHOICE); | ||
197 | wxComboCtrl* rightmapCombo = new wxComboCtrl(propertyEditor, RIGHTMAP_MAP_CHOICE, "", wxDefaultPosition, wxDefaultSize, wxCB_READONLY); | ||
198 | rightmapCombo->SetPopupControl(new MapSelectComboPopup(mapTree, currentMap->getRightMoveMapID())); | ||
199 | |||
200 | wxStaticText* upmapLabel = new wxStaticText(propertyEditor, wxID_ANY, "Upmap Action:"); | ||
201 | wxChoice* upmapChoice = new wxChoice(propertyEditor, UPMAP_TYPE_CHOICE); | ||
202 | wxComboCtrl* upmapCombo = new wxComboCtrl(propertyEditor, UPMAP_MAP_CHOICE, "", wxDefaultPosition, wxDefaultSize, wxCB_READONLY); | ||
203 | upmapCombo->SetPopupControl(new MapSelectComboPopup(mapTree, currentMap->getUpMoveMapID())); | ||
204 | |||
205 | wxStaticText* downmapLabel = new wxStaticText(propertyEditor, wxID_ANY, "Downmap Action:"); | ||
206 | wxChoice* downmapChoice = new wxChoice(propertyEditor, DOWNMAP_TYPE_CHOICE); | ||
207 | wxComboCtrl* downmapCombo = new wxComboCtrl(propertyEditor, DOWNMAP_MAP_CHOICE, "", wxDefaultPosition, wxDefaultSize, wxCB_READONLY); | ||
208 | downmapCombo->SetPopupControl(new MapSelectComboPopup(mapTree, currentMap->getDownMoveMapID())); | ||
209 | |||
210 | for (auto type : Map::listMoveTypes()) | ||
211 | { | ||
212 | leftmapChoice->Append(Map::stringForMoveType(type), new MoveTypeCtr(type)); | ||
213 | rightmapChoice->Append(Map::stringForMoveType(type), new MoveTypeCtr(type)); | ||
214 | upmapChoice->Append(Map::stringForMoveType(type), new MoveTypeCtr(type)); | ||
215 | downmapChoice->Append(Map::stringForMoveType(type), new MoveTypeCtr(type)); | ||
216 | } | ||
217 | |||
170 | wxBoxSizer* propertySizer = new wxBoxSizer(wxVERTICAL); | 218 | wxBoxSizer* propertySizer = new wxBoxSizer(wxVERTICAL); |
171 | wxBoxSizer* propertySizer1 = new wxBoxSizer(wxHORIZONTAL); | 219 | wxBoxSizer* propertySizer1 = new wxBoxSizer(wxHORIZONTAL); |
172 | propertySizer1->Add(titleLabel, 0, wxALIGN_RIGHT | wxLEFT, 10); | 220 | propertySizer1->Add(titleLabel, 0, wxALIGN_RIGHT | wxLEFT, 10); |
@@ -176,7 +224,42 @@ MapeditFrame::MapeditFrame(std::unique_ptr<World> world) : wxFrame(NULL, wxID_AN | |||
176 | propertySizer2->Add(startposLabel, 0, wxALIGN_RIGHT | wxLEFT, 10); | 224 | propertySizer2->Add(startposLabel, 0, wxALIGN_RIGHT | wxLEFT, 10); |
177 | propertySizer2->Add(setStartposButton, 0, wxALIGN_LEFT | wxLEFT, 10); | 225 | propertySizer2->Add(setStartposButton, 0, wxALIGN_LEFT | wxLEFT, 10); |
178 | propertySizer2->Add(cancelStartposButton, 0, wxALIGN_LEFT | wxLEFT, 10); | 226 | propertySizer2->Add(cancelStartposButton, 0, wxALIGN_LEFT | wxLEFT, 10); |
179 | propertySizer->Add(propertySizer2, 0, wxEXPAND | wxTOP | wxBOTTOM, 10); | 227 | propertySizer->Add(propertySizer2, 0, wxEXPAND | wxTOP, 10); |
228 | |||
229 | wxBoxSizer* propertySizer3 = new wxBoxSizer(wxHORIZONTAL); | ||
230 | wxBoxSizer* leftmapSizer = new wxBoxSizer(wxHORIZONTAL); | ||
231 | leftmapSizer->Add(leftmapLabel, 0, wxALIGN_RIGHT, 0); | ||
232 | wxBoxSizer* leftmapToolsSizer = new wxBoxSizer(wxVERTICAL); | ||
233 | leftmapToolsSizer->Add(leftmapChoice, 0, wxEXPAND, 0); | ||
234 | leftmapToolsSizer->Add(leftmapCombo, 0, wxEXPAND | wxTOP, 10); | ||
235 | leftmapSizer->Add(leftmapToolsSizer, 1, wxEXPAND | wxLEFT, 10); | ||
236 | propertySizer3->Add(leftmapSizer, 1, wxALIGN_LEFT | wxLEFT, 10); | ||
237 | wxBoxSizer* rightmapSizer = new wxBoxSizer(wxHORIZONTAL); | ||
238 | rightmapSizer->Add(rightmapLabel, 0, wxALIGN_RIGHT, 0); | ||
239 | wxBoxSizer* rightmapToolsSizer = new wxBoxSizer(wxVERTICAL); | ||
240 | rightmapToolsSizer->Add(rightmapChoice, 0, wxEXPAND, 0); | ||
241 | rightmapToolsSizer->Add(rightmapCombo, 0, wxEXPAND | wxTOP, 10); | ||
242 | rightmapSizer->Add(rightmapToolsSizer, 1, wxEXPAND | wxLEFT, 10); | ||
243 | propertySizer3->Add(rightmapSizer, 1, wxALIGN_LEFT | wxLEFT, 10); | ||
244 | propertySizer->Add(propertySizer3, 0, wxEXPAND | wxTOP, 10); | ||
245 | |||
246 | wxBoxSizer* propertySizer4 = new wxBoxSizer(wxHORIZONTAL); | ||
247 | wxBoxSizer* upmapSizer = new wxBoxSizer(wxHORIZONTAL); | ||
248 | upmapSizer->Add(upmapLabel, 0, wxALIGN_RIGHT, 0); | ||
249 | wxBoxSizer* upmapToolsSizer = new wxBoxSizer(wxVERTICAL); | ||
250 | upmapToolsSizer->Add(upmapChoice, 0, wxEXPAND, 0); | ||
251 | upmapToolsSizer->Add(upmapCombo, 0, wxEXPAND | wxTOP, 10); | ||
252 | upmapSizer->Add(upmapToolsSizer, 1, wxEXPAND | wxLEFT, 10); | ||
253 | propertySizer4->Add(upmapSizer, 1, wxALIGN_LEFT | wxLEFT, 10); | ||
254 | wxBoxSizer* downmapSizer = new wxBoxSizer(wxHORIZONTAL); | ||
255 | downmapSizer->Add(downmapLabel, 0, wxALIGN_RIGHT, 0); | ||
256 | wxBoxSizer* downmapToolsSizer = new wxBoxSizer(wxVERTICAL); | ||
257 | downmapToolsSizer->Add(downmapChoice, 0, wxEXPAND, 0); | ||
258 | downmapToolsSizer->Add(downmapCombo, 0, wxEXPAND | wxTOP, 10); | ||
259 | downmapSizer->Add(downmapToolsSizer, 1, wxEXPAND | wxLEFT, 10); | ||
260 | propertySizer4->Add(downmapSizer, 1, wxALIGN_LEFT | wxLEFT, 10); | ||
261 | propertySizer->Add(propertySizer4, 0, wxEXPAND | wxTOP | wxBOTTOM, 10); | ||
262 | |||
180 | propertyEditor->SetSizer(propertySizer); | 263 | propertyEditor->SetSizer(propertySizer); |
181 | propertySizer->SetSizeHints(propertyEditor); | 264 | propertySizer->SetSizeHints(propertyEditor); |
182 | 265 | ||
@@ -588,18 +671,174 @@ void MapeditFrame::OnThreeMovingSash(wxSplitterEvent& event) | |||
588 | layout3->SetSashPosition(event.GetSashPosition(), true); | 671 | layout3->SetSashPosition(event.GetSashPosition(), true); |
589 | } | 672 | } |
590 | 673 | ||
674 | void MapeditFrame::OnSetLeftmapType(wxCommandEvent&) | ||
675 | { | ||
676 | wxChoice* leftmapChoice = (wxChoice*) wxWindow::FindWindowById(LEFTMAP_TYPE_CHOICE, this); | ||
677 | wxComboCtrl* leftmapCombo = (wxComboCtrl*) wxWindow::FindWindowById(LEFTMAP_MAP_CHOICE, this); | ||
678 | |||
679 | Map::MoveType old = currentMap->getLeftMoveType(); | ||
680 | Map::MoveType newt = ((MoveTypeCtr*) leftmapChoice->GetClientData(leftmapChoice->GetSelection()))->type; | ||
681 | |||
682 | commitAction(std::make_shared<Undoable>("Set Leftmap Action", [=] () { | ||
683 | leftmapChoice->SetSelection(leftmapChoice->FindString(Map::stringForMoveType(newt))); | ||
684 | currentMap->setLeftMoveType(newt); | ||
685 | leftmapCombo->Enable(Map::moveTypeTakesMap(currentMap->getLeftMoveType())); | ||
686 | }, [=] () { | ||
687 | leftmapChoice->SetSelection(leftmapChoice->FindString(Map::stringForMoveType(old))); | ||
688 | currentMap->setLeftMoveType(old); | ||
689 | leftmapCombo->Enable(Map::moveTypeTakesMap(currentMap->getLeftMoveType())); | ||
690 | })); | ||
691 | } | ||
692 | |||
693 | void MapeditFrame::OnSetLeftmapMap(wxCommandEvent&) | ||
694 | { | ||
695 | wxComboCtrl* leftmapCombo = (wxComboCtrl*) wxWindow::FindWindowById(LEFTMAP_MAP_CHOICE, this); | ||
696 | MapSelectComboPopup* popup = (MapSelectComboPopup*) leftmapCombo->GetPopupControl(); | ||
697 | int old = currentMap->getLeftMoveMapID(); | ||
698 | int newt = popup->GetSelectedMapID(); | ||
699 | |||
700 | if (old == newt) return; | ||
701 | |||
702 | commitAction(std::make_shared<Undoable>("Set Leftmap Map", [=] () { | ||
703 | popup->SetSelectedMapID(newt); | ||
704 | leftmapCombo->SetValue(world->getMap(newt)->getTitle()); | ||
705 | currentMap->setLeftMoveMapID(newt); | ||
706 | }, [=] () { | ||
707 | popup->SetSelectedMapID(old); | ||
708 | leftmapCombo->SetValue(world->getMap(old)->getTitle()); | ||
709 | currentMap->setLeftMoveMapID(old); | ||
710 | })); | ||
711 | } | ||
712 | |||
713 | void MapeditFrame::OnSetRightmapType(wxCommandEvent&) | ||
714 | { | ||
715 | wxChoice* rightmapChoice = (wxChoice*) wxWindow::FindWindowById(RIGHTMAP_TYPE_CHOICE, this); | ||
716 | wxComboCtrl* rightmapCombo = (wxComboCtrl*) wxWindow::FindWindowById(RIGHTMAP_MAP_CHOICE, this); | ||
717 | |||
718 | Map::MoveType old = currentMap->getRightMoveType(); | ||
719 | Map::MoveType newt = ((MoveTypeCtr*) rightmapChoice->GetClientData(rightmapChoice->GetSelection()))->type; | ||
720 | |||
721 | commitAction(std::make_shared<Undoable>("Set Rightmap Action", [=] () { | ||
722 | rightmapChoice->SetSelection(rightmapChoice->FindString(Map::stringForMoveType(newt))); | ||
723 | currentMap->setRightMoveType(newt); | ||
724 | rightmapCombo->Enable(Map::moveTypeTakesMap(currentMap->getRightMoveType())); | ||
725 | }, [=] () { | ||
726 | rightmapChoice->SetSelection(rightmapChoice->FindString(Map::stringForMoveType(old))); | ||
727 | currentMap->setRightMoveType(old); | ||
728 | rightmapCombo->Enable(Map::moveTypeTakesMap(currentMap->getRightMoveType())); | ||
729 | })); | ||
730 | } | ||
731 | |||
732 | void MapeditFrame::OnSetRightmapMap(wxCommandEvent&) | ||
733 | { | ||
734 | wxComboCtrl* rightmapCombo = (wxComboCtrl*) wxWindow::FindWindowById(RIGHTMAP_MAP_CHOICE, this); | ||
735 | MapSelectComboPopup* popup = (MapSelectComboPopup*) rightmapCombo->GetPopupControl(); | ||
736 | int old = currentMap->getRightMoveMapID(); | ||
737 | int newt = popup->GetSelectedMapID(); | ||
738 | |||
739 | if (old == newt) return; | ||
740 | |||
741 | commitAction(std::make_shared<Undoable>("Set Rightmap Map", [=] () { | ||
742 | popup->SetSelectedMapID(newt); | ||
743 | rightmapCombo->SetValue(world->getMap(newt)->getTitle()); | ||
744 | currentMap->setRightMoveMapID(newt); | ||
745 | }, [=] () { | ||
746 | popup->SetSelectedMapID(old); | ||
747 | rightmapCombo->SetValue(world->getMap(old)->getTitle()); | ||
748 | currentMap->setRightMoveMapID(old); | ||
749 | })); | ||
750 | } | ||
751 | |||
752 | void MapeditFrame::OnSetUpmapType(wxCommandEvent&) | ||
753 | { | ||
754 | wxChoice* upmapChoice = (wxChoice*) wxWindow::FindWindowById(UPMAP_TYPE_CHOICE, this); | ||
755 | wxComboCtrl* upmapCombo = (wxComboCtrl*) wxWindow::FindWindowById(UPMAP_MAP_CHOICE, this); | ||
756 | |||
757 | Map::MoveType old = currentMap->getUpMoveType(); | ||
758 | Map::MoveType newt = ((MoveTypeCtr*) upmapChoice->GetClientData(upmapChoice->GetSelection()))->type; | ||
759 | |||
760 | commitAction(std::make_shared<Undoable>("Set Upmap Action", [=] () { | ||
761 | upmapChoice->SetSelection(upmapChoice->FindString(Map::stringForMoveType(newt))); | ||
762 | currentMap->setUpMoveType(newt); | ||
763 | upmapCombo->Enable(Map::moveTypeTakesMap(currentMap->getUpMoveType())); | ||
764 | }, [=] () { | ||
765 | upmapChoice->SetSelection(upmapChoice->FindString(Map::stringForMoveType(old))); | ||
766 | currentMap->setUpMoveType(old); | ||
767 | upmapCombo->Enable(Map::moveTypeTakesMap(currentMap->getUpMoveType())); | ||
768 | })); | ||
769 | } | ||
770 | |||
771 | void MapeditFrame::OnSetUpmapMap(wxCommandEvent&) | ||
772 | { | ||
773 | wxComboCtrl* upmapCombo = (wxComboCtrl*) wxWindow::FindWindowById(UPMAP_MAP_CHOICE, this); | ||
774 | MapSelectComboPopup* popup = (MapSelectComboPopup*) upmapCombo->GetPopupControl(); | ||
775 | int old = currentMap->getUpMoveMapID(); | ||
776 | int newt = popup->GetSelectedMapID(); | ||
777 | |||
778 | if (old == newt) return; | ||
779 | |||
780 | commitAction(std::make_shared<Undoable>("Set Upmap Map", [=] () { | ||
781 | popup->SetSelectedMapID(newt); | ||
782 | upmapCombo->SetValue(world->getMap(newt)->getTitle()); | ||
783 | currentMap->setUpMoveMapID(newt); | ||
784 | }, [=] () { | ||
785 | popup->SetSelectedMapID(old); | ||
786 | upmapCombo->SetValue(world->getMap(old)->getTitle()); | ||
787 | currentMap->setUpMoveMapID(old); | ||
788 | })); | ||
789 | } | ||
790 | |||
791 | void MapeditFrame::OnSetDownmapType(wxCommandEvent&) | ||
792 | { | ||
793 | wxChoice* downmapChoice = (wxChoice*) wxWindow::FindWindowById(DOWNMAP_TYPE_CHOICE, this); | ||
794 | wxComboCtrl* downmapCombo = (wxComboCtrl*) wxWindow::FindWindowById(DOWNMAP_MAP_CHOICE, this); | ||
795 | |||
796 | Map::MoveType old = currentMap->getDownMoveType(); | ||
797 | Map::MoveType newt = ((MoveTypeCtr*) downmapChoice->GetClientData(downmapChoice->GetSelection()))->type; | ||
798 | |||
799 | commitAction(std::make_shared<Undoable>("Set Downmap Action", [=] () { | ||
800 | downmapChoice->SetSelection(downmapChoice->FindString(Map::stringForMoveType(newt))); | ||
801 | currentMap->setDownMoveType(newt); | ||
802 | downmapCombo->Enable(Map::moveTypeTakesMap(currentMap->getDownMoveType())); | ||
803 | }, [=] () { | ||
804 | downmapChoice->SetSelection(downmapChoice->FindString(Map::stringForMoveType(old))); | ||
805 | currentMap->setDownMoveType(old); | ||
806 | downmapCombo->Enable(Map::moveTypeTakesMap(currentMap->getDownMoveType())); | ||
807 | })); | ||
808 | } | ||
809 | |||
810 | void MapeditFrame::OnSetDownmapMap(wxCommandEvent&) | ||
811 | { | ||
812 | wxComboCtrl* downmapCombo = (wxComboCtrl*) wxWindow::FindWindowById(DOWNMAP_MAP_CHOICE, this); | ||
813 | MapSelectComboPopup* popup = (MapSelectComboPopup*) downmapCombo->GetPopupControl(); | ||
814 | int old = currentMap->getDownMoveMapID(); | ||
815 | int newt = popup->GetSelectedMapID(); | ||
816 | |||
817 | if (old == newt) return; | ||
818 | |||
819 | commitAction(std::make_shared<Undoable>("Set Downmap Map", [=] () { | ||
820 | popup->SetSelectedMapID(newt); | ||
821 | downmapCombo->SetValue(world->getMap(newt)->getTitle()); | ||
822 | currentMap->setDownMoveMapID(newt); | ||
823 | }, [=] () { | ||
824 | popup->SetSelectedMapID(old); | ||
825 | downmapCombo->SetValue(world->getMap(old)->getTitle()); | ||
826 | currentMap->setDownMoveMapID(old); | ||
827 | })); | ||
828 | } | ||
829 | |||
591 | void MapeditFrame::NewWorld() | 830 | void MapeditFrame::NewWorld() |
592 | { | 831 | { |
593 | LaunchWindow(std::unique_ptr<World>(new World())); | 832 | LaunchWindow(new World()); |
594 | } | 833 | } |
595 | 834 | ||
596 | bool MapeditFrame::OpenWorld(std::string filename) | 835 | bool MapeditFrame::OpenWorld(std::string filename) |
597 | { | 836 | { |
598 | try | 837 | try |
599 | { | 838 | { |
600 | auto world = std::unique_ptr<World>(new World(filename)); | 839 | auto world = new World(filename); |
601 | 840 | ||
602 | LaunchWindow(std::move(world)); | 841 | LaunchWindow(world); |
603 | 842 | ||
604 | return true; | 843 | return true; |
605 | } catch (std::exception& ex) | 844 | } catch (std::exception& ex) |
@@ -610,9 +849,9 @@ bool MapeditFrame::OpenWorld(std::string filename) | |||
610 | return false; | 849 | return false; |
611 | } | 850 | } |
612 | 851 | ||
613 | void MapeditFrame::LaunchWindow(std::unique_ptr<World> world) | 852 | void MapeditFrame::LaunchWindow(World* world) |
614 | { | 853 | { |
615 | MapeditFrame* frame = new MapeditFrame(std::move(world)); | 854 | MapeditFrame* frame = new MapeditFrame(world); |
616 | frame->closer = openWindows.insert(end(openWindows), frame); | 855 | frame->closer = openWindows.insert(end(openWindows), frame); |
617 | frame->Show(true); | 856 | frame->Show(true); |
618 | } | 857 | } |
@@ -674,6 +913,30 @@ void MapeditFrame::SelectMap(Map* map) | |||
674 | 913 | ||
675 | titleBox->ChangeValue(map->getTitle()); | 914 | titleBox->ChangeValue(map->getTitle()); |
676 | world->setLastMap(map); | 915 | world->setLastMap(map); |
916 | |||
917 | wxChoice* leftmapChoice = (wxChoice*) wxWindow::FindWindowById(LEFTMAP_TYPE_CHOICE, this); | ||
918 | wxChoice* rightmapChoice = (wxChoice*) wxWindow::FindWindowById(RIGHTMAP_TYPE_CHOICE, this); | ||
919 | wxChoice* upmapChoice = (wxChoice*) wxWindow::FindWindowById(UPMAP_TYPE_CHOICE, this); | ||
920 | wxChoice* downmapChoice = (wxChoice*) wxWindow::FindWindowById(DOWNMAP_TYPE_CHOICE, this); | ||
921 | wxComboCtrl* leftmapCombo = (wxComboCtrl*) wxWindow::FindWindowById(LEFTMAP_MAP_CHOICE, this); | ||
922 | wxComboCtrl* rightmapCombo = (wxComboCtrl*) wxWindow::FindWindowById(RIGHTMAP_MAP_CHOICE, this); | ||
923 | wxComboCtrl* upmapCombo = (wxComboCtrl*) wxWindow::FindWindowById(UPMAP_MAP_CHOICE, this); | ||
924 | wxComboCtrl* downmapCombo = (wxComboCtrl*) wxWindow::FindWindowById(DOWNMAP_MAP_CHOICE, this); | ||
925 | |||
926 | leftmapChoice->SetSelection(leftmapChoice->FindString(Map::stringForMoveType(currentMap->getLeftMoveType()))); | ||
927 | rightmapChoice->SetSelection(rightmapChoice->FindString(Map::stringForMoveType(currentMap->getRightMoveType()))); | ||
928 | upmapChoice->SetSelection(upmapChoice->FindString(Map::stringForMoveType(currentMap->getUpMoveType()))); | ||
929 | downmapChoice->SetSelection(downmapChoice->FindString(Map::stringForMoveType(currentMap->getDownMoveType()))); | ||
930 | |||
931 | leftmapCombo->Enable(Map::moveTypeTakesMap(currentMap->getLeftMoveType())); | ||
932 | rightmapCombo->Enable(Map::moveTypeTakesMap(currentMap->getRightMoveType())); | ||
933 | upmapCombo->Enable(Map::moveTypeTakesMap(currentMap->getUpMoveType())); | ||
934 | downmapCombo->Enable(Map::moveTypeTakesMap(currentMap->getDownMoveType())); | ||
935 | |||
936 | leftmapCombo->SetValue(world->getMap(currentMap->getLeftMoveMapID())->getTitle()); | ||
937 | rightmapCombo->SetValue(world->getMap(currentMap->getRightMoveMapID())->getTitle()); | ||
938 | upmapCombo->SetValue(world->getMap(currentMap->getUpMoveMapID())->getTitle()); | ||
939 | downmapCombo->SetValue(world->getMap(currentMap->getDownMoveMapID())->getTitle()); | ||
677 | } | 940 | } |
678 | 941 | ||
679 | wxTreeItemId MapeditFrame::MoveTreeNode(wxTreeItemId toCopy, wxTreeItemId newParent) | 942 | wxTreeItemId MapeditFrame::MoveTreeNode(wxTreeItemId toCopy, wxTreeItemId newParent) |