with Entities; use Entities;
with Events.Listeners; use Events.Listeners;
private with Ada.Containers.Ordered_Maps;
private with Ada.Containers.Ordered_Sets;
private with Events;
private with Events.Entities;
private with Events.World;
private with Interfaces;
private with Maps;
private with Tiles.Libraries;
private with Widgets.Sprites;
package Widgets.Containers.Scenes is
type Scene is abstract new Container and Event_Listener with private;
type A_Scene is access all Scene'Class;
procedure Draw_Layer( this : access Scene;
dc : Drawing_Context;
layer : Positive;
startX,
startY : Integer;
tileX1,
tileY1,
tileX2,
tileY2 : Integer
) is abstract;
function Get_Height_Tiles( this : not null access Scene'Class ) return Natural;
function Get_Width_Tiles( this : not null access Scene'Class ) return Natural;
procedure Scroll( this : not null access Scene'Class; x, y : Float );
procedure Set_Selection( this : access Scene; child : A_Widget );
procedure Set_Target( this : access Scene; target : Entity_Id );
procedure Unselect( this : access Scene; child : not null A_Widget );
private
use Events;
use Events.Entities;
use Events.World;
use Interfaces;
use Maps;
use Tiles.Libraries;
use Widgets.Sprites;
package Sprite_Maps is new Ada.Containers.Ordered_Maps( Entity_Id, A_Sprite, "<", "=" );
use Sprite_Maps;
package Widget_Sets is new Ada.Containers.Ordered_Sets( A_Widget, Lt, "=" );
use Widget_Sets;
type Boolean_Array is array (Natural range <>) of Boolean;
type A_Boolean_Array is access all Boolean_Array;
type Byte_Array is array (Natural range <>) of Unsigned_8;
type A_Byte_Array is access all Byte_Array;
type Cached_Bitmap is
record
tileId : Natural := 0;
bmp : A_Bitmap := null;
end record;
type Cached_Bitmap_Array is array (Natural range <>) of Cached_Bitmap;
type A_Cached_Bitmap_Array is access all Cached_Bitmap_Array;
type Bitmap_Cache is array (Natural range <>) of A_Cached_Bitmap_Array;
type A_Bitmap_Cache is access all Bitmap_Cache;
type Scene is abstract new Container and Event_Listener with
record
hasData : Boolean := False;
mapWidth,
mapHeight : Natural := 0;
mapLayers : A_Layer_Array := null;
bitmapCache : A_Bitmap_Cache := null;
visibleLayers : A_Boolean_Array := null;
lightLevels : A_Byte_Array := null;
spriteLayer : Integer := Integer'Last;
tileWidth : Positive := 1;
tileLib : A_Tile_Library := null;
target : Entity_Id := INVALID_ID;
wFocusX,
wFocusY : Float := 0.0;
wSlackX,
wSlackY : Float := 0.0;
spriteMap : Sprite_Maps.Map;
selectedSet : Widget_Sets.Set;
waitForLoad : Boolean := False;
end record;
procedure Add( this : access Scene;
child : in out A_Widget;
consume : Boolean := True );
pragma Postcondition( consume xor child /= null );
procedure Clear_Selection( this : access Scene );
procedure Construct( this : access Scene;
view : not null access Game_Views.Game_View'Class;
id : String );
pragma Precondition( id'Length > 0 );
procedure Delete( this : in out Scene );
procedure Delete_Children( this : access Scene );
procedure Draw_Content( this : access Scene; dc : Drawing_Context );
procedure Draw_Layer_Overlay( this : access Scene;
dc : Drawing_Context;
startX,
startY : Integer;
tileX1,
tileY1,
tileX2,
tileY2 : Integer );
function Find_Sprite( this : not null access Scene'Class;
id : Entity_Id ) return A_Sprite;
procedure Focus_On( this : not null access Scene'Class;
x, y : Float;
centered : Boolean := False );
function Get_Min_Height( this : access Scene ) return Natural;
function Get_Min_Width( this : access Scene ) return Natural;
procedure Handle_Entity_Attribute_Changed( this : access Scene;
evt : not null A_Entity_Attribute_Changed_Event );
procedure Handle_Entity_Created( this : access Scene;
evt : not null A_Entity_Created_Event );
procedure Handle_Entity_Deleted( this : access Scene;
evt : not null A_Entity_Deleted_Event );
procedure Handle_Entity_Moved( this : access Scene;
evt : not null A_Entity_Moved_Event );
procedure Handle_Entity_Resized( this : access Scene;
evt : not null A_Entity_Resized_Event );
procedure Handle_Event( this : access Scene;
evt : in out A_Event;
resp : out Response_Type );
pragma Precondition( evt /= null );
procedure Handle_Frame_Changed( this : access Scene;
evt : not null A_Frame_Changed_Event );
procedure Handle_New_World( this : access Scene;
evt : not null A_New_World_Event );
procedure Handle_Tile_Changed( this : access Scene;
evt : not null A_Tile_Changed_Event );
procedure Handle_World_Property_Changed( this : access Scene;
evt : not null A_World_Property_Changed_Event );
function Is_Tile_Visible( this : not null access Scene'Class;
layer : Positive;
x, y : Integer ) return Boolean;
procedure Remove( this : access Scene; child : not null A_Widget );
procedure Delete( ba : in out A_Boolean_Array );
procedure Delete( ba : in out A_Byte_Array );
procedure Delete( bc : in out A_Bitmap_Cache );
end Widgets.Containers.Scenes;