1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-21 17:17:06 +02:00

introduce getModScope method toEntity class and subclasses

This commit is contained in:
godric3 2024-08-10 16:08:04 +02:00
parent 18e96171de
commit c34956e912
26 changed files with 85 additions and 6 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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);

View File

@ -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;

View File

@ -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);

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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());

View File

@ -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;

View File

@ -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]);

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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();

View File

@ -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) {};

View File

@ -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();

View File

@ -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) {};

View File

@ -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();

View File

@ -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) {};

View File

@ -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)

View File

@ -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;

View File

@ -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();

View File

@ -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;

View File

@ -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)
{