1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-08-10 22:31:40 +02:00

Merge pull request #5506 from IvanSavenko/regressions

Fix bonus icon loading
This commit is contained in:
Ivan Savenko
2025-03-08 16:03:14 +02:00
committed by GitHub
13 changed files with 236 additions and 186 deletions

View File

@@ -183,6 +183,10 @@
"MIND_IMMUNITY":
{
},
"NEGATIVE_EFFECTS_IMMUNITY" :
{
},
"NONE":
{

View File

@@ -14,7 +14,7 @@
"level" : {
"type" : "number"
},
"bonus" : { "$ref" : "bonus.json" }
"bonus" : { "$ref" : "bonusInstance.json" }
}
}
}
@@ -68,7 +68,7 @@
"bonuses" : {
"type" : "array",
"description" : "Bonuses provided by this artifact using bonus system",
"items" : { "$ref" : "bonus.json" }
"items" : { "$ref" : "bonusInstance.json" }
},
"growing" : {
"type" : "object",

View File

@@ -17,7 +17,7 @@
"bonuses": {
"type":"array",
"description": "List of bonuses that will affect all battles on this battlefield",
"items": { "$ref" : "bonus.json" }
"items": { "$ref" : "bonusInstance.json" }
},
"graphics" : {
"type" : "string",

View File

@@ -1,189 +1,43 @@
{
"type" : "object",
"$schema" : "http://json-schema.org/draft-04/schema",
"title" : "VCMI bonus system format",
"description" : "Subsection of several formats, used to add generic bonuses to objects",
"title" : "VCMI bonus type format",
"description" : "Definition of bonus types",
"required" : ["type"],
"definitions" :
{
"nestedLimiter" : {
"anyOf" : [
{
"type" : "string",
"enum" : [ "SHOOTER_ONLY", "DRAGON_NATURE", "IS_UNDEAD", "CREATURE_NATIVE_TERRAIN", "CREATURE_FACTION", "SAME_FACTION", "CREATURES_ONLY", "OPPOSITE_SIDE" ],
"description" : "parameterless limiter or boolean operator at start of array"
},
{
"type" : "object",
"additionalProperties" : false,
"properties" : {
"type" : {
"type" : "string",
"enum" : [ "CREATURE_TYPE_LIMITER", "HAS_ANOTHER_BONUS_LIMITER", "CREATURE_ALIGNMENT_LIMITER", "FACTION_LIMITER", "CREATURE_LEVEL_LIMITER", "CREATURE_TERRAIN_LIMITER", "UNIT_ON_HEXES" ],
"description" : "type"
},
"parameters" : {
"type" : "array",
"description" : "parameters",
"additionalItems" : true
}
}
},
{
"type" : "array",
"additionalItems" : {
"$ref" : "#/definitions/nestedLimiter",
"description" : "nested limiters optionally prefixed with boolean operator"
}
}
]
}
},
"additionalProperties" : false,
"properties" : {
"type" : {
"type" : "string",
"description" : "type"
"hidden" : {
"type" : "boolean",
"description" : "If set to true, all instances of this bonus will be hidden in UI"
},
"subtype" : {
"type" : "string",
"description" : "subtype"
},
"sourceID" : {
"type" : "number",
"description" : "sourceID"
},
"sourceType" : {
"type" : "string",
"enum" : [ "ARTIFACT", "ARTIFACT_INSTANCE", "OBJECT_TYPE", "OBJECT_INSTANCE", "CREATURE_ABILITY", "TERRAIN_NATIVE", "TERRAIN_OVERLAY", "SPELL_EFFECT", "TOWN_STRUCTURE", "HERO_BASE_SKILL", "SECONDARY_SKILL", "HERO_SPECIAL", "ARMY", "CAMPAIGN_BONUS", "STACK_EXPERIENCE", "COMMANDER", "GLOBAL", "OTHER", ],
"description" : "sourceType"
},
"targetSourceType" : {
"type" : "string",
"enum" : [ "ARTIFACT", "ARTIFACT_INSTANCE", "OBJECT_TYPE", "OBJECT_INSTANCE", "CREATURE_ABILITY", "TERRAIN_NATIVE", "TERRAIN_OVERLAY", "SPELL_EFFECT", "TOWN_STRUCTURE", "HERO_BASE_SKILL", "SECONDARY_SKILL", "HERO_SPECIAL", "ARMY", "CAMPAIGN_BONUS", "STACK_EXPERIENCE", "COMMANDER", "GLOBAL", "OTHER", ],
"description" : "targetSourceType"
},
"propagator" : {
"description" : "propagator",
"type" : "string",
"enum" : [ "BATTLE_WIDE", "VISITED_TOWN_AND_VISITOR", "PLAYER_PROPAGATOR", "HERO", "TEAM_PROPAGATOR", "GLOBAL_EFFECT" ]
},
"updater" : {
"anyOf" : [
{
"graphics" : {
"type" : "object",
"additionalProperties" : false,
"properties" : {
"icon" : {
"type" : "string",
"enum" : [ "TIMES_HERO_LEVEL", "TIMES_STACK_LEVEL", "ARMY_MOVEMENT", "BONUS_OWNER_UPDATER" ]
"description" : "Resourse path of generic icon for this bonus",
"format" : "imageFile"
},
{
"description" : "updater",
"subtypeIcons" : {
"type" : "object",
"required" : ["type", "parameters"],
"additionalProperties" : false,
"properties" : {
"type" : {
"type" : "string",
"enum" : [ "GROWS_WITH_LEVEL", "ARMY_MOVEMENT" ],
"description" : "type"
},
"parameters" : {
"type" : "array",
"description" : "parameters",
"additionalItems" : true
}
}
}
]
},
"propagationUpdater" : {
"anyOf" : [
{
"type" : "string",
"enum" : [ "TIMES_HERO_LEVEL", "TIMES_STACK_LEVEL", "ARMY_MOVEMENT", "BONUS_OWNER_UPDATER" ]
},
{
"description" : "propagationUpdater",
"type" : "object",
"required" : ["type", "parameters"],
"additionalProperties" : false,
"properties" : {
"type" : {
"type" : "string",
"enum" : [ "GROWS_WITH_LEVEL", "ARMY_MOVEMENT" ],
"description" : "type"
},
"parameters" : {
"type" : "array",
"description" : "parameters",
"additionalItems" : true
}
}
}
]
},
"limiters" : {
"$ref" : "#/definitions/nestedLimiter",
"description" : "limiter"
},
"effectRange" : {
"type" : "string",
"enum" : [ "NO_LIMIT", "ONLY_DISTANCE_FIGHT", "ONLY_MELEE_FIGHT" ],
"description" : "effectRange"
},
"val" : {
"type" : "number",
"description" : "val"
},
"valueType" : {
"type" : "string",
"enum" : ["ADDITIVE_VALUE", "BASE_NUMBER", "PERCENT_TO_ALL", "PERCENT_TO_BASE", "PERCENT_TO_SOURCE", "PERCENT_TO_TARGET_TYPE", "INDEPENDENT_MAX", "INDEPENDENT_MIN" ],
"description" : "valueType"
},
"addInfo" : {
"anyOf" : [
{ "type" : "string" },
{ "type" : "number" },
{
"type" : "array",
"items" : {
"anyof" : [
{ "type" : "string" },
{ "type" : "number" }
]
}
}
],
"description" : "addInfo"
},
"duration" : {
"anyOf" : [
{
"type" : "string",
"enum" : ["PERMANENT", "ONE_BATTLE", "ONE_DAY", "ONE_WEEK", "N_TURNS", "N_DAYS", "UNTIL_BEING_ATTACKED", "UNTIL_ATTACK", "STACK_GETS_TURN", "COMMANDER_KILLED", "UNTIL_OWN_ATTACK" ]
},
{
"type" : "array",
"items" : {
"description" : "Resourse path of icon for this bonus subtype",
"additionalProperties" : {
"type" : "string",
"enum" : ["PERMANENT", "ONE_BATTLE", "ONE_DAY", "ONE_WEEK", "N_TURNS", "N_DAYS", "UNTIL_BEING_ATTACKED", "UNTIL_ATTACK", "STACK_GETS_TURN", "COMMANDER_KILLED", "UNTIL_OWN_ATTACK" ]
"format" : "imageFile"
}
},
"valueIcons" : {
"type" : "object",
"description" : "Resourse path of icon for this bonus value",
"additionalProperties" : {
"type" : "string",
"format" : "imageFile"
}
}
],
"description" : "duration"
},
"turns" : {
"type" : "number",
"description" : "turns"
},
"stacking" : {
"type" : "string",
"description" : "stacking"
},
"description" : {
"anyOf" : [
{ "type" : "string" },
{ "type" : "number" }
],
"description" : "description"
}
}
}
}

View File

@@ -0,0 +1,189 @@
{
"type" : "object",
"$schema" : "http://json-schema.org/draft-04/schema",
"title" : "VCMI bonus system format",
"description" : "Subsection of several formats, used to add generic bonuses to objects",
"required" : ["type"],
"definitions" :
{
"nestedLimiter" : {
"anyOf" : [
{
"type" : "string",
"enum" : [ "SHOOTER_ONLY", "DRAGON_NATURE", "IS_UNDEAD", "CREATURE_NATIVE_TERRAIN", "CREATURE_FACTION", "SAME_FACTION", "CREATURES_ONLY", "OPPOSITE_SIDE" ],
"description" : "parameterless limiter or boolean operator at start of array"
},
{
"type" : "object",
"additionalProperties" : false,
"properties" : {
"type" : {
"type" : "string",
"enum" : [ "CREATURE_TYPE_LIMITER", "HAS_ANOTHER_BONUS_LIMITER", "CREATURE_ALIGNMENT_LIMITER", "FACTION_LIMITER", "CREATURE_LEVEL_LIMITER", "CREATURE_TERRAIN_LIMITER", "UNIT_ON_HEXES" ],
"description" : "type"
},
"parameters" : {
"type" : "array",
"description" : "parameters",
"additionalItems" : true
}
}
},
{
"type" : "array",
"additionalItems" : {
"$ref" : "#/definitions/nestedLimiter",
"description" : "nested limiters optionally prefixed with boolean operator"
}
}
]
}
},
"additionalProperties" : false,
"properties" : {
"type" : {
"type" : "string",
"description" : "type"
},
"subtype" : {
"type" : "string",
"description" : "subtype"
},
"sourceID" : {
"type" : "number",
"description" : "sourceID"
},
"sourceType" : {
"type" : "string",
"enum" : [ "ARTIFACT", "ARTIFACT_INSTANCE", "OBJECT_TYPE", "OBJECT_INSTANCE", "CREATURE_ABILITY", "TERRAIN_NATIVE", "TERRAIN_OVERLAY", "SPELL_EFFECT", "TOWN_STRUCTURE", "HERO_BASE_SKILL", "SECONDARY_SKILL", "HERO_SPECIAL", "ARMY", "CAMPAIGN_BONUS", "STACK_EXPERIENCE", "COMMANDER", "GLOBAL", "OTHER", ],
"description" : "sourceType"
},
"targetSourceType" : {
"type" : "string",
"enum" : [ "ARTIFACT", "ARTIFACT_INSTANCE", "OBJECT_TYPE", "OBJECT_INSTANCE", "CREATURE_ABILITY", "TERRAIN_NATIVE", "TERRAIN_OVERLAY", "SPELL_EFFECT", "TOWN_STRUCTURE", "HERO_BASE_SKILL", "SECONDARY_SKILL", "HERO_SPECIAL", "ARMY", "CAMPAIGN_BONUS", "STACK_EXPERIENCE", "COMMANDER", "GLOBAL", "OTHER", ],
"description" : "targetSourceType"
},
"propagator" : {
"description" : "propagator",
"type" : "string",
"enum" : [ "BATTLE_WIDE", "VISITED_TOWN_AND_VISITOR", "PLAYER_PROPAGATOR", "HERO", "TEAM_PROPAGATOR", "GLOBAL_EFFECT" ]
},
"updater" : {
"anyOf" : [
{
"type" : "string",
"enum" : [ "TIMES_HERO_LEVEL", "TIMES_STACK_LEVEL", "ARMY_MOVEMENT", "BONUS_OWNER_UPDATER" ]
},
{
"description" : "updater",
"type" : "object",
"required" : ["type", "parameters"],
"additionalProperties" : false,
"properties" : {
"type" : {
"type" : "string",
"enum" : [ "GROWS_WITH_LEVEL", "ARMY_MOVEMENT" ],
"description" : "type"
},
"parameters" : {
"type" : "array",
"description" : "parameters",
"additionalItems" : true
}
}
}
]
},
"propagationUpdater" : {
"anyOf" : [
{
"type" : "string",
"enum" : [ "TIMES_HERO_LEVEL", "TIMES_STACK_LEVEL", "ARMY_MOVEMENT", "BONUS_OWNER_UPDATER" ]
},
{
"description" : "propagationUpdater",
"type" : "object",
"required" : ["type", "parameters"],
"additionalProperties" : false,
"properties" : {
"type" : {
"type" : "string",
"enum" : [ "GROWS_WITH_LEVEL", "ARMY_MOVEMENT" ],
"description" : "type"
},
"parameters" : {
"type" : "array",
"description" : "parameters",
"additionalItems" : true
}
}
}
]
},
"limiters" : {
"$ref" : "#/definitions/nestedLimiter",
"description" : "limiter"
},
"effectRange" : {
"type" : "string",
"enum" : [ "NO_LIMIT", "ONLY_DISTANCE_FIGHT", "ONLY_MELEE_FIGHT" ],
"description" : "effectRange"
},
"val" : {
"type" : "number",
"description" : "val"
},
"valueType" : {
"type" : "string",
"enum" : ["ADDITIVE_VALUE", "BASE_NUMBER", "PERCENT_TO_ALL", "PERCENT_TO_BASE", "PERCENT_TO_SOURCE", "PERCENT_TO_TARGET_TYPE", "INDEPENDENT_MAX", "INDEPENDENT_MIN" ],
"description" : "valueType"
},
"addInfo" : {
"anyOf" : [
{ "type" : "string" },
{ "type" : "number" },
{
"type" : "array",
"items" : {
"anyof" : [
{ "type" : "string" },
{ "type" : "number" }
]
}
}
],
"description" : "addInfo"
},
"duration" : {
"anyOf" : [
{
"type" : "string",
"enum" : ["PERMANENT", "ONE_BATTLE", "ONE_DAY", "ONE_WEEK", "N_TURNS", "N_DAYS", "UNTIL_BEING_ATTACKED", "UNTIL_ATTACK", "STACK_GETS_TURN", "COMMANDER_KILLED", "UNTIL_OWN_ATTACK" ]
},
{
"type" : "array",
"items" : {
"type" : "string",
"enum" : ["PERMANENT", "ONE_BATTLE", "ONE_DAY", "ONE_WEEK", "N_TURNS", "N_DAYS", "UNTIL_BEING_ATTACKED", "UNTIL_ATTACK", "STACK_GETS_TURN", "COMMANDER_KILLED", "UNTIL_OWN_ATTACK" ]
}
}
],
"description" : "duration"
},
"turns" : {
"type" : "number",
"description" : "turns"
},
"stacking" : {
"type" : "string",
"description" : "stacking"
},
"description" : {
"anyOf" : [
{ "type" : "string" },
{ "type" : "number" }
],
"description" : "description"
}
}
}

View File

@@ -127,7 +127,7 @@
"description" : "Creature abilities described using Bonus system",
"type" : "object",
"additionalProperties" : {
"$ref" : "bonus.json"
"$ref" : "bonusInstance.json"
}
},
"graphics" : {
@@ -285,7 +285,7 @@
"required" : [ "bonus", "values" ],
"description" : "0",
"properties" : {
"bonus" : {"$ref" : "bonus.json" },
"bonus" : {"$ref" : "bonusInstance.json" },
"values" : {
"type" : "array",
"minItems" : 10,

View File

@@ -18,7 +18,7 @@
"bonuses" : {
"type" : "object",
"description" : "List of bonuses provided by this map object. See bonus format for more details",
"additionalProperties" : { "$ref" : "bonus.json" }
"additionalProperties" : { "$ref" : "bonusInstance.json" }
},
"message" : {

View File

@@ -127,7 +127,7 @@
"bonuses" : {
"type" : "object",
"description" : "List of bonuses added by this specialty. See bonus format for more details",
"additionalProperties" : { "$ref" : "bonus.json" }
"additionalProperties" : { "$ref" : "bonusInstance.json" }
},
"creature" : {
"type" : "string",

View File

@@ -117,7 +117,7 @@
"bonuses" : {
"type":"array",
"description": "List of bonuses that will be granted to visiting hero",
"items": { "$ref" : "bonus.json" }
"items": { "$ref" : "bonusInstance.json" }
},
"resources" : { "$ref" : "#/definitions/identifierWithValueList" },

View File

@@ -37,7 +37,7 @@
"effects" : {
"type" : "object",
"additionalProperties" : {
"$ref" : "bonus.json"
"$ref" : "bonusInstance.json"
}
}
}

View File

@@ -84,14 +84,14 @@
"type" : "object",
"description" : "Timed effects (updated by prolongation)",
"additionalProperties" : {
"$ref" : "bonus.json"
"$ref" : "bonusInstance.json"
}
},
"cumulativeEffects" : {
"type" : "object",
"description" : "Timed effects (updated by unique bonus)",
"additionalProperties" : {
"$ref" : "bonus.json"
"$ref" : "bonusInstance.json"
}
},
"battleEffects" : {

View File

@@ -124,7 +124,7 @@
"bonuses" : {
"type" : "array",
"description" : "Bonuses that are provided by this building in any town where this building has been built. Only affects town itself (including siege), to propagate effect to player or team please use bonus propagators",
"items" : { "$ref" : "bonus.json" }
"items" : { "$ref" : "bonusInstance.json" }
},
"marketModes" : {
"type" : "array",

View File

@@ -881,8 +881,11 @@ void CModListView::installFiles(QStringList files)
JsonNode repoData = JsonUtils::jsonFromFile(filename);
if(repoData["name"].isNull())
{
// MODS COMPATIBILITY: in 1.6, repository list contains mod list directly, in 1.7 it is located in 'availableMods' node
const auto & availableRepositoryMods = repoData["availableMods"].isNull() ? repoData : repoData["availableMods"];
// This is main repository index. Download all referenced mods
for(const auto & [modName, modJson] : repoData.Struct())
for(const auto & [modName, modJson] : availableRepositoryMods.Struct())
{
auto modNameLower = boost::algorithm::to_lower_copy(modName);
auto modJsonUrl = modJson["mod"];