restructure Content Patcher schema a bit (#654)

This commit is contained in:
Jesse Plamondon-Willard 2019-08-06 00:15:21 -04:00
parent 3331beb17a
commit 22480d25b9
No known key found for this signature in database
GPG Key ID: CF8B1456B3E29F49
1 changed files with 238 additions and 270 deletions

View File

@ -5,12 +5,84 @@
"description": "Content Patcher content file for mods",
"@documentationUrl": "https://github.com/Pathoschild/StardewMods/tree/develop/ContentPatcher#readme",
"type": "object",
"definitions": {
"Version": {
"properties": {
"Format": {
"title": "Format version",
"description": "The format version. You should always use the latest version to use the latest features and avoid obsolete behavior.",
"type": "string",
"pattern": "\\d+\\.\\d+"
},
"Change": {
"ConfigSchema": {
"title": "Config schema",
"description": "Defines the config.json format, to support more complex mods.",
"type": "object",
"additionalProperties": {
"type": "object",
"properties": {
"AllowValues": {
"title": "Allowed values",
"description": "The values the player can provide, as a comma-delimited string. If omitted, any value is allowed.\nTip: for a boolean flag, use \"true, false\".",
"type": "string"
},
"AllowBlank": {
"title": "Allow blank",
"description": "Whether the field can be left blank. If false or omitted, blank fields will be replaced with the default value.",
"type": "boolean"
},
"AllowMultiple": {
"title": "Allow multiple values",
"description": "Whether the player can specify multiple comma-delimited values. Default false.",
"type": "boolean"
},
"Default": {
"title": "Default value",
"description": "The default values when the field is missing. Can contain multiple comma-delimited values if AllowMultiple is true. If omitted, blank fields are left blank.",
"type": "string"
}
},
"if": {
"properties": {
"AllowBlank": { "const": false }
},
"required": [ "AllowBlank" ]
},
"then": {
"required": [ "Default" ]
}
}
},
"DynamicTokens": {
"title": "Dynamic tokens",
"description": "Custom tokens that you can use.",
"type": "array",
"items": {
"type": "object",
"properties": {
"Name": {
"title": "Name",
"description": "The name of the token to use for tokens & condition.",
"type": "string"
},
"Value": {
"title": "Token value",
"description": "The value(s) to set. This can be a comma-delimited value to give it multiple values. If any block for a token name has multiple values, it will only be usable in conditions. This field supports tokens, including dynamic tokens defined before this entry.",
"type": "string"
},
"When": {
"title": "When",
"description": "Only set the value if the given conditions match. If not specified, always matches.",
"$ref": "#/definitions/Condition"
}
},
"required": [ "Name", "Value" ]
}
},
"Changes": {
"title": "Changes",
"description": "The changes you want to make. Each entry is called a patch, and describes a specific action to perform: replace this file, copy this image into the file, etc. You can list any number of patches.",
"type": "array",
"items": {
"properties": {
"Action": {
"title": "Action",
@ -53,62 +125,25 @@
{
"if": {
"properties": {
"Action": {
"const": "Load"
}
"Action": { "const": "Load" }
}
},
"then": {
"$ref": "#/definitions/LoadChange"
}
},
{
"if": {
"properties": {
"Action": {
"const": "EditImage"
}
}
},
"then": {
"$ref": "#/definitions/EditImageChange"
}
},
{
"if": {
"properties": {
"Action": {
"const": "EditData"
}
}
},
"then": {
"$ref": "#/definitions/EditDataChange"
}
},
{
"if": {
"properties": {
"Action": {
"const": "EditMap"
}
}
},
"then": {
"$ref": "#/definitions/EditMapChange"
}
}
]
},
"LoadChange": {
"properties": {
"FromFile": {
"$ref": "#/definitions/FromFile"
}
},
"required": [ "FromFile" ]
}
},
"EditImageChange": {
{
"if": {
"properties": {
"Action": { "const": "EditImage" }
}
},
"then": {
"properties": {
"FromFile": {
"$ref": "#/definitions/FromFile"
@ -131,8 +166,15 @@
}
},
"required": [ "FromFile" ]
}
},
"EditDataChange": {
{
"if": {
"properties": {
"Action": { "const": "EditData" }
}
},
"then": {
"properties": {
"Fields": {
"title": "Fields",
@ -199,8 +241,15 @@
}
}
}
}
},
"EditMapChange": {
{
"if": {
"properties": {
"Action": { "const": "EditMap" }
}
},
"then": {
"properties": {
"FromFile": {
"description": "The relative path to the map in your content pack folder from which to copy (like assets/town.tbin). This can be a .tbin or .xnb file. This field supports tokens and capitalisation doesn't matter.\nContent Patcher will handle tilesheets referenced by the FromFile map for you if it's a .tbin file:\n - If a tilesheet isn't referenced by the target map, Content Patcher will add it for you (with a z_ ID prefix to avoid conflicts with hardcoded game logic). If the source map has a custom version of a tilesheet that's already referenced, it'll be added as a separate tilesheet only used by your tiles.\n - If you include the tilesheet file in your mod folder, Content Patcher will use that one automatically; otherwise it will be loaded from the game's Content/Maps folder.",
@ -218,73 +267,25 @@
}
},
"required": [ "FromFile", "ToArea" ]
},
"Config": {
"type": "object",
"additionalProperties": {
"type": "object",
"properties": {
"AllowValues": {
"title": "Allowed values",
"description": "The values the player can provide, as a comma-delimited string. If omitted, any value is allowed.\nTip: for a boolean flag, use \"true, false\".",
"type": "string"
},
"AllowBlank": {
"title": "Allow blank",
"description": "Whether the field can be left blank. If false or omitted, blank fields will be replaced with the default value.",
"type": "boolean"
},
"AllowMultiple": {
"title": "Allow multiple values",
"description": "Whether the player can specify multiple comma-delimited values. Default false.",
"type": "boolean"
},
"Default": {
"title": "Default value",
"description": "The default values when the field is missing. Can contain multiple comma-delimited values if AllowMultiple is true. If omitted, blank fields are left blank.",
"type": "string"
}
},
"if": {
"properties": {
"AllowBlank": {
"const": false
}
},
"required": [ "AllowBlank" ]
},
"then": {
"required": [ "Default" ]
}
}
]
}
},
"$schema": {
"title": "Schema",
"description": "The schema this JSON should follow. Useful for JSON validation tools.",
"type": "string",
"format": "uri"
}
},
"definitions": {
"Condition": {
"type": "object",
"additionalProperties": {
"type": "string"
}
},
"DynamicToken": {
"type": "object",
"properties": {
"Name": {
"title": "Name",
"description": "The name of the token to use for tokens & condition.",
"type": "string"
},
"Value": {
"title": "Token value",
"description": "The value(s) to set. This can be a comma-delimited value to give it multiple values. If any block for a token name has multiple values, it will only be usable in conditions. This field supports tokens, including dynamic tokens defined before this entry.",
"type": "string"
},
"When": {
"title": "When",
"description": "Only set the value if the given conditions match. If not specified, always matches.",
"$ref": "#/definitions/Condition"
}
},
"required": [ "Name", "Value" ]
},
"FromFile": {
"title": "Source file",
"description": "The relative file path in your content pack folder to load instead (like assets/dinosaur.png). This can be a .json (data), .png (image), .tbin (map), or .xnb file. This field supports tokens and capitalisation doesn't matter.",
@ -321,39 +322,6 @@
}
}
},
"properties": {
"Format": {
"title": "Format version",
"description": "The format version. You should always use the latest version to use the latest features and avoid obsolete behavior.",
"$ref": "#/definitions/Version"
},
"Changes": {
"title": "Changes",
"description": "The changes you want to make. Each entry is called a patch, and describes a specific action to perform: replace this file, copy this image into the file, etc. You can list any number of patches.",
"type": "array",
"items": {
"$ref": "#/definitions/Change"
}
},
"ConfigSchema": {
"title": "Config schema",
"description": "Defines the config.json format, to support more complex mods.",
"$ref": "#/definitions/Config"
},
"DynamicTokens": {
"title": "Dynamic tokens",
"description": "Custom tokens that you can use.",
"type": "array",
"items": {
"$ref": "#/definitions/DynamicToken"
}
},
"$schema": {
"title": "Schema",
"description": "The schema this JSON should follow. Useful for JSON validation tools.",
"type": "string",
"format": "uri"
}
},
"required": [ "Format", "Changes" ]
}