Browse Source

- fixed some bugs with artifacts icons

Ivan Savenko 12 years ago
parent
commit
1c0ccd2b02
3 changed files with 15 additions and 9 deletions
  1. 2 2
      Mods/WoG/config/wog/artifacts.json
  2. 7 1
      client/CBitmapHandler.cpp
  3. 6 6
      lib/CArtHandler.cpp

+ 2 - 2
Mods/WoG/config/wog/artifacts.json

@@ -1,10 +1,10 @@
 {
-	"art144":
+	"art144": // placeholder for selection image
 	{
 		"index" : 144,
 		"type" : ["HERO"]
 	},
-	"art145":
+	"art145": // placeholder for lock image
 	{
 		"index" : 145,
 		"type" : ["HERO"]

+ 7 - 1
client/CBitmapHandler.cpp

@@ -157,15 +157,21 @@ SDL_Surface * BitmapHandler::loadBitmapFromDir(std::string path, std::string fna
 	// When modifyin anything here please check two use cases:
 	// 1) Vampire mansion in Necropolis (not 1st color is transparent)
 	// 2) Battle background when fighting on grass/dirt, topmost sky part (NO transparent color)
+	// 3) New objects that may use 24-bit images for icons (e.g. witchking arts)
+	auto colorID = SDL_MapRGB(ret->format, 0, 255, 255);
+
 	if (ret->format->palette)
 	{
-		auto colorID = SDL_MapRGB(ret->format, 0, 255, 255);
 		auto & color = ret->format->palette->colors[colorID];
 
 		// set color key only if exactly such color was found
 		if (color.r == 0 && color.g == 255 && color.b == 255)
 			SDL_SetColorKey(ret, SDL_SRCCOLORKEY, colorID);
 	}
+	else // always set
+	{
+		SDL_SetColorKey(ret, SDL_SRCCOLORKEY, colorID);
+	}
 	return ret;
 }
 

+ 6 - 6
lib/CArtHandler.cpp

@@ -199,10 +199,10 @@ void CArtHandler::loadObject(std::string scope, std::string name, const JsonNode
 {
 	auto object = loadFromJson(data);
 	object->id = ArtifactID(artifacts.size());
-	if (object->id < ArtifactID::ART_SELECTION)
+	//if (object->id < ArtifactID::ART_SELECTION)
 		object->iconIndex = object->id;
-	else
-		object->iconIndex = object->id + 2;
+	//else
+	//	object->iconIndex = object->id + 2;
 
 	artifacts.push_back(object);
 
@@ -213,10 +213,10 @@ void CArtHandler::loadObject(std::string scope, std::string name, const JsonNode
 {
 	auto object = loadFromJson(data);
 	object->id = ArtifactID(index);
-	if (object->id < ArtifactID::ART_SELECTION)
+	//if (object->id < ArtifactID::ART_SELECTION)
 		object->iconIndex = object->id;
-	else
-		object->iconIndex = object->id + 2;
+	//else
+	//	object->iconIndex = object->id + 2;
 
 	assert(artifacts[index] == nullptr); // ensure that this id was not loaded before
 	artifacts[index] = object;