The Battle for Wesnoth  1.19.7+dev
brush.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2008 - 2024
3  by Tomasz Sniatowski <kailoran@gmail.com>
4  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY.
12 
13  See the COPYING file for more details.
14 */
15 
16 #pragma once
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 
66  std::string name_;
67  std::string id_;
68 };
69 
70 
71 } //end namespace editor
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:172
The brush class represents a single brush – a set of relative locations around a "hotspot",...
Definition: brush.hpp:27
brush()
Construct a default (empty) brush.
Definition: brush.cpp:25
void add_relative_location(int relative_x, int relative_y)
Add a location to the brush.
Definition: brush.cpp:56
std::set< map_location > relative_tiles_
The relative locations of the brush.
Definition: brush.hpp:64
const std::string id() const
Definition: brush.hpp:58
std::string name_
Definition: brush.hpp:66
std::set< map_location > project(const map_location &hotspot) const
Get a set of locations affected (i.e.
Definition: brush.cpp:61
const std::string name() const
Definition: brush.hpp:53
std::string id_
Definition: brush.hpp:67
Manage the empty-palette in the editor.
Definition: action.cpp:31
Encapsulates the map of the game.
Definition: location.hpp:45