1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-06-27 00:41:08 +02:00

Reenabled campaigns. Workaround for crash when button graphic is not available.

This commit is contained in:
Michał W. Urbańczyk
2010-10-24 21:29:18 +00:00
parent daeb3af67a
commit e301f8e048
3 changed files with 16 additions and 5 deletions

View File

@ -51,9 +51,19 @@ void CButtonBase::show(SDL_Surface * to)
int img = std::min(state+bitmapOffset,int(imgs[curimg]->size()-1));
img = std::max(0, img);
SDL_Surface *toBlit = imgs[curimg]->image(img);
if (abs)
{
blitAt(imgs[curimg]->image(img),pos.x,pos.y,to);
if(toBlit)
{
blitAt(toBlit,pos.x,pos.y,to);
}
else
{
SDL_Rect r = pos;
SDL_FillRect(to, &r, 0x505000);
}
if(text)
{//using "state" instead of "state == 1" screwed up hoverable buttons with text
CSDL_Ext::printAt(text->text, text->x + pos.x + (state == 1), text->y + pos.y + (state == 1), text->font, text->color, to);
@ -61,7 +71,7 @@ void CButtonBase::show(SDL_Surface * to)
}
else
{
blitAt(imgs[curimg]->image(img),pos.x+ourObj->pos.x,pos.y+ourObj->pos.y,to);
blitAt(toBlit,pos.x+ourObj->pos.x,pos.y+ourObj->pos.y,to);
}
}