Skip to content

Resource file format (sad::resource::Tree, supported from 1.3 )

ahiddenseeker edited this page May 21, 2015 · 1 revision

Resource file

A resource file format is a format used to describe list of loaded assets for sad::db::Tree::load command. It can be used to load:

  • A texture files
  • A texture mapped fonts
  • A texture atlases
  • A schema for objects with custom properties (sad::db::custom::Object)

A format description

A resource file is JSON file, which must contain an array of objects. An each object, which describe one resource and file or several resources, stored in one file must have following properties:

  • "type" - a class name for a resource.
  • "filename" - a name of file, where resources are stored. Note, that you must omit file extension for texture mapped fonts to make it automatically deduce, where are configuration and image stored.
  • "name" - a name for resource, must be provided for fonts and textures.

A "type" value could be one of following values:

  • "sad::Texture" for a texture
  • "sad::TextureMappedFont" for a texture mapped font
  • "sad::freetype::Font" for a freetype font
  • "sad::irrklang::Sound" for sound source from irrKlang
  • "sad::resource::TextureAtlasFile" for a texture atlas files (note that you shouldn't use separate entry to specify texture for atlas entries - a file loader will do it for you)
  • "sad::db::custom::SchemaFile" for a file with schema for objects with custom properties.

An example

An example coule be found in $SADDY$/bin/tests/valid.json

[
	{ "type": "sad::Texture",  "filename": "examples/game/objects.bmp", "name" : "objects"},
	{ "type": "sad::TextureMappedFont",  "filename": "examples/game/font", "name": "myfont"},
	{ "type": "sad::freetype::Font",  "filename": "ifaceed/EMPORIUM.TTF", "name": "emporium.ttf"}
]