ManaPlus
text.h
Go to the documentation of this file.
1 /*
2  * The ManaPlus Client
3  * Copyright (C) 2008 Douglas Boffey <[email protected]>
4  * Copyright (C) 2008-2009 The Mana World Development Team
5  * Copyright (C) 2009-2010 The Mana Developers
6  * Copyright (C) 2011-2019 The ManaPlus Developers
7  * Copyright (C) 2019-2021 Andrei Karas
8  *
9  * This file is part of The ManaPlus Client.
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program. If not, see <http://www.gnu.org/licenses/>.
23  */
24 
25 #ifndef TEXT_H
26 #define TEXT_H
27 
28 #include "enums/simpletypes/move.h"
30 
31 #include "gui/fonts/textchunk.h"
32 
33 #include "render/graphics.h"
34 
35 #include "localconsts.h"
36 
37 class Font;
38 
40 {
41  friend class TextManager;
42 
43  public:
47  Text(const std::string &text,
48  const int x, const int y,
49  const Graphics::Alignment alignment,
50  const Color *const color,
51  const Speech isSpeech,
52  Font *const font);
53 
55 
56 
59  virtual ~Text();
60 
61  void setColor(const Color *const color);
62 
64  { return mWidth; }
65 
67  { return mHeight; }
68 
72  void adviseXY(const int x, const int y, const Move move);
73 
77  virtual void draw(Graphics *const graphics,
78  const int xOff, const int yOff) A_NONNULL(2);
79 
80 // int getWidth() A_WARN_UNUSED;
81 
83  { return mX; }
84 
86  { return mY; }
87 
88  private:
91  int mX;
92  int mY;
93  int mWidth;
94  int mHeight;
95  int mXOffset;
96  static int mInstances;
97  std::string mText;
98  const Color *mColor;
102 
103  protected:
105 };
106 
107 class FlashText final : public Text
108 {
109  public:
110  FlashText(const std::string &text, const int x, const int y,
111  const Graphics::Alignment alignment,
112  const Color *const color,
113  Font *const font);
114 
116 
117 
120  void flash(const int time)
121  { mTime = time; }
122 
126  void draw(Graphics *const graphics,
127  const int xOff,
128  const int yOff) override final A_NONNULL(2);
129 
130  private:
131  int mTime;
132 };
133 
134 #endif // TEXT_H
Definition: color.h:76
void flash(const int time)
Definition: text.h:120
FlashText(const std::string &text, const int x, const int y, const Graphics::Alignment alignment, const Color *const color, Font *const font)
Definition: text.cpp:188
int mTime
Definition: text.h:131
void draw(Graphics *const graphics, const int xOff, const int yOff)
Definition: text.cpp:198
Definition: font.h:90
Definition: text.h:40
const Color * mColor
Definition: text.h:98
int getHeight() const
Definition: text.h:66
int mXOffset
Definition: text.h:95
std::string mText
Definition: text.h:97
virtual ~Text()
Definition: text.cpp:112
static int mInstances
Definition: text.h:96
int getX() const
Definition: text.h:82
TextChunk mTextChunk
Definition: text.h:90
void setColor(const Color *const color)
Definition: text.cpp:130
Font * mFont
Definition: text.h:89
int mX
Definition: text.h:91
Speech mIsSpeech
Definition: text.h:100
bool mTextChanged
Definition: text.h:101
int mWidth
Definition: text.h:93
int mHeight
Definition: text.h:94
Text(const std::string &text, const int x, const int y, const Graphics::Alignment alignment, const Color *const color, const Speech isSpeech, Font *const font)
Definition: text.cpp:46
Color mOutlineColor
Definition: text.h:99
int getWidth() const
Definition: text.h:63
virtual void draw(Graphics *const graphics, const int xOff, const int yOff)
Definition: text.cpp:158
static ImageRect mBubble
Definition: text.h:104
int getY() const
Definition: text.h:85
int mY
Definition: text.h:92
void adviseXY(const int x, const int y, const Move move)
Definition: text.cpp:144
bool Move
Definition: move.h:30
#define A_WARN_UNUSED
Definition: localconsts.h:161
#define notfinal
Definition: localconsts.h:261
#define A_NONNULL(...)
Definition: localconsts.h:168
#define noexcept2
Definition: localconsts.h:50
#define final
Definition: localconsts.h:46
#define A_DELETE_COPY(func)
Definition: localconsts.h:53
bool move(InputEvent &event)
Definition: commands.cpp:44
bool Speech
Definition: speech.h:30