Mana
Loading...
Searching...
No Matches
textparticle.cpp
Go to the documentation of this file.
1/*
2 * The Mana Client
3 * Copyright (C) 2006-2009 The Mana World Development Team
4 * Copyright (C) 2009-2012 The Mana Developers
5 *
6 * This file is part of The Mana Client.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22#include "textparticle.h"
23
24#include "graphics.h"
25
26#include <guichan/color.hpp>
27
28TextParticle::TextParticle(Map *map, const std::string &text,
29 const gcn::Color *color,
30 gcn::Font *font, bool outline):
31 Particle(map),
32 mText(text),
33 mTextFont(font),
34 mColor(color),
35 mOutline(outline)
36{
37}
38
39bool TextParticle::draw(Graphics *graphics, int offsetX, int offsetY) const
40{
41 if (!isAlive())
42 return false;
43
44 int screenX = (int) mPos.x + offsetX;
45 int screenY = (int) mPos.y - (int) mPos.z + offsetY;
46
47 gcn::Color color = *mColor;
48 color.a = getCurrentAlpha() * 255;
49
51 screenX, screenY, gcn::Graphics::CENTER,
52 color, mTextFont, mOutline, false);
53
54 return true;
55}
Vector mPos
Position in pixels relative to map.
Definition actor.h:114
A central point of control for graphics.
Definition graphics.h:78
void drawText(const std::string &text, int x, int y, gcn::Graphics::Alignment alignment, const gcn::Color &color, gcn::Font *font, bool outline=false, bool shadow=false, const std::optional< gcn::Color > &outlineColor={}, const std::optional< gcn::Color > &shadowColor={})
Definition graphics.cpp:176
A tile map.
Definition map.h:147
A particle spawned by a ParticleEmitter.
Definition particle.h:42
float getCurrentAlpha() const
Calculates the current alpha transparency taking current fade status into account.
Definition particle.cpp:410
bool isAlive() const
Definition particle.h:228
bool mOutline
Make the text better readable.
std::string mText
Text of the particle.
gcn::Font * mTextFont
Font used for drawing the text.
const gcn::Color * mColor
Color used for drawing the text.
TextParticle(Map *map, const std::string &text, const gcn::Color *color, gcn::Font *font, bool outline=false)
bool draw(Graphics *graphics, int offsetX, int offsetY) const override
Draws the particle image.
float z
Definition vector.h:173
float y
Definition vector.h:172
float x
Definition vector.h:171
Graphics * graphics
Definition client.cpp:104