1. with Events; 
  2. with Values;                            use Values; 
  3.  
  4. pragma Elaborate_All( Events ); 
  5.  
  6. package Events.Game is 
  7.  
  8.     type End_Game_Event is new Event with private; 
  9.     type A_End_Game_Event is access all End_Game_Event'Class; 
  10.  
  11.     END_GAME_ID : constant Event_Id := To_Event_Id( "End_Game" ); 
  12.  
  13.     ---------------------------------------------------------------------------- 
  14.  
  15.     type Game_Paused_Event is new Event with private; 
  16.     type A_Game_Paused_Event is access all Game_Paused_Event'Class; 
  17.  
  18.     GAME_PAUSED_ID : constant Event_Id := To_Event_Id( "Game_Paused" ); 
  19.  
  20.     function Is_Paused( this : not null access Game_Paused_Event'Class ) return Boolean; 
  21.  
  22.     ---------------------------------------------------------------------------- 
  23.  
  24.     type Game_State_Event is new Event with private; 
  25.     type A_Game_State_Event is access all Game_State_Event'Class; 
  26.  
  27.     GAME_STATE_ID : constant Event_Id := To_Event_Id( "Game_State" ); 
  28.  
  29.     function Is_Playing( this : not null access Game_State_Event'Class ) return Boolean; 
  30.  
  31.     ---------------------------------------------------------------------------- 
  32.  
  33.     type Game_Var_Changed_Event is new Event with private; 
  34.     type A_Game_Var_Changed_Event is access all Game_Var_Changed_Event'Class; 
  35.  
  36.     GAME_VAR_CHANGED_ID : constant Event_Id := To_Event_Id( "Game_Var_Changed" ); 
  37.  
  38.     function Get_Var( this : not null access Game_Var_Changed_Event'Class ) return String; 
  39.  
  40.     procedure Copy_Value( this : access Game_Var_Changed_Event; 
  41.                           val  : in out A_Value ); 
  42.     pragma Precondition( val = null ); 
  43.  
  44.     ---------------------------------------------------------------------------- 
  45.  
  46.     type Loading_Event is new Event with private; 
  47.     type A_Loading_Event is access all Loading_Event'Class; 
  48.  
  49.     LOADING_ID : constant Event_Id := To_Event_Id( "Loading" ); 
  50.  
  51.     function Is_Loading( this : not null access Loading_Event'Class ) return Boolean; 
  52.  
  53.     ---------------------------------------------------------------------------- 
  54.  
  55.     type New_Game_Event is new Event with private; 
  56.     type A_New_Game_Event is access all New_Game_Event'Class; 
  57.  
  58.     NEW_GAME_ID : constant Event_Id := To_Event_Id( "New_Game" ); 
  59.  
  60.     ---------------------------------------------------------------------------- 
  61.  
  62.     type Pause_Game_Event is new Event with private; 
  63.     type A_Pause_Game_Event is access all Pause_Game_Event'Class; 
  64.  
  65.     PAUSE_GAME_ID : constant Event_Id := To_Event_Id( "Pause_Game" ); 
  66.  
  67.     function Is_Paused( this : not null access Pause_Game_Event'Class ) return Boolean; 
  68.  
  69.     ---------------------------------------------------------------------------- 
  70.  
  71.     type Scroll_View_Event is new Event with private; 
  72.     type A_Scroll_View_Event is access all Scroll_View_Event'Class; 
  73.  
  74.     SCROLL_VIEW_ID : constant Event_Id := To_Event_Id( "Scroll_View" ); 
  75.  
  76.     -- Amount to scroll view in the X axis in world coordinates. 
  77.     function Get_X( this : not null access Scroll_View_Event'Class ) return Float; 
  78.  
  79.     -- Amount to scroll view in the Y axis in world coordinates. 
  80.     function Get_Y( this : not null access Scroll_View_Event'Class ) return Float; 
  81.  
  82.     ---------------------------------------------------------------------------- 
  83.  
  84.     type View_Ready_Event is new Event with private; 
  85.     type A_View_Ready_Event is access all View_Ready_Event'Class; 
  86.  
  87.     VIEW_READY_ID : constant Event_Id := To_Event_Id( "View_Ready" ); 
  88.  
  89.     function Is_Ready( this : not null access View_Ready_Event'Class ) return Boolean; 
  90.  
  91.     ---------------------------------------------------------------------------- 
  92.  
  93.     procedure Queue_End_Game; 
  94.  
  95.     procedure Queue_Game_Paused( paused : Boolean ); 
  96.  
  97.     procedure Queue_Game_State( playing : Boolean ); 
  98.  
  99.     procedure Queue_Game_Var_Changed( var : String; 
  100.                                       val : in out A_Value ); 
  101.     pragma Precondition( var'Length > 0 ); 
  102.     pragma Postcondition( val = null ); 
  103.  
  104.     procedure Queue_Loading( loading : Boolean ); 
  105.  
  106.     procedure Queue_New_Game; 
  107.  
  108.     procedure Queue_Pause_Game( paused : Boolean ); 
  109.  
  110.     procedure Queue_Scroll_View( x, y : Float ); 
  111.  
  112.     procedure Queue_View_Ready( ready : Boolean ); 
  113.  
  114. private 
  115.  
  116.     type End_Game_Event is new Event with null record; 
  117.  
  118.     ---------------------------------------------------------------------------- 
  119.  
  120.     type Game_Paused_Event is new Event with 
  121.         record 
  122.             paused : Boolean := True; 
  123.         end record; 
  124.  
  125.     procedure Construct( this : access Game_Paused_Event; paused : Boolean ); 
  126.  
  127.     function To_String( this : access Game_Paused_Event ) return String; 
  128.  
  129.     ---------------------------------------------------------------------------- 
  130.  
  131.     type Game_State_Event is new Event with 
  132.         record 
  133.             playing : Boolean := True; 
  134.         end record; 
  135.  
  136.     procedure Construct( this : access Game_State_Event; playing : Boolean ); 
  137.  
  138.     function To_String( this : access Game_State_Event ) return String; 
  139.  
  140.     ---------------------------------------------------------------------------- 
  141.  
  142.     type Game_Var_Changed_Event is new Event with 
  143.         record 
  144.             var : Unbounded_String; 
  145.             val : A_Value := null; 
  146.         end record; 
  147.  
  148.     procedure Adjust( this : access Game_Var_Changed_Event ); 
  149.  
  150.     procedure Construct( this : access Game_Var_Changed_Event; 
  151.                          var  : String; 
  152.                          val  : in out A_Value ); 
  153.     pragma Precondition( var'Length > 0 ); 
  154.     pragma Postcondition( val = null ); 
  155.  
  156.     procedure Delete( this : in out Game_Var_Changed_Event ); 
  157.  
  158.     function To_String( this : access Game_Var_Changed_Event ) return String; 
  159.  
  160.     ---------------------------------------------------------------------------- 
  161.  
  162.     type Loading_Event is new Event with 
  163.         record 
  164.             loading : Boolean; 
  165.         end record; 
  166.  
  167.     procedure Construct( this : access Loading_Event; loading : Boolean ); 
  168.  
  169.     function To_String( this : access Loading_Event ) return String; 
  170.  
  171.     ---------------------------------------------------------------------------- 
  172.  
  173.     type New_Game_Event is new Event with null record; 
  174.  
  175.     ---------------------------------------------------------------------------- 
  176.  
  177.     type Pause_Game_Event is new Event with 
  178.         record 
  179.             paused : Boolean := True; 
  180.         end record; 
  181.  
  182.     procedure Construct( this : access Pause_Game_Event; paused : Boolean ); 
  183.  
  184.     ---------------------------------------------------------------------------- 
  185.  
  186.     type Scroll_View_Event is new Event with 
  187.         record 
  188.             x, y : Float := 0.0; 
  189.         end record; 
  190.  
  191.     procedure Construct( this : access Scroll_View_Event; x, y : Float ); 
  192.  
  193.     ---------------------------------------------------------------------------- 
  194.  
  195.     type View_Ready_Event is new Event with 
  196.         record 
  197.             ready : Boolean := True; 
  198.         end record; 
  199.  
  200.     procedure Construct( this : access View_Ready_Event; ready : Boolean ); 
  201.  
  202. end Events.Game;