Debian Codegraph @

engine/core/view/renderers/cellselectionrenderer.h

raw
1 /***************************************************************************
2 * Copyright (C) 2005-2019 by the FIFE team *
3 * http://www.fifengine.net *
4 * This file is part of FIFE. *
5 * *
6 * FIFE is free software; you can redistribute it and/or *
7 * modify it under the terms of the GNU Lesser General Public *
8 * License as published by the Free Software Foundation; either *
9 * version 2.1 of the License, or (at your option) any later version. *
10 * *
11 * This library is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14 * Lesser General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU Lesser General Public *
17 * License along with this library; if not, write to the *
18 * Free Software Foundation, Inc., *
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
20 ***************************************************************************/
21
22 #ifndef FIFE_CELLSELECTIONRENDERER_H
23 #define FIFE_CELLSELECTIONRENDERER_H
24
25 // Standard C++ library includes
26
27 // 3rd party library includes
28
29 // FIFE includes
30 // These includes are split up in two parts, separated by one empty line
31 // First block: files included from the FIFE root src directory
32 // Second block: files included from the same folder
33 #include "view/rendererbase.h"
34 #include "model/structures/location.h"
35
36 namespace FIFE {
37 class RenderBackend;
38
39 /** CellSelectionRenderer renders a frame around selected cells.
40 */
41 class CellSelectionRenderer: public RendererBase {
42 public:
43 /** Constructor.
44 *
45 * @param renderbackend The renderbackend to use.
46 * @param position The position for this renderer in rendering pipeline.
47 * @ see setPipelinePosition
48 */
49 CellSelectionRenderer(RenderBackend* renderbackend, int32_t position);
50
51 /** Copy Constructor.
52 */
53 CellSelectionRenderer(const CellSelectionRenderer& old);
54
55 /** Makes copy of this renderer.
56 */
57 RendererBase* clone();
58
59 /** Destructor.
60 */
61 virtual ~CellSelectionRenderer();
62
63 /** This method is called by the view to ask renderer to draw its rendering aspect based on
64 * given parameters.
65 *
66 * @param cam Camera view to draw
67 * @param layer Current layer to be rendered
68 * @param instances Instances on the current layer
69 */
70 void render(Camera* cam, Layer* layer, RenderList& instances);
71
72 /** Returns the renderer name.
73 *
74 * @return The name as string.
75 */
76 std::string getName() { return "CellSelectionRenderer"; }
77
78 /** Gets instance for interface access.
79 */
80 static CellSelectionRenderer* getInstance(IRendererContainer* cnt);
81
82 /** Deselects all locations.
83 */
84 void reset();
85
86 /** Selects given location on map.
87 *
88 * @param loc The location.
89 */
90 void selectLocation(const Location* loc);
91
92 /** Deselects given location on map.
93 *
94 * @param loc The location.
95 */
96 void deselectLocation(const Location* loc);
97
98 /** Returns selected locations.
99 *
100 * @return A vector that contains all selected locations.
101 */
102 const std::vector<Location> getLocations() const { return m_locations; }
103
104 /** Changes the used color.
105 *
106 * @param r The value for red, range 0-255.
107 * @param g The value for green, range 0-255.
108 * @param b The value for blue, range 0-255.
109 */
110 void setColor(uint8_t r, uint8_t g, uint8_t b);
111
112 private:
113 //! selected locations
114 std::vector<Location> m_locations;
115
116 //! currently used color
117 SDL_Color m_color;
118 };
119
120 }
121
122 #endif