Debian Codegraph @

engine/core/view/renderers/floatingtextrenderer.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_FLOATINGTEXTRENDERER_H
23 #define FIFE_FLOATINGTEXTRENDERER_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 namespace FIFE {
36 class RenderBackend;
37 class IFont;
38
39 class FloatingTextRenderer: public RendererBase {
40 public:
41 /** Constructor.
42 *
43 * @param renderbackend The renderbackend to use.
44 * @param position The position for this renderer in rendering pipeline.
45 * @ see setPipelinePosition
46 */
47 FloatingTextRenderer(RenderBackend* renderbackend, int32_t position);
48
49 /** Copy Constructor.
50 */
51 FloatingTextRenderer(const FloatingTextRenderer& old);
52
53 /** Makes copy of this renderer.
54 */
55 RendererBase* clone();
56
57 /** Destructor.
58 */
59 virtual ~FloatingTextRenderer();
60
61 /** This method is called by the view to ask renderer to draw its rendering aspect based on
62 * given parameters.
63 *
64 * @param cam Camera view to draw
65 * @param layer Current layer to be rendered
66 * @param instances Instances on the current layer
67 */
68 void render(Camera* cam, Layer* layer, RenderList& instances);
69
70 /** Returns the renderer name.
71 *
72 * @return The name as string.
73 */
74 std::string getName() { return "FloatingTextRenderer"; }
75
76 /** Changes default font in the renderer
77 * Note that this does not change the font ownership
78 */
79 void setFont(IFont* font) { m_font = font; }
80
81 /** Changes default font color
82 * Only useful for .ttf fonts
83 */
84 void setColor(uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255);
85
86 /** Set default background quad
87 * r,g,b,a values for background
88 */
89 void setBackground(uint8_t br, uint8_t bg, uint8_t bb, uint8_t ba = 255);
90
91 /** Set default border
92 * r,g,b,a values for border
93 */
94 void setBorder(uint8_t bbr, uint8_t bbg, uint8_t bbb, uint8_t bba = 255);
95
96 /** Disable the default background
97 */
98 void resetBackground();
99
100 /** Disable the default border
101 */
102 void resetBorder();
103
104 /** Gets instance for interface access.
105 */
106 static FloatingTextRenderer* getInstance(IRendererContainer* cnt);
107
108 /** Provides access point to the RenderBackend
109 */
110 RenderBackend* getRenderBackend() const {return m_renderbackend;}
111
112 private:
113 RenderBackend* m_renderbackend;
114 IFont* m_font;
115 bool m_font_color;
116 SDL_Color m_color;
117 bool m_background;
118 bool m_backborder;
119 SDL_Color m_backcolor;
120 SDL_Color m_backbordercolor;
121 };
122
123 }
124
125 #endif