with Events.Corrals; use Events.Corrals;
with Events.Listeners; use Events.Listeners;
with Objects; use Objects;
with Processes; use Processes;
with Widgets; use Widgets;
with Widgets.Containers.Windows; use Widgets.Containers.Windows;
private with Ada.Containers.Indefinite_Hashed_Maps;
private with Ada.Strings.Hash_Case_Insensitive;
private with Ada.Real_Time;
private with Audio_Players;
private with Events;
private with Input_Handlers;
private with Processes.Managers;
private with Renderers;
package Game_Views is
type Game_View is abstract new Limited_Object and Event_Listener and Process with private;
type A_Game_View is access all Game_View'Class;
pragma No_Strict_Aliasing( A_Game_View );
function Create_Game_View( xres, yres : Positive;
scale : Positive ) return A_Game_View;
pragma Postcondition( Create_Game_View'Result /= null );
procedure Attach( this : access Game_View; process : not null A_Process );
procedure Detach( this : access Game_View; process : not null A_Process );
function Get_Corral( this : not null access Game_View'Class ) return A_Corral;
pragma Postcondition( Get_Corral'Result /= null );
function Get_Widget( this : access Game_View; id : String ) return A_Widget;
pragma Postcondition( Get_Widget'Result /= null );
function Get_Window( this : access Game_View ) return A_Window;
procedure Register( this : access Game_View; widget : not null A_Widget );
procedure Set_Window( this : access Game_View; window : in out A_Window );
pragma Postcondition( window = null );
procedure Start( this : access Game_View );
procedure Stop( this : access Game_View );
procedure Unregister( this : access Game_View; id : String );
pragma Precondition( id'Length > 0 );
procedure Delete( this : in out A_Game_View );
pragma Postcondition( this = null );
DUPLICATE_ID,
ID_NOT_FOUND : exception;
private
use Ada.Real_Time;
use Audio_Players;
use Events;
use Input_Handlers;
use Processes.Managers;
use Renderers;
package Widget_Registry is new Ada.Containers.Indefinite_Hashed_Maps(
String, A_Widget, Ada.Strings.Hash_Case_Insensitive, "=", "=" );
use Widget_Registry;
type Game_View is abstract new Limited_Object and Event_Listener and Process with
record
started,
stopped : Boolean := False;
paused : Boolean := False;
win : A_Window := null;
renderer : A_Renderer := null;
audioPlayer : A_Audio_Player := null;
inhandler : A_Input_Handler := null;
pman : A_Process_Manager := null;
corral : A_Corral := null;
widgets : Widget_Registry.Map;
end record;
procedure Construct( this : access Game_View );
procedure Delete( this : in out Game_View );
function Get_Process_Name( this : access Game_View ) return String;
pragma Postcondition( Get_Process_Name'Result'Length > 0 );
procedure Handle_Close_Request( this : access Game_View );
procedure Handle_Event( this : access Game_View;
evt : in out A_Event;
resp : out Response_Type );
pragma Precondition( evt /= null );
procedure Handle_Loading( this : access Game_View; loading : Boolean );
procedure Handle_Paused( this : access Game_View; paused : Boolean );
procedure Tick( this : access Game_View; upTime, dt : Time_Span );
type Allocator is
access function( xres, yres : Positive;
scale : Positive ) return A_Game_View;
procedure Register_Allocator( allocate : not null Allocator );
end Game_Views;