Browse Source

Icon index for map format is now defined in config

Ivan Savenko 2 years ago
parent
commit
daaaf84392

+ 2 - 2
Mods/vcmi/Sprites/ScSelC.json

@@ -1,7 +1,7 @@
 {
-        "basepath" : "mapFormatIcons/",
+	"basepath" : "mapFormatIcons/",
 	"images" :
 	[
-		{ "group" : 1, "frame" : 0, "file" : "vcmi1.png"}
+		{ "frame" : 3, "file" : "vcmi1.png"}
 	]
 }

+ 1 - 1
client/lobby/RandomMapTab.cpp

@@ -137,7 +137,7 @@ void RandomMapTab::updateMapInfoByHost()
 	mapInfo = std::make_shared<CMapInfo>();
 	mapInfo->isRandomMap = true;
 	mapInfo->mapHeader = std::make_unique<CMapHeader>();
-	mapInfo->mapHeader->version = EMapFormat::SOD;
+	mapInfo->mapHeader->version = EMapFormat::VCMI;
 	mapInfo->mapHeader->name = CGI->generaltexth->allTexts[740];
 	mapInfo->mapHeader->description = CGI->generaltexth->allTexts[741];
 	mapInfo->mapHeader->difficulty = 1; // Normal

+ 2 - 2
client/lobby/SelectionTab.cpp

@@ -543,7 +543,7 @@ bool SelectionTab::isMapSupported(const CMapInfo & info)
 		case EMapFormat::HOTA:
 			return CGI->settings()->getValue(EGameSettings::MAP_FORMAT_HORN_OF_THE_ABYSS)["supported"].Bool();
 		case EMapFormat::VCMI:
-			return true;
+			return CGI->settings()->getValue(EGameSettings::MAP_FORMAT_JSON_VCMI)["supported"].Bool();
 	}
 	return false;
 }
@@ -694,7 +694,7 @@ void SelectionTab::ListItem::updateItem(std::shared_ptr<CMapInfo> info, bool sel
 		labelMapSizeLetter->setText(info->getMapSizeName());
 		labelMapSizeLetter->setColor(color);
 		iconFormat->enable();
-		iconFormat->setFrame(info->getMapSizeFormatIconId().first, info->getMapSizeFormatIconId().second);
+		iconFormat->setFrame(info->getMapSizeFormatIconId());
 		iconVictoryCondition->enable();
 		iconVictoryCondition->setFrame(info->mapHeader->victoryIconIndex, 0);
 		iconLossCondition->enable();

+ 22 - 5
config/gameConfig.json

@@ -125,11 +125,28 @@
 		},
 		
 		"mapFormat" : {
-			"restorationOfErathia" : { "supported" : true },
-			"armageddonsBlade" : { "supported" : true },
-			"shadowOfDeath" : { "supported" : true },
-			"hornOfTheAbyss" : { "supported" : false },
-			"inTheWakeOfGods" : { "supported" : false }
+			"restorationOfErathia" : { 
+				"supported" : true,
+				"iconIndex" : 0
+			},
+			"armageddonsBlade" : {
+				"supported" : true,
+				"iconIndex" : 1
+			},
+			"shadowOfDeath" : { 
+				"supported" : true,
+				"iconIndex" : 2
+			},
+			"jsonVCMI" : { 
+				"supported" : true,
+				"iconIndex" : 3
+			},
+			"hornOfTheAbyss" : { 
+				"supported" : false
+			},
+			"inTheWakeOfGods" : { 
+				"supported" : false
+			}
 		},
 
 		"heroes" :

+ 1 - 0
lib/GameSettings.cpp

@@ -76,6 +76,7 @@ void GameSettings::load(const JsonNode & input)
 		{EGameSettings::MAP_FORMAT_SHADOW_OF_DEATH,             "mapFormat", "shadowOfDeath"              },
 		{EGameSettings::MAP_FORMAT_HORN_OF_THE_ABYSS,           "mapFormat", "hornOfTheAbyss"             },
 		{EGameSettings::MAP_FORMAT_IN_THE_WAKE_OF_GODS,         "mapFormat", "inTheWakeOfGods"            },
+		{EGameSettings::MAP_FORMAT_JSON_VCMI,                   "mapFormat", "jsonVCMI"                   },
 		{EGameSettings::MARKETS_BLACK_MARKET_RESTOCK_PERIOD,    "markets",   "blackMarketRestockPeriod"   },
 		{EGameSettings::MODULE_COMMANDERS,                      "modules",   "commanders"                 },
 		{EGameSettings::MODULE_STACK_ARTIFACT,                  "modules",   "stackArtifact"              },

+ 1 - 0
lib/GameSettings.h

@@ -55,6 +55,7 @@ enum class EGameSettings
 	MAP_FORMAT_ARMAGEDDONS_BLADE,
 	MAP_FORMAT_SHADOW_OF_DEATH,
 	MAP_FORMAT_HORN_OF_THE_ABYSS,
+	MAP_FORMAT_JSON_VCMI,
 	MAP_FORMAT_IN_THE_WAKE_OF_GODS,
 	TOWNS_BUILDINGS_PER_TURN_CAP,
 	TOWNS_STARTING_DWELLING_CHANCES,

+ 1 - 1
lib/mapping/CMap.cpp

@@ -229,7 +229,7 @@ void CMapHeader::setupEvents()
 	defeatMessage = VLC->generaltexth->lossCondtions[0];
 }
 
-CMapHeader::CMapHeader() : version(EMapFormat::SOD), height(72), width(72),
+CMapHeader::CMapHeader() : version(EMapFormat::VCMI), height(72), width(72),
 	twoLevel(true), difficulty(1), levelLimit(0), howManyTeams(0), areAnyPlayers(false)
 {
 	setupEvents();

+ 1 - 1
lib/mapping/CMap.h

@@ -260,7 +260,7 @@ enum class EMapFormat: uint8_t
 	SOD   = 0x1c, // 28
 	HOTA  = 0x20, // 32
 	WOG   = 0x33, // 51
-	VCMI  = 0xF0
+	VCMI  = 0x64
 };
 
 // Inherit from container to enable forward declaration

+ 15 - 24
lib/mapping/CMapInfo.cpp

@@ -22,6 +22,7 @@
 #include "../CGeneralTextHandler.h"
 #include "../rmg/CMapGenOptions.h"
 #include "../CCreatureHandler.h"
+#include "../GameSettings.h"
 #include "../CHeroHandler.h"
 #include "../CModHandler.h"
 
@@ -149,34 +150,24 @@ int CMapInfo::getMapSizeIconId() const
 	}
 }
 
-std::pair<int, int> CMapInfo::getMapSizeFormatIconId() const
+int CMapInfo::getMapSizeFormatIconId() const
 {
-	int frame = -1;
-	int group = 0;
 	switch(mapHeader->version)
 	{
-	case EMapFormat::ROE:
-		frame = 0;
-		break;
-	case EMapFormat::AB:
-		frame = 1;
-		break;
-	case EMapFormat::SOD:
-		frame = 2;
-		break;
-	case EMapFormat::WOG:
-		frame = 3;
-		break;
-	case EMapFormat::VCMI:
-		frame = 0;
-		group = 1;
-		break;
-	default:
-		// Unknown version. Be safe and ignore that map
-		//logGlobal->warn("Warning: %s has wrong version!", currentItem->fileURI);
-		break;
+		case EMapFormat::ROE:
+			return VLC->settings()->getValue(EGameSettings::MAP_FORMAT_RESTORATION_OF_ERATHIA)["iconIndex"].Integer();
+		case EMapFormat::AB:
+			return VLC->settings()->getValue(EGameSettings::MAP_FORMAT_ARMAGEDDONS_BLADE)["iconIndex"].Integer();
+		case EMapFormat::SOD:
+			return VLC->settings()->getValue(EGameSettings::MAP_FORMAT_SHADOW_OF_DEATH)["iconIndex"].Integer();
+		case EMapFormat::WOG:
+			return VLC->settings()->getValue(EGameSettings::MAP_FORMAT_IN_THE_WAKE_OF_GODS)["iconIndex"].Integer();
+		case EMapFormat::HOTA:
+			return VLC->settings()->getValue(EGameSettings::MAP_FORMAT_HORN_OF_THE_ABYSS)["iconIndex"].Integer();
+		case EMapFormat::VCMI:
+			return VLC->settings()->getValue(EGameSettings::MAP_FORMAT_JSON_VCMI)["iconIndex"].Integer();
 	}
-	return std::make_pair(frame, group);
+	return 0;
 }
 
 std::string CMapInfo::getMapSizeName() const

+ 1 - 1
lib/mapping/CMapInfo.h

@@ -52,7 +52,7 @@ public:
 	std::string getNameForList() const;
 	std::string getDescription() const;
 	int getMapSizeIconId() const;
-	std::pair<int, int> getMapSizeFormatIconId() const;
+	int getMapSizeFormatIconId() const;
 	std::string getMapSizeName() const;
 
 	template <typename Handler> void serialize(Handler &h, const int Version)