QtCraft API C++ classes QML types Handbook

QcContentParser Namespace

Turns content-pack JSON documents into definitions. More...

Header: #include <common/content/registry/QcContentParser.h>

Functions

QcResult<QcHandbookChapter> parseHandbookChapter(const QJsonObject &json, const QString &packNamespace)
QcResult<QcTextureDefinition> parseProceduralTexture(const QJsonObject &json, const QString &packNamespace)
QcResult<QHash<QString, QString>> parseTranslations(const QJsonObject &json)
QList<QcTextureDefinition> textureTiles(const QcTextureDefinition &texture)

Detailed Description

Unqualified names get the pack's namespace. All input is untrusted: every field is type-checked and range-checked.

Function Documentation

QcResult<QcHandbookChapter> QcContentParser::parseHandbookChapter(const QJsonObject &json, const QString &packNamespace)

Returns the handbook chapter described by json, with unqualified names in packNamespace, or the first problem found.

QcResult<QcTextureDefinition> QcContentParser::parseProceduralTexture(const QJsonObject &json, const QString &packNamespace)

Returns the procedural texture described by json, with an unqualified name in packNamespace, or the first problem found. Only the fields the texture synthesizer reads are kept.

QcResult<QHash<QString, QString>> QcContentParser::parseTranslations(const QJsonObject &json)

Returns the key-text pairs of the language file json, or an error when a value is no string or the file holds more than QcStreamLimits::maxDefinitions entries.

QList<QcTextureDefinition> QcContentParser::textureTiles(const QcTextureDefinition &texture)

Returns the tiles of texture when it is larger than one block (decision E-791, "tiles": [width, height], 1 to QcPaintingMotif::maxSide each): one texture per block named "<name>_<column>_<row>" with its place as "tile": [column, row]; empty for a texture of one block.