1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-12 02:28:11 +02:00

* minor fix for bonus selection screen

This commit is contained in:
mateuszb 2013-02-05 19:33:09 +00:00
parent bda92a4a73
commit 898228fd54
2 changed files with 24 additions and 21 deletions

View File

@ -3161,7 +3161,7 @@ void CBonusSelection::init()
if (highlightedRegion == NULL) if (highlightedRegion == NULL)
{ {
highlightedRegion = regions.back(); highlightedRegion = regions.back();
selectMap(g); selectMap(g, true);
} }
} }
else if (ourCampaign->camp->scenarios[g].conquered) //display as striped else if (ourCampaign->camp->scenarios[g].conquered) //display as striped
@ -3285,29 +3285,32 @@ void CBonusSelection::loadPositionsOfGraphics()
assert(idx == CGI->generaltexth->campaignMapNames.size()); assert(idx == CGI->generaltexth->campaignMapNames.size());
} }
void CBonusSelection::selectMap( int whichOne ) void CBonusSelection::selectMap( int whichOne, bool initialSelect )
{ {
sInfo.difficulty = ourCampaign->camp->scenarios[whichOne].difficulty; if(initialSelect || ourCampaign->currentMap != whichOne)
sInfo.mapname = ourCampaign->camp->header.filename; {
sInfo.mode = StartInfo::CAMPAIGN; sInfo.difficulty = ourCampaign->camp->scenarios[whichOne].difficulty;
sInfo.campState = ourCampaign; sInfo.mapname = ourCampaign->camp->header.filename;
ourCampaign->currentMap = whichOne; sInfo.mode = StartInfo::CAMPAIGN;
sInfo.campState = ourCampaign;
ourCampaign->currentMap = whichOne;
//get header //get header
delete ourHeader; delete ourHeader;
std::string & headerStr = ourCampaign->camp->mapPieces.find(whichOne)->second; std::string & headerStr = ourCampaign->camp->mapPieces.find(whichOne)->second;
auto buffer = reinterpret_cast<const ui8 *>(headerStr.data()); auto buffer = reinterpret_cast<const ui8 *>(headerStr.data());
ourHeader = CMapService::loadMapHeader(buffer, headerStr.size()).release(); ourHeader = CMapService::loadMapHeader(buffer, headerStr.size()).release();
std::map<TPlayerColor, std::string> names; std::map<TPlayerColor, std::string> names;
names[1] = settings["general"]["playerName"].String(); names[1] = settings["general"]["playerName"].String();
updateStartInfo(ourCampaign->camp->header.filename, sInfo, ourHeader, names); updateStartInfo(ourCampaign->camp->header.filename, sInfo, ourHeader, names);
sInfo.turnTime = 0; sInfo.turnTime = 0;
sInfo.difficulty = ourCampaign->camp->scenarios[whichOne].difficulty; sInfo.difficulty = ourCampaign->camp->scenarios[whichOne].difficulty;
mapDesc->setTxt(ourHeader->description); mapDesc->setTxt(ourHeader->description);
updateBonusSelection(); updateBonusSelection();
}
} }
void CBonusSelection::show(SDL_Surface * to) void CBonusSelection::show(SDL_Surface * to)
@ -3675,7 +3678,7 @@ void CBonusSelection::CRegion::clickLeft( tribool down, bool previousState )
} }
if( !down && selectable && !CSDL_Ext::isTransparent(graphics[0], GH.current->motion.x-pos.x, GH.current->motion.y-pos.y) ) if( !down && selectable && !CSDL_Ext::isTransparent(graphics[0], GH.current->motion.x-pos.x, GH.current->motion.y-pos.y) )
{ {
owner->selectMap(myNumber); owner->selectMap(myNumber, false);
owner->highlightedRegion = this; owner->highlightedRegion = this;
parent->showAll(screen); parent->showAll(screen);
} }

View File

@ -603,7 +603,7 @@ public:
StartInfo sInfo; StartInfo sInfo;
CDefHandler *sFlags; CDefHandler *sFlags;
void selectMap(int whichOne); void selectMap(int whichOne, bool initialSelect);
void selectBonus(int id); void selectBonus(int id);
void init(); void init();