customLen
for formatting text on booster shop, we pass the desired length from
getformatted text with noremove(no removal of {}) enabled, if its not
enabled then default the value to zero(passing zero means use the
default values)
This commit is contained in:
@@ -52,7 +52,7 @@ public:
|
|||||||
// Set Base for the character set to use.
|
// Set Base for the character set to use.
|
||||||
virtual void SetBase(int base) = 0;
|
virtual void SetBase(int base) = 0;
|
||||||
// Format text.
|
// Format text.
|
||||||
virtual void FormatText(string &s, vector<string>& output) = 0;
|
virtual void FormatText(string &s, vector<string>& output, int customLen = 0) = 0;
|
||||||
WFont(int inID) : mFontID(inID) {};
|
WFont(int inID) : mFontID(inID) {};
|
||||||
virtual ~WFont() {};
|
virtual ~WFont() {};
|
||||||
};
|
};
|
||||||
@@ -117,7 +117,7 @@ public:
|
|||||||
it->SetBase(base);
|
it->SetBase(base);
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
void FormatText(string &s, vector<string>& output);
|
void FormatText(string &s, vector<string>& output, int customLen = 0);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
JLBFont * it;
|
JLBFont * it;
|
||||||
@@ -143,7 +143,7 @@ public:
|
|||||||
virtual float GetStringWidth(const char *s) const;
|
virtual float GetStringWidth(const char *s) const;
|
||||||
void SetTracking(float) {};
|
void SetTracking(float) {};
|
||||||
void SetBase(int) {};
|
void SetBase(int) {};
|
||||||
void FormatText(string &, vector<string>&) {};
|
void FormatText(string &, vector<string>&, int customLen = 0) {};
|
||||||
|
|
||||||
virtual void DrawString(const char *s, float x, float y, int align = JGETEXT_LEFT, float leftOffset = 0, float width = 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;
|
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);
|
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 GetCode(const u8 *ch, int *charLength) const;
|
||||||
int GetMana(const u8 *ch) const;
|
int GetMana(const u8 *ch) const;
|
||||||
void FormatText(string &s, vector<string>& output);
|
void FormatText(string &s, vector<string>& output, int customLen = 0);
|
||||||
};
|
};
|
||||||
|
|
||||||
class WUFont: public WFBFont
|
class WUFont: public WFBFont
|
||||||
@@ -198,7 +198,7 @@ public:
|
|||||||
|
|
||||||
int GetCode(const u8 *ch, int *charLength) const;
|
int GetCode(const u8 *ch, int *charLength) const;
|
||||||
int GetMana(const u8 *ch) const;
|
int GetMana(const u8 *ch) const;
|
||||||
void FormatText(string &s, vector<string>& output);
|
void FormatText(string &s, vector<string>& output, int customLen = 0);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -312,8 +312,9 @@ const vector<string>& CardPrimitive::getFormattedText(bool noremove)
|
|||||||
found = text.find_first_of("{}", found + 1);
|
found = text.find_first_of("{}", found + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
int defL = noremove?44:0;
|
||||||
WFont * mFont = WResourceManager::Instance()->GetWFont(Fonts::MAGIC_FONT);
|
WFont * mFont = WResourceManager::Instance()->GetWFont(Fonts::MAGIC_FONT);
|
||||||
mFont->FormatText(text, formattedText);
|
mFont->FormatText(text, formattedText, defL);
|
||||||
|
|
||||||
text = "";
|
text = "";
|
||||||
|
|
||||||
|
|||||||
@@ -115,10 +115,12 @@ WLBFont::WLBFont(int inFontID, const char *fontname, int lineheight, bool useVid
|
|||||||
it = NEW JLBFont(path.c_str(), lineheight, useVideoRAM);
|
it = NEW JLBFont(path.c_str(), lineheight, useVideoRAM);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WLBFont::FormatText(string &s, vector<string>& output)
|
void WLBFont::FormatText(string &s, vector<string>& output, int customLen)
|
||||||
{
|
{
|
||||||
|
int defL = (customLen>0)?customLen:30;
|
||||||
// The way of CardPrimitive::formattedText() in r2081.
|
// 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)
|
while (s.length() > 0)
|
||||||
{
|
{
|
||||||
std::string::size_type cut = s.find_first_of("., \t)", 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;
|
return mana;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WGBKFont::FormatText(string &s, vector<string>& output)
|
void WGBKFont::FormatText(string &s, vector<string>& output, int customLen)
|
||||||
{
|
{
|
||||||
while (s.length() > 0)
|
while (s.length() > 0)
|
||||||
{
|
{
|
||||||
@@ -1196,7 +1198,7 @@ int WUFont::GetMana(const u8 *ch) const
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WUFont::FormatText(string &s, vector<string>& output)
|
void WUFont::FormatText(string &s, vector<string>& output, int customLen)
|
||||||
{
|
{
|
||||||
std::string::size_type limit = 22; //28
|
std::string::size_type limit = 22; //28
|
||||||
string delim("., \t)");
|
string delim("., \t)");
|
||||||
|
|||||||
Reference in New Issue
Block a user