The Battle for Wesnoth  1.13.10+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
action_label.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2010 - 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 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 "color.hpp"
29 #include "editor/action/action.hpp"
30 #include "map/map.hpp"
31 
32 namespace editor
33 {
34 /**
35  * Set label action
36  */
38 {
39 public:
41  const std::string& text,
42  const std::string& team_name,
43  color_t color,
44  bool visible_fog,
45  bool visible_shroud,
46  bool immutable,
47  std::string category)
49  , text_(text)
50  , team_name_(team_name)
51  , category_(category)
52  , color_(color)
53  , visible_fog_(visible_fog)
54  , visible_shroud_(visible_shroud)
55  , immutable_(immutable)
56  {
57  }
58 
59  /** Inherited from editor_action, implemented by IMPLEMENT_ACTION. */
60  editor_action_label* clone() const;
61 
62  editor_action* perform(map_context& mc) const;
63 
64  void perform_without_undo(map_context& mc) const;
65 
66  /** Inherited from editor_action, implemented by IMPLEMENT_ACTION. */
67  const std::string& get_name() const;
68 
69 protected:
73 
75 
78  bool immutable_;
79 };
80 
82 {
83 public:
86  {
87  }
88 
89  /** Inherited from editor_action, implemented by IMPLEMENT_ACTION. */
91 
92  editor_action* perform(map_context& mc) const;
93 
94  void perform_without_undo(map_context& mc) const;
95 
96  /** Inherited from editor_action, implemented by IMPLEMENT_ACTION. */
97  const std::string& get_name() const;
98 };
99 
100 } // end namespace editor
const std::string team_name_
std::vector< char_t > string
void perform_without_undo(map_context &mc) const
Perform the action without creating an undo action.
editor_action_label_delete(map_location loc)
editor_action_label * clone() const
Inherited from editor_action, implemented by IMPLEMENT_ACTION.
editor_action * perform(map_context &mc) const
Perform the action, returning an undo action that, when performed, shall reverse any effects of this ...
Base class for actions which act on a specified location (and possibly on other locations that can be...
Definition: action.hpp:189
const std::string & get_name() const
Inherited from editor_action, implemented by IMPLEMENT_ACTION.
const std::string category_
Editor action classes.
Manage the empty-palette in the editor.
Definition: action.cpp:29
const std::string & get_name() const
Inherited from editor_action, implemented by IMPLEMENT_ACTION.
void perform_without_undo(map_context &mc) const
Perform the action without creating an undo action.
Encapsulates the map of the game.
Definition: location.hpp:40
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
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_label(map_location loc, const std::string &text, const std::string &team_name, color_t color, bool visible_fog, bool visible_shroud, bool immutable, std::string category)
editor_action_label_delete * clone() const
Inherited from editor_action, implemented by IMPLEMENT_ACTION.