The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
action_village.hpp
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 action classes. Some important points:
18  * - This is a polymorphic hierarchy of classes, so actions are usually passed around
19  * as editor_action pointers
20  * - The pointers can, in general, be null. Always check for null before doing anything.
21  * The helper functions perform_ that take a pointer do that.
22  * - The perform() functions can throw when an error occurs. Use smart pointers if you
23  * need to ensure the pointer is deleted.
24  */
25 
26 #ifndef EDITOR_ACTION_VILLAGE_HPP
27 #define EDITOR_ACTION_VILLAGE_HPP
28 
29 #include "action.hpp"
30 
31 
32 namespace editor {
33 
34 /**
35  * Sets the ownership of a village to the current side.
36  */
38 {
39  public:
41  : editor_action_location(loc), side_number_(side_number)
42  {
43  }
45  editor_action* perform(map_context& mc) const;
46  void perform_without_undo(map_context& mc) const;
47  const char* get_name() const { return "village"; }
48  private:
50 };
51 
52 /**
53  * Clears the ownership of a village.
54  */
56 {
57  public:
60  {
61  }
63  editor_action* perform(map_context& mc) const;
64  void perform_without_undo(map_context& mc) const;
65  const char* get_name() const { return "village_delete"; }
66 };
67 
68 
69 } //end namespace editor
70 
71 #endif
editor_action_village_delete(map_location loc)
Base class for actions which act on a specified location (and possibly on other locations that can be...
Definition: action.hpp:177
Sets the ownership of a village to the current side.
void perform_without_undo(map_context &mc) const
Perform the action without creating an undo action.
editor_action_village * clone() const
Action cloning.
editor_action * perform(map_context &mc) const
Perform the action, returning an undo action that, when performed, shall reverse any effects of this ...
editor_action * perform(map_context &mc) const
Perform the action, returning an undo action that, when performed, shall reverse any effects of this ...
Editor action classes.
Manage the empty-palette in the editor.
Definition: action.cpp:28
Encapsulates the map of the game.
Definition: location.hpp:38
editor_action_village_delete * clone() const
Action cloning.
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
void perform_without_undo(map_context &mc) const
Perform the action without creating an undo action.
const char * get_name() const
editor_action_village(map_location loc, int side_number)
int side_number
Definition: game_info.hpp:44
Clears the ownership of a village.