Index

Package: Game_Views

Description

package Game_Views is
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.

Classes

Game_View (abstract)

type Game_View is abstract new Limited_Object and
                                   Event_Listener and
                                   Process with private;
The Game_View object is the parent object in the View system, which is responsible for managing all user interaction with the game. Input handling, rendering, and audio are all subsystems managed by the Game_View class. The Game_View provides a Process_Manager to service Process objects within the view system, and a Corral to receive events sent to event listener objects. The Game_View itself is a Process and an Event_Listener object.

Types

A_Game_View

type A_Game_View is access all Game_View'Class;

Constants & Global variables

DUPLICATE_ID

DUPLICATE_ID : exception;
raised on attempt to register a widget with a duplicate id

ID_NOT_FOUND

ID_NOT_FOUND : exception;
raised on attempt to access an registered widget by id

Subprograms & Entries

Create_Game_View

function Create_Game_View
( display: not null A_Allegro_Display ) return A_Game_View;
Creates and returns a new Game_View object using the registered allocator function. The size of 'display' is the actual size of OS window on the screen. An exception will be raised if no allocator is registered.

Delete

procedure Delete
( this: in out A_Game_View );
Deletes the Game_View.

Initialize

procedure Initialize
( this: not null access Game_View'Class );
Initializes the game view, attaching it to the framework. This will attach event listeners, processes, start the view's subsystems (audio, etc.) and begin running the view's Process_Manager. If the view has already been started, then this will do nothing. Start_View() will be called at the end of this procedure.

Finalize

procedure Finalize
( this: not null access Game_View'Class );
Finalizes the game view, detaching it from the framework. This must be called after Initialize() and before deleting the object. If the view has not been initialize, or has already been finalized, this will do nothing. Stop_View() will be called at the beginning of this procedure.

New_Game

procedure New_Game
( this: not null access Game_View'Class );
Queues an event to begin a new game from the beginning. If a game session is currently in progress, it will be aborted first. The new game will not begin immediately; The view will be notified of the game session beginning via the On_Game_State_Changed() procedure.

Ready_For_Play

procedure Ready_For_Play
( this: not null access Game_View'Class );
Notifies the game session that the view has finished loading resources after a world change and is ready for game play. When the current world changes, the game notifies the view of the next world for play, via the New_World event, and goes into a waiting state. It remains waiting until the view indicates it is ready for game play via this procedure.

Pause_Game

procedure Pause_Game
( this: not null access Game_View'Class;
pause: Boolean );
Queue an event to pause/resume game play, if a game is in session. Note that the paused state of the game will not change immediately; the view will be notified of the change in state by an event, which can be handled with the On_Game_Paused() procedure.

Is_Game_In_Session

function Is_Game_In_Session
( this: not null access Game_View'Class ) return Boolean;
Returns True if a game is in session.

Is_Paused

function Is_Paused
( this: not null access Game_View'Class ) return Boolean;
Returns True if a game is in session and game play is paused.

End_Game

procedure End_Game
( this: not null access Game_View'Class );
Queues an event to end the current game, if a game is in session. It will not be ended immediately; The view will be notified of the game session ending via the On_Game_State_Changed() procedure.

Quit

procedure Quit
( this: not null access Game_View'Class );
Exits the application. Make sure game session data is saved prior to calling this, if it needs to be saved.

Attach

procedure Attach
( this: not null access Game_View'Class;
process: not null A_Process );
Attaches a Process to the view's Process_Manager.

Detach

procedure Detach
( this: not null access Game_View'Class;
process: not null A_Process );
Detaches a Process from the view's Process_Manager.

Get_Corral

function Get_Corral
( this: not null access Game_View'Class ) return A_Corral;
Returns the view's Corral. The view creates its corral at construction.

Get_Display

function Get_Display
( this: not null access Game_View'Class ) return A_Allegro_Display;
Returns the view's display.

Get_Widget

function Get_Widget
( this: not null access Game_View'Class;
id: String ) return A_Widget;
Returns a widget in the registry by id. Raises exception ID_NOT_FOUND if the widget does not exist.

Get_Window

function Get_Window
( this: not null access Game_View'Class ) return A_Window;
Returns the view's Window widget. This will return null if the window has not yet been set.

Register

procedure Register
( this: not null access Game_View'Class;
widget: not null A_Widget );
Adds a widget to the view's widget registry. Raises exception DUPLICATE_ID if a widget with the same id is already registered.

Unregister

procedure Unregister
( this: not null access Game_View'Class;
id: String );
Removes a widget from the view's registry. If the widget is not registered, nothing happens.