71 m_blockerColor(old.m_blockerColor),
72 m_pathColor(old.m_pathColor){
95 return "CellRenderer";
101 FL_WARN(
_log,
"No cellgrid assigned to layer, cannot draw grid");
106 FL_WARN(
_log,
"No cellcache on layer created, cannot draw cells");
121 std::vector<Cell*>::iterator cit = cells.begin();
122 for (; cit != cells.end(); ++cit) {
125 std::vector<ExactModelCoordinate> vertices;
126 cg->
getVertices(vertices, (*cit)->getLayerCoordinates());
127 std::vector<ExactModelCoordinate>::const_iterator it = vertices.begin();
128 int32_t halfind = vertices.size() / 2;
130 Point pt1(firstpt.
x, firstpt.
y);
133 for (; it != vertices.end(); it++) {
152 std::set<std::string>::iterator cost_it =
m_visualCosts.begin();
154 std::vector<std::string> cell_costs = cache->
getCellCosts(*cit);
155 std::vector<std::string>::iterator cc_it = cell_costs.begin();
156 for (; cc_it != cell_costs.end(); ++cc_it) {
157 if (*cc_it == *cost_it) {
159 cost = cache->
getCost(*cost_it);
172 std::stringstream stream;
213 Route* route = (*it)->getRoute();
217 Path::iterator pit = path.begin();
218 for (; pit != path.end(); ++pit) {
219 if ((*pit).getLayer() != layer) {
222 std::vector<ExactModelCoordinate> vertices;
223 cg->
getVertices(vertices, (*pit).getLayerCoordinates());
224 std::vector<ExactModelCoordinate>::const_iterator it = vertices.begin();
225 int32_t halfind = vertices.size() / 2;
227 Point pt1(firstpt.
x, firstpt.
y);
230 for (; it != vertices.end(); it++) {
357 for (std::vector<Instance*>::iterator it =
m_visualPaths.begin();
360 if (*it == instance) {
376 std::set<std::string>::iterator it =
m_visualCosts.find(costId);
std::vector< Instance * > m_visualPaths
#define FL_WARN(logger, msg)
Abstract interface for all the renderbackends.
virtual ImagePtr loadBlank(uint32_t width, uint32_t height)
Loads a blank resource.
static CellRenderer * getInstance(IRendererContainer *cnt)
Gets instance for interface access.
T * get() const
allows direct access to underlying pointer
void addPathVisual(Instance *instance)
Adds a instance to path visualization.
void createFowMap(Camera *cam, Layer *layer)
Creates render target for Fog of War.
bool isUpdated()
Gets whether the CellCache need to be updated.
void setLayerCoordinates(const ModelCoordinate &coordinates)
Sets "cell precise" layer coordinates to this location.
void addQuad(const std::string &group, Point n1, Point n2, Point n3, Point n4, uint8_t r, uint8_t g, uint8_t b, uint8_t a=255)
void setFogOfWarLayer(Layer *layer)
Sets the layer that is used for Fog of War visualization.
std::vector< RenderItem * > RenderList
void setConcealImage(ImagePtr image)
Sets the image that is used for concealed spaces.
std::list< Location > Path
A path is a list with locations. Each location holds the coordinate for one cell. ...
T h
Height of the rectangle.
void resizeImage(const std::string &group, Point n, ImagePtr image, int32_t width, int32_t height)
std::vector< std::string > getCellCosts(Cell *cell)
Returns cost identifiers for cell.
void setRenderTarget(const std::string &targetname, bool discard, int32_t ndraws=0)
std::set< std::string > m_visualCosts
bool isEnabledFogOfWar()
Gets whether Fog of War visualization is enabled.
std::vector< Cell * > getCellsInRect(const Rect &rec)
Returns all cells in the rect.
A CellCache is an abstract depiction of one or a few layers and contains additional information...
CellCache * getCellCache()
Returns the CellCache of this layer.
Interface to class owning the renderers Used to get correct subclass of renderer in scripting side (v...
virtual Image * getAsImage(const std::string &text)=0
Gets given text as Image The rsulting image is pooled, so it's not that time critical.
static Logger _log(LM_AUDIO)
void addImage(const std::string &group, Point n, ImagePtr image)
void setMaskImage(ImagePtr image)
Sets the fog image.
IFont * getFont()
Returns the font.
void setEnabledFogOfWar(bool enabled)
Enables Fog of War visualization.
virtual RendererBase * getRenderer(const std::string &renderername)=0
Returns renderer with given name.
Camera describes properties of a view port shown in the main screen Main screen can have multiple cam...
void addMaskImageToMap(Camera *cam, Point center, ImagePtr image)
Adds mask/fog image to FoW render target.
static ImageManager * instance()
virtual void getVertices(std::vector< ExactModelCoordinate > &vtx, const ModelCoordinate &cell)=0
Fills given point vector with vertices from selected cell.
void setBlockerColor(uint8_t r, uint8_t g, uint8_t b)
Sets color that is used to visualize blocker.
uint32_t getHeight() const
RenderBackend * m_renderbackend
PointType2D< int32_t > Point
const Rect & getViewPort() const
Gets the viewport for camera in pixel coordinates.
static bool Equal(T _val1, T _val2)
Base class for all view renderers View renderer renders one aspect of the view shown on screen...
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.
double getZoom() const
Gets camera zoom.
TargetRenderer * m_targetRenderer
virtual void drawLine(const Point &p1, const Point &p2, uint8_t r, uint8_t g, uint8_t b, uint8_t a=255)=0
Draws line between given points with given RGBA.
virtual void setEnabled(bool enabled)
Enables renderer.
uint32_t getWidth() const
void setEnabledPathVisual(bool enabled)
Enables path visualization.
void setEnabledBlocking(bool enabled)
Enables blocking visualization.
CellGrid * getCellGrid() const
Get the Cellgrid.
Layer * getFowLayer()
Returns the layer that is used for Fog of War visualization.
Path getPath()
Returns the path.
bool isUpdated()
Returns true if camera view has been updated, otherwise false.
Pure abstract Font interface.
void setPathColor(uint8_t r, uint8_t g, uint8_t b)
Sets color that is used to visualize paths.
virtual void render(const Rect &rect, uint8_t alpha=255, uint8_t const *rgb=0)=0
Renders itself to the current render target (main screen or attached destination image) at the rectan...
ScreenPoint toScreenCoordinates(const ExactModelCoordinate &map_coords)
Transforms given point from map coordinates to screen coordinates.
void addConcealImageToMap(Camera *cam, Point center, ImagePtr image)
Adds conceal image to FoW render target.
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.
DoublePoint intPt2doublePt(Point pt)
Convert from 2D int32_t point to 2D double point.
bool isEnabledBlocking()
Gets whether blocking visualization is enabled.
RenderTargetPtr m_fowTarget
void updateFowMap()
Updates render target.
RendererBase * clone()
Makes copy of this renderer.
double getCost(const std::string &costId)
Returns the cost value for the given id.
ExactModelCoordinate toMapCoordinates(const ModelCoordinate &layer_coords)
Transforms given point from layer coordinates to map coordinates.
RenderTargetPtr createRenderTarget(const std::string &name, uint32_t width, uint32_t height)
Creates render target.
T w
Width of the rectangle.
An Instance is an "instantiation" of an Object at a Location.
ExactModelCoordinate getMapCoordinates() const
Gets map coordinates set to this location.
bool isEnabledPathVisual()
Gets whether path visualization is enabled.
void removeAll(const std::string &group)
Rect getLayerViewPort(Layer *layer)
Gets the viewport for camera in layer coordinates.
virtual ~CellRenderer()
Destructor.