The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
brush.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2008 - 2016 by Tomasz Sniatowski <[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 #ifndef EDITOR_BRUSH_HPP_INCLUDED
16 #define EDITOR_BRUSH_HPP_INCLUDED
17 
19 
20 namespace editor {
21 
22 /**
23  * The brush class represents a single brush -- a set of relative locations around a "hotspot",
24  * and related info such as the icon image. It is constructed from WML -- the [brush] tag.
25  */
26 class brush
27 {
28 public:
29  /**
30  * Construct a default (empty) brush. Note that not even the hotspot is affected by default,
31  */
32  brush();
33 
34  /**
35  * Construct a brush object from config
36  */
37  explicit brush(const config& cfg);
38 
39  /**
40  * Add a location to the brush. If it already exists nothing will change.
41  */
42  void add_relative_location(int relative_x, int relative_y);
43 
44  /**
45  * Get a set of locations affected (i.e. under the brush) when the center (hotspot)
46  * is in given location
47  */
48  std::set<map_location> project(const map_location& hotspot) const;
49 
50  /**
51  * @return the name of this brush
52  */
53  const std::string name() const { return name_; }
54 
55  /**
56  * @return the image of this brush
57  */
58  const std::string id() const { return id_; }
59 
60 protected:
61  /**
62  * The relative locations of the brush
63  */
64  std::set<map_location> relative_tiles_;
65 
68 };
69 
70 
71 } //end namespace editor
72 
73 #endif
std::string id_
Definition: brush.hpp:67
std::string name_
Definition: brush.hpp:66
const std::string id() const
Definition: brush.hpp:58
The brush class represents a single brush – a set of relative locations around a "hotspot"...
Definition: brush.hpp:26
brush()
Construct a default (empty) brush.
Definition: brush.cpp:59
const std::string name() const
Definition: brush.hpp:53
Manage the empty-palette in the editor.
Definition: action.cpp:28
Encapsulates the map of the game.
Definition: location.hpp:38
std::set< map_location > relative_tiles_
The relative locations of the brush.
Definition: brush.hpp:64
void add_relative_location(int relative_x, int relative_y)
Add a location to the brush.
Definition: brush.cpp:90
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:83
GLsizei const GLcharARB ** string
Definition: glew.h:4503
std::set< map_location > project(const map_location &hotspot) const
Get a set of locations affected (i.e.
Definition: brush.cpp:95