summaryrefslogtreecommitdiff
path: root/src/gui/fonts/textchunk.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/fonts/textchunk.cpp')
-rw-r--r--src/gui/fonts/textchunk.cpp31
1 files changed, 30 insertions, 1 deletions
diff --git a/src/gui/fonts/textchunk.cpp b/src/gui/fonts/textchunk.cpp
index b0933a3e0..a0c8a39dc 100644
--- a/src/gui/fonts/textchunk.cpp
+++ b/src/gui/fonts/textchunk.cpp
@@ -25,6 +25,8 @@
#include "sdlshared.h"
+#include "gui/fonts/font.h"
+
#include "resources/image.h"
#include "resources/surfaceimagehelper.h"
@@ -45,10 +47,24 @@ char *strBuf = nullptr;
int textChunkCnt = 0;
#endif
+TextChunk::TextChunk() :
+ img(nullptr),
+ textFont(nullptr),
+ text(),
+ color(),
+ color2(),
+ prev(nullptr),
+ next(nullptr)
+{
+#ifdef UNITTESTS
+ textChunkCnt ++;
+#endif
+}
+
TextChunk::TextChunk(const std::string &text0,
const Color &color0,
const Color &color1,
- const Font *const font) :
+ Font *const font) :
img(nullptr),
textFont(font),
text(text0),
@@ -167,3 +183,16 @@ void TextChunk::generate(TTF_Font *const font, const float alpha)
BLOCK_END("TextChunk::generate")
}
+
+void TextChunk::deleteImage()
+{
+ if (textFont)
+ {
+ textFont->insertChunk(this);
+ img = nullptr;
+ }
+ else
+ {
+ delete2(img);
+ }
+}