Angel 3.2
A 2D Game Prototyping Engine
Public Member Functions | Static Public Member Functions | Static Protected Attributes | List of all members
UserInterface Class Reference
+ Inheritance diagram for UserInterface:

Public Member Functions

void Render ()
 
virtual void MouseMotionEvent (Vec2i screenCoordinates)
 
virtual void MouseDownEvent (Vec2i screenCoordinates, MouseButtonInput button)
 
virtual void MouseUpEvent (Vec2i screenCoordinates, MouseButtonInput button)
 
virtual void MouseWheelEvent (const Vector2 &position)
 
void HandleKey (int key, bool down)
 
void HandleCharacter (wchar_t chr)
 
void Shutdown ()
 
AngelUIHandle AddButton (const String &label, Vec2i position, void(*callback)(), bool center=false, const String &font="", Vec2i padding=Vec2i(10, 10))
 
AngelUIHandle ShowChoiceBox (const String &choiceLabel, const StringList &labels, void(*callback)(int), const String &font="", Vec2i padding=Vec2i(10, 10), bool modal=true)
 
void RemoveUIElement (AngelUIHandle element)
 
- Public Member Functions inherited from MouseListener
 MouseListener ()
 
virtual ~MouseListener ()
 

Static Public Member Functions

static UserInterfaceGetInstance ()
 

Static Protected Attributes

static UserInterfaces_UserInterface = NULL
 

Detailed Description

Definition at line 51 of file UserInterface.h.

Member Function Documentation

UserInterface & UserInterface::GetInstance ( )
static

Used to access the singleton instance of this class. As a shortcut, you can just use "theUI".

Returns
The singleton

Definition at line 133 of file UserInterface.cpp.

void UserInterface::Render ( )

For internal engine use only; does the actual UI drawing.

Definition at line 182 of file UserInterface.cpp.

void UserInterface::MouseMotionEvent ( Vec2i  screenCoordinates)
virtual

Called whenever the player moves the mouse.

Parameters
screenCoordinatesThe new coordinates of the mouse in screen coordinates (pixels). Use the MathUtil::ScreenToWorld function if you want GL units.

Reimplemented from MouseListener.

Definition at line 224 of file UserInterface.cpp.

void UserInterface::MouseDownEvent ( Vec2i  screenCoordinates,
MouseButtonInput  button 
)
virtual

Called whenever the player presses down on a mouse button.

Parameters
screenCoordinatesThe new coordinates of the mouse in screen coordinates (pixels). Use the MathUtil::ScreenToWorld function if you want GL units.
buttonWhich button was pressed. Will be one of MOUSE_LEFT, MOUSE_MIDDLE, or MOUSE_RIGHT.

Reimplemented from MouseListener.

Definition at line 240 of file UserInterface.cpp.

void UserInterface::MouseUpEvent ( Vec2i  screenCoordinates,
MouseButtonInput  button 
)
virtual

Called whenever the player releases a mouse button.

Parameters
screenCoordinatesThe new coordinates of the mouse in screen coordinates (pixels). Use the MathUtil::ScreenToWorld function if you want GL units.
buttonWhich button was released. Will be one of MOUSE_LEFT, MOUSE_MIDDLE, or MOUSE_RIGHT.

Reimplemented from MouseListener.

Definition at line 252 of file UserInterface.cpp.

void UserInterface::MouseWheelEvent ( const Vector2 scrollOffset)
virtual

Called whenever the player moves the scroll wheel on the mouse.

Parameters
scrollOffsetThe change in position of the scroll wheel. Note that if it's an actual wheel, the X component of the vector will always be 0; the two-dimensional vector also takes into account trackpad scrolling.

Reimplemented from MouseListener.

Definition at line 264 of file UserInterface.cpp.

void UserInterface::HandleKey ( int  key,
bool  down 
)

For internal engine use only; handles keyboard input.

void UserInterface::HandleCharacter ( wchar_t  chr)

For internal engine use only; handles keyboard input.

void UserInterface::Shutdown ( )

For internal engine use only; shuts down the UI layer cleanly when the world is destroyed.

Definition at line 174 of file UserInterface.cpp.

AngelUIHandle UserInterface::AddButton ( const String &  label,
Vec2i  position,
void(*)()  callback,
bool  center = false,
const String &  font = "",
Vec2i  padding = Vec2i(10, 10) 
)

Adds a UI button to the world with formatting and a callback function.

Parameters
labelThe text that will appear on the button
positionWhere the button will appear on screen (in pixel units)
callbackThe function to be called when the button is pressed. Must return void and not take any parameters.
centerWhether the button should be centered on the given position. If false, the position will be its top left.
fontThe font to use for the button's text. If left as an empty string (the default), it will use the UI layer's default font, which is the same as the Angel console.
paddingHow much space (in pixels) to leave between the text and the edge of the button.
Returns
A UI handle that can be passed to RemoveUIElement

Definition at line 292 of file UserInterface.cpp.

AngelUIHandle UserInterface::ShowChoiceBox ( const String &  choiceLabel,
const StringList &  labels,
void(*)(int)  callback,
const String &  font = "",
Vec2i  padding = Vec2i(10, 10),
bool  modal = true 
)

Pops a choice box consisting of several buttons and reports to the callback when one is clicked. When a button is clicked, the choice box will automatically remove itself, so the AngelUIHandle returned from this function only has to be tracked if you want to remove the box manually for some reason.

Parameters
choiceLabelThe label at the top of the box, describing the choice the player is making
labelsA list of Strings that will be used for the buttons in the choice
callbackThe function to be called when any of the buttons are pressed. Must return void and take a single integer as a parameter. When the function is called, the integer will be the index of the button that was pressed (from zero, so it will match the index in the labels list).
fontThe font to use for the buttons' text. If left as an empty string (the default), it will use the UI layer's default font, which is the same as the Angel console.
paddingHow much space (in pixels) to leave between the text and the edge of the button. Also how much space will be left between buttons.
Returns
A UI handle that can be passed to RemoveUIElement.

Definition at line 320 of file UserInterface.cpp.

void UserInterface::RemoveUIElement ( AngelUIHandle  element)

Removes a UI element that was added through one of the UI functions described elsewhere in this file. Requires the opaque handle that was returned when the element was created.

Parameters
elementThe handle for the UI element to remove.

Definition at line 277 of file UserInterface.cpp.


The documentation for this class was generated from the following files: