FIFE  6e1afdbeda11afe9ac53e6023a4be96ef88f1dc6
FIFE::CellRenderer Class Reference

#include <cellrenderer.h>

+ Inheritance diagram for FIFE::CellRenderer:
+ Collaboration diagram for FIFE::CellRenderer:

Public Member Functions

 CellRenderer (RenderBackend *renderbackend, int32_t position)
 Constructor. More...
 
 CellRenderer (const CellRenderer &old)
 Copy Constructor. More...
 
RendererBaseclone ()
 Makes copy of this renderer. More...
 
virtual ~CellRenderer ()
 Destructor. More...
 
std::string getName ()
 Returns the renderer name. More...
 
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 parameters. More...
 
void setBlockerColor (uint8_t r, uint8_t g, uint8_t b)
 Sets color that is used to visualize blocker. More...
 
void setPathColor (uint8_t r, uint8_t g, uint8_t b)
 Sets color that is used to visualize paths. More...
 
void setEnabledBlocking (bool enabled)
 Enables blocking visualization. More...
 
bool isEnabledBlocking ()
 Gets whether blocking visualization is enabled. More...
 
void setEnabledFogOfWar (bool enabled)
 Enables Fog of War visualization. More...
 
bool isEnabledFogOfWar ()
 Gets whether Fog of War visualization is enabled. More...
 
void setEnabledPathVisual (bool enabled)
 Enables path visualization. More...
 
bool isEnabledPathVisual ()
 Gets whether path visualization is enabled. More...
 
void setFogOfWarLayer (Layer *layer)
 Sets the layer that is used for Fog of War visualization. More...
 
void setConcealImage (ImagePtr image)
 Sets the image that is used for concealed spaces. More...
 
void setMaskImage (ImagePtr image)
 Sets the fog image. More...
 
void addPathVisual (Instance *instance)
 Adds a instance to path visualization. More...
 
void removePathVisual (Instance *instance)
 Removes a instance from path visualization. More...
 
void createFowMap (Camera *cam, Layer *layer)
 Creates render target for Fog of War. More...
 
void addImageToMap (Camera *cam, Point center, ImagePtr image, const std::string &id)
 Adds image to FoW render target. More...
 
LayergetFowLayer ()
 Returns the layer that is used for Fog of War visualization. More...
 
void setEnabledCost (const std::string &costId, bool enabled)
 Enables cost visualization. More...
 
bool isEnabledCost (const std::string &costId)
 Gets whether a cost visualization is enabled. More...
 
void setFont (IFont *font)
 Sets the font. More...
 
IFontgetFont ()
 Returns the font. More...
 
void updateFowMap ()
 Updates render target. More...
 
- Public Member Functions inherited from FIFE::RendererBase
 RendererBase (RenderBackend *renderbackend, int32_t position)
 Constructor. More...
 
 RendererBase (const RendererBase &old)
 Copy Constructor. More...
 
virtual ~RendererBase ()
 Destructor. More...
 
int32_t getPipelinePosition () const
 Gets renderer position in the rendering pipeline. More...
 
void setPipelinePosition (int32_t position)
 Sets renderer position in the rendering pipeline Pipeline position defines in which order view calls the renderers when update occurs Note that renderers are called once per rendered layer, thus to update the whole screen, renderer might receive multiple calls. More...
 
virtual void setEnabled (bool enabled)
 Enables renderer. More...
 
virtual void reset ()
 Resets information in the renderer. More...
 
bool isEnabled () const
 Is renderer enabled. More...
 
void setRendererListener (IRendererListener *listener)
 Sets listener for renderer. More...
 
void addActiveLayer (Layer *layer)
 Adds active layer to renderer. More...
 
void removeActiveLayer (Layer *layer)
 Removes active layer from renderer. More...
 
void clearActiveLayers ()
 Clears all active layers from renderer. More...
 
void activateAllLayers (Map *elevation)
 Activates all layers from given elevation. More...
 
bool isActivedLayer (Layer *layer)
 Returns if given layer is currently activated. More...
 
std::list< Layer * > getActiveLayers () const
 Returns list of activated layer. More...
 

Static Public Member Functions

static CellRenderergetInstance (IRendererContainer *cnt)
 Gets instance for interface access. More...
 

Private Attributes

SDL_Color m_blockerColor
 
SDL_Color m_pathColor
 
bool m_blockingEnabled
 
bool m_fowEnabled
 
bool m_pathVisualEnabled
 
TargetRendererm_targetRenderer
 
RenderTargetPtr m_fowTarget
 
Layerm_fowLayer
 
ImagePtr m_concealImage
 
