The Battle for Wesnoth  1.19.0-dev
action_label.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2010 - 2024
3  by Fabian Mueller <fabianmueller5@gmx.de>
4  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY.
12 
13  See the COPYING file for more details.
14 */
15 
16 /**
17  * @file
18  * Editor action classes. Some important points:
19  * - This is a polymorphic hierarchy of classes, so actions are usually passed around
20  * as editor_action pointers
21  * - The pointers can, in general, be null. Always check for null before doing anything.
22  * The helper functions perform_ that take a pointer do that.
23  * - The perform() functions can throw when an error occurs. Use smart pointers if you
24  * need to ensure the pointer is deleted.
25  */
26 
27 #pragma once
28 
29 #include "color.hpp"
30 #include "editor/action/action.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  std::unique_ptr<editor_action> clone() const override;
60  std::unique_ptr<editor_action> perform(map_context& mc) const override;
61  void perform_without_undo(map_context& mc) const override;
62  const std::string& get_name() const override;
63 
64 protected:
65  const std::string text_;
66  const std::string team_name_;
67  const std::string category_;
68 
70 
73  bool immutable_;
74 };
75 
77 {
78 public:
81  {
82  }
83 
84  std::unique_ptr<editor_action> clone() const override;
85  std::unique_ptr<editor_action> perform(map_context& mc) const override;
86  void perform_without_undo(map_context& mc) const override;
87  const std::string& get_name() const override;
88 };
89 
90 } // end namespace editor
std::unique_ptr< editor_action > clone() const override
Action cloning.
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 > perform(map_context &mc) const override
Perform the action, returning an undo action that, when performed, shall reverse any effects of this ...
editor_action_label_delete(map_location loc)
const std::string category_
void perform_without_undo(map_context &mc) const override
Perform the action without creating an undo action.
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)
const std::string & get_name() const override
const std::string team_name_
std::unique_ptr< editor_action > clone() const override
Action cloning.
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 ...
Base class for actions which act on a specified location (and possibly on other locations that can be...
Definition: action.hpp:177
This class wraps around a map to provide a concise interface for the editor to work with.
Definition: map_context.hpp:63
Editor action classes.
Manage the empty-palette in the editor.
Definition: action.cpp:31
The basic class for representing 8-bit RGB or RGBA colour values.
Definition: color.hpp:59
Encapsulates the map of the game.
Definition: location.hpp:38