Debian Codegraph @

engine/core/view/renderers/cellrenderer.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_CELLRENDERER_H
23 #define FIFE_CELLRENDERER_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
35 #include "targetrenderer.h"
36
37 namespace FIFE {
38 class RenderBackend;
39 class Cell;
40 class IFont;
41
42 class CellRenderer: public RendererBase {
43 public:
44 /** Constructor.
45 *
46 * @param renderbackend The renderbackend to use.
47 * @param position The position for this renderer in rendering pipeline.
48 * @ see setPipelinePosition
49 */
50 CellRenderer(RenderBackend* renderbackend, int32_t position);
51
52 /** Copy Constructor.
53 */
54 CellRenderer(const CellRenderer& old);
55
56 /** Makes copy of this renderer.
57 */
58 RendererBase* clone();
59
60 /** Destructor.
61 */
62 virtual ~CellRenderer();
63
64 /** Returns the renderer name.
65 *
66 * @return The name as string.
67 */
68 std::string getName();
69
70 /** This method is called by the view to ask renderer to draw its rendering aspect based on
71 * given parameters.
72 *
73 * @param cam Camera view to draw
74 * @param layer Current layer to be rendered
75 * @param instances Instances on the current layer
76 */
77 void render(Camera* cam, Layer* layer, RenderList& instances);
78
79 /** Sets color that is used to visualize blocker.
80 *
81 * @param r The value for red, range 0-255.
82 * @param g The value for green, range 0-255.
83 * @param b The value for blue, range 0-255.
84 */
85 void setBlockerColor(uint8_t r, uint8_t g, uint8_t b);
86
87 /** Sets color that is used to visualize paths.
88 *
89 * @param r The value for red, range 0-255.
90 * @param g The value for green, range 0-255.
91 * @param b The value for blue, range 0-255.
92 */
93 void setPathColor(uint8_t r, uint8_t g, uint8_t b);
94
95 /** Enables blocking visualization.
96 *
97 * @param enabled A bool that enables or disables the visualization.
98 */
99 void setEnabledBlocking(bool enabled);
100
101 /** Gets whether blocking visualization is enabled.
102 *
103 * @return A bool, true if visualization is enabled, otherwise false.
104 */
105 bool isEnabledBlocking();
106
107 /** Enables path visualization.
108 *
109 * @param enabled A bool that enables or disables the visualization.
110 */
111 void setEnabledPathVisual(bool enabled);
112
113 /** Gets whether path visualization is enabled.
114 *
115 * @return A bool, true if visualization is enabled, otherwise false.
116 */
117 bool isEnabledPathVisual();
118
119 /** Adds a instance to path visualization. The current path is automatically rendered.
120 *
121 * @param instance The instance's path is visualized.
122 */
123 void addPathVisual(Instance* instance);
124
125 /** Removes a instance from path visualization.
126 *
127 * @param instance The instance's path is visualized.
128 */
129 void removePathVisual(Instance* instance);
130
131 /** Enables cost visualization.
132 *
133 * @param costId The cost identifier as string.
134 * @param enabled A bool that enables or disables the visualization.
135 */
136 void setEnabledCost(const std::string& costId, bool enabled);
137
138 /** Gets whether a cost visualization is enabled.
139 *
140 * @param costId The cost identifier as string.
141 * @return A bool, true if visualization is enabled, otherwise false.
142 */
143 bool isEnabledCost(const std::string& costId);
144
145 /** Sets the font.
146 *
147 * @param font The used font.
148 */
149 void setFont(IFont* font);
150
151 /** Returns the font.
152 *
153 * @return The used font.
154 */
155 IFont* getFont();
156
157 /** Gets instance for interface access.
158 */
159 static CellRenderer* getInstance(IRendererContainer* cnt);
160
161 private:
162 SDL_Color m_blockerColor;
163 SDL_Color m_pathColor;
164 bool m_blockingEnabled;
165 bool m_pathVisualEnabled;
166 IFont* m_font;
167
168 std::vector<Instance*> m_visualPaths;
169 std::set<std::string> m_visualCosts;
170 };
171 }
172
173 #endif