Explorar el Código

introduce `getModScope` method to`Entity` class and subclasses

godric3 hace 1 año
padre
commit
c34956e912

+ 1 - 0
include/vcmi/Entity.h

@@ -40,6 +40,7 @@ public:
 	virtual int32_t getIndex() const = 0;
 	virtual int32_t getIconIndex() const = 0;
 	virtual std::string getJsonKey() const = 0;
+	virtual std::string getModScope() const = 0;
 	virtual std::string getNameTranslated() const = 0;
 	virtual std::string getNameTextID() const = 0;
 

+ 5 - 0
lib/BattleFieldHandler.cpp

@@ -73,6 +73,11 @@ std::string BattleFieldInfo::getJsonKey() const
 	return modScope + ':' + identifier;
 }
 
+std::string BattleFieldInfo::getModScope() const
+{
+	return modScope;
+}
+
 std::string BattleFieldInfo::getNameTextID() const
 {
 	return name;

+ 1 - 0
lib/BattleFieldHandler.h

@@ -52,6 +52,7 @@ public:
 	int32_t getIndex() const override;
 	int32_t getIconIndex() const override;
 	std::string getJsonKey() const override;
+	std::string getModScope() const override;
 	std::string getNameTextID() const override;
 	std::string getNameTranslated() const override;
 	void registerIcons(const IconRegistar & cb) const override;

+ 5 - 0
lib/CArtHandler.cpp

@@ -106,6 +106,11 @@ std::string CArtifact::getJsonKey() const
 	return modScope + ':' + identifier;
 }
 
+std::string CArtifact::getModScope() const
+{
+	return modScope;
+}
+
 void CArtifact::registerIcons(const IconRegistar & cb) const
 {
 	cb(getIconIndex(), 0, "ARTIFACT", image);

+ 1 - 0
lib/CArtHandler.h

@@ -106,6 +106,7 @@ public:
 	int32_t getIndex() const override;
 	int32_t getIconIndex() const override;
 	std::string getJsonKey() const override;
+	std::string getModScope() const override;
 	void registerIcons(const IconRegistar & cb) const override;
 	ArtifactID getId() const override;
 	const IBonusBearer * getBonusBearer() const override;

+ 5 - 0
lib/CCreatureHandler.cpp

@@ -61,6 +61,11 @@ std::string CCreature::getJsonKey() const
 	return modScope + ':' + identifier;
 }
 
+std::string CCreature::getModScope() const
+{
+	return modScope;
+}
+
 void CCreature::registerIcons(const IconRegistar & cb) const
 {
 	cb(getIconIndex(), 0, "CPRSMALL", smallIconName);

+ 1 - 0
lib/CCreatureHandler.h

@@ -131,6 +131,7 @@ public:
 	int32_t getIndex() const override;
 	int32_t getIconIndex() const override;
 	std::string getJsonKey() const override;
+	std::string getModScope() const override;
 	void registerIcons(const IconRegistar & cb) const override;
 	CreatureID getId() const override;
 	const IBonusBearer * getBonusBearer() const override;

+ 10 - 0
lib/CHeroHandler.cpp

@@ -53,6 +53,11 @@ std::string CHero::getJsonKey() const
 	return modScope + ':' + identifier;
 }
 
+std::string CHero::getModScope() const
+{
+	return modScope;
+}
+
 HeroTypeID CHero::getId() const
 {
 	return ID;
@@ -189,6 +194,11 @@ std::string CHeroClass::getJsonKey() const
 	return modScope + ':' + identifier;
 }
 
