gma.hud

Provides HUD functionality

Package

gma/utils/hud

Methods

setup (spec)
Creates the necessary HTML elements that form the hud
It will also store this on self and inside positions

Parameters

spec

Object

Specifies what displays where on the HUD

createSection (divID, dlClass) -> The created/found dl element
Return a dl element inside a div element
Both of these elements are created if they don’t already exist
The div element will have a particular id
The dl element will have a particular class
Both id/class are found with (and created on) using those passed into the function

Parameters

divID

String

The id of the div element

dlClass

String

The class of the dl element

fillSection ($container, items)
Fills some element (suggested to be a dl) with dt and dd elements
It will prepend each element’s label with “hud_” and convert to lowercase to form the id for each dt
And insert the lable inside a span element inside the dt
It will then use the the value for the label as the value for the dd,
or if the value is a function, then using the result of calling that function as the value inside the dd
This function will then register this function to this particular dt for updating at a later stage

Parameters

$container

HTML Element

The container to add the dt and dd elements to

items

Dictionary

Dictionary of label:value to put into the $container

reset ( )

Ensures the canvasContainer is empty

refresh ( )

Fills out HUD information using the functions provided to setup

hide (position)
Hides the HTML elements that makes up the HUD
Optionally, you can hide just a particular part of the HUD

Parameters

position

String

Particular part of the HUD you want to hide

show (position)
Shows the HTML elements that makes up the HUD
Optionally, you can show just a particular part of the HUD

Parameters

position

String

Particular part of the HUD you want to show

displayMessage (msg, wait, callBack)
Hides the HTML elements that makes up the HUD
Optionally, you can hide just a particular part of the HUD
It will use a div with id of “message” to display the message in

Parameters

msg

String

The message to display

wait

Number

The amount to wait before automatically hiding the message

callBack

Function

Optional function that is executed either immediately or when the timeout has finished

hideMessage ( )

Hides the message div (div with id “message”)