1
0
Fork 0
mirror of https://github.com/AquariaOSE/Aquaria.git synced 2025-10-06 22:32:48 +00:00

Fix font bounds calculation

BitmapFont::getActualWidth() is still a bit less than getStringWidth(),
but won't fix that now since it shouldn't cause any issues... hopefully.
This commit is contained in:
fgenesis 2015-11-11 23:27:32 +01:00
commit 26549f84b7
11 changed files with 118 additions and 73 deletions

View file

@ -3562,7 +3562,7 @@ std::string DSQ::getUserInputString(std::string labelText, std::string t, bool a
text.resize(text.size()-1);
inputText->setText(text);
}
if (inputText->getWidth() < 800-60)
if (inputText->getActualWidth() < 800-60)
{
doAlphabetInputKey(KEY_A, 'a', (char*)&map, &text, 'A');
doAlphabetInputKey(KEY_B, 'b', (char*)&map, &text, 'B');

View file

@ -10024,9 +10024,9 @@ const float helpTextScrollClickTime = -helpTextScrollSpeed;
void Game::onHelpDown()
{
float to = helpText->offset.y - helpTextScrollClickAmount;
if (to < -helpText->getFullHeight() + core->getVirtualHeight())
if (to < -helpText->getHeight() + core->getVirtualHeight())
{
to = -helpText->getFullHeight() + core->getVirtualHeight();
to = -helpText->getHeight() + core->getVirtualHeight();
}
helpText->offset.interpolateTo(Vector(0, to), helpTextScrollClickTime);
}
@ -10052,9 +10052,9 @@ void Game::update(float dt)
{
helpText->offset.stop();
helpText->offset.y -= helpTextScrollSpeed * dt;
if (helpText->offset.y < -helpText->getFullHeight() + core->getVirtualHeight())
if (helpText->offset.y < -helpText->getHeight() + core->getVirtualHeight())
{
helpText->offset.y = -helpText->getFullHeight() + core->getVirtualHeight();
helpText->offset.y = -helpText->getHeight() + core->getVirtualHeight();
}
}
if (isActing(ACTION_SWIMUP))

View file

@ -9195,7 +9195,7 @@ luaFunc(text_setFontSize)
{
BaseText *txt = getText(L);
if (txt)
txt->setFontSize(lua_tointeger(L, 2));
txt->setFontSize(lua_tonumber(L, 2));
luaReturnNil();
}
@ -9203,7 +9203,7 @@ luaFunc(text_setWidth)
{
BaseText *txt = getText(L);
if (txt)
txt->setWidth(lua_tointeger(L, 2));
txt->setWidth(lua_tonumber(L, 2));
luaReturnNil();
}
@ -9227,6 +9227,12 @@ luaFunc(text_getStringWidth)
luaReturnNum(txt ? txt->getStringWidth(getString(L, 2)) : 0.0f);
}
luaFunc(text_getActualWidth)
{
BaseText *txt = getText(L);
luaReturnNum(txt ? txt->getActualWidth() : 0.0f);
}
luaFunc(loadShader)
{
int handle = 0;
@ -10333,6 +10339,7 @@ static const struct {
luaRegister(text_setAlign),
luaRegister(text_getHeight),
luaRegister(text_getStringWidth),
luaRegister(text_getActualWidth),
luaRegister(loadShader),
luaRegister(createShader),

View file

@ -323,7 +323,7 @@ public:
text->setAlign(ALIGN_CENTER);
textBG = new RoundedRect();
textBG->setWidthHeight(text->getWidth() + 20, 25, 10); // 30
textBG->setWidthHeight(text->getActualWidth() + 20, 25, 10); // 30
textBG->alpha = 0;
textBG->followCamera = 1;
game->addRenderObject(textBG, LR_WORLDMAPHUD);