StampClipboard namespace
Stamps as text in the clipboard of the system, so they can be pasted into another instance of the game.
The text is JSON: {"J2R":1,"w":...,"h":...,"t":[source,index,flags,...]} for tiles (source -1 for a tile left out), followed by "events":[...] and "offgrid":[...] as below for tiles with their events (see TileStamp::{"J2R":1,"events":[x,y,type,flags,generator flags,generator delay,params...],"offgrid":[...]} for events, those off the grid by their offsets in pixels in the same form (older versions read only those on it), and {"J2R":2,"w":...,"h":...,"x":...,"y":...,"layers":[{"o":...,"t":[...]},...],"events":[...]} for several layers with their events. Older versions read the first layer of the last one as tiles, and its events as events. Everything is read without trusting it, a text that isn't whole or is too large isn't a stamp, and events this version doesn't know are left out.
Tiles written with the level they're of have "sets":[name,offset,embedded,...] after them too, the default tile set and the extra ones by their sources. Read into another level, its tiles are found in the tile sets of the same names, in whatever slots it has them, and tiles of tile sets it hasn't, or of one a level has in itself, are left out. A text without them, of an older version, is read as it is.
Functions
- auto WriteTiles(const TileStamp& stamp, const LevelDocument* document = nullptr) -> String
- Returns tiles as text, with the tile sets of
documentthey're of if it's given. - auto ReadTiles(StringView text, TileStamp& stamp, const LevelDocument* document = nullptr) -> bool
- Reads tiles from text, returns
falseif it isn't a stamp, withdocumentthey're found in its tile sets. - auto WriteEvents(const EventStamp& stamp) -> String
- Returns events as text.
- auto ReadEvents(StringView text, EventStamp& stamp) -> bool
- Reads events from text, returns
falseif there are none. - auto WriteLayered(const LayeredStamp& stamp, const LevelDocument* document = nullptr) -> String
- Returns tiles of several layers and events as text, with the tile sets of
documentas WriteTiles(). - auto ReadLayered(StringView text, LayeredStamp& stamp, const LevelDocument* document = nullptr) -> bool
- Reads tiles of several layers and events from text, returns
falseif it isn't such a stamp, see ReadTiles(). - auto HasTile(const LevelDocument& document, const TileRef& tile) -> bool
- Returns whether a level has a tile, a stamp copied from another level can refer to tile sets and animated tiles it hasn't.
- void RemoveUnknownTiles(const LevelDocument& document, TileStamp& stamp)
- Leaves tiles the level doesn't have out of a stamp, as if they weren't copied.
Variables
-
std::
int32_t MaxStampSide constexpr - The longest side of a stamp in tiles, larger ones aren't read, nor picked.
-
std::
int32_t MaxStampTiles constexpr - The most tiles a stamp has, larger ones aren't read, nor picked.