1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-03-19 21:10:12 +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);
}
}

View File

@ -53,10 +53,11 @@ std::vector<CCampaignHeader> CCampaignHandler::getCampaignHeaders(GetMode mode)
}
if (mode == ALL) //add all lod campaigns
{
ext = "#H3C";
for(int g=0; g<bitmaph->entries.size(); ++g)
{
const std::string & nameS = bitmaph->entries[g].nameStr;
if( boost::ends_with(nameS, ext) && nameS != "TOSBLK1.H3C" )
if( boost::ends_with(nameS, ext) && nameS != "TOSBLK1#H3C" )
{
ret.push_back( getHeader(bitmaph->entries[g].nameStr, true) );
}

View File

@ -247,7 +247,7 @@ void CLodHandler::init(std::string lodFile, std::string dirName)
if ( dotPos < entry.nameStr.size() )
{
std::string ext = entry.nameStr.substr(dotPos);
if (ext == ".MSK" || ext == ".MSG")
if (ext == ".MSK" || ext == ".MSG" || ext == ".H3C")
entry.nameStr[dotPos] = '#';//this files have same name as def - rename to defName#msk
else
entry.nameStr.erase(dotPos);//filename.ext becomes filename
@ -277,7 +277,7 @@ void CLodHandler::init(std::string lodFile, std::string dirName)
if ( dotPos < name.size() )
{
std::string ext = name.substr(dotPos);
if (ext == ".MSK" || ext == ".MSG")
if (ext == ".MSK" || ext == ".MSG" || ext == ".H3C")
name[dotPos] = '#';//this files have same name as def - rename to defName#msk
else
name.erase(dotPos);//filename.ext becomes filename