The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
action_item.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2008 - 2016 by Fabian Mueller <[email protected]>
3  Part of the Battle for Wesnoth Project http://www.wesnoth.org/
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY.
11 
12  See the COPYING file for more details.
13 */
14 
15 /**
16  * @file
17  * Editor item action class
18  */
19 
20 //TODO is a textdomain needed?
21 #define GETTEXT_DOMAIN "wesnoth-editor"
22 
24 
26 
27 #include <boost/scoped_ptr.hpp>
28 
29 namespace editor {
30 
32 {
33  return new editor_action_item(*this);
34 }
35 
37 {
38  std::unique_ptr<editor_action> undo(new editor_action_item_delete(loc_));
40  return undo.release();
41 }
42 
44 {
45 
46 //
47 // mc.get_items().add(loc_,u_);
48 // mc.get_items().find(loc_)->set_location(loc_);
49 // mc.add_changed_location(loc_);
50 }
51 
52 
54 {
55  return new editor_action_item_delete(*this);
56 }
57 
59 {
60 // item_map& items = mc.get_items();
61 // item_map::const_item_iterator item_it = items.find(loc_);
62 //
63 // std::unique_ptr<editor_action> undo;
64 // if (item_it != items.end()) {
65 // undo.reset(new editor_action_item(loc_, *item_it));
66 // perform_without_undo(mc);
67 // return undo.release();
68 // }
69  return nullptr;
70 }
71 
73 {
74 // item_map& items = mc.get_items();
75 // if (!items.erase(loc_)) {
76 // ERR_ED << "Could not delete item on " << loc_.x << "/" << loc_.y << std::endl;
77 // } else {
78 // mc.add_changed_location(loc_);
79 // }
80 }
81 
82 
84 {
85  return new editor_action_item_replace(*this);
86 }
87 
89 {
90  std::unique_ptr<editor_action> undo(new editor_action_item_replace(new_loc_, loc_));
91 
93  return undo.release();
94 }
95 
97 {
98 // item_map& items = mc.get_items();
99 // items.move(loc_, new_loc_);
100 // item::clear_status_caches();
101 //
102 // item& u = *items.find(new_loc_);
103 // //TODO do we still need set_standing?
104 // u.anim_comp().set_standing();
105 //
106 // mc.add_changed_location(loc_);
107 // mc.add_changed_location(new_loc_);
108 //
109 // /* @todo
110 // if (mc.get_map().is_village(new_loc_)) {
111 // (*(resources::teams))[u.side()].get_village(new_loc_);
112 // }
113 // */
114 //
115 ////TODO check if that is useful
116 //// resources::screen->invalidate_item_after_move(loc_, new_loc_);
117 //// resources::screen->draw();
118 }
119 
120 
122 {
123  return new editor_action_item_facing(*this);
124 }
125 
127 {
128  std::unique_ptr<editor_action> undo(new editor_action_item_facing(loc_, old_direction_, new_direction_));
130  return undo.release();
131 }
132 
134 {
135 // item_map& items = mc.get_items();
136 // item_map::item_iterator item_it = items.find(loc_);
137 //
138 // if (item_it != items.end()) {
139 // item_it->set_facing(new_direction_);
140 // item_it->set_standing();
141 // }
142 }
143 
144 
145 } //end namespace editor
void perform_without_undo(map_context &mc) const
Perform the action without creating an undo action.
Definition: action_item.cpp:43
place a new item on the map
Definition: action_item.hpp:42
editor_action_item(map_location loc, const overlay &item)
Definition: action_item.hpp:45
editor_action_item * clone() const
Action cloning.
Definition: action_item.cpp:31
editor_action_item_facing(map_location loc, map_location::DIRECTION new_direction, map_location::DIRECTION old_direction)
Definition: action_item.hpp:92
editor_action_item_replace * clone() const
Action cloning.
Definition: action_item.cpp:83
editor_action_item_delete(map_location loc)
Definition: action_item.hpp:64
editor_action * perform(map_context &mc) const
Perform the action, returning an undo action that, when performed, shall reverse any effects of this ...
Definition: action_item.cpp:88
editor_action_item_replace(map_location loc, map_location new_loc)
Definition: action_item.hpp:77
editor_action_item_facing * clone() const
Action cloning.
map_location::DIRECTION new_direction_
editor_action * perform(map_context &mc) const
Perform the action, returning an undo action that, when performed, shall reverse any effects of this ...
Definition: action_item.cpp:58
editor_action * perform(map_context &mc) const
Perform the action, returning an undo action that, when performed, shall reverse any effects of this ...
Remove a item from the map.
Definition: action_item.hpp:61
Manage the empty-palette in the editor.
Definition: action.cpp:28
void perform_without_undo(map_context &mc) const
Perform the action without creating an undo action.
Definition: action_item.cpp:96
map_location::DIRECTION old_direction_
editor_action * perform(map_context &mc) const
Perform the action, returning an undo action that, when performed, shall reverse any effects of this ...
Definition: action_item.cpp:36
Base class for all editor actions.
Definition: action_base.hpp:41
This class wraps around a map to provide a concise interface for the editor to work with...
Definition: map_context.hpp:41
editor_action_item_delete * clone() const
Action cloning.
Definition: action_item.cpp:53
void perform_without_undo(map_context &mc) const
Perform the action without creating an undo action.
Definition: action_item.cpp:72
Editor action classes.
void perform_without_undo(map_context &mc) const
Perform the action without creating an undo action.