1. -- 
  2. -- Copyright (c) 2012 Kevin Wellwood 
  3. -- All rights reserved. 
  4. -- 
  5. -- This source code is distributed under the Modified BSD License. For terms and 
  6. -- conditions, see license.txt. 
  7. -- 
  8.  
  9. private with Ada.Real_Time; 
  10. private with Ada.Strings.Unbounded; 
  11. --private with Entities; 
  12.  
  13. package Game_Views.Keen is 
  14.  
  15.     type Keen_View is new Game_View with private; 
  16.     type A_Keen_View is access all Keen_View'Class; 
  17.  
  18.     procedure New_Game( this : not null access Keen_View'Class ); 
  19.  
  20.     -- Quits the game, closing the application. Make sure game session data is 
  21.     -- saved before this point, if it needs to be saved. 
  22.     procedure Quit( this : not null access Keen_View'Class ); 
  23.  
  24. private 
  25.  
  26.     use Ada.Real_Time; 
  27.     use Ada.Strings.Unbounded; 
  28.  
  29.     type Keen_View is new Game_View with 
  30.         record 
  31.             -- true if a game is currently in-session 
  32.             gameInProgress : Boolean := False; 
  33.  
  34.             -- paused automatically by the gui. this indicates that the gui 
  35.             -- should resume the game because the pause command was not given by 
  36.             -- the user. (ex: auto pause when showing progress board or entering 
  37.             -- the menu) 
  38.             autoPaused : Boolean := False; 
  39.  
  40.             -- player can pause/resume the game. the gui may lock the pause 
  41.             -- feature temporarily so the user can't directly pause/resume. 
  42.             pauseEnabled : Boolean := True; 
  43.  
  44.             -- true when loading is in progress. this occurs between levels. 
  45.             loading : Boolean := False; 
  46.  
  47.             -- loading screen is being displayed. 
  48.             loadingScreen : Boolean := False; 
  49.  
  50.             -- time when the loading screen is to be hidden, if loading has 
  51.             -- finished. if this equals Time_First, loading has not begun. 
  52.             loadingScreenComplete : Time := Time_First; 
  53.  
  54.             -- the name of the music for the current world. this is set when the 
  55.             -- 'music' world property changes and played when the world loading 
  56.             -- dialog is closed. 
  57.             worldMusic : Unbounded_String; 
  58.         end record; 
  59.  
  60.     procedure Construct( this : access Keen_View ); 
  61.  
  62.     -- Pauses the game automatically if it isn't already paused, or unpauses the 
  63.     -- game if it was paused automatically and not by the player. 
  64.     procedure Auto_Pause( this  : not null access Keen_View'Class; 
  65.                           pause : Boolean ); 
  66.  
  67.     procedure Handle_Close_Request( this : access Keen_View ); 
  68.  
  69.     -- Inherited from the Event_Listener interface. Handles events that the view 
  70.     -- is registered to receive. 
  71.     procedure Handle_Event( this : access Keen_View; 
  72.                             evt  : in out A_Event; 
  73.                             resp : out Response_Type ); 
  74.     pragma Precondition( evt /= null ); 
  75.  
  76.     -- This is called when the application starts and stops loading resources. 
  77.     procedure Handle_Loading( this : access Keen_View; loading : Boolean ); 
  78.  
  79.     -- This is called when the paused state of the Game changes. 
  80.     procedure Handle_Paused( this : access Keen_View; paused : Boolean ); 
  81.  
  82.     -- Returns True if gameplay is paused. 
  83.     function Is_Paused( this : not null access Keen_View'Class ) return Boolean; 
  84.  
  85.     -- Queues an event to pause or resume the game. The user must be allowed to 
  86.     -- pause or resume the game or else 'force' must be set to True. Note that 
  87.     -- the paused state of the game remains unchanged until Handle_Paused is 
  88.     -- called. 
  89.     procedure Pause_Game( this  : not null access Keen_View'Class; 
  90.                           pause : Boolean; 
  91.                           force : Boolean := False ); 
  92.  
  93.     -- This is called to start the view and attach it to the application 
  94.     -- framework on startup. 
  95.     procedure Start_View( this : access Keen_View ); 
  96.  
  97.     -- This is called to stop the view and detach it from the application 
  98.     -- framework on shutdown. 
  99.     procedure Stop_View( this : access Keen_View ); 
  100.  
  101.     -- Inherited from the Process interface. This will be called regularly after 
  102.     -- the view is started. 
  103.     procedure Tick( this : access Keen_View; time : Tick_Time ); 
  104.  
  105. end Game_Views.Keen;