1 /* 2 * Copyright (C) 2012-2020 by the Widelands Development Team 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU General Public License 6 * as published by the Free Software Foundation; either version 2 7 * of the License, or (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 * 18 */ 19 20 #ifndef WL_EDITOR_TOOLS_HISTORY_H 21 #define WL_EDITOR_TOOLS_HISTORY_H 22 23 #include <deque> 24 25 #include "editor/tools/draw_tool.h" 26 #include "editor/tools/tool.h" 27 #include "ui_basic/button.h" 28 29 /** 30 * The all actions done with an editor tool are saved on a stack to 31 * provide undo / redo functionality. 32 * Do all tool action you want to make "undoable" using this class. 33 */ 34 struct EditorHistory { EditorHistoryEditorHistory35 EditorHistory(UI::Button& undo, UI::Button& redo) : undo_button_(undo), redo_button_(redo) { 36 } 37 38 uint32_t do_action(EditorTool& tool, 39 EditorTool::ToolIndex ind, 40 Widelands::Map& map, 41 const Widelands::NodeAndTriangle<>& center, 42 EditorInteractive& parent, 43 bool draw = false); 44 uint32_t undo_action(); 45 uint32_t redo_action(); 46 47 private: 48 UI::Button& undo_button_; 49 UI::Button& redo_button_; 50 51 EditorDrawTool draw_tool_; 52 53 std::deque<EditorToolAction> undo_stack_; 54 std::deque<EditorToolAction> redo_stack_; 55 }; 56 57 #endif // end of include guard: WL_EDITOR_TOOLS_HISTORY_H 58