Explorar el Código

Added palette colors for neutral "player" (Thx to Dru). Support for using them via blueToPlayersAdv(surface, 255).

Michał W. Urbańczyk hace 16 años
padre
commit
9aff190899
Se han modificado 4 ficheros con 33 adiciones y 2 borrados
  1. 2 1
      client/CPlayerInterface.cpp
  2. 29 1
      client/Graphics.cpp
  3. 2 0
      client/Graphics.h
  4. BIN
      config/NEUTRAL.PAL

+ 2 - 1
client/CPlayerInterface.cpp

@@ -1514,11 +1514,12 @@ void CPlayerInterface::openHeroWindow(const CGHeroInstance *hero)
 void CPlayerInterface::heroArtifactSetChanged(const CGHeroInstance*hero)
 {
 	boost::unique_lock<boost::recursive_mutex> un(*pim);
-	if(adventureInt->heroWindow->curHero)
+	if(adventureInt->heroWindow->curHero) //hero window is opened
 	{
 		adventureInt->heroWindow->deactivate();
 		adventureInt->heroWindow->setHero(adventureInt->heroWindow->curHero);
 		adventureInt->heroWindow->activate();
+		return;
 	}
 	CExchangeWindow* cew = dynamic_cast<CExchangeWindow*>(listInt.front());
 	if(cew) //exchange window is open

+ 29 - 1
client/Graphics.cpp

@@ -117,6 +117,19 @@ void Graphics::loadPaletteAndColors()
 		col.unused = pals[startPoint++];
 		playerColorPalette[i] = col;
 	}
+
+	neutralColorPalette = new SDL_Color[32];
+	std::ifstream ncp;
+	ncp.open("config/NEUTRAL.PAL", std::ios::binary);
+	for(int i=0; i<32; ++i)
+	{
+		ncp.read((char*)&neutralColorPalette[i].r,1);
+		ncp.read((char*)&neutralColorPalette[i].g,1);
+		ncp.read((char*)&neutralColorPalette[i].b,1);
+		ncp.read((char*)&neutralColorPalette[i].unused,1);
+	}
+
+
 	//colors initialization
 	int3 kolory[] = {int3(0xff,0,0),int3(0x31,0x52,0xff),int3(0x9c,0x73,0x52),int3(0x42,0x94,0x29),
 		int3(0xff,0x84,0x0),int3(0x8c,0x29,0xa5),int3(0x09,0x9c,0xa5),int3(0xc6,0x7b,0x8c)};
@@ -472,9 +485,24 @@ void Graphics::blueToPlayersAdv(SDL_Surface * sur, int player)
 		return;
 	if(sur->format->BitsPerPixel == 8)
 	{
+		SDL_Color *palette = NULL;
+		if(player < PLAYER_LIMIT)
+		{
+			palette = playerColorPalette + 32*player;
+		}
+		else if(player == 255)
+		{
+			palette = neutralColorPalette;
+		}
+		else
+		{
+			tlog1 << "Wrong player id in blueToPlayersAdv (" << player << ")!\n";
+			return;
+		}
+
 		for(int i=0; i<32; ++i)
 		{
-			sur->format->palette->colors[224+i] = playerColorPalette[32*player+i];
+			sur->format->palette->colors[224+i] = palette[i];
 		}
 	}
 	else if(sur->format->BitsPerPixel == 24) //should never happen in general

+ 2 - 0
client/Graphics.h

@@ -28,6 +28,8 @@ public:
 	SDL_Color * playerColors; //array [8]
 	SDL_Color * neutralColor;
 	SDL_Color * playerColorPalette; //palette to make interface colors good - array of size [256]
+	SDL_Color * neutralColorPalette; 
+
 	SDL_Surface * hInfo, *tInfo; //hero and town infobox bgs
 	SDL_Surface *heroInGarrison; //icon for town infobox
 	std::vector<std::pair<int, int> > slotsPos; //creature slot positions in infoboxes

BIN
config/NEUTRAL.PAL