--
-- Copyright (c) 2012 Kevin Wellwood
-- All rights reserved.
--
-- This source code is distributed under the Modified BSD License. For terms and
-- conditions, see license.txt.
--
private with Ada.Real_Time;
private with Ada.Strings.Unbounded;
package Game_Views.Keen is
type Keen_View is new Game_View with private;
type A_Keen_View is access all Keen_View'Class;
-- Pauses or resumes the game, in the context of a menu or dialog on the
-- screen. For every pause by a menu, there must be a corresponding resume
-- as a menu.
--
-- Nested menus may all pause the game, so a menu pause count is preserved
-- and tracked by this procedure. The first time a menu calls
-- Pause_By_Menu(True), the game play will be paused (if it wasn't already
-- paused by the player.) When the same menu calls the corresponding
-- Pause_By_Menu(False), the menu pause count is decremented. When the count
-- reaches zero, play will resume (again, if it wasn't already paused by the
-- player.)
procedure Pause_By_Menu( this : not null access Keen_View'Class;
enabled : Boolean );
-- Pauses or resumes the game, in the context of the player. If game has
-- already been paused by a menu (via Pause_By_Menu) then the player will
-- not be allowed to pause or resume play.
procedure Pause_By_Player( this : not null access Keen_View'Class;
enabled : Boolean );
private
use Ada.Real_Time;
use Ada.Strings.Unbounded;
type Keen_View is new Game_View with
record
-- game play was paused explicitly by the player
pausedByPlayer : Boolean := False;
-- a count of the number of times the game as been automatically
-- paused by the menu system. the menus must unpause the same number
-- of times before game play may resume. the is a count instead of a
-- boolean because of nested pause situations (e.g. the status board
-- is being shown (pausedByMenu=1) and the player exits back to the
-- menu (pausedByMenu=2).
pausedByMenu : Integer := 0;
-- true when loading is in progress. this occurs between levels.
loading : Boolean := False;
-- loading screen is being displayed.
loadingScreen : Boolean := False;
-- time when the loading screen is to be hidden, if loading has
-- finished. if this equals Time_First, loading has not begun.
loadingScreenComplete : Time := Time_First;
-- the name of the music for the current world. this is set when the
-- 'music' world property changes and played when the world loading
-- dialog is closed.
worldMusic : Unbounded_String;
end record;
-- This is called when the user clicks the X window button on the window.
procedure On_Close_Window( this : access Keen_View;
allowed : in out Boolean );
-- Inherited from the Event_Listener interface. Handles events that the view
-- is registered to receive.
procedure Handle_Event( this : access Keen_View;
evt : in out A_Event;
resp : out Response_Type );
pragma Precondition( evt /= null );
-- Creates all of the widgets required for the game view. An exception will
-- be raised if an error occurs creating the widgets.
procedure Initialize_Widgets( this : access Keen_View;
win : not null A_Window );
-- This is called once, just after the view has been initialized at startup.
procedure On_Initialize( this : access Keen_View );
-- This is called once, just before the view is finalized at shutdown.
procedure On_Finalize( this : access Keen_View );
-- This is called when the paused state of the Game changes.
procedure On_Game_Paused( this : access Keen_View; paused : Boolean );
-- This is called when a game session begins or ends. 'isInterrupted"
-- indicates if the game session was aborted before the player won or lost.
procedure On_Game_State_Changed( this : access Keen_View;
isPlaying : Boolean;
isInterrupted : Boolean );
-- Called when loading begins. Stops any music currently being played, and
-- shows the loading screen.
procedure On_Loading_Begin( this : access Keen_View );
-- Called when loading ends. Hides the loading screen and begins playing the
-- world's music.
procedure On_Loading_End( this : access Keen_View;
success : Boolean;
message : String );
-- This is called when a property of the current world changes.
procedure On_World_Property_Changed( this : access Keen_View;
name : String;
value : Value_Ptr'Class );
-- Inherited from the Process interface. This will be called regularly after
-- the view is started.
procedure Tick( this : access Keen_View; time : Tick_Time );
end Game_Views.Keen;