From 1c0ccd2b022611e8e0602ecd784c7711bcf1b9d1 Mon Sep 17 00:00:00 2001 From: Ivan Savenko Date: Fri, 31 May 2013 11:46:19 +0000 Subject: [PATCH] - fixed some bugs with artifacts icons --- Mods/WoG/config/wog/artifacts.json | 4 ++-- client/CBitmapHandler.cpp | 8 +++++++- lib/CArtHandler.cpp | 12 ++++++------ 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/Mods/WoG/config/wog/artifacts.json b/Mods/WoG/config/wog/artifacts.json index c714fbc64..ecdcf3561 100644 --- a/Mods/WoG/config/wog/artifacts.json +++ b/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"] diff --git a/client/CBitmapHandler.cpp b/client/CBitmapHandler.cpp index 72feab920..03130eeb7 100644 --- a/client/CBitmapHandler.cpp +++ b/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; } diff --git a/lib/CArtHandler.cpp b/lib/CArtHandler.cpp index a51291900..629d52819 100644 --- a/lib/CArtHandler.cpp +++ b/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;