ImagePtr m_maskImage
 
ImagePtr m_fowImage
 
IFontm_font
 
std::vector< Instance * > m_visualPaths
 
std::set< std::string > m_visualCosts
 

Additional Inherited Members

- Protected Member Functions inherited from FIFE::RendererBase
 RendererBase ()
 
- Protected Attributes inherited from FIFE::RendererBase
std::list< Layer * > m_active_layers
 
RenderBackendm_renderbackend
 

Detailed Description

Definition at line 42 of file cellrenderer.h.

Constructor & Destructor Documentation

FIFE::CellRenderer::CellRenderer ( RenderBackend renderbackend,
int32_t  position 
)

Constructor.

Parameters
renderbackendThe renderbackend to use.
positionThe position for this renderer in rendering pipeline. @ see setPipelinePosition

Definition at line 51 of file cellrenderer.cpp.

References FIFE::RenderBackend::isFramebufferEnabled(), m_blockerColor, m_blockingEnabled, m_font, m_fowEnabled, m_fowLayer, m_pathColor, m_pathVisualEnabled, FIFE::RendererBase::m_renderbackend, m_targetRenderer, and FIFE::RendererBase::setEnabled().

Referenced by clone().

+ Here is the caller graph for this function:

FIFE::CellRenderer::~CellRenderer ( )
virtual

Destructor.

Definition at line 86 of file cellrenderer.cpp.

References m_targetRenderer.

Member Function Documentation

void FIFE::CellRenderer::addImageToMap ( Camera cam,
Point  center,
ImagePtr  image,
const std::string &  id 
)

Adds image to FoW render target.

Parameters
camThe used camera.
centerThe coordinates.
imageThe used image.
idThe id as string.

Definition at line 316 of file cellrenderer.cpp.

References FIFE::RenderTarget::addImage(), FIFE::Math< T >::Equal(), FIFE::Image::getHeight(), FIFE::Image::getWidth(), FIFE::Camera::getZoom(), m_fowTarget, m_targetRenderer, FIFE::Image::render(), FIFE::RenderTarget::resizeImage(), FIFE::PointType2D< T >::x, and FIFE::PointType2D< T >::y.

Referenced by render().

+ Here is the caller graph for this function:

void FIFE::CellRenderer::addPathVisual ( Instance instance)

Adds a instance to path visualization.

The current path is automatically rendered.

Parameters
instanceThe instance's path is visualized.

Definition at line 359 of file cellrenderer.cpp.

References m_visualPaths.

RendererBase * FIFE::CellRenderer::clone ( )
virtual

Makes copy of this renderer.

Implements FIFE::RendererBase.

Definition at line 82 of file cellrenderer.cpp.

References CellRenderer().

void FIFE::CellRenderer::createFowMap ( Camera cam,
Layer layer 
)

Creates render target for Fog of War.

Parameters
camThe used camera.
layerThe used layer.

Definition at line 292 of file cellrenderer.cpp.

References FIFE::RenderTarget::addQuad(), FIFE::TargetRenderer::createRenderTarget(), FIFE::Camera::getViewPort(), FIFE::RectType< T >::h, FIFE::DynamicSingleton< ImageManager >::instance(), FIFE::ImageManager::loadBlank(), m_fowImage, m_fowTarget, m_targetRenderer, FIFE::TargetRenderer::setRenderTarget(), and FIFE::RectType< T >::w.

Referenced by render().

+ Here is the caller graph for this function:

IFont * FIFE::CellRenderer::getFont ( )

Returns the font.

Returns
The used font.

Definition at line 348 of file cellrenderer.cpp.

References m_font.

Layer * FIFE::CellRenderer::getFowLayer ( )

Returns the layer that is used for Fog of War visualization.

Returns
The used layer.

Definition at line 340 of file cellrenderer.cpp.

References m_fowLayer.

Referenced by FIFE::InstanceRenderer::renderAlreadySorted(), and FIFE::InstanceRenderer::renderUnsorted().

+ Here is the caller graph for this function:

CellRenderer * FIFE::CellRenderer::getInstance ( IRendererContainer cnt)
static

Gets instance for interface access.

Definition at line 90 of file cellrenderer.cpp.

References FIFE::IRendererContainer::getRenderer().

std::string FIFE::CellRenderer::getName ( )
virtual

Returns the renderer name.

Returns
The name as string.

Implements FIFE::RendererBase.

Definition at line 94 of file cellrenderer.cpp.

bool FIFE::CellRenderer::isEnabledBlocking ( )

Gets whether blocking visualization is enabled.

Returns
A bool, true if visualization is enabled, otherwise false.

