private with Drawing_Contexts;
private with Games;
private with Processes;
private with Processes.Managers;
package Applications.Gui.Games is
-- An abstract application class that runs an event-based game.
type Game_Application is abstract new Gui_Application with private;
type A_Game_Application is access all Game_Application'Class;
-- Stops the running game. This will cause the thread that called Run to
-- return. The value of 'errorCode' determines the value of 'returnCode'
-- that will be returned from Run.
procedure Stop( this : not null access Game_Application'Class;
errorCode : Integer := NO_ERROR );
----------------------------------------------------------------------------
-- Forces the application to shut down, displaying the given error message.
-- If no Application has been created, then the system level shutdown
-- procedure will be called. This is only to be used in the case of a fatal
-- error. Execution will return from this procedure, so plan accordingly.
procedure Terminate_Application( error : String );
private
use Drawing_Contexts;
use Processes;
use Processes.Managers;
use Standard.Games;
type Game_Application is abstract new Gui_Application with
record
-- the following fields are protected by .lock
errorCode : Integer := NO_ERROR; -- return code for the OS
game : A_Game := null; -- game logic implementation
pman : A_Process_Manager := null; -- for application-level processes
end record;
-- Closes the application and releases all resources. Do not call this if
-- the application didn't successfully initialize. This should be called
-- last by an overriding implementation.
procedure Close( this : access Game_Application );
-- Override to draw the loading screen displayed while the game is
-- initializing. This is the only place where drawing can be done before the
-- renderer is created by the game view. If this procedure is left null, the
-- window will be solid black until the gui is started.
procedure Draw_Loading_Screen( this : access Game_Application;
dc : Drawing_Context ) is null;
-- Initializes the application and game subsystems. The application will
-- will open in 640x400 windowed mode by default. This setting can be
-- overridden by the application's configuration. To specify the default
-- window parameters, call Init(4) instead. Returns True on success. If
-- initialization fails, Close will be called automatically to clean up. No
-- exceptions will be raised. This should be called first by an overriding
-- implementation.
function Init( this : access Game_Application ) return Boolean;
-- Initializes the application and game subsystems. Returns True on success.
-- If initialization fails, Close will be called automatically to clean up.
-- No exceptions will be raised. This should be called first by an
-- overriding implementation.
function Init( this : access Game_Application;
app_xres,
app_yres : Natural;
app_scale : Positive;
app_windowed : Boolean ) return Boolean;
function Run( this : access Game_Application ) return Integer;
end Applications.Gui.Games;