The Battle for Wesnoth  1.13.10+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 - 2017 by Fabian Mueller <fabianmueller5@gmx.de>
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 namespace editor
28 {
29 IMPLEMENT_ACTION(item)
30 
32 {
34  perform_without_undo(mc);
35  return undo.release();
36 }
37 
39 {
40  //
41  // mc.get_items().add(loc_,u_);
42  // mc.get_items().find(loc_)->set_location(loc_);
43  // mc.add_changed_location(loc_);
44 }
45 
46 IMPLEMENT_ACTION(item_delete)
47 
49 {
50  // item_map& items = mc.get_items();
51  // item_map::const_item_iterator item_it = items.find(loc_);
52  //
53  // editor_action_ptr undo;
54  // if (item_it != items.end()) {
55  // undo.reset(new editor_action_item(loc_, *item_it));
56  // perform_without_undo(mc);
57  // return undo.release();
58  // }
59  return nullptr;
60 }
61 
63 {
64  // item_map& items = mc.get_items();
65  // if (!items.erase(loc_)) {
66  // ERR_ED << "Could not delete item on " << loc_.x << "/" << loc_.y << std::endl;
67  // } else {
68  // mc.add_changed_location(loc_);
69  // }
70 }
71 
72 IMPLEMENT_ACTION(item_replace)
73 
75 {
77 
78  perform_without_undo(mc);
79  return undo.release();
80 }
81 
83 {
84  // item_map& items = mc.get_items();
85  // items.move(loc_, new_loc_);
86  // item::clear_status_caches();
87  //
88  // item& u = *items.find(new_loc_);
89  // //TODO do we still need set_standing?
90  // u.anim_comp().set_standing();
91  //
92  // mc.add_changed_location(loc_);
93  // mc.add_changed_location(new_loc_);
94  //
95  // /* @todo
96  // if (mc.get_map().is_village(new_loc_)) {
97  // (*(resources::gameboard->teams()))[u.side()].get_village(new_loc_);
98  // }
99  // */
100  //
101  ////TODO check if that is useful
102  //// resources::screen->invalidate_item_after_move(loc_, new_loc_);
103  //// resources::screen->draw();
104 }
105 
106 IMPLEMENT_ACTION(item_facing)
107 
109 {
110  editor_action_ptr undo(new editor_action_item_facing(loc_, old_direction_, new_direction_));
111  perform_without_undo(mc);
112  return undo.release();
113 }
114 
116 {
117  // item_map& items = mc.get_items();
118  // item_map::item_iterator item_it = items.find(loc_);
119  //
120  // if (item_it != items.end()) {
121  // item_it->set_facing(new_direction_);
122  // item_it->set_standing();
123  // }
124 }
125 
126 } // end namespace editor
void perform_without_undo(map_context &mc) const
Perform the action without creating an undo action.
Definition: action_item.cpp:38
place a new item on the map
Definition: action_item.hpp:39
std::unique_ptr< editor_action > editor_action_ptr
Action pointer typedef.
map_location loc_
Remove a item from the map.
Definition: action_item.hpp:65
Manage the empty-palette in the editor.
Definition: action.cpp:29
void perform_without_undo(map_context &mc) const
Perform the action without creating an undo action.
Definition: action_item.cpp:82
Base class for all editor actions.
Definition: action_base.hpp:40
This class wraps around a map to provide a concise interface for the editor to work with...
Definition: map_context.hpp:55
#define IMPLEMENT_ACTION(id)
Helper macro to implement common action methods.
void perform_without_undo(map_context &mc) const
Perform the action without creating an undo action.
Definition: action_item.cpp:62
Editor action classes.
void perform_without_undo(map_context &mc) const
Perform the action without creating an undo action.