QtCraft API C++ classes QML types Handbook

QcWorldOptions Namespace

The values of the world generation options of one world (decision E-917): world.json keeps them as {"<option>": number or true/false} in "generator"/"worldOptions", written in full when the world is created, so that later changes of the content's defaults do not change it. More...

Header: #include <worldgen/generators/QcWorldOptions.h>

Classes

struct Applied
struct Option

Variables

const qsizetype maxValues

Functions

QcWorldOptions::Applied apply(std::shared_ptr<const QcContentRegistry> content, const QString &type, const QJsonObject &values)
QStringList check(const QcContentRegistry &content)
QJsonObject defaults(const QcContentRegistry &content)
QList<QcWorldOptions::Option> optionsOf(const QcContentRegistry &content)
QcResult<QJsonObject> parseText(const QString &text, const QcContentRegistry &content)
QString presetOf(const QJsonObject &values, const QcContentRegistry &content)
QcResult<QJsonObject> presetValues(const QString &name, const QcContentRegistry &content)
bool takesOptions(const QString &type)
QcResult<QJsonObject> valuesToStore(const QString &type, const QJsonObject &given, const QcContentRegistry &content)

Detailed Description

A world without them (made before the options, or of a type without options) generates with the content's values alone. The menu (QcWorldOptionsController), qtcraft-headless (–world-options) and a later map preview read the options through here; the generator and the server get a copy of the content with the values set (apply).

Classes

class Applied

The result of apply: the content to generate and serve the world with, and what was ignored. More...

class Option

A usable option of the content: its definition, its target and its default. More...

Variable Documentation

const qsizetype QcWorldOptions::maxValues

At most this many values per world.

Function Documentation

QcWorldOptions::Applied QcWorldOptions::apply(std::shared_ptr<const QcContentRegistry> content, const QString &type, const QJsonObject &values)

Returns a copy of content with values, the values of a world of type, set; the same content when there are none or the type takes no options.

QStringList QcWorldOptions::check(const QcContentRegistry &content)

Returns one warning per option or preset value of content that does not fit (checked with the mods, QcModLoader).

QJsonObject QcWorldOptions::defaults(const QcContentRegistry &content)

Returns every usable option of content at its default.

QList<QcWorldOptions::Option> QcWorldOptions::optionsOf(const QcContentRegistry &content)

Returns the options of content whose target, subject, group, range and default fit, in content order.

QcResult<QJsonObject> QcWorldOptions::parseText(const QString &text, const QcContentRegistry &content)

Returns the values text names, options of content as written on a command line: "preset=more_villages,village_spacing=256,caves=off" (names without namespace are the base game's; switches on/off or true/false). Only the values named, a preset's included; valuesToStore fills in the rest. Presets apply first, in the order given, then the single values, so "village_chance=0.5,preset=more_villages" keeps 0.5.

QString QcWorldOptions::presetOf(const QJsonObject &values, const QcContentRegistry &content)

Returns the name of the preset of content whose values are exactly values; empty when there is none.

QcResult<QJsonObject> QcWorldOptions::presetValues(const QString &name, const QcContentRegistry &content)

Returns the values of the preset name (qualified, or of the base game) over the defaults, both of content; values that do not fit are left out.

bool QcWorldOptions::takesOptions(const QString &type)

Returns whether worlds of the generator type type take options (terrain worlds).

QcResult<QJsonObject> QcWorldOptions::valuesToStore(const QString &type, const QJsonObject &given, const QcContentRegistry &content)

Returns the values a new world of type stores: given over the defaults of content; an unknown option or a value of the wrong type or outside its range is refused. Worlds of other types store none.