The Battle for Wesnoth  1.17.0-dev
action_village.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2008 - 2018 by Fabian Mueller <fabianmueller5@gmx.de>
3  Part of the Battle for Wesnoth Project https://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 #pragma once
27 
28 #include "editor/action/action.hpp"
29 
30 namespace editor
31 {
32 /**
33  * Sets the ownership of a village to the current side.
34  */
36 {
37 public:
40  , side_number_(side_number)
41  {
42  }
43 
44  std::unique_ptr<editor_action> clone() const override;
45  std::unique_ptr<editor_action> perform(map_context& mc) const override;
46  void perform_without_undo(map_context& mc) const override;
47  const std::string& get_name() const override;
48 
49 private:
51 };
52 
53 /**
54  * Clears the ownership of a village.
55  */
57 {
58 public:
61  {
62  }
63 
64  std::unique_ptr<editor_action> clone() const override;
65  std::unique_ptr<editor_action> perform(map_context& mc) const override;
66  void perform_without_undo(map_context& mc) const override;
67  const std::string& get_name() const override;
68 };
69 
70 } // end namespace editor
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:175
Sets the ownership of a village to the current side.
const std::string & get_name() const override
void perform_without_undo(map_context &mc) const override
Perform the action without creating an undo action.
std::unique_ptr< editor_action > clone() const override
Action cloning.
Editor action classes.
Manage the empty-palette in the editor.
Definition: action.cpp:29
Encapsulates the map of the game.
Definition: location.hpp:37
This class wraps around a map to provide a concise interface for the editor to work with...
Definition: map_context.hpp:59
editor_action_village(map_location loc, int side_number)
int side_number
Definition: game_info.hpp:39
std::unique_ptr< editor_action > perform(map_context &mc) const override
Perform the action, returning an undo action that, when performed, shall reverse any effects of this ...
Clears the ownership of a village.