The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
action_label.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2010 - 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 label action classes
18  */
19 #define GETTEXT_DOMAIN "wesnoth-editor"
20 
22 
24 
25 
26 namespace editor {
27 
29 {
30  return new editor_action_label(*this);
31 }
32 
34 {
35  std::unique_ptr<editor_action> undo;
36 
37  const terrain_label *old_label = mc.get_labels().get_label(loc_);
38  if (old_label) {
39  undo.reset(new editor_action_label(loc_, old_label->text(), old_label->team_name(), old_label->color()
40  , old_label->visible_in_fog(), old_label->visible_in_shroud(), old_label->immutable(), old_label->category()) );
41  } else {
42  undo.reset(new editor_action_label_delete(loc_));
43  }
44 
46  return undo.release();
47 }
48 
50 {
51  mc.get_labels()
53 }
54 
56 {
57  return new editor_action_label_delete(*this);
58 }
59 
61 {
62  std::unique_ptr<editor_action> undo;
63 
64  const terrain_label* deleted = mc.get_labels().get_label(loc_);
65 
66  if (!deleted) return nullptr;
67 
68  undo.reset(new editor_action_label(loc_, deleted->text(), deleted->team_name()
69  , deleted->color(), deleted->visible_in_fog(), deleted->visible_in_shroud(), deleted->immutable(), deleted->category()));
70 
72  return undo.release();
73 }
74 
76 {
77  mc.get_labels().set_label(loc_, "");
78 }
79 
80 
81 } //end namespace editor
const std::string team_name_
editor_action_label_delete * clone() const
Action cloning.
Editor action classes.
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 * perform(map_context &mc) const
Perform the action, returning an undo action that, when performed, shall reverse any effects of this ...
map_labels & get_labels()
const terrain_label * set_label(const map_location &loc, const t_string &text, const int creator=-1, const std::string &team="", const SDL_Color color=font::NORMAL_COLOR, const bool visible_in_fog=true, const bool visible_in_shroud=false, const bool immutable=false, const std::string &category="", const t_string &tooltip="")
Definition: label.cpp:145
bool immutable() const
Definition: label.cpp:454
const std::string & team_name() const
Definition: label.cpp:439
const SDL_Color & color() const
Definition: label.cpp:464
const t_string & text() const
Definition: label.cpp:419
const std::string & category() const
Definition: label.cpp:434
const std::string category_
editor_action_label(map_location loc, const std::string &text, const std::string &team_name, SDL_Color color, bool visible_fog, bool visible_shroud, bool immutable, std::string category)
Manage the empty-palette in the editor.
Definition: action.cpp:28
void perform_without_undo(map_context &mc) const
Perform the action without creating an undo action.
const terrain_label * get_label(const map_location &loc, const std::string &team_name) const
Definition: label.cpp:97
editor_action_label * clone() const
Action cloning.
bool visible_in_shroud() const
Definition: label.cpp:449
Base class for all editor actions.
Definition: action_base.hpp:41
bool visible_in_fog() const
Definition: label.cpp:444
This class wraps around a map to provide a concise interface for the editor to work with...
Definition: map_context.hpp:41
To store label data Class implements logic for rendering.
Definition: label.hpp:103
editor_action * perform(map_context &mc) const
Perform the action, returning an undo action that, when performed, shall reverse any effects of this ...