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. package Widgets.Containers.Game_Screens is 
  10.  
  11.     -- A Game_Screen is a simple abstract container for multiple widgets, 
  12.     -- intended to be used with a Screen_Manager object. It fills the entire 
  13.     -- window and is intended to represent one "state" of a game's GUI, managing 
  14.     -- input and logic, and transitions to other screens. A screen can have an 
  15.     -- optional background image or color or it can have a transparent 
  16.     -- background. 
  17.     -- 
  18.     -- This class is abstract with the intention that it be instantiated 
  19.     -- specifically for each screen in a game's interface (e.g. title screen, 
  20.     -- main menu, loading screen, game play, etc.) 
  21.     -- 
  22.     -- A screen populates its child widgets at construction and also handles all 
  23.     -- Actions dispatched by its children. 
  24.     type Game_Screen is abstract new Container with private; 
  25.     type A_Game_Screen is access all Game_Screen'Class; 
  26.  
  27.     -- Activates the screen when it hits the front of the screen manager and 
  28.     -- begins accepting user input. This procedure should be overriden to focus 
  29.     -- an input widget, if necessary. It is possible for Activate to be called 
  30.     -- multiple times without deactivation, so if its important that this only 
  31.     -- happens once, check Is_Active. When overriding this procedure, call this 
  32.     -- base implementation first. 
  33.     procedure Activate( this : access Game_Screen ); 
  34.  
  35.     -- Deactivates the screen when becomes hidden by another screen in the 
  36.     -- screen manager, or when it is removed from the screen manager. When 
  37.     -- overriding this procedure, call this base implementation first. 
  38.     procedure Deactivate( this : access Game_Screen ); 
  39.  
  40.     -- Indicates the screen will now begin exiting. On the screen manager's next 
  41.     -- tick after this screen has finished exiting, the screen will be removed 
  42.     -- and destroyed. Deactivate will be called just before the screen is 
  43.     -- removed from its manager. 
  44.     procedure Exit_Screen( this : not null access Game_Screen'Class ); 
  45.  
  46.     -- Returns True if the game screen has been activated by a call from the 
  47.     -- screen manager to Activate. This remains True until the screen is 
  48.     -- deactivated. 
  49.     function Is_Active( this : not null access Game_Screen'Class ) return Boolean; 
  50.  
  51.     -- Returns True if the screen is in the processing of exiting. 
  52.     function Is_Exiting( this : not null access Game_Screen'Class ) return Boolean; 
  53.  
  54.     -- Returns True if the game screen is a light-weight popup screen with a 
  55.     -- transparent screen. 
  56.     function Is_Popup( this : not null access Game_Screen'Class ) return Boolean; 
  57.  
  58. private 
  59.  
  60.     type Game_Screen is abstract new Container with 
  61.         record 
  62.             background : Natural := 0;      -- background image's tile id 
  63.             popup      : Boolean := False;  -- screen is a popup (transparent background) 
  64.             active     : Boolean := False;  -- screen has been activated 
  65.             exiting    : Boolean := False;  -- in the process of exiting? 
  66.         end record; 
  67.  
  68.     procedure Construct( this  : access Game_Screen; 
  69.                          view  : not null access Game_Views.Game_View'Class; 
  70.                          id    : String; 
  71.                          popup : Boolean ); 
  72.  
  73.     -- Draws the screen's background image, if it has one, or background color 
  74.     -- if it's not transparent. 
  75.     procedure Draw_Content( this : access Game_Screen ); 
  76.  
  77.     -- Sets the background image name to display behind all the child widgets. 
  78.     -- If the background image is not found in the interface's tile library, or 
  79.     -- an empty string is given, the background will be transparent. 
  80.     procedure Set_Background( this       : not null access Game_Screen'Class; 
  81.                               background : String ); 
  82.  
  83. end Widgets.Containers.Game_Screens;