00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef EDITOR_UNDO_H_INCLUDED
00022 #define EDITOR_UNDO_H_INCLUDED
00023
00024 #include "global.hpp"
00025
00026 #include "map.hpp"
00027
00028 #include <queue>
00029 #include <vector>
00030 #include <set>
00031
00032 namespace map_editor {
00033
00034
00035 class map_undo_action {
00036 public:
00037 map_undo_action();
00038
00039 const std::map<gamemap::location, t_translation::t_terrain>& undo_terrains() const;
00040 const std::map<gamemap::location, t_translation::t_terrain>& redo_terrains() const;
00041
00042 const std::set<gamemap::location> undo_selection() const;
00043 const std::set<gamemap::location> redo_selection() const;
00044
00045 std::string new_map_data() const;
00046 std::string old_map_data() const;
00047
00048 const std::map<gamemap::location, int>& undo_starting_locations() const;
00049 const std::map<gamemap::location, int>& redo_starting_locations() const;
00050
00051 void add_terrain(const t_translation::t_terrain& old_tr,
00052 const t_translation::t_terrain& new_tr,
00053 const gamemap::location& lc);
00054
00055
00056
00057 bool terrain_set() const;
00058
00059 void set_selection(const std::set<gamemap::location> &old_selection,
00060 const std::set<gamemap::location> &new_selection);
00061
00062
00063
00064 bool selection_set() const;
00065
00066 void set_map_data(const std::string &old_data,
00067 const std::string &new_data);
00068
00069
00070
00071 bool map_data_set() const;
00072
00073 void add_starting_location(const int old_side, const int new_side,
00074 const gamemap::location &old_loc,
00075 const gamemap::location &new_loc);
00076
00077
00078
00079 bool starting_location_set() const;
00080
00081
00082 bool something_set() const;
00083
00084 private:
00085 std::map<gamemap::location, t_translation::t_terrain> old_terrain_;
00086 std::map<gamemap::location, t_translation::t_terrain> new_terrain_;
00087 bool terrain_set_;
00088 std::set<gamemap::location> old_selection_;
00089 std::set<gamemap::location> new_selection_;
00090 bool selection_set_;
00091 std::string old_map_data_;
00092 std::string new_map_data_;
00093 bool map_data_set_;
00094 std::map<gamemap::location,int> old_starting_locations_;
00095 std::map<gamemap::location,int> new_starting_locations_;
00096 bool starting_locations_set_;
00097 };
00098
00099 typedef std::deque<map_undo_action> map_undo_list;
00100
00101
00102
00103
00104
00105
00106 void add_undo_action(const map_undo_action &action);
00107
00108
00109 bool exist_undo_actions();
00110
00111 bool exist_redo_actions();
00112
00113
00114
00115
00116 map_undo_action pop_undo_action();
00117
00118
00119
00120 map_undo_action pop_redo_action();
00121
00122
00123 void clear_undo_actions();
00124
00125 }
00126
00127
00128 #endif // EDITOR_UNDO_H_INCLUDED