mirror of
https://github.com/vcmi/vcmi.git
synced 2025-03-25 21:38:59 +02:00
* monster campaign bonus handled
* selecting / displaying difficulty
This commit is contained in:
parent
c6653949e1
commit
b441143a73
@ -2193,7 +2193,8 @@ void CHotSeatPlayers::enterSelectionScreen()
|
||||
}
|
||||
|
||||
CBonusSelection::CBonusSelection( const CCampaign * _ourCampaign, int _whichMap )
|
||||
: ourCampaign(_ourCampaign), whichMap(_whichMap), highlightedRegion(NULL), ourHeader(NULL), bonuses(NULL)
|
||||
: ourCampaign(_ourCampaign), whichMap(_whichMap), highlightedRegion(NULL), ourHeader(NULL), bonuses(NULL),
|
||||
diffLb(NULL), diffRb(NULL)
|
||||
{
|
||||
OBJ_CONSTRUCTION;
|
||||
static const std::string bgNames [] = {"E1_BG.BMP", "G2_BG.BMP", "E2_BG.BMP", "G1_BG.BMP", "G3_BG.BMP", "N1_BG.BMP",
|
||||
@ -2262,6 +2263,23 @@ CBonusSelection::CBonusSelection( const CCampaign * _ourCampaign, int _whichMap
|
||||
|
||||
//difficulty
|
||||
printAtLoc("Difficulty", 691, 431, FONT_MEDIUM, zwykly, background); //Difficulty
|
||||
{//difficulty pics
|
||||
for (int b=0; b<ARRAY_COUNT(diffPics); ++b)
|
||||
{
|
||||
CDefEssential * cde = CDefHandler::giveDefEss("GSPBUT" + boost::lexical_cast<std::string>(b+3) + ".DEF");
|
||||
SDL_Surface * surfToDuplicate = cde->ourImages[0].bitmap;
|
||||
diffPics[b] = SDL_ConvertSurface(surfToDuplicate, surfToDuplicate->format,
|
||||
surfToDuplicate->flags);
|
||||
|
||||
delete cde;
|
||||
}
|
||||
}
|
||||
//difficulty selection buttons
|
||||
if (ourCampaign->header.difficultyChoosenByPlayer)
|
||||
{
|
||||
diffLb = new AdventureMapButton("", "", bind(&CBonusSelection::changeDiff, this, false), 694, 508, "SCNRBLF.DEF");
|
||||
diffRb = new AdventureMapButton("", "", bind(&CBonusSelection::changeDiff, this, true), 738, 508, "SCNRBRT.DEF");
|
||||
}
|
||||
|
||||
//load miniflags
|
||||
sFlags = CDefHandler::giveDef("ITGFLAGS.DEF");
|
||||
@ -2274,6 +2292,10 @@ CBonusSelection::~CBonusSelection()
|
||||
delete sizes;
|
||||
delete ourHeader;
|
||||
delete sFlags;
|
||||
for (int b=0; b<ARRAY_COUNT(diffPics); ++b)
|
||||
{
|
||||
SDL_FreeSurface(diffPics[b]);
|
||||
}
|
||||
}
|
||||
|
||||
void CBonusSelection::goBack()
|
||||
@ -2340,6 +2362,7 @@ void CBonusSelection::selectMap( int whichOne )
|
||||
CSelectionScreen::updateStartInfo(curMap, sInfo, ourHeader);
|
||||
sInfo.turnTime = 0;
|
||||
sInfo.whichMapInCampaign = whichOne;
|
||||
sInfo.difficulty = ourCampaign->scenarios[whichOne].difficulty;
|
||||
|
||||
mapDesc->setTxt(ourHeader->description);
|
||||
|
||||
@ -2395,6 +2418,9 @@ void CBonusSelection::show( SDL_Surface * to )
|
||||
*myx += sFlags->ourImages[i->color].bitmap->w;
|
||||
}
|
||||
|
||||
//difficulty
|
||||
blitAt(diffPics[sInfo.difficulty], 709, 455, to);
|
||||
|
||||
CIntObject::show(to);
|
||||
}
|
||||
|
||||
@ -2592,6 +2618,7 @@ void CBonusSelection::updateBonusSelection()
|
||||
void CBonusSelection::startMap()
|
||||
{
|
||||
StartInfo *si = new StartInfo(sInfo);
|
||||
//don't pop - we should get back to this screen
|
||||
GH.popInts(3);
|
||||
curOpts = NULL;
|
||||
::startGame(si);
|
||||
@ -2602,6 +2629,18 @@ void CBonusSelection::selectBonus( int id )
|
||||
sInfo.choosenCampaignBonus = id;
|
||||
}
|
||||
|
||||
void CBonusSelection::changeDiff( bool increase )
|
||||
{
|
||||
if (increase)
|
||||
{
|
||||
sInfo.difficulty = std::min(sInfo.difficulty + 1, 4);
|
||||
}
|
||||
else
|
||||
{
|
||||
sInfo.difficulty = std::max(sInfo.difficulty - 1, 0);
|
||||
}
|
||||
}
|
||||
|
||||
CBonusSelection::CRegion::CRegion( CBonusSelection * _owner, bool _accessible, bool _selectable, int _myNumber )
|
||||
: owner(_owner), accessible(_accessible), selectable(_selectable), myNumber(_myNumber)
|
||||
{
|
||||
|
@ -319,6 +319,9 @@ class CBonusSelection : public CIntObject
|
||||
const CCampaign * ourCampaign;
|
||||
CMapHeader *ourHeader;
|
||||
CDefHandler *sizes; //icons of map sizes
|
||||
SDL_Surface * diffPics[5]; //pictures of difficulties, user-selectable (or not if campaign locks this)
|
||||
AdventureMapButton * diffLb, * diffRb; //buttons for changing difficulty
|
||||
void changeDiff(bool increase); //if false, then decrease
|
||||
int whichMap;
|
||||
|
||||
//bonus selection
|
||||
|
@ -1198,11 +1198,11 @@ void CGameState::init( StartInfo * si, ui32 checksum, int Seed )
|
||||
{
|
||||
struct HLP
|
||||
{
|
||||
//heroType: FFFD means 'most powerful' and FFFE means 'generated'
|
||||
static void giveCampaignBonusToHero(CGHeroInstance * hero, si32 heroType, const StartInfo * si, const CScenarioTravel & st )
|
||||
//it's assumed that given hero should receive the bonus
|
||||
static void giveCampaignBonusToHero(CGHeroInstance * hero, const StartInfo * si, const CScenarioTravel & st )
|
||||
{
|
||||
const CScenarioTravel::STravelBonus & curBonus = st.bonusesToChoose[si->choosenCampaignBonus];
|
||||
if(curBonus.isBonusForHero() && curBonus.info1 == heroType)
|
||||
if(curBonus.isBonusForHero())
|
||||
{
|
||||
//apply bonus
|
||||
switch (curBonus.type)
|
||||
@ -1211,7 +1211,19 @@ void CGameState::init( StartInfo * si, ui32 checksum, int Seed )
|
||||
hero->spells.insert(curBonus.info2);
|
||||
break;
|
||||
case 1: //monster
|
||||
//TODO
|
||||
{
|
||||
CCreatureSet newArmy = hero->getArmy();
|
||||
for(int i=0; i<ARMY_SIZE; i++)
|
||||
{
|
||||
if(newArmy.slotEmpty(i))
|
||||
{
|
||||
newArmy.addToSlot(i, CStackInstance(curBonus.info2, curBonus.info3));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
hero->setArmy(newArmy);
|
||||
}
|
||||
break;
|
||||
case 3: //artifact
|
||||
hero->giveArtifact(curBonus.info2);
|
||||
@ -1411,7 +1423,7 @@ void CGameState::init( StartInfo * si, ui32 checksum, int Seed )
|
||||
//give campaign bonus
|
||||
if (si->mode == 2 && getPlayer(nnn->tempOwner)->human)
|
||||
{
|
||||
HLP::giveCampaignBonusToHero(nnn, 0xFFFE, si, campaign->camp->scenarios[si->whichMapInCampaign].travelOptions);
|
||||
HLP::giveCampaignBonusToHero(nnn, si, campaign->camp->scenarios[si->whichMapInCampaign].travelOptions);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1579,7 +1591,7 @@ void CGameState::init( StartInfo * si, ui32 checksum, int Seed )
|
||||
maxB = b;
|
||||
}
|
||||
}
|
||||
HLP::giveCampaignBonusToHero(heroes[maxB], 0xFFFD, si, campaign->camp->scenarios[si->whichMapInCampaign].travelOptions);
|
||||
HLP::giveCampaignBonusToHero(heroes[maxB], si, campaign->camp->scenarios[si->whichMapInCampaign].travelOptions);
|
||||
}
|
||||
else //specific hero
|
||||
{
|
||||
@ -1587,7 +1599,7 @@ void CGameState::init( StartInfo * si, ui32 checksum, int Seed )
|
||||
{
|
||||
if (heroes[b]->subID == chosenBonus.info1)
|
||||
{
|
||||
HLP::giveCampaignBonusToHero(heroes[b], chosenBonus.info1, si, campaign->camp->scenarios[si->whichMapInCampaign].travelOptions);
|
||||
HLP::giveCampaignBonusToHero(heroes[b], si, campaign->camp->scenarios[si->whichMapInCampaign].travelOptions);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user