From e882367d80a0bcdd09b5412d908b0fdb6b6bfe34 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Tue, 17 Mar 2015 13:58:32 -0400 Subject: Implemented undo/redo framework in map editor --- tools/mapedit/src/frame.h | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) (limited to 'tools/mapedit/src/frame.h') diff --git a/tools/mapedit/src/frame.h b/tools/mapedit/src/frame.h index 067c848..b0f27e9 100644 --- a/tools/mapedit/src/frame.h +++ b/tools/mapedit/src/frame.h @@ -14,6 +14,7 @@ #include #include #include +#include "undo.h" class MapPtrCtr : public wxTreeItemData { public: @@ -37,7 +38,6 @@ class MapeditFrame : public wxFrame { std::list::iterator closer; - private: static void LaunchWindow(std::unique_ptr world); void populateMapTree(wxTreeItemId node, std::list> maps); void SelectMap(Map* map); @@ -60,7 +60,6 @@ class MapeditFrame : public wxFrame { void OnAddRoot(wxCommandEvent& event); void OnAddChild(wxCommandEvent& event); void OnDidSelectMap(wxTreeEvent& event); - void OnWillSelectMap(wxTreeEvent& event); void OnWillDragMap(wxTreeEvent& event); void OnDidDragMap(wxTreeEvent& event); void OnRightClickTree(wxTreeEvent& event); @@ -69,25 +68,44 @@ class MapeditFrame : public wxFrame { std::unique_ptr world; Map* currentMap; + MapeditWidget* mapEditor; TileWidget* tileEditor; - wxTextCtrl* titleBox; - std::string filename; + wxToolBar* toolbar; + wxMenu* menuFile; + + // Notebook wxNotebook* notebook; wxChoice* entityTypeBox; wxButton* addEntityButton; wxButton* cancelEntityButton; - wxToolBar* toolbar; - wxMenu* menuFile; + + // Map tree wxTreeCtrl* mapTree; wxTreeItemId dragMap; wxMenu* mapTreePopup; + bool dontSelectMap = false; + + // Property editor + UndoableTextBox* titleBox; + wxString prevTitle; wxStaticText* startposLabel; wxButton* setStartposButton; wxButton* cancelStartposButton; + // Undo stuff + wxMenu* menuEdit; + std::list> history; + std::list>::iterator currentAction {begin(history)}; + void OnUndo(wxCommandEvent& event); + void OnRedo(wxCommandEvent& event); + void UpdateUndoLabels(); + void commitAction(std::shared_ptr action); + void commitAfter(std::shared_ptr action); + bool addingEntity = false; + private: wxDECLARE_EVENT_TABLE(); }; -- cgit 1.4.1