ソースを参照

Fix battle absolute obstactes rendering

AlexVinS 11 年 前
コミット
082c9a506e
3 ファイル変更17 行追加8 行削除
  1. 4 6
      client/CAnimation.cpp
  2. 7 1
      client/CBitmapHandler.cpp
  3. 6 1
      client/battle/CBattleInterface.cpp

+ 4 - 6
client/CAnimation.cpp

@@ -640,13 +640,11 @@ SDLImage::SDLImage(std::string filename, bool compressed):
 		if (surf->format->palette)
 		{
 			const SDL_Color &c = temp->format->palette->colors[0];
-			SDL_SetColorKey(temp, (SDL_SRCCOLORKEY ),
-				SDL_MapRGB(temp -> format, c.r, c.g, c.b));
+			uint32_t key = SDL_MapRGBA(temp -> format, c.r, c.g, c.b,c.a);
+			SDL_SetColorKey(temp, SDL_TRUE, key);
 		}
-		SDL_SetSurfaceRLE(temp, SDL_RLEACCEL);
-		
-		#endif
-		
+		SDL_SetSurfaceRLE(temp, SDL_RLEACCEL);		
+		#endif		
 
 		// convert surface to enable RLE
 		surf = SDL_ConvertSurface(temp, temp->format, temp->flags);

+ 7 - 1
client/CBitmapHandler.cpp

@@ -122,7 +122,13 @@ SDL_Surface * BitmapHandler::loadBitmapFromDir(std::string path, std::string fna
 			if(ret->format->BytesPerPixel == 1  &&  setKey)
 			{
 				const SDL_Color &c = ret->format->palette->colors[0];
-				SDL_SetColorKey(ret,SDL_SRCCOLORKEY,SDL_MapRGB(ret->format, c.r, c.g, c.b));		
+				#ifdef VCMI_SDL1
+				uint32_t key = SDL_MapRGB(ret->format, c.r, c.g, c.b); 
+				#else
+				uint32_t key = SDL_MapRGBA(ret->format, c.r, c.g, c.b, c.a); 
+				#endif
+				
+				SDL_SetColorKey(ret,SDL_SRCCOLORKEY,key);		
 			}
 		}
 		else

+ 6 - 1
client/battle/CBattleInterface.cpp

@@ -364,7 +364,12 @@ CBattleInterface::CBattleInterface(const CCreatureSet * army1, const CCreatureSe
 			idToObstacle[ID] = CDefHandler::giveDef(elem->getInfo().defName);
 			for(auto & _n : idToObstacle[ID]->ourImages)
 			{
-				SDL_SetColorKey(_n.bitmap, SDL_SRCCOLORKEY, SDL_MapRGB(_n.bitmap->format,0,255,255));
+				#ifdef VCMI_SDL1
+				uint32_t key = SDL_MapRGB(_n.bitmap->format, 0, 255, 255); 
+				#else
+				uint32_t key = SDL_MapRGBA(_n.bitmap->format, 0, 255, 255, 0); 
+				#endif				
+				SDL_SetColorKey(_n.bitmap, SDL_SRCCOLORKEY, key);
 			}
 		}
 		else if(elem->obstacleType == CObstacleInstance::ABSOLUTE_OBSTACLE)