Index

Package: Libraries

Description

package Tiles.Libraries is
Copyright (c) 2012 Kevin Wellwood All rights reserved. This source code is distributed under the Modified BSD License. For terms and conditions, see license.txt.

Classes

Tile_Library

type Tile_Library is new Limited_Object with private;

Ancestors:

Primitive operations:

Delete (overriding Objects.Delete)
Objects.Construct (Inherited)
Objects.To_String (Inherited)
A Tile_Library is an organized container for images refered to as Tiles. Not all images in the library have the same dimensions or file format. A library is stored as a .zip archive containing a number of image files and a catalog file describing the order and attributes of the tiles. For performance reasons, tile libraries are reference counted and cached in memory. The library can be loaded in stages, first including just the tile attributes information, and then later the tile bitmaps as well. If the application uses a GUI, the tiles' bitmaps will automatically be cached to atlas bitmaps (sprite sheets) to improve drawing performance when drawing many bitmaps from the same library consecutively.

Types

A_Tile_Library

type A_Tile_Library is access all Tile_Library'Class;

Subprograms & Entries

Get_Id

function Get_Id
( this: not null access Tile_Library'Class;
name: String ) return Natural;
Finds the id of the first tile matching 'name' in the library. If 'name' does not include a file extension, a matching .png file will be searched first, then a matching .bmp file. Zero will be returned if no tile matching 'name' can be found.

Get_Name

function Get_Name
( this: not null access Tile_Library'Class ) return String;
Returns the name of the tile library.

Get_Matrix

function Get_Matrix
( this: not null access Tile_Library'Class;
index: Natural ) return A_Tile_Matrix;
Returns a reference to a tile matrix by index. Do not modify the matrix, it belongs to the library!

Get_Matrix_Count

function Get_Matrix_Count
( this: not null access Tile_Library'Class ) return Natural;
Returns the number of matrices in the library.

Get_Tile

function Get_Tile
( this: not null access Tile_Library'Class;
id: Natural ) return A_Tile;
Returns a reference to a tile by id, or 'null' if 'id' doesn't exist. Do not modify the tile, it belongs to the library.

Is_Loaded

function Is_Loaded
( this: not null access Tile_Library'Class ) return Boolean;
Returns True if the tile library has been loaded completely.

Iterate_By_Id

procedure Iterate_By_Id
( this: not null access Tile_Library'Class;
examine: not null access procedure( tile : not null A_Tile ) );
Iterates across all unique tiles in the tile library, in order of ascending ids.

Iterate_By_Slot

procedure Iterate_By_Slot
( this: not null access Tile_Library'Class;
examine: not null access procedure( slot : Positive;
tile: A_Tile ) );
Iterates across all slots in the tile library, beginning at 1. Not every slot in the library contains a tile, so the 'tile' argument of 'examine' may be null.

Load_Bitmaps

procedure Load_Bitmaps
( this: not null access Tile_Library'Class );
Loads the library's bitmaps from its archive file, if the library was loaded from an archive. This procedure will not return until all the bitmaps have been loaded. If the library's bitmaps have already been loaded, or the library was built in memory and not loaded from an archive, it will return immediately. If another thread is loading the bitmaps, the caller will be blocked until loading is complete.