Index

Package: Game_Views

Description

package Game_Views is

Classes

Game_View (abstract)

type Game_View is abstract new Limited_Object and
                                   Event_Listener and
                                   Process with private;

Ancestors:

Immediate Children:

Primitive operations:

Construct (overriding Objects.Construct)
Delete (overriding Objects.Delete)
Events.Listeners.To_String (Inherited)
Get_Process_Name (overriding Processes.Get_Process_Name)
Handle_Close_Request
Handle_Event (overriding Events.Listeners.Handle_Event)
Handle_Loading
Handle_Paused
Objects.To_String (Inherited)
Start_View
Stop_View
Tick (overriding Processes.Tick)
The Game_View class is parent object in the View system, which is responsible for managing all user input/output for the game. This includes receiving mouse and keyboard input, rendering the screen and playing audio. No game logic is performed by the view, it only receives input and displays a view of the current game state (graphically and audibly) for the user. The Game_View provides a Process_Manager to service the view system, a Corral to receive events sent to listeners in the view, and a various child objects to handle screen drawing, input capturing, and audio playback. The Game_View itself is a Process and Event_Listener that is attached to its own Process_Manager and Corral facilities.

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
( xres, yres: Positive;
scale: Positive ) return A_Game_View;
Creates and returns a new Game_View object using the registered allocator function. An exception will be raised if no allocator is registered.

Attach

procedure Attach
( this: not null access Game_View'Class;
process: not null A_Process );
Attachs 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_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.

Set_Window

procedure Set_Window
( this: not null access Game_View'Class;
window: in out A_Window );
Sets the view's Window widget. If 'window' is null, the view's Window will be removed. The window can only be set before the view is started. All attempts to change the window after the view has been started will be ignored and 'window' will be deleted. The view's Renderer is deleted and recreated when its Window is changed. If this procedure raises an exception, the view will be left without a Window and the given 'window' reference will remain unchanged.

Start

procedure Start
( this: not null access Game_View'Class );
Starts 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.

Stop

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

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.

Delete

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