1
0
Fork 0
mirror of https://github.com/AquariaOSE/Aquaria.git synced 2025-10-07 06:41:38 +00:00

Add two more font/text related Lua functions, and some more:

+ entity_getBoneByInternalId()
+ entity_getNumBones()
+ text_getLineHeight()
+ text_getNumLines()
This commit is contained in:
fgenesis 2015-11-16 03:59:47 +01:00
commit ed089f38f7
8 changed files with 54 additions and 2 deletions

View file

@ -13,6 +13,8 @@ public:
virtual void setWidth(float width) = 0;
virtual void setFontSize(float sz) = 0;
virtual void setAlign(Align a) = 0;
virtual float getLineHeight() = 0;
virtual int getNumLines() = 0;
virtual float getHeight() = 0; // total height
virtual float getStringWidth(const std::string& text) = 0; // width of string when not auto-wrapped
virtual float getActualWidth() = 0; // width of text after wrapping

View file

@ -148,6 +148,11 @@ float BitmapText::getHeight()
return lines.size()*sz;
}
float BitmapText::getLineHeight()
{
return bmpFont->font.GetCharHeight('A') * bmpFont->scale;
}
void BitmapText::formatText()
{
std::string text;

View file

@ -77,8 +77,9 @@ public:
void reloadDevice();
float getStringWidth(const std::string& text);
float getActualWidth() { return maxW; }
float getLineHeight();
int getNumLines();
protected:
float scrollSpeed;
BmpFont *bmpFont;

View file

@ -53,6 +53,11 @@ float DebugFont::getHeight()
return fontDrawSize * lines.size() * 1.5f; // vspc in render()
}
float DebugFont::getLineHeight()
{
return fontDrawSize * 1.5f; // vspc in render()
}
float DebugFont::getStringWidth(const std::string& text)
{
int maxchars = 0;

View file

@ -34,6 +34,7 @@ public:
int getNumLines() { return lines.size(); }
virtual void setAlign(Align align);
virtual float getHeight();
virtual float getLineHeight();
virtual float getStringWidth(const std::string& text);
virtual float getActualWidth();
protected:

View file

@ -96,6 +96,10 @@ void TTFText::updateAlign()
}
}
int TTFText::getNumLines()
{
return (int)text.size();
}
float TTFText::getHeight()
{

View file

@ -61,6 +61,7 @@ public:
bool shadow;
int findLine(const std::string &label);
float getLineHeight();
int getNumLines();
protected:
float width;
float lineHeight;