comparison engine/core/view/rendererbase.cpp @ 0:4a0efb7baf70

* Datasets becomes the new trunk and retires after that :-)
author mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
date Sun, 29 Jun 2008 18:44:17 +0000
parents
children 90005975cdbb
comparison
equal deleted inserted replaced
-1:000000000000 0:4a0efb7baf70
1 /***************************************************************************
2 * Copyright (C) 2005-2008 by the FIFE team *
3 * http://www.fifengine.de *
4 * This file is part of FIFE. *
5 * *
6 * FIFE is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
10 * *
11 * This program 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 *
14 * GNU General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program; if not, write to the *
18 * Free Software Foundation, Inc., *
19 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
20 ***************************************************************************/
21
22 // Standard C++ library includes
23
24 // 3rd party library includes
25
26 // FIFE includes
27 // These includes are split up in two parts, separated by one empty line
28 // First block: files included from the FIFE root src directory
29 // Second block: files included from the same folder
30 #include "model/structures/layer.h"
31 #include "model/structures/map.h"
32 #include "util/log/logger.h"
33 #include "rendererbase.h"
34
35 namespace FIFE {
36 static Logger _log(LM_VIEW);
37
38 // use some big value, so that non-positioned renderers show on top
39 const int DEFAULT_RENDERER_POSITION = 1000;
40
41 RendererBase::RendererBase(RenderBackend* renderbackend, int position):
42 m_renderbackend(renderbackend),
43 m_enabled(false),
44 m_pipeline_position(DEFAULT_RENDERER_POSITION),
45 m_listener(NULL) {
46 setPipelinePosition(position);
47 }
48
49 RendererBase::RendererBase(const RendererBase& old):
50 m_renderbackend(old.m_renderbackend),
51 m_enabled(old.m_enabled),
52 m_pipeline_position(old.m_pipeline_position),
53 m_listener(NULL) {
54 setPipelinePosition(old.m_pipeline_position);
55 }
56
57 RendererBase::RendererBase():
58 m_renderbackend(NULL),
59 m_enabled(false),
60 m_pipeline_position(DEFAULT_RENDERER_POSITION),
61 m_listener(NULL) {
62 }
63
64 void RendererBase::setPipelinePosition(int position) {
65 if (position !=m_pipeline_position) {
66 m_pipeline_position = position;
67 if (m_listener) {
68 m_listener->onRendererPipelinePositionChanged(this);
69 }
70 }
71 }
72
73 void RendererBase::setEnabled(bool enabled) {
74 if (m_enabled != enabled) {
75 m_enabled = enabled;
76 if (m_listener) {
77 m_listener->onRendererEnabledChanged(this);
78 }
79 }
80 }
81
82 void RendererBase::addActiveLayer(Layer* layer) {
83 if (std::find(m_active_layers.begin(), m_active_layers.end(), layer) == m_active_layers.end()) {
84 m_active_layers.push_back(layer);
85 }
86 }
87
88 void RendererBase::removeActiveLayer(Layer* layer) {
89 m_active_layers.remove(layer);
90 }
91
92 void RendererBase::clearActiveLayers() {
93 m_active_layers.clear();
94 }
95
96 bool RendererBase::isActivedLayer(Layer* layer) {
97 return std::find(m_active_layers.begin(), m_active_layers.end(), layer) != m_active_layers.end();
98 }
99
100 void RendererBase::activateAllLayers(Map* map) {
101 clearActiveLayers();
102
103 const std::list<Layer*>& tmp = map->getLayers();
104 std::list<Layer*>::const_iterator it = tmp.begin();
105 for (; it != tmp.end(); ++it) {
106 addActiveLayer(*it);
107 }
108 }
109
110 }