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.Message is 
  10.  
  11.     -- The message screen is a blue bordered box in the center of the screen 
  12.     -- with a character's picture on the left and up to three lines of text on 
  13.     -- the right. It does not accept any input. 
  14.     type Message_Screen is new Game_Screen and Key_Listener with private; 
  15.  
  16.     -- Creates a new message screen with a default icon of Keen and no text. 
  17.     -- Set 'transparent' to False to hide the screen behind this one with a 
  18.     -- black background. 
  19.     function Create_Message_Screen( view        : not null access Game_Views.Game_View'Class; 
  20.                                     id          : String; 
  21.                                     transparent : Boolean := True ) return A_Game_Screen; 
  22.  
  23.     -- Sets whether or not the message screen can be closed by the user. The 
  24.     -- default is False. 
  25.     procedure Set_Closable( this     : not null access Message_Screen'Class; 
  26.                             closable : Boolean ); 
  27.  
  28.     -- Sets the icon to the left of the text in the message box. 
  29.     procedure Set_Icon( this     : not null access Message_Screen'Class; 
  30.                         filename : String ); 
  31.  
  32.     -- If enabled, the message screen will auto-pause gameplay while the screen 
  33.     -- is active. Don't put other opaque screens on top of the message popup 
  34.     -- screen, because this will deactivate it. 
  35.     procedure Set_Auto_Pause( this    : not null access Message_Screen'Class; 
  36.                               enabled : Boolean ); 
  37.  
  38.     -- Puts 'text' into the message box, splitting it into multiple lines on 
  39.     -- whitespace boundaries, as necessary. 
  40.     procedure Set_Text( this : not null access Message_Screen'Class; text : String ); 
  41.  
  42.     -- Sets the text alignment in the message box. If it is aligned to the left, 
  43.     -- the icon will be on the right. If it is aligned to the right, the icon 
  44.     -- will be on the left. The default is Align_Right. 
  45.     procedure Set_Text_Align( this  : not null access Message_Screen'Class; 
  46.                               align : Align_Type ); 
  47.  
  48. private 
  49.  
  50.     type Message_Screen is new Game_Screen and Key_Listener with 
  51.         record 
  52.             text      : Unbounded_String; 
  53.             textAlign : Align_Type := Align_Right; 
  54.             closable  : Boolean := False; 
  55.             autoPause : Boolean := False; 
  56.         end record; 
  57.  
  58.     procedure Construct( this        : access Message_Screen; 
  59.                          view        : not null access Game_Views.Game_View'Class; 
  60.                          id          : String; 
  61.                          transparent : Boolean ); 
  62.  
  63.     -- Pauses the game if auto-pause is enabled. 
  64.     procedure Activate( this : access Message_Screen ); 
  65.  
  66.     -- Unpauses the game if auto-pause is enabled. 
  67.     procedure Deactivate( this : access Message_Screen ); 
  68.  
  69.     -- Exits the screen on a space/enter key press if the screen is closeable. 
  70.     procedure Handle_Action( this    : access Message_Screen; 
  71.                              action  : A_Key_Action; 
  72.                              handled : out Boolean ); 
  73.  
  74.     procedure Pack( this : access Message_Screen ); 
  75.  
  76. end Widgets.Containers.Game_Screens.Message;