The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
action_select.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2008 - 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_SELECT_HPP
27 #define EDITOR_ACTION_SELECT_HPP
28 
29 #include "action.hpp"
30 
31 
32 namespace editor {
33 
34 /**
35  * Select the given locations
36  */
38 {
39  public:
40  editor_action_select(const std::set<map_location>& area)
41  : editor_action_area(area)
42  {
43  }
44  editor_action_select* clone() const;
45  void extend(const editor_map& map, const std::set<map_location>& locs);
46  editor_action* perform(map_context& mc) const;
47  void perform_without_undo(map_context& mc) const;
48  const char* get_name() const { return "select"; }
49 };
50 
51 /**
52  * Deselect the given locations
53  */
55 {
56 public:
57  editor_action_deselect(const std::set<map_location>& area) :
58  editor_action_area(area) {}
59 
61  void extend(const editor_map& map, const std::set<map_location>& locs);
62  editor_action* perform(map_context& mc) const;
63  void perform_without_undo(map_context& mc) const;
64  const char* get_name() const { return "deselect"; }
65 };
66 
67 /**
68  * Select the entire map
69  */
71 {
72  public:
74  {
75  }
78  void perform_without_undo(map_context& mc) const;
79  const char* get_name() const { return "select_all"; }
80 };
81 
82 /**
83  * Clear selection
84  */
86 {
87  public:
89  {
90  }
93  void perform_without_undo(map_context& mc) const;
94  const char* get_name() const { return "select_none"; }
95 };
96 
97 /**
98  * Invert the selection
99  */
101 {
102  public:
104  {
105  }
108  void perform_without_undo(map_context& mc) const;
109  const char* get_name() const { return "select_inverse"; }
110 };
111 
112 
113 
114 } //end namespace editor
115 
116 #endif
void perform_without_undo(map_context &mc) const
Perform the action without creating an undo action.
void perform_without_undo(map_context &mc) const
Perform the action without creating an undo action.
Select the entire map.
editor_action_select_inverse * clone() const
Action cloning.
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_deselect * clone() const
Action cloning.
Base class for area-affecting actions.
Definition: action.hpp:208
editor_action_deselect(const std::set< map_location > &area)
void perform_without_undo(map_context &mc) const
Perform the action without creating an undo action.
void perform_without_undo(map_context &mc) const
Perform the action without creating an undo action.
editor_action_select(const std::set< map_location > &area)
editor_action_select_all * clone() const
Action cloning.
const char * get_name() const
const char * get_name() const
Select the given locations.
Editor action classes.
void perform_without_undo(map_context &mc) const
Perform the action without creating an undo action.
Manage the empty-palette in the editor.
Definition: action.cpp:28
This class adds extra editor-specific functionality to a normal gamemap.
Definition: editor_map.hpp:70
Base class for all editor actions.
Definition: action_base.hpp:41
editor_action_select * clone() const
Action cloning.
editor_action_select_none * clone() const
Action cloning.
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 ...
void extend(const editor_map &map, const std::set< map_location > &locs)
The crux of the extendable contract.
editor_action_select_inverse * perform(map_context &mc) const
Perform the action, returning an undo action that, when performed, shall reverse any effects of this ...
void extend(const editor_map &map, const std::set< map_location > &locs)
The crux of the extendable contract.
editor_action_select * perform(map_context &mc) const
Perform the action, returning an undo action that, when performed, shall reverse any effects of this ...
Deselect the given locations.
editor_action_select * perform(map_context &mc) const
Perform the action, returning an undo action that, when performed, shall reverse any effects of this ...
const char * get_name() const