with Ada.Unchecked_Deallocation;
with Allegro.Bitmaps; use Allegro.Bitmaps;
with Ada.Streams; use Ada.Streams;
with Objects; use Objects;
with Values; use Values;
with Values.Associations; use Values.Associations;
private with Ada.Containers.Doubly_Linked_Lists;
private with Ada.Strings.Unbounded;
private with Completions;
private with Locking_Objects;
private with Resources.Archives;
package Tiles is
type Tile_Id_Array is array (Integer range <>) of Natural;
type A_Tile_Id_Array is access all Tile_Id_Array;
function A_Tile_Id_Array_Input( stream : access Root_Stream_Type'Class ) return A_Tile_Id_Array;
for A_Tile_Id_Array'Input use A_Tile_Id_Array_Input;
procedure A_Tile_Id_Array_Output( stream : access Root_Stream_Type'Class; tia : A_Tile_Id_Array );
for A_Tile_Id_Array'Output use A_Tile_Id_Array_Output;
function Copy( src : A_Tile_Id_Array ) return A_Tile_Id_Array;
pragma Postcondition( Copy'Result /= src or else src = null );
procedure Delete is new Ada.Unchecked_Deallocation( Tile_Id_Array, A_Tile_Id_Array );
type Tile_Object is new Object with private;
type A_Tile is access all Tile_Object'Class;
function Create_Tile return A_Tile;
function Get_Attribute( this : access Tile_Object'Class;
name : String ) return Value_Ptr;
function Get_Bitmap( this : access Tile_Object'Class ) return A_Allegro_Bitmap;
function Get_Id( this : not null access Tile_Object'Class ) return Natural;
function Get_Name( this : not null access Tile_Object'Class ) return String;
function Is_Loaded( this : not null access Tile_Object'Class ) return Boolean;
function Object_Input( stream : access Root_Stream_Type'Class ) return Tile_Object;
for Tile_Object'Input use Object_Input;
procedure Object_Output( stream : access Root_Stream_Type'Class; obj : Tile_Object );
for Tile_Object'Output use Object_Output;
procedure Set_Attribute( this : not null access Tile_Object'Class;
name : String;
val : Value_Ptr'Class );
pragma Precondition( name'Length > 0 );
pragma Precondition( Value_Ptr(val) /= Values.Nul );
procedure Set_Id( this : access Tile_Object; id : Natural );
procedure Set_Name( this : access Tile_Object; name : String );
pragma Precondition( name'Length > 0 );
procedure Delete( this : in out A_Tile );
pragma Postcondition( this = null );
ATTRIBUTE_ERROR : exception;
private
use Ada.Strings.Unbounded;
use Completions;
use Locking_Objects;
use Resources.Archives;
type Tile_Object is new Object with
record
id : Natural := 0;
name : Unbounded_String;
attributes : Assoc_Ptr;
lock : A_Locking_Object := null;
bmp : A_Allegro_Bitmap := null;
priority : Integer := 0;
loadState : A_Completion := null;
end record;
procedure Adjust( this : access Tile_Object );
procedure Construct( this : access Tile_Object );
procedure Delete( this : in out Tile_Object );
procedure Load_Bitmap( this : not null access Tile_Object'Class;
archive : not null A_Archive );
procedure Object_Read( stream : access Root_Stream_Type'Class; obj : out Tile_Object );
for Tile_Object'Read use Object_Read;
procedure Object_Write( stream : access Root_Stream_Type'Class; obj : Tile_Object );
for Tile_Object'Write use Object_Write;
function A_Tile_Input( stream : access Root_Stream_Type'Class ) return A_Tile;
for A_Tile'Input use A_Tile_Input;
procedure A_Tile_Output( stream : access Root_Stream_Type'Class; tile : A_Tile );
for A_Tile'Output use A_Tile_Output;
procedure A_Tile_Read( stream : access Root_Stream_Type'Class; tile : out A_Tile );
for A_Tile'Read use A_Tile_Read;
procedure A_Tile_Write( stream : access Root_Stream_Type'Class; tile : A_Tile );
for A_Tile'Write use A_Tile_Write;
package Tile_Lists is new Ada.Containers.Doubly_Linked_Lists( A_Tile, "=" );
use Tile_Lists;
end Tiles;