浏览代码

* showing spell effects affecting stack in creature info window
* more appropriate coloring of stack amount box when stack is affected by a spell

mateuszb 17 年之前
父节点
当前提交
6fc8ed9365
共有 6 个文件被更改,包括 93 次插入11 次删除
  1. 74 9
      CBattleInterface.cpp
  2. 1 1
      CBattleInterface.h
  3. 1 1
      CGameInterface.h
  4. 15 0
      CPlayerInterface.cpp
  5. 1 0
      client/Graphics.cpp
  6. 1 0
      client/Graphics.h

+ 74 - 9
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; g<amountNormal->format->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; g<amountPositive->format->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; g<amountNegative->format->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; g<amountNegative->format->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; c<stacks[stackAliveByHex[b][v]].effects.size(); ++c)
+					{
+						pos += CGI->spellh->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<<stacks[stackAliveByHex[b][v]].amount;
 				CSDL_Ext::printAtMiddleWB(ss.str(), creAnims[stackAliveByHex[b][v]]->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<CStack> stacksSorted;
 		stacksSorted = LOCPLINT->cb->battleGetStackQueue();
-		//for(int v=0; v<stacks.size(); ++v)
-		//{
-		//	if(stacks[v].alive()) //we don't want dead stacks to be there
-		//		stacksSorted.push_back(stacks[v]);
-		//}
-		//std::stable_sort(stacksSorted.begin(), stacksSorted.end(), cmpst2);
 		int startFrom = -1;
 		for(int n=0; n<stacksSorted.size(); ++n)
 		{
@@ -2073,6 +2134,10 @@ void CBattleHex::clickRight(boost::logic::tribool down)
 				pom->luck = h->getCurrentLuck();
 				pom->morale = h->getCurrentMorale();
 				pom->shotsLeft = myst.shots;
+				for(int vb=0; vb<myst.effects.size(); ++vb)
+				{
+					pom->effects.insert(myst.effects[vb].id);
+				}
 			}
 			pom->currentHealth = myst.firstHPleft;
 			(new CCreInfoWindow(myst.creature->idNumber,0,myst.amount,pom,boost::function<void()>(),boost::function<void()>(),NULL))

+ 1 - 1
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;

+ 1 - 1
CGameInterface.h

@@ -36,7 +36,7 @@ struct StackState
 	int attackBonus, defenseBonus, healthBonus, speedBonus;
 	int currentHealth;
 	int shotsLeft;
-	std::set<int> effects;
+	std::set<int> effects; //IDs of spells affecting stack
 	int morale, luck;
 };
 

+ 15 - 0
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<int>::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()
 {

+ 1 - 0
client/Graphics.cpp

@@ -176,6 +176,7 @@ void Graphics::initializeBattleGraphics()
 			battleACToDef[ACid] = toAdd;
 		}
 	}
+	spellEffectsPics = CDefHandler::giveDef("SpellInt.def");
 }
 Graphics::Graphics()
 {

+ 1 - 0
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<std::string> guildBgs;// name of bitmaps with imgs for mage guild screen
 	//functions
 	Graphics();