FIFE  be64c707dea6b3250bd4355bf5c825d25920087d
cellrenderer.h
Go to the documentation of this file.
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:
50  CellRenderer(RenderBackend* renderbackend, int32_t position);
51 
54  CellRenderer(const CellRenderer& old);
55 
59 
62  virtual ~CellRenderer();
63 
68  std::string getName();
69 
77  void render(Camera* cam, Layer* layer, RenderList& instances);
78 
85  void setBlockerColor(uint8_t r, uint8_t g, uint8_t b);
86 
93  void setPathColor(uint8_t r, uint8_t g, uint8_t b);
94 
99  void setEnabledBlocking(bool enabled);
100 
105  bool isEnabledBlocking();
106 
111  void setEnabledPathVisual(bool enabled);
112 
117  bool isEnabledPathVisual();
118 
123  void addPathVisual(Instance* instance);
124 
129  void removePathVisual(Instance* instance);
130 
136  void setEnabledCost(const std::string& costId, bool enabled);
137 
143  bool isEnabledCost(const std::string& costId);
144 
149  void setFont(IFont* font);
150 
155  IFont* getFont();
156 
160 
161  private:
162  SDL_Color m_blockerColor;
163  SDL_Color m_pathColor;
167 
168  std::vector<Instance*> m_visualPaths;
169  std::set<std::string> m_visualCosts;
170  };
171 }
172 
173 #endif
std::vector< Instance * > m_visualPaths
Definition: cellrenderer.h:168
Abstract interface for all the renderbackends.
static CellRenderer * getInstance(IRendererContainer *cnt)
Gets instance for interface access.
void addPathVisual(Instance *instance)
Adds a instance to path visualization.
std::vector< RenderItem * > RenderList
Definition: renderitem.h:130
std::set< std::string > m_visualCosts
Definition: cellrenderer.h:169
Interface to class owning the renderers Used to get correct subclass of renderer in scripting side (v...
Definition: rendererbase.h:66
IFont * getFont()
Returns the font.
Camera describes properties of a view port shown in the main screen Main screen can have multiple cam...
Definition: camera.h:59
void setBlockerColor(uint8_t r, uint8_t g, uint8_t b)
Sets color that is used to visualize blocker.
unsigned char uint8_t
Definition: core.h:38
Base class for all view renderers View renderer renders one aspect of the view shown on screen...
Definition: rendererbase.h:78
void removePathVisual(Instance *instance)
Removes a instance from path visualization.
bool isEnabledCost(const std::string &costId)
Gets whether a cost visualization is enabled.
CellRenderer(RenderBackend *renderbackend, int32_t position)
Constructor.
void setEnabledCost(const std::string &costId, bool enabled)
Enables cost visualization.
A basic layer on a map.
Definition: layer.h:99
void setEnabledPathVisual(bool enabled)
Enables path visualization.
void setEnabledBlocking(bool enabled)
Enables blocking visualization.
Pure abstract Font interface.
Definition: ifont.h:43
void setPathColor(uint8_t r, uint8_t g, uint8_t b)
Sets color that is used to visualize paths.
void render(Camera *cam, Layer *layer, RenderList &instances)
This method is called by the view to ask renderer to draw its rendering aspect based on given paramet...
void setFont(IFont *font)
Sets the font.
std::string getName()
Returns the renderer name.
SDL_Color m_blockerColor
Definition: cellrenderer.h:162
bool isEnabledBlocking()
Gets whether blocking visualization is enabled.
RendererBase * clone()
Makes copy of this renderer.
SDL_Color m_pathColor
Definition: cellrenderer.h:163
An Instance is an "instantiation" of an Object at a Location.
Definition: instance.h:94
bool isEnabledPathVisual()
Gets whether path visualization is enabled.
virtual ~CellRenderer()
Destructor.