The Battle for Wesnoth  1.13.4+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 - 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_LABEL_HPP
27 #define EDITOR_ACTION_LABEL_HPP
28 
29 #include "editor/action/action.hpp"
30 
31 #include "map/map.hpp"
32 #include "map/label.hpp"
33 
34 
35 namespace editor {
36 
37 /**
38  * Set label action
39  */
41 {
42  public:
43  editor_action_label(map_location loc, const std::string& text, const std::string& team_name,
44  SDL_Color color, bool visible_fog, bool visible_shroud, bool immutable, std::string category)
45  : editor_action_location(loc), text_(text) , team_name_(team_name), category_(category), color_(color)
46  , visible_fog_(visible_fog), visible_shroud_(visible_shroud), immutable_(immutable)
47  {
48  }
49  editor_action_label* clone() const;
50  editor_action* perform(map_context& mc) const;
51  void perform_without_undo(map_context& mc) const;
52  const char* get_name() const { return "label"; }
53  protected:
57  SDL_Color color_;
60  bool immutable_;
61 };
62 
64 {
65  public:
68  {
69  }
71  editor_action* perform(map_context& mc) const;
72  void perform_without_undo(map_context& mc) const;
73  const char* get_name() const { return "label_delete"; }
74 };
75 
76 } //end namespace editor
77 
78 #endif
const std::string team_name_
editor_action_label_delete * clone() const
Action cloning.
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 ...
Base class for actions which act on a specified location (and possibly on other locations that can be...
Definition: action.hpp:177
const char * get_name() const
const std::string category_
Editor action classes.
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.
GLuint color
Definition: glew.h:5801
editor_action_label * clone() const
Action cloning.
Encapsulates the map of the game.
Definition: location.hpp:38
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
const char * get_name() const
editor_action * perform(map_context &mc) const
Perform the action, returning an undo action that, when performed, shall reverse any effects of this ...
GLsizei const GLcharARB ** string
Definition: glew.h:4503