diff --git a/Aquaria/ScriptInterface.cpp b/Aquaria/ScriptInterface.cpp index 5d92b50..79f264f 100644 --- a/Aquaria/ScriptInterface.cpp +++ b/Aquaria/ScriptInterface.cpp @@ -8507,6 +8507,11 @@ luaFunc(castLine) return 3; } +luaFunc(getUserInputString) +{ + luaReturnStr(dsq->getUserInputString(getString(L, 1), getString(L, 2), true).c_str()); +} + luaFunc(inv_isFull) { @@ -8658,6 +8663,12 @@ luaFunc(text_setAlign) luaReturnNil(); } +luaFunc(text_getHeight) +{ + BaseText *txt = getText(L); + luaReturnNum(txt ? txt->getHeight() : 0.0f); +} + luaFunc(loadShader) { int handle = 0; @@ -9314,6 +9325,7 @@ static const struct { luaRegister(getObstruction), luaRegister(findPath), luaRegister(castLine), + luaRegister(getUserInputString), luaRegister(isFlag), @@ -9706,6 +9718,7 @@ static const struct { luaRegister(text_setFontSize), luaRegister(text_setWidth), luaRegister(text_setAlign), + luaRegister(text_getHeight), luaRegister(loadShader), luaRegister(createShader), diff --git a/BBGE/BaseText.h b/BBGE/BaseText.h index a3be629..203bf18 100644 --- a/BBGE/BaseText.h +++ b/BBGE/BaseText.h @@ -13,6 +13,7 @@ public: virtual void setWidth(int width) = 0; virtual void setFontSize(int sz) = 0; virtual void setAlign(Align a) = 0; + virtual float getHeight() = 0; }; diff --git a/BBGE/BitmapFont.h b/BBGE/BitmapFont.h index 730e265..613faf9 100644 --- a/BBGE/BitmapFont.h +++ b/BBGE/BitmapFont.h @@ -72,7 +72,7 @@ public: void autoKern(); void setBitmapFontEffect(BitmapFontEffect bfe); void render(); - float getHeight(); + virtual float getHeight(); void unloadDevice(); void reloadDevice(); diff --git a/BBGE/DebugFont.cpp b/BBGE/DebugFont.cpp index d7611cc..f1ffc69 100644 --- a/BBGE/DebugFont.cpp +++ b/BBGE/DebugFont.cpp @@ -47,6 +47,11 @@ void DebugFont::setFontSize(int sz) fontDrawSize = sz; } +float DebugFont::getHeight() +{ + return fontDrawSize * lines.size() * 1.5f; // vspc in render() +} + void DebugFont::formatText() { std::string text; diff --git a/BBGE/DebugFont.h b/BBGE/DebugFont.h index c8620fd..2a1d5bc 100644 --- a/BBGE/DebugFont.h +++ b/BBGE/DebugFont.h @@ -33,6 +33,7 @@ public: void setFontSize(int sz); int getNumLines() { return lines.size(); } virtual void setAlign(Align align); + virtual float getHeight(); protected: int fontDrawSize, textWidth; void formatText();