diff --git a/projects/mtg/include/WFont.h b/projects/mtg/include/WFont.h index 4645b360e..83f07f12e 100644 --- a/projects/mtg/include/WFont.h +++ b/projects/mtg/include/WFont.h @@ -52,7 +52,7 @@ public: // Set Base for the character set to use. virtual void SetBase(int base) = 0; // Format text. - virtual void FormatText(string &s, vector& output) = 0; + virtual void FormatText(string &s, vector& output, int customLen = 0) = 0; WFont(int inID) : mFontID(inID) {}; virtual ~WFont() {}; }; @@ -117,7 +117,7 @@ public: it->SetBase(base); } ; - void FormatText(string &s, vector& output); + void FormatText(string &s, vector& output, int customLen = 0); private: JLBFont * it; @@ -143,7 +143,7 @@ public: virtual float GetStringWidth(const char *s) const; void SetTracking(float) {}; void SetBase(int) {}; - void FormatText(string &, vector&) {}; + void FormatText(string &, vector&, int customLen = 0) {}; virtual void DrawString(const char *s, float x, float y, int align = JGETEXT_LEFT, float leftOffset = 0, float width = 0); virtual int GetCode(const u8 *ch, int *charLength) const = 0; @@ -187,7 +187,7 @@ public: void DrawString(const char *s, float x, float y, int align = JGETEXT_LEFT, float leftOffset = 0, float width = 0); int GetCode(const u8 *ch, int *charLength) const; int GetMana(const u8 *ch) const; - void FormatText(string &s, vector& output); + void FormatText(string &s, vector& output, int customLen = 0); }; class WUFont: public WFBFont @@ -198,7 +198,7 @@ public: int GetCode(const u8 *ch, int *charLength) const; int GetMana(const u8 *ch) const; - void FormatText(string &s, vector& output); + void FormatText(string &s, vector& output, int customLen = 0); }; #endif diff --git a/projects/mtg/src/CardPrimitive.cpp b/projects/mtg/src/CardPrimitive.cpp index 0db87d2e0..9a3a458e2 100644 --- a/projects/mtg/src/CardPrimitive.cpp +++ b/projects/mtg/src/CardPrimitive.cpp @@ -312,8 +312,9 @@ const vector& CardPrimitive::getFormattedText(bool noremove) found = text.find_first_of("{}", found + 1); } } + int defL = noremove?44:0; WFont * mFont = WResourceManager::Instance()->GetWFont(Fonts::MAGIC_FONT); - mFont->FormatText(text, formattedText); + mFont->FormatText(text, formattedText, defL); text = ""; diff --git a/projects/mtg/src/WFont.cpp b/projects/mtg/src/WFont.cpp index 1de0133bd..6ee3a5e74 100644 --- a/projects/mtg/src/WFont.cpp +++ b/projects/mtg/src/WFont.cpp @@ -115,10 +115,12 @@ WLBFont::WLBFont(int inFontID, const char *fontname, int lineheight, bool useVid it = NEW JLBFont(path.c_str(), lineheight, useVideoRAM); } -void WLBFont::FormatText(string &s, vector& output) +void WLBFont::FormatText(string &s, vector& output, int customLen) { + int defL = (customLen>0)?customLen:30; // The way of CardPrimitive::formattedText() in r2081. - std::string::size_type len = 30; + //std::string::size_type len = 30; + std::string::size_type len = defL; while (s.length() > 0) { std::string::size_type cut = s.find_first_of("., \t)", 0); @@ -1055,7 +1057,7 @@ int WGBKFont::GetMana(const u8 *ch) const return mana; } -void WGBKFont::FormatText(string &s, vector& output) +void WGBKFont::FormatText(string &s, vector& output, int customLen) { while (s.length() > 0) { @@ -1196,7 +1198,7 @@ int WUFont::GetMana(const u8 *ch) const return -1; } -void WUFont::FormatText(string &s, vector& output) +void WUFont::FormatText(string &s, vector& output, int customLen) { std::string::size_type limit = 22; //28 string delim("., \t)");