QtCraft API C++ classes QML types Handbook

QcVillageParser Namespace

Parses village styles (villages/*.json) and the village settings (worldgen/villages.json), decision E-403. More...

Header: #include <common/content/villages/QcVillageParser.h>

Functions

QcResult<QcVillageStyleDefinition> extendVillageStyle(const QJsonObject &json, const QString &packNamespace, const QcVillageStyleDefinition &base)
QcResult<QString> extendedStyle(const QJsonObject &json, const QString &packNamespace)
QcResult<QcVillageSettings> parseVillageSettings(const QJsonObject &json, const QString &packNamespace)
QcResult<QcVillageSettings> parseVillageSettings(const QJsonObject &json, const QString &packNamespace, QcVillageSettings settings)
QcResult<QcVillageStyleDefinition> parseVillageStyle(const QJsonObject &json, const QString &packNamespace)

Detailed Description

A style with "extends" (decision E-421) starts from the style it names: without its own "name" it patches that style, with one it is a new style (without the base's biomes and fallback unless it gives them). It replaces the base's fields it gives, takes the biomes of its "remove" object and appends the lists of its "add" object (biomes, crops, pieces, layouts).

Function Documentation

QcResult<QcVillageStyleDefinition> QcVillageParser::extendVillageStyle(const QJsonObject &json, const QString &packNamespace, const QcVillageStyleDefinition &base)

Returns the style json makes of base, names qualified with packNamespace, or the first error: base patched when json has no other "name", else a new style (see above).

QcResult<QString> QcVillageParser::extendedStyle(const QJsonObject &json, const QString &packNamespace)

Returns the style that json extends, qualified with packNamespace; an error when "extends" is no valid name.

QcResult<QcVillageSettings> QcVillageParser::parseVillageSettings(const QJsonObject &json, const QString &packNamespace)

Returns the village settings defined by json over the defaults, names qualified with packNamespace, or the first error.

QcResult<QcVillageSettings> QcVillageParser::parseVillageSettings(const QJsonObject &json, const QString &packNamespace, QcVillageSettings settings)

Returns the settings of a later pack (json, names qualified with packNamespace) read over settings (the earlier packs'): the fields it gives replace theirs, golem field by field (decision E-421).

QcResult<QcVillageStyleDefinition> QcVillageParser::parseVillageStyle(const QJsonObject &json, const QString &packNamespace)

Returns the village style defined by json, names qualified with packNamespace, or the first error; a file with "extends" is an error here (extendVillageStyle() reads it).