MapFormat

Serializes/deserializes XMF map data in SDLang format. Each layer can contain objects (eg. for marking events, clipping, or sprites if applicable), tilemapping (not for SpriteLayers), embedded data such as tilemapping or scripts, and so on.

Also does some basic resource managing.

Note on layer tags: As of this version, additional tags within layers must have individual names. Subtags within a parent also need to have individual names. Namespaces are reserved for internal use (eg. file sources, objects).

class MapFormat {}

Constructors

this
this(string name, int resX, int resY)

Creates new instance from scratch.

this
this(F file)

Serializes itself from file.

Members

Functions

addEmbeddedMapData
void addEmbeddedMapData(int pri, ubyte[] base64Code)

Adds an embedded MapData to a TileLayer.

addEmbeddedMapData
void addEmbeddedMapData(int pri, MappingElement[] me)

Adds an embedded MapData to a TileLayer.

addEmbeddedPalette
Tag addEmbeddedPalette(Color[] c, string name, int offset)

Adds an embedded palette to the document.

addMapDataFile
void addMapDataFile(int pri, string filename, string dataPakSrc)

Adds a TileData file to a TileLayer. Filename should contain relative path.

addNewLayer
void addNewLayer(int pri, Tag t, Layer l)

Adds a layer from preexsting tag.

addNewTileLayer
void addNewTileLayer(int pri, int tX, int tY, int mX, int mY, string name, TileLayer l)

Adds a newly created TileLayer to the document.

addObjectToLayer
Tag addObjectToLayer(int layer, Tag t)

Adds an object to a layer. Intended for editor use.

addPaletteFile
Tag addPaletteFile(string filename, string dataPakSrc, int offset, int palShift)

Adds a palette file source to the document.

addPropertyTagToLayer
void addPropertyTagToLayer(int pri, string name, string parent, T args)

Adds a new property tag to a layer's tag. Note: Property tag must be first created by addTagToLayer.

addTagToLayer
void addTagToLayer(int pri, string name, T args)

Adds a new tag to a layer.

addTile
void addTile(int pri, TileInfo item, string source, string dpkSource)

Adds a single TileInfo to a preexisting chunk on the layer.

addTile
void addTile(int pri, Tag t, string source, string dpkSource)

Ditto, but from preexiting Tag.

addTileInfo
void addTileInfo(int pri, TileInfo[] list, string source, string dpkSource)

Adds TileInfo to a TileLayer from an array. Joins together multiple chunks with the same source identifier. (should be a path)

addTileInfo
void addTileInfo(int pri, Tag t, string source, string dpkSource)

Adds TileInfo to a TileLayer from a preexiting tag. Joins together multiple chunks with the same source identifier. (should be a path)

addTileSourceFile
void addTileSourceFile(int pri, string filename, string dataPakSrc, int palShift)

Adds a tile source file (file that contains the tiles) to a TileLayer.

alterTileLayerInfo
void alterTileLayerInfo(int layerNum, int dataNum, T value)

Alters a tile layer data.

editLayerPropertyTagValues
Value[] editLayerPropertyTagValues(int pri, string name, string parent, T args)

Edits the values of a layer's property tag.

editLayerTagValues
Value[] editLayerTagValues(int pri, string name, T args)

Edits the values of a layer's tag.

getAllTileSources
Tag[] getAllTileSources(int pri)

Returns all tile sources for a given layer. Intended to use with a loader.

getHorizontalResolution
int getHorizontalResolution()

Returns the horizontal resolution.

getLayerInfo
LayerInfo[] getLayerInfo()

Returns all layer's basic information.

getLayerInfo
LayerInfo getLayerInfo(int pri)

Returns a specified layer's basic information.

getLayerObjects
MapObject[] getLayerObjects(int layerID)

Returns all objects belonging to a layerID in an array.

getLayerPropertyTagValues
Value[] getLayerPropertyTagValues(int pri, string name, string parent)

Gets the values of a layer's property tag.

getLayerRootTagValues
Value[] getLayerRootTagValues(int pri)

Gets the values of a layer's root tag.

getLayerTagValues
Value[] getLayerTagValues(int pri, string name)

Gets the values of a layer's tag.

getMetadata
T getMetadata(string name)

Returns the given metadata.

getName
string getName()

Returns the name of the map from metadata.

getTileInfo
TileInfo[] getTileInfo(int pri)

Returns a selected tile layer's all tile's basic information. Mainly used to display information in editors.

getTileSourceTag
Tag getTileSourceTag(int pri, string filename, string dataPakSrc)

Accesses tile source tags in documents for adding extra data (eg. tile names).

getVerticalResolution
int getVerticalResolution()

Returns the vertical resolution.

isPaletteFileExists
bool isPaletteFileExists(string filename, string dataPakSrc)

Returns whether the given palette file source exists.

loadAllSpritesAndObjects
void loadAllSpritesAndObjects(PaletteContainer paletteTarget, ObjectCollisionDetector ocd)

Loads all sprites and objects to thir respective layers and the supplied ObjectCollisionDetector.

loadMappingData
void loadMappingData()

Loads mapping data from disk to all layers.

loadSprites
ABitmap[int] loadSprites(int layerID, PaletteContainer paletteTarget)

Loads the sprites associated with the layer ID.

loadTiles
void loadTiles(PaletteContainer paletteTarget)

Loads tiles from disk to all layers. Also loads the palette. TODO: Add dpk support

opIndex
Layer opIndex(int index)

Returns the requested layer.

pullMapDataFromLayer
void pullMapDataFromLayer(int pri)

Pulls TileLayer data from the layer, and stores it in the preconfigured location.

removeEmbeddedMapData
Tag removeEmbeddedMapData(int pri)

Removes embedded TileData from a TileLayer.

removeLayer
Tag removeLayer(int pri)

Removes a given layer of any kind.

removeLayerTagValues
Tag removeLayerTagValues(int pri, string name)

Removes a layer's tag.

removeMapDataFile
Tag removeMapDataFile(int pri)

Removes a TileData file from a TileLayer.

removeObjectFromLayer
Tag removeObjectFromLayer(int layer, int objID)

Removes an object from a layer. Intended for editor use.

removeTile
Tag removeTile(int pri, int id, string source, string dpkSource)

Removes a single tile from a TileInfo chunk.

removeTileSourceFile
Tag removeTileSourceFile(int pri, string filename, string dataPakSrc)

Removes a tile source.

renameTile
string renameTile(int pri, int id, string newName)

Renames a single tile.

save
void save(string path)

Saves the document to disc.

Static variables

renderingModeLookup
RenderingMode[string] renderingModeLookup;

Associative array used for rendering mode lookups in one way.

Variables

layerData
TreeMap!(int, Tag) layerData;

Layerdata stored as SDLang tags.

layeroutput
TreeMap!(int, Layer) layeroutput;

Used to fast map and object data pullback in editors

metadata
Tag metadata;

Stores metadata.

root
Tag root;

Root tag for common information.

tileDataFromExt
TileInfo[][int] tileDataFromExt;

Stores basic TileData that are loaded through extensions

Meta