1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-07-05 00:49:09 +02:00

Implemented #715 (load game from sys options). Fixed #224. Minor improvements.

This commit is contained in:
Michał W. Urbańczyk
2012-04-09 02:53:50 +00:00
parent f9f0fe9d97
commit 8baec8b093
14 changed files with 85 additions and 42 deletions

View File

@ -1299,6 +1299,23 @@ void CSDL_Ext::fillRect( SDL_Surface *dst, SDL_Rect *dstrect, Uint32 color )
SDL_FillRect(dst, &newRect, color);
}
std::string CSDL_Ext::trimToFit(std::string text, int widthLimit, EFonts font)
{
int widthSoFar = 0;
for(auto i = text.begin(); i != text.end(); i++)
{
widthSoFar += graphics->fonts[font]->getCharWidth(*i);
if(widthSoFar > widthLimit)
{
//remove all characteres past limit
text.erase(i, text.end());
break;
}
}
return text;
}
SDL_Surface * CSDL_Ext::std32bppSurface = NULL;
//instantiation of templates used in CAnimation and CCreatureAnimation, required for correct linking