RulesFile class
#include <Jazz2/Editor/Smart/RulesFile.h>
The rules of a tile set, Tilesets/<name>.rules.
A JSON object of parts the editor keeps for a tile set — prefabs (see TilePrefab) and terrain rules (see TerrainRules). It's looked for as tile sets are, the user content first, and saved into the user content. Each part is changed on its own, the others are kept as they are. A file that is there but can't be read (a syntax error, say) is never written over, it would lose all of its parts, and the previous file is kept as .rules.bak whenever one is written over.
Public types
-
enum class ReadResult : std::
uint8_t { Missing, Ok, Unreadable } - What reading the rules of a tile set found.
Public static functions
- static auto TryRead(StringView tileSet, Json::Value& doc) -> ReadResult
- Reads the rules of a tile set, an empty object if it has none or they can't be read.
- static auto Read(StringView tileSet, Json::Value& doc) -> bool
- Reads the rules of a tile set, an empty object if it has none or they can't be read, returns
falsethen. - static auto Write(StringView tileSet, const Json::Value& doc) -> bool
- Writes the rules of a tile set into the user content.
- static auto Stage(StringView tileSet, const Json::Value& doc, String& path) -> bool
- Writes the rules of a tile set only into the temporary file of
path, see Utils::AtomicFile:: Stage(). - static auto GetWritablePath(StringView tileSet, bool create) -> String
- Returns the path the rules of a tile set are saved to, in the user content, empty if there's none.
Constructors, destructors, conversion operators
- RulesFile() deleted
Enum documentation
enum class Jazz2:: Editor:: RulesFile:: ReadResult : std:: uint8_t
What reading the rules of a tile set found.
| Enumerators | |
|---|---|
| Missing |
The tile set has no rules, an empty object |
| Ok |
The rules were read |
| Unreadable |
There is a file but it can't be read or isn't a JSON object, an empty object, it must not be written over |
Function documentation
static bool Jazz2:: Editor:: RulesFile:: Write(StringView tileSet,
const Json::Value& doc)
Writes the rules of a tile set into the user content.
Returns false without writing anything if the rules that are there can't be read, see ReadResult::
static bool Jazz2:: Editor:: RulesFile:: Stage(StringView tileSet,
const Json::Value& doc,
String& path)
Writes the rules of a tile set only into the temporary file of path, see Utils::
For rules that change together with other files, they're committed or discarded with them. Returns false as Write() does, or if the file couldn't be written.