The Battle for Wesnoth  1.13.10+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 - 2017 by Tomasz Sniatowski <kailoran@gmail.com>
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 #pragma once
16 
18 
19 namespace editor {
20 
21 /**
22  * The brush class represents a single brush -- a set of relative locations around a "hotspot",
23  * and related info such as the icon image. It is constructed from WML -- the [brush] tag.
24  */
25 class brush
26 {
27 public:
28  /**
29  * Construct a default (empty) brush. Note that not even the hotspot is affected by default,
30  */
31  brush();
32 
33  /**
34  * Construct a brush object from config
35  */
36  explicit brush(const config& cfg);
37 
38  /**
39  * Add a location to the brush. If it already exists nothing will change.
40  */
41  void add_relative_location(int relative_x, int relative_y);
42 
43  /**
44  * Get a set of locations affected (i.e. under the brush) when the center (hotspot)
45  * is in given location
46  */
47  std::set<map_location> project(const map_location& hotspot) const;
48 
49  /**
50  * @return the name of this brush
51  */
52  const std::string name() const { return name_; }
53 
54  /**
55  * @return the image of this brush
56  */
57  const std::string id() const { return id_; }
58 
59 protected:
60  /**
61  * The relative locations of the brush
62  */
63  std::set<map_location> relative_tiles_;
64 
67 };
68 
69 
70 } //end namespace editor
std::vector< char_t > string
std::string id_
Definition: brush.hpp:66
std::string name_
Definition: brush.hpp:65
const std::string id() const
Definition: brush.hpp:57
The brush class represents a single brush – a set of relative locations around a "hotspot"...
Definition: brush.hpp:25
brush()
Construct a default (empty) brush.
Definition: brush.cpp:59
const std::string name() const
Definition: brush.hpp:52
Manage the empty-palette in the editor.
Definition: action.cpp:29
Encapsulates the map of the game.
Definition: location.hpp:40
std::set< map_location > relative_tiles_
The relative locations of the brush.
Definition: brush.hpp:63
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:93
std::set< map_location > project(const map_location &hotspot) const
Get a set of locations affected (i.e.
Definition: brush.cpp:95