+std::string CHeroClass::getModScope() const
+{
+	return modScope;
+}
+
 HeroClassID CHeroClass::getId() const
 {
 	return id;

+ 2 - 0
lib/CHeroHandler.h

@@ -84,6 +84,7 @@ public:
 	int32_t getIndex() const override;
 	int32_t getIconIndex() const override;
 	std::string getJsonKey() const override;
+	std::string getModScope() const override;
 	HeroTypeID getId() const override;
 	void registerIcons(const IconRegistar & cb) const override;
 
@@ -145,6 +146,7 @@ public:
 	int32_t getIndex() const override;
 	int32_t getIconIndex() const override;
 	std::string getJsonKey() const override;
+	std::string getModScope() const override;
 	HeroClassID getId() const override;
 	void registerIcons(const IconRegistar & cb) const override;
 

+ 5 - 0
lib/CPlayerState.cpp

@@ -50,6 +50,11 @@ std::string PlayerState::getJsonKey() const
 	return color.toString();
 }
 
+std::string PlayerState::getModScope() const
+{
+	return "core";
+}
+
 std::string PlayerState::getNameTranslated() const
 {
 	return VLC->generaltexth->translate(getNameTextID());

+ 1 - 0
lib/CPlayerState.h

@@ -85,6 +85,7 @@ public:
 	int32_t getIndex() const override;
 	int32_t getIconIndex() const override;
 	std::string getJsonKey() const override;
+	std::string getModScope() const override;
 	std::string getNameTranslated() const override;
 	std::string getNameTextID() const override;
 	void registerIcons(const IconRegistar & cb) const override;

+ 5 - 0
lib/CSkillHandler.cpp

@@ -64,6 +64,11 @@ std::string CSkill::getJsonKey() const
 	return modScope + ':' + identifier;
 }
 
+std::string CSkill::getModScope() const
+{
+	return modScope;
+}
+
 std::string CSkill::getDescriptionTextID(int level) const
 {
 	TextIdentifier id("skill", modScope, identifier, "description", NSecondarySkill::levels[level]);

+ 1 - 0
lib/CSkillHandler.h

@@ -52,6 +52,7 @@ public:
 	int32_t getIndex() const override;
 	int32_t getIconIndex() const override;
 	std::string getJsonKey() const override;
+	std::string getModScope() const override;
 	void registerIcons(const IconRegistar & cb) const override;
 	SecondarySkill getId() const override;
 

+ 5 - 0
lib/ObstacleHandler.cpp

@@ -31,6 +31,11 @@ std::string ObstacleInfo::getJsonKey() const
 	return identifier;
 }
 
+std::string ObstacleInfo::getModScope() const
+{
+	return "core";
+}
+
 std::string ObstacleInfo::getNameTranslated() const
 {
 	return identifier;

+ 1 - 0
lib/ObstacleHandler.h

@@ -47,6 +47,7 @@ public:
 	int32_t getIndex() const override;
 	int32_t getIconIndex() const override;
 	std::string getJsonKey() const override;
+	std::string getModScope() const override;
 	std::string getNameTranslated() const override;
 	std::string getNameTextID() const override;
 	void registerIcons(const IconRegistar & cb) const override;

+ 5 - 0
lib/RiverHandler.cpp

@@ -74,6 +74,11 @@ std::string RiverType::getJsonKey() const
 	return modScope + ":" + identifier;
 }
 
+std::string RiverType::getModScope() const
+{
+	return modScope;
+}
+
 std::string RiverType::getNameTextID() const
 {
 	return TextIdentifier( "river", modScope, identifier, "name" ).get();

+ 1 - 0
lib/RiverHandler.h

@@ -37,6 +37,7 @@ public:
 	int32_t getIndex() const override { return id.getNum(); }
 	int32_t getIconIndex() const override { return 0; }
 	std::string getJsonKey() const override;
+	std::string getModScope() const override;
 	void registerIcons(const IconRegistar & cb) const override {}
 	RiverId getId() const override { return id;}
 	void updateFrom(const JsonNode & data) {};

+ 5 - 0
lib/RoadHandler.cpp

@@ -65,6 +65,11 @@ std::string RoadType::getJsonKey() const
 	return modScope + ":" + identifier;
 }
 
