Prechádzať zdrojové kódy

Fix h3 bug: icons of View Earth and View Air are swapped

Ivan Savenko 1 rok pred
rodič
commit
2b692c2606

+ 7 - 0
Mods/vcmi/Content/Sprites/spells.json

@@ -0,0 +1,7 @@
+{
+	"images" :
+	[
+		{ "frame" : 3, "defFile" : "spells.def", "defFrame" : 5},
+		{ "frame" : 5, "defFile" : "spells.def", "defFrame" : 3}
+	]
+}

+ 6 - 4
client/render/ImageLocator.cpp

@@ -15,15 +15,17 @@
 
 #include "../../lib/json/JsonNode.h"
 
-
 ImageLocator::ImageLocator(const JsonNode & config)
-	: image(ImagePath::fromJson(config["file"]))
-	, defFile(AnimationPath::fromJson(config["defFile"]))
-	, defFrame(config["defFrame"].Integer())
+	: defFrame(config["defFrame"].Integer())
 	, defGroup(config["defGroup"].Integer())
 	, verticalFlip(config["verticalFlip"].Bool())
 	, horizontalFlip(config["horizontalFlip"].Bool())
 {
+	if(!config["file"].isNull())
+		image = ImagePath::fromJson(config["file"]);
+
+	if(!config["defFile"].isNull())
+		defFile = AnimationPath::fromJson(config["defFile"]);
 }
 
 ImageLocator::ImageLocator(const ImagePath & path)

+ 7 - 1
client/renderSDL/RenderHandler.cpp

@@ -142,7 +142,13 @@ void RenderHandler::initFromJson(AnimationLayoutMap & source, const JsonNode & c
 
 		JsonNode toAdd = node;
 		JsonUtils::inherit(toAdd, base);
-		toAdd["file"].String() = basepath + node["file"].String();
+
+		if (toAdd.Struct().count("file"))
+			toAdd["file"].String() = basepath + node["file"].String();
+
+		if (toAdd.Struct().count("defFile"))
+			toAdd["defFile"].String() = basepath + node["defFile"].String();
+
 		source[group][frame] = ImageLocator(toAdd);
 	}
 }