diff --git a/CBattleInterface.cpp b/CBattleInterface.cpp index aa7c7576b..d13e59a35 100644 --- a/CBattleInterface.cpp +++ b/CBattleInterface.cpp @@ -66,7 +66,6 @@ CBattleInterface::CBattleInterface(CCreatureSet * army1, CCreatureSet * army2, C graphics->blueToPlayersAdv(menu, hero1->tempOwner); //preparing graphics for displaying amounts of creatures - amountBasic = BitmapHandler::loadBitmap("CMNUMWIN.BMP"); amountNormal = BitmapHandler::loadBitmap("CMNUMWIN.BMP"); CSDL_Ext::alphaTransform(amountNormal); for(int g=0; gformat->palette->ncolors; ++g) @@ -80,6 +79,45 @@ CBattleInterface::CBattleInterface(CCreatureSet * army1, CCreatureSet * army2, C (amountNormal->format->palette->colors+g)->b = (float)((amountNormal->format->palette->colors+g)->b) * 0.93f; } } + amountPositive = BitmapHandler::loadBitmap("CMNUMWIN.BMP"); + CSDL_Ext::alphaTransform(amountPositive); + for(int g=0; gformat->palette->ncolors; ++g) + { + if((amountPositive->format->palette->colors+g)->b != 132 && + (amountPositive->format->palette->colors+g)->g != 231 && + (amountPositive->format->palette->colors+g)->r != 255) //it's not yellow border + { + (amountPositive->format->palette->colors+g)->r = (float)((amountPositive->format->palette->colors+g)->r) * 0.18f; + (amountPositive->format->palette->colors+g)->g = (float)((amountPositive->format->palette->colors+g)->g) * 1.00f; + (amountPositive->format->palette->colors+g)->b = (float)((amountPositive->format->palette->colors+g)->b) * 0.18f; + } + } + amountNegative = BitmapHandler::loadBitmap("CMNUMWIN.BMP"); + CSDL_Ext::alphaTransform(amountNegative); + for(int g=0; gformat->palette->ncolors; ++g) + { + if((amountNegative->format->palette->colors+g)->b != 132 && + (amountNegative->format->palette->colors+g)->g != 231 && + (amountNegative->format->palette->colors+g)->r != 255) //it's not yellow border + { + (amountNegative->format->palette->colors+g)->r = (float)((amountNegative->format->palette->colors+g)->r) * 1.00f; + (amountNegative->format->palette->colors+g)->g = (float)((amountNegative->format->palette->colors+g)->g) * 0.18f; + (amountNegative->format->palette->colors+g)->b = (float)((amountNegative->format->palette->colors+g)->b) * 0.18f; + } + } + amountEffNeutral = BitmapHandler::loadBitmap("CMNUMWIN.BMP"); + CSDL_Ext::alphaTransform(amountNegative); + for(int g=0; gformat->palette->ncolors; ++g) + { + if((amountNegative->format->palette->colors+g)->b != 132 && + (amountNegative->format->palette->colors+g)->g != 231 && + (amountNegative->format->palette->colors+g)->r != 255) //it's not yellow border + { + (amountNegative->format->palette->colors+g)->r = (float)((amountNegative->format->palette->colors+g)->r) * 1.00f; + (amountNegative->format->palette->colors+g)->g = (float)((amountNegative->format->palette->colors+g)->g) * 1.00f; + (amountNegative->format->palette->colors+g)->b = (float)((amountNegative->format->palette->colors+g)->b) * 0.18f; + } + } ////blitting menu background and terrain blitAt(background, 0, 0); @@ -203,8 +241,10 @@ CBattleInterface::~CBattleInterface() { SDL_FreeSurface(background); SDL_FreeSurface(menu); - SDL_FreeSurface(amountBasic); SDL_FreeSurface(amountNormal); + SDL_FreeSurface(amountNegative); + SDL_FreeSurface(amountPositive); + SDL_FreeSurface(amountEffNeutral); SDL_FreeSurface(cellBorders); SDL_FreeSurface(backgroundWithHexes); delete bOptions; @@ -398,7 +438,34 @@ void CBattleInterface::show(SDL_Surface * to) { int xAdd = stacks[stackAliveByHex[b][v]].attackerOwned ? 220 : 202; - SDL_BlitSurface(amountNormal, NULL, to, &genRect(amountNormal->h, amountNormal->w, creAnims[stackAliveByHex[b][v]]->pos.x + xAdd, creAnims[stackAliveByHex[b][v]]->pos.y + 260)); + //blitting amoutn background box + SDL_Surface *amountBG = NULL; + if(stacks[stackAliveByHex[b][v]].effects.size() == 0) + { + amountBG = amountNormal; + } + else + { + int pos=0; //determining total positiveness of effects + for(int c=0; cspellh->spells[ stacks[stackAliveByHex[b][v]].effects[c].id ].positiveness; + } + if(pos > 0) + { + amountBG = amountPositive; + } + else if(pos < 0) + { + amountBG = amountNegative; + } + else + { + amountBG = amountEffNeutral; + } + } + SDL_BlitSurface(amountBG, NULL, to, &genRect(amountNormal->h, amountNormal->w, creAnims[stackAliveByHex[b][v]]->pos.x + xAdd, creAnims[stackAliveByHex[b][v]]->pos.y + 260)); + //blitting amount std::stringstream ss; ss<pos.x + xAdd + 14, creAnims[stackAliveByHex[b][v]]->pos.y + 260 + 4, GEOR13, 20, zwykly, to); @@ -436,12 +503,6 @@ void CBattleInterface::show(SDL_Surface * to) std::vector stacksSorted; stacksSorted = LOCPLINT->cb->battleGetStackQueue(); - //for(int v=0; vluck = h->getCurrentLuck(); pom->morale = h->getCurrentMorale(); pom->shotsLeft = myst.shots; + for(int vb=0; vbeffects.insert(myst.effects[vb].id); + } } pom->currentHealth = myst.firstHPleft; (new CCreInfoWindow(myst.creature->idNumber,0,myst.amount,pom,boost::function(),boost::function(),NULL)) diff --git a/CBattleInterface.h b/CBattleInterface.h index c578abfd7..974c218f4 100644 --- a/CBattleInterface.h +++ b/CBattleInterface.h @@ -118,7 +118,7 @@ public: class CBattleInterface : public CMainInterface, public MotionInterested, public KeyInterested { private: - SDL_Surface * background, * menu, * amountBasic, * amountNormal, * cellBorders, * backgroundWithHexes; + SDL_Surface * background, * menu, * amountNormal, * amountNegative, * amountPositive, * amountEffNeutral, * cellBorders, * backgroundWithHexes; AdventureMapButton * bOptions, * bSurrender, * bFlee, * bAutofight, * bSpell, * bWait, * bDefence, * bConsoleUp, * bConsoleDown; CBattleConsole * console; diff --git a/CGameInterface.h b/CGameInterface.h index 7a074d6da..b64a58761 100644 --- a/CGameInterface.h +++ b/CGameInterface.h @@ -36,7 +36,7 @@ struct StackState int attackBonus, defenseBonus, healthBonus, speedBonus; int currentHealth; int shotsLeft; - std::set effects; + std::set effects; //IDs of spells affecting stack int morale, luck; }; diff --git a/CPlayerInterface.cpp b/CPlayerInterface.cpp index 956b58228..548b0f7e3 100644 --- a/CPlayerInterface.cpp +++ b/CPlayerInterface.cpp @@ -3302,6 +3302,21 @@ CCreInfoWindow::CCreInfoWindow(int Cid, int Type, int creatureCount, StackState { printAtWB(c->abilityText,17,231,GEOR13,35,zwykly,bitmap); } + + //spell effects + if(State) + { + int printed=0; //how many effect pics have been printed + for(std::set::const_iterator it = State->effects.begin(); it!=State->effects.end(); ++it) + { + blitAt(graphics->spellEffectsPics->ourImages[*it + 1].bitmap, 127 + 52 * printed, 186, bitmap); + ++printed; + if(printed >= 3) + { + break; + } + } + } } CCreInfoWindow::~CCreInfoWindow() { diff --git a/client/Graphics.cpp b/client/Graphics.cpp index cbef8a908..99d6f9e7a 100644 --- a/client/Graphics.cpp +++ b/client/Graphics.cpp @@ -176,6 +176,7 @@ void Graphics::initializeBattleGraphics() battleACToDef[ACid] = toAdd; } } + spellEffectsPics = CDefHandler::giveDef("SpellInt.def"); } Graphics::Graphics() { diff --git a/client/Graphics.h b/client/Graphics.h index fe2d84324..01f3ff00e 100644 --- a/client/Graphics.h +++ b/client/Graphics.h @@ -40,6 +40,7 @@ public: std::vector< std::vector< std::string > > battleBacks; //battleBacks[terType] - vector of possible names for certain terrain type std::vector< std::string > battleHeroes; //battleHeroes[hero type] - name of def that has hero animation for battle std::map< int, std::vector < std::string > > battleACToDef; //maps AC format to vector of appropriate def names + CDefHandler * spellEffectsPics; //bitmaps representing spells affecting a stack in battle std::vector guildBgs;// name of bitmaps with imgs for mage guild screen //functions Graphics();