diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-04-22 21:24:52 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-04-25 16:35:59 +0300 |
commit | 0d300e7aa5699154810af67282dacbcd65929768 (patch) | |
tree | e84bcce0aebdfeaf8ead8ee936851548883fc57e /src/gui/sdlfont.h | |
parent | cf3ee45291930bec0b10d9bd4b5b525e6e2b395d (diff) | |
download | mv-0d300e7aa5699154810af67282dacbcd65929768.tar.gz mv-0d300e7aa5699154810af67282dacbcd65929768.tar.bz2 mv-0d300e7aa5699154810af67282dacbcd65929768.tar.xz mv-0d300e7aa5699154810af67282dacbcd65929768.zip |
impliment new list in sdlfont.
Diffstat (limited to 'src/gui/sdlfont.h')
-rw-r--r-- | src/gui/sdlfont.h | 54 |
1 files changed, 47 insertions, 7 deletions
diff --git a/src/gui/sdlfont.h b/src/gui/sdlfont.h index 4e77943f8..2e5376148 100644 --- a/src/gui/sdlfont.h +++ b/src/gui/sdlfont.h @@ -24,6 +24,7 @@ #ifndef SDLFONT_H #define SDLFONT_H +#include <guichan/color.hpp> #include <guichan/font.hpp> #ifdef __WIN32__ @@ -37,9 +38,48 @@ #include "localconsts.h" -const unsigned int CACHES_NUMBER = 256; +class Image; -class SDLTextChunk; +class SDLTextChunk final +{ + public: + SDLTextChunk(const std::string &text0, const gcn::Color &color0, + const gcn::Color &color1); + + ~SDLTextChunk(); + + bool operator==(const SDLTextChunk &chunk) const; + + void generate(TTF_Font *const font, const float alpha); + + Image *img; + std::string text; + gcn::Color color; + gcn::Color color2; + SDLTextChunk *prev; + SDLTextChunk *next; +}; + + +class TextChunkList final +{ + public: + TextChunkList(); + + void insertFirst(SDLTextChunk *const item); + + void moveToFirst(SDLTextChunk *item); + + void removeBack(); + + void removeBack(int n); + + void clear(); + + SDLTextChunk *start; + SDLTextChunk *end; + uint32_t size; +}; /** * A wrapper around SDL_ttf for allowing the use of TrueType fonts. @@ -67,14 +107,11 @@ class SDLFont final : public gcn::Font void loadFont(std::string filename, const int size, const int style = 0); - void createSDLTextChunk(SDLTextChunk *const chunk); - virtual int getWidth(const std::string &text) const A_WARN_UNUSED; virtual int getHeight() const A_WARN_UNUSED; - std::list<SDLTextChunk> *getCache() A_WARN_UNUSED - { return mCache; } + TextChunkList *getCache() A_WARN_UNUSED; /** * @see Font::drawString @@ -101,8 +138,11 @@ class SDLFont final : public gcn::Font unsigned mDeleteCounter; // Word surfaces cache - mutable std::list<SDLTextChunk> mCache[CACHES_NUMBER]; int mCleanTime; }; +#ifdef UNITTESTS +extern int sdlTextChunkCnt; +#endif + #endif |