Definition at line 272 of file cellrenderer.cpp.

References m_blockingEnabled.

bool FIFE::CellRenderer::isEnabledCost ( const std::string &  costId)

Gets whether a cost visualization is enabled.

Parameters
costIdThe cost identifier as string.
Returns
A bool, true if visualization is enabled, otherwise false.

Definition at line 382 of file cellrenderer.cpp.

References m_visualCosts.

bool FIFE::CellRenderer::isEnabledFogOfWar ( )

Gets whether Fog of War visualization is enabled.

Returns
A bool, true if visualization is enabled, otherwise false.

Definition at line 280 of file cellrenderer.cpp.

References m_fowEnabled.

Referenced by FIFE::InstanceRenderer::renderAlreadySorted(), and FIFE::InstanceRenderer::renderUnsorted().

+ Here is the caller graph for this function:

bool FIFE::CellRenderer::isEnabledPathVisual ( )

Gets whether path visualization is enabled.

Returns
A bool, true if visualization is enabled, otherwise false.

Definition at line 288 of file cellrenderer.cpp.

References m_pathVisualEnabled.

void FIFE::CellRenderer::removePathVisual ( Instance instance)

Removes a instance from path visualization.

Parameters
instanceThe instance's path is visualized.

Definition at line 363 of file cellrenderer.cpp.

References m_visualPaths.

void FIFE::CellRenderer::render ( Camera cam,
Layer layer,
RenderList instances 
)
virtual

This method is called by the view to ask renderer to draw its rendering aspect based on given parameters.

Parameters
camCamera view to draw
layerCurrent layer to be rendered
instancesInstances on the current layer

Implements FIFE::RendererBase.

Definition at line 98 of file cellrenderer.cpp.

References FIFE::_log, addImageToMap(), FIFE::CELLV_CONCEALED, FIFE::CELLV_MASKED, createFowMap(), FIFE::CTYPE_NO_BLOCKER, FIFE::RenderBackend::drawLine(), FIFE::Math< T >::Equal(), FL_WARN, FIFE::SharedPtr< T >::get(), FIFE::IFont::getAsImage(), FIFE::Layer::getCellCache(), FIFE::CellCache::getCellCosts(), FIFE::Layer::getCellGrid(), FIFE::CellCache::getCellsInRect(), FIFE::CellCache::getCost(), FIFE::Image::getHeight(), FIFE::Camera::getLayerViewPort(), FIFE::Location::getMapCoordinates(), FIFE::Route::getPath(), FIFE::CellGrid::getVertices(), FIFE::Camera::getViewPort(), FIFE::Image::getWidth(), FIFE::Camera::getZoom(), FIFE::RectType< T >::h, FIFE::intPt2doublePt(), FIFE::CellCache::isUpdated(), FIFE::Camera::isUpdated(), m_blockerColor, m_blockingEnabled, m_concealImage, m_font, m_fowEnabled, m_fowImage, m_fowLayer, m_maskImage, m_pathColor, m_pathVisualEnabled, FIFE::RendererBase::m_renderbackend, m_targetRenderer, m_visualCosts, m_visualPaths, FIFE::Image::render(), FIFE::Location::setLayerCoordinates(), FIFE::CellGrid::toMapCoordinates(), FIFE::Camera::toScreenCoordinates(), updateFowMap(), FIFE::RectType< T >::w, FIFE::PointType2D< T >::x, FIFE::RectType< T >::x, FIFE::PointType3D< T >::x, FIFE::PointType2D< T >::y, FIFE::RectType< T >::y, and FIFE::PointType3D< T >::y.

void FIFE::CellRenderer::setBlockerColor ( uint8_t  r,
uint8_t  g,
uint8_t  b 
)

Sets color that is used to visualize blocker.

Parameters
rThe value for red, range 0-255.
gThe value for green, range 0-255.
bThe value for blue, range 0-255.

Definition at line 252 of file cellrenderer.cpp.

References m_blockerColor.

void FIFE::CellRenderer::setConcealImage ( ImagePtr  image)

Sets the image that is used for concealed spaces.

Parameters
imageThe used image.

Definition at line 308 of file cellrenderer.cpp.

References m_concealImage.

void FIFE::CellRenderer::setEnabledBlocking ( bool  enabled)

Enables blocking visualization.

Parameters
enabledA bool that enables or disables the visualization.

Definition at line 268 of file cellrenderer.cpp.

References m_blockingEnabled.

void FIFE::CellRenderer::setEnabledCost ( const std::string &  costId,
bool  enabled 
)

Enables cost visualization.

Parameters
costIdThe cost identifier as string.
enabledA bool that enables or disables the visualization.

Definition at line 374 of file cellrenderer.cpp.

References m_visualCosts.

void FIFE::CellRenderer::setEnabledFogOfWar ( bool  enabled)

Enables Fog of War visualization.

Parameters
enabledA bool that enables or disables the visualization.

Definition at line 276 of file cellrenderer.cpp.

References m_fowEnabled.

void FIFE::CellRenderer::setEnabledPathVisual ( bool  enabled)

Enables path visualization.

Parameters
enabledA bool that enables or disables the visualization.

Definition at line 284 of file cellrenderer.cpp.

References m_pathVisualEnabled.

void FIFE::CellRenderer::setFogOfWarLayer ( Layer layer)

Sets the layer that is used for Fog of War visualization.

Parameters
layerThe layer that is used for visualization.

Definition at line 264 of file cellrenderer.cpp.

References m_fowLayer.

void FIFE::CellRenderer::setFont ( IFont font)

Sets the font.

Parameters
fontThe used font.

Definition at line 344 of file cellrenderer.cpp.

References m_font.

void FIFE::CellRenderer::setMaskImage ( ImagePtr  image)

Sets the fog image.

Parameters
imageThe used image.

Definition at line 312 of file cellrenderer.cpp.

References m_maskImage.

void FIFE::CellRenderer::setPathColor ( uint8_t  r,
uint8_t  g,
uint8_t  b 
)

Sets color that is used to visualize paths.

Parameters
rThe value for red, range 0-255.
gThe value for green, range 0-255.
bThe value for blue, range 0-255.

Definition at line 258 of file cellrenderer.cpp.

References m_pathColor.

void FIFE::CellRenderer::updateFowMap ( )

Updates render target.

Definition at line 352 of file cellrenderer.cpp.

References m_fowTarget, m_targetRenderer, FIFE::RenderTarget::removeAll(), FIFE::TargetRenderer::render(), and FIFE::TargetRenderer::setRenderTarget().

Referenced by render().

+ Here is the caller graph for this function:

Member Data Documentation

SDL_Color FIFE::CellRenderer::m_blockerColor
private

Definition at line 218 of file cellrenderer.h.

Referenced by CellRenderer(), render(), and setBlockerColor().

bool FIFE::CellRenderer::m_blockingEnabled
private

Definition at line 220 of file cellrenderer.h.

Referenced by CellRenderer(), isEnabledBlocking(), render(), and setEnabledBlocking().

ImagePtr FIFE::CellRenderer::m_concealImage
private

Definition at line 227 of file cellrenderer.h.

Referenced by render(), and setConcealImage().

IFont* FIFE::CellRenderer::m_font
private

Definition at line 230 of file cellrenderer.h.

Referenced by CellRenderer(), getFont(), render(), and setFont().

bool FIFE::CellRenderer::m_fowEnabled
private

Definition at line 221 of file cellrenderer.h.

Referenced by CellRenderer(), isEnabledFogOfWar(), render(), and setEnabledFogOfWar().

ImagePtr FIFE::CellRenderer::m_fowImage
private

Definition at line 229 of file cellrenderer.h.

Referenced by createFowMap(), and render().

Layer* FIFE::CellRenderer::m_fowLayer
private

Definition at line 226 of file cellrenderer.h.

Referenced by CellRenderer(), getFowLayer(), render(), and setFogOfWarLayer().

RenderTargetPtr FIFE::CellRenderer::m_fowTarget
private

Definition at line 225 of file cellrenderer.h.

Referenced by addImageToMap(), createFowMap(), and updateFowMap().

ImagePtr FIFE::CellRenderer::m_maskImage
private

Definition at line 228 of file cellrenderer.h.

Referenced by render(), and setMaskImage().

SDL_Color FIFE::CellRenderer::m_pathColor
private

Definition at line 219 of file cellrenderer.h.

Referenced by CellRenderer(), render(), and setPathColor().

bool FIFE::CellRenderer::m_pathVisualEnabled
private

Definition at line 222 of file cellrenderer.h.

Referenced by CellRenderer(), isEnabledPathVisual(), render(), and setEnabledPathVisual().

TargetRenderer* FIFE::CellRenderer::m_targetRenderer
private
std::set<std::string> FIFE::CellRenderer::m_visualCosts
private

Definition at line 233 of file cellrenderer.h.

Referenced by isEnabledCost(), render(), and setEnabledCost().

std::vector<Instance*> FIFE::CellRenderer::m_visualPaths
private

Definition at line 232 of file cellrenderer.h.

Referenced by addPathVisual(), removePathVisual(), and render().


The documentation for this class was generated from the following files: