QcWorldLibrary Class
The saved worlds of this installation: one sub-directory per world below root. More...
| Header: | #include <worlds/QcWorldLibrary.h> |
Public Types
Public Functions
| QcResult<QcWorldLibrary::Entry> | create(const QString &name, qint64 seed, const QcWorldLibrary::NewWorld &setup = {}) const |
| QString | directoryOf(const QString &folder) const |
| QList<QcWorldLibrary::Entry> | list() const |
| QcStatus | remove(const QString &folder) const |
| const QString & | root() const |
| QcResult<QString> | worldDirectory(const QString &folder) const |
Static Public Members
| QString | dataRoot() |
| QString | defaultRoot() |
| qint64 | seedFromText(const QString &text) |
Detailed Description
Member Function Documentation
QcResult<QcWorldLibrary::Entry> QcWorldLibrary::create(const QString &name, qint64 seed, const QcWorldLibrary::NewWorld &setup = {}) const
Creates the directory and world.json for a new world called name with seed and setup; returns the new entry. The folder name comes from name (other characters than letters, digits, - and _ replaced), with a number appended when it is taken. The generator's setup runs when the world first opens.
[static] QString QcWorldLibrary::dataRoot()
Returns the base directory for worlds and mods. QTCRAFT_DATA_DIR overrides the platform's application data location (tests, screenshots).
[static] QString QcWorldLibrary::defaultRoot()
Returns <data root>/worlds.
QString QcWorldLibrary::directoryOf(const QString &folder) const
Returns the path of the world directory folder below the root.
QList<QcWorldLibrary::Entry> QcWorldLibrary::list() const
Returns the worlds (directories with a world.json), newest first by last played time, worlds played at the same time by name and folder.
QcStatus QcWorldLibrary::remove(const QString &folder) const
Deletes the world directory folder. Only plain folder names directly below the root are accepted. Returns an error when folder is no plain name, is a link, holds no world.json or cannot be deleted.
const QString &QcWorldLibrary::root() const
Returns the directory that holds the worlds.
[static] qint64 QcWorldLibrary::seedFromText(const QString &text)
Returns the seed of a new world from the menu's text: a number as it is, any other text hashed (FNV-1a, stable across runs and platforms, unlike qHash). The map preview takes the same seed.
QcResult<QString> QcWorldLibrary::worldDirectory(const QString &folder) const
Returns the path of the world directory folder, or an error when folder is no plain folder name directly below the root, is a link or holds no world.json. remove() and whoever opens a world's folder check a folder from outside with it.