19 #define GETTEXT_DOMAIN "wesnoth-editor"
37 #ifdef EDITOR_DEBUG_ACTION_LIFETIME
38 LOG_ED <<
"Action " << std::setw(2) <<
id_ <<
" ctor " <<
this <<
" (count is " << instance_count <<
"\n";
45 #ifdef EDITOR_DEBUG_ACTION_LIFETIME
46 LOG_ED <<
"Action " << std::setw(2) <<
id_ <<
" dtor " <<
this <<
" (count is " << instance_count <<
"\n";
57 return "Unknown action";
84 if (
this == &other)
return *
this;
90 actions_.push_back(a->
clone());
108 count +=
a->action_count();
138 undo->append_action(
a->perform(mc));
141 std::reverse(undo->actions_.begin(), undo->actions_.end());
148 a->perform_without_undo(mc);
155 area_.insert(locs.begin(), locs.end());
171 return undo.release();
190 return undo.release();
226 if (old_loc_id !=
nullptr) {
231 undo.
reset(undo_chain);
245 if (old_id !=
nullptr) {
294 return undo.release();
299 std::vector<map_location>
shuffle;
300 std::copy(
area_.begin(),
area_.end(), std::inserter(shuffle, shuffle.begin()));
301 std::random_shuffle(shuffle.begin(), shuffle.end());
302 std::vector<map_location>::const_iterator shuffle_it = shuffle.begin();
303 std::set<map_location>::const_iterator orig_it =
area_.begin();
304 while (orig_it !=
area_.end()) {
void add_changed_location(const map_location &loc)
t_translation::t_terrain t_
Randomize terrain in an area.
A map fragment – a collection of locations and information abut them.
virtual std::string get_description() const
A textual description of the action.
void perform_without_undo(map_context &mc) const
Perform the action without creating an undo action.
void append_action(editor_action *a)
Add an action at the end of the chain.
void resize(int width, int height, int x_offset, int y_offset, const t_translation::t_terrain &filler=t_translation::NONE_TERRAIN)
Resize the map.
editor_action_shuffle_area * clone() const
Action cloning.
editor_action_chain * perform(map_context &m) const
Perform all the actions in order and create a undo action chain.
editor_action_paste * clone() const
Action cloning.
editor_action_chain & operator=(const editor_action_chain &other)
void perform_without_undo(map_context &mc) const
Perform the action without creating an undo action.
Paste a map fragment into the map.
void paste_into(gamemap &map, const map_location &loc) const
Paste the map fragment into the map, treating loc as the (0,0) point (offset).
Container action wrapping several actions into one.
Replace contents of the entire map, Useful as a fallback undo method when something else would be imp...
editor_action_starting_position(map_location loc, std::string loc_id)
editor_action * perform(map_context &mc) const
Perform the action, returning an undo action that, when performed, shall reverse any effects of this ...
void draw_terrain(const t_translation::t_terrain &terrain, const map_location &loc, bool one_layer_only=false)
Draw a terrain on a single location on the map.
editor_action_paint_area * clone() const
Action cloning.
editor_action_create_mask(const editor_map &target)
Set starting position action.
void set_needs_reload(bool value=true)
Setter for the reload flag.
void perform_without_undo(map_context &mc) const
Perform the action without creating an undo action.
std::set< map_location > get_contiguous_terrain_tiles(const map_location &start) const
Get a contiguous set of tiles having the same terrain as the starting location.
void perform_without_undo(map_context &mc) const
Perform the action without creating an undo action.
void set_map(const editor_map &map)
virtual int action_count() const
void perform_without_undo(map_context &mc) const
Perform the action without creating an undo action.
void perform_without_undo(map_context &m) const
Perform the action without creating an undo action.
editor_action_paint_area(const std::set< map_location > &area, const t_translation::t_terrain &t, bool one_layer=false)
std::set< map_location > get_offset_area(const map_location &offset) const
Get the area covered by this map fragment, shifted by an offset.
gamemap mask_to(const gamemap &target) const
A sort-of diff operation returning a mask that, when applied to the current editor_map, will transform it into the target map.
std::vector< ttip > shuffle(const std::vector< ttip > &tips)
Shuffles the tips.
void perform_without_undo(map_context &mc) const
Perform the action without creating an undo action.
void extend(const editor_map &map, const std::set< map_location > &locs)
The crux of the extendable contract.
editor_action * pop_first_action()
Remove the first added action and return it, transferring ownership to the caller.
editor_map & get_map()
Map accessor.
GLboolean GLboolean GLboolean GLboolean a
void extend(const editor_map &map, const std::set< map_location > &locs)
The crux of the extendable contract.
editor_action_apply_mask(const gamemap &mask)
void set_special_location(const std::string &id, const map_location &loc)
editor_action_paste * perform(map_context &mc) const
Perform the action, returning an undo action that, when performed, shall reverse any effects of this ...
t_translation::t_terrain t_
std::deque< editor_action * > actions_
The action pointers owned by this action chain.
editor_action * pop_last_action()
Remove the last added action and return it, transferring ownership to the caller. ...
virtual editor_action * clone() const =0
Action cloning.
Manage the empty-palette in the editor.
Templates and utility-routines for strings and numbers.
GLuint GLuint GLsizei count
Paint the same terrain on a number of locations on the map.
A terrain string which is converted to a terrain is a string with 1 or 2 layers the layers are separa...
editor_action_shuffle_area(const std::set< map_location > &area)
void set_needs_terrain_rebuild(bool value=true)
Setter for the terrain rebuild flag.
Encapsulates the map of the game.
editor_action_whole_map(const editor_map &m)
t_translation::t_terrain fill_
map_location special_location(const std::string &id) const
editor_action_apply_mask * clone() const
Action cloning.
editor_action_fill(map_location loc, const t_translation::t_terrain &t, bool one_layer=false)
This class adds extra editor-specific functionality to a normal gamemap.
editor_action_paste(const map_fragment &paste, const map_location &offset=map_location::ZERO())
editor_action_paste * perform(map_context &mc) const
Perform the action, returning an undo action that, when performed, shall reverse any effects of this ...
int action_count() const
Go through the chain and add up all the action counts.
static int instance_count_
Base class for all editor actions.
void prepend_action(editor_action *a)
Add an action at the beginning of the chain.
editor_action_whole_map * clone() const
Action cloning.
This class wraps around a map to provide a concise interface for the editor to work with...
void add_tiles(const gamemap &map, const std::set< map_location > &loc)
Add many locations and pull their info from the map.
void perform_without_undo(map_context &mc) const
Perform the action without creating an undo action.
editor_action_paint_area * perform(map_context &mc) const
Perform the action, returning an undo action that, when performed, shall reverse any effects of this ...
editor_action_paste * perform(map_context &mc) const
Perform the action, returning an undo action that, when performed, shall reverse any effects of this ...
t_translation::t_terrain get_terrain(const map_location &loc) const
Looks up terrain at a particular location.
void perform_without_undo(map_context &mc) const
Perform the action without creating an undo action.
editor_action_starting_position * clone() const
Action cloning.
editor_action_resize_map(int x_size, int y_size, int x_offset, int y_offset, const t_translation::t_terrain &fill=t_translation::NONE_TERRAIN)
editor_action_fill * clone() const
Action cloning.
void set_needs_labels_reset(bool value=true)
Setter for the labels reset flag.
~editor_action_chain()
The destructor deletes all the owned action pointers.
editor_action_chain()
Create an empty action chain.
const std::string * is_starting_position(const map_location &loc) const
returns the side number of the side starting at position loc, 0 if no such side exists.
void perform_without_undo(map_context &m) const
Perform all the actions in order.
virtual void perform_without_undo(map_context &) const =0
Perform the action without creating an undo action.
void overlay(const gamemap &m, const config &rules, int x=0, int y=0, bool border=false)
Overlays another map onto this one at the given position.
editor_action_create_mask * clone() const
Action cloning.
virtual editor_action * perform(map_context &) const
Perform the action, returning an undo action that, when performed, shall reverse any effects of this ...
editor_action_resize_map * clone() const
Action cloning.
std::set< map_location > area_
A config object defines a single node in a WML file, with access to child nodes.
GLsizei const GLcharARB ** string
editor_action_chain * clone() const
Action cloning.