+std::string RoadType::getModScope() const
+{
+	return modScope;
+}
+
 std::string RoadType::getNameTextID() const
 {
 	return TextIdentifier( "road", modScope, identifier, "name" ).get();

+ 1 - 0
lib/RoadHandler.h

@@ -29,6 +29,7 @@ public:
 	int32_t getIndex() const override { return id.getNum(); }
 	int32_t getIconIndex() const override { return 0; }
 	std::string getJsonKey() const override;
+	std::string getModScope() const override;
 	void registerIcons(const IconRegistar & cb) const override {}
 	RoadId getId() const override { return id;}
 	void updateFrom(const JsonNode & data) {};

+ 5 - 0
lib/TerrainHandler.cpp

@@ -191,6 +191,11 @@ std::string TerrainType::getJsonKey() const
 	return modScope + ":" + identifier;
 }
 
+std::string TerrainType::getModScope() const
+{
+	return modScope;
+}
+
 std::string TerrainType::getNameTextID() const
 {
 	return TextIdentifier( "terrain", modScope, identifier, "name" ).get();

+ 1 - 0
lib/TerrainHandler.h

@@ -55,6 +55,7 @@ public:
 	int32_t getIndex() const override { return id.getNum(); }
 	int32_t getIconIndex() const override { return 0; }
 	std::string getJsonKey() const override;
+	std::string getModScope() const override;
 	void registerIcons(const IconRegistar & cb) const override {}
 	TerrainId getId() const override { return id;}
 	void updateFrom(const JsonNode & data) {};

+ 5 - 0
lib/entities/faction/CFaction.cpp

@@ -41,6 +41,11 @@ std::string CFaction::getJsonKey() const
 	return modScope + ':' + identifier;
 }
 
+std::string CFaction::getModScope() const
+{
+	return modScope;
+}
+
 void CFaction::registerIcons(const IconRegistar & cb) const
 {
 	if(town)

+ 1 - 0
lib/entities/faction/CFaction.h

@@ -63,6 +63,7 @@ public:
 	int32_t getIndex() const override;
 	int32_t getIconIndex() const override;
 	std::string getJsonKey() const override;
+	std::string getModScope() const override;
 	void registerIcons(const IconRegistar & cb) const override;
 	FactionID getId() const override;
 

+ 5 - 0
lib/spells/CSpellHandler.cpp

@@ -200,6 +200,11 @@ std::string CSpell::getJsonKey() const
 	return modScope + ':' + identifier;
 }
 
+std::string CSpell::getModScope() const
+{
+	return modScope;
+}
+
 int32_t CSpell::getIndex() const
 {
 	return id.toEnum();

+ 1 - 0
lib/spells/CSpellHandler.h

@@ -228,6 +228,7 @@ public:
 	int32_t getIndex() const override;
 	int32_t getIconIndex() const override;
 	std::string getJsonKey() const override;
+	std::string getModScope() const override;
 	SpellID getId() const override;
 
 	std::string getNameTextID() const override;

+ 6 - 6
mapeditor/mapcontroller.cpp

@@ -616,17 +616,17 @@ ModCompatibilityInfo MapController::modAssessmentMap(const CMap & map)
 
 	auto extractEntityMod = [&result](const auto & entity) 
 	{
-		auto modName = QString::fromStdString(entity->getJsonKey()).split(":").at(0).toStdString();
-		if(modName != "core")
-			result[modName] = VLC->modh->getModInfo(modName).getVerificationInfo();
+		auto modScope = entity->getModScope();
+		if(modScope != "core")
+			result[modScope] = VLC->modh->getModInfo(modScope).getVerificationInfo();
 	};
 
 	for(auto obj : map.objects)
 	{
 		auto handler = obj->getObjectHandler();
-		auto modName = QString::fromStdString(handler->getJsonKey()).split(":").at(0).toStdString();
-		if(modName != "core")
-			result[modName] = VLC->modh->getModInfo(modName).getVerificationInfo();
+		auto modScope = QString::fromStdString(handler->getJsonKey()).split(":").at(0).toStdString();
+		if(modScope != "core")
+			result[modScope] = VLC->modh->getModInfo(modScope).getVerificationInfo();
 
 		if(obj->ID == Obj::TOWN || obj->ID == Obj::RANDOM_TOWN)
 		{