1. private with Drawing_Contexts; 
  2. private with Games; 
  3. private with Processes; 
  4. private with Processes.Managers; 
  5.  
  6. package Applications.Gui.Games is 
  7.  
  8.     -- An abstract application class that runs an event-based game. 
  9.     type Game_Application is abstract new Gui_Application with private; 
  10.     type A_Game_Application is access all Game_Application'Class; 
  11.  
  12.     -- Stops the running game. This will cause the thread that called Run to 
  13.     -- return. The value of 'errorCode' determines the value of 'returnCode' 
  14.     -- that will be returned from Run. 
  15.     procedure Stop( this      : not null access Game_Application'Class; 
  16.                     errorCode : Integer := NO_ERROR ); 
  17.  
  18.     ---------------------------------------------------------------------------- 
  19.  
  20.     -- Forces the application to shut down, displaying the given error message. 
  21.     -- If no Application has been created, then the system level shutdown 
  22.     -- procedure will be called. This is only to be used in the case of a fatal 
  23.     -- error. Execution will return from this procedure, so plan accordingly. 
  24.     procedure Terminate_Application( error : String ); 
  25.  
  26. private 
  27.  
  28.     use Drawing_Contexts; 
  29.     use Processes; 
  30.     use Processes.Managers; 
  31.     use Standard.Games; 
  32.  
  33.     type Game_Application is abstract new Gui_Application with 
  34.         record 
  35.             -- the following fields are protected by .lock 
  36.             errorCode : Integer := NO_ERROR;         -- return code for the OS 
  37.             game      : A_Game := null;              -- game logic implementation 
  38.             pman      : A_Process_Manager := null;   -- for application-level processes 
  39.         end record; 
  40.  
  41.     -- Closes the application and releases all resources. Do not call this if 
  42.     -- the application didn't successfully initialize. This should be called 
  43.     -- last by an overriding implementation. 
  44.     procedure Close( this : access Game_Application ); 
  45.  
  46.     -- Override to draw the loading screen displayed while the game is 
  47.     -- initializing. This is the only place where drawing can be done before the 
  48.     -- renderer is created by the game view. If this procedure is left null, the 
  49.     -- window will be solid black until the gui is started. 
  50.     procedure Draw_Loading_Screen( this : access Game_Application; 
  51.                                    dc   : Drawing_Context ) is null; 
  52.  
  53.     -- Initializes the application and game subsystems. The application will 
  54.     -- will open in 640x400 windowed mode by default. This setting can be 
  55.     -- overridden by the application's configuration. To specify the default 
  56.     -- window parameters, call Init(4) instead. Returns True on success. If 
  57.     -- initialization fails, Close will be called automatically to clean up. No 
  58.     -- exceptions will be raised. This should be called first by an overriding 
  59.     -- implementation. 
  60.     function Init( this : access Game_Application ) return Boolean; 
  61.  
  62.     -- Initializes the application and game subsystems. Returns True on success. 
  63.     -- If initialization fails, Close will be called automatically to clean up. 
  64.     -- No exceptions will be raised. This should be called first by an 
  65.     -- overriding implementation. 
  66.     function Init( this         : access Game_Application; 
  67.                    app_xres, 
  68.                    app_yres     : Natural; 
  69.                    app_scale    : Positive; 
  70.                    app_windowed : Boolean ) return Boolean; 
  71.  
  72.     function Run( this : access Game_Application ) return Integer; 
  73.  
  74. end Applications.Gui.Games;