MessageUI

Displays game-related messages to the user.  The MessageUI is the box that sits in the upper-right corner of the UI and posts game-related information and messages to the user, telling them what is going on at that time.  MessageUI is updated by transmitting a DataObject to the eventMessageUI Event via the Controller.  The transmitted DataObject must have a wxString as its first parameter and the current Game object as its second.  The MessageUI sets its output text to the wxString and updates the color of text based on the color of the current player, determined through the Game object.

Derived From

BaseUI

Project

Cities3D

Include

MessageUI.h

Summary
Displays game-related messages to the user.
The MessageUI constructor.
The MessageUI destructor.
Initializes the MessageUI.
Paints the MessageUI.
Provides the TraitsUI object for the MessageUI.
Resizes the MessageUI.
Updates the text in the MessageUI.
The output <wxStaticText> control.

Public

Summary
The MessageUI constructor.
The MessageUI destructor.
Initializes the MessageUI.

Constructors

MessageUI

MessageUI(wxWindow *parent)

The MessageUI constructor.  Makes the MessageUI visible and adds OnUpdate as a receiver of the eventMessageUI Event.

Parameters

parentThe parent window.  Must not be NULL.

Destructor

~MessageUI

~MessageUI()

The MessageUI destructor.  Removes OnUpdate as a receiver of the eventMessageUI Event.

Virtual Functions

InitializeUI

virtual void InitializeUI(const GamePtr &game)

Initializes the MessageUI.  Creates the wxBaseStaticText control that displays message text, then creates the TraitsUI object with default sizes and calls ResizeUI to set the size of the UI properly.

Parameters

gameThe current Game.

Private

Summary
Paints the MessageUI.
Provides the TraitsUI object for the MessageUI.
Resizes the MessageUI.
Updates the text in the MessageUI.
The output <wxStaticText> control.

Virtual Functions

Paint

virtual void Paint(wxMemoryDC &dc)

Paints the MessageUI.  Fills in the background color and draws the rounded outline.

Parameters

dcThe memory dc to draw into.

GetTraitsUI

virtual const TraitsUIPtr &GetTraitsUI()

Provides the TraitsUI object for the MessageUI.

Returns

A const reference to the TraitsUI object.

ResizeUI

virtual void ResizeUI()

Resizes the MessageUI.  Uses the internal TraitsUI object to set the width and height for the entire UI.  Resizes the wxBaseStaticText control to fill the new dimensions.  Recalculates the maximum font size that can fit three lines of text inside the wxBaseStaticText control.

Game Event Functions

OnUpdate

void OnUpdate(DataObject object)

Updates the text in the MessageUI.  Triggered by the eventMessageUI Event.  The given DataObject must have a wxString as its first parameter and the current Game as its second.  The wxBaseStaticText control is set to the wxString text and changes its color to the color of the current player (or white if none).

Parameters

objectThe DataObject containing the update information.  Must have a wxString as its first parameter and a Game object as its second.

Variables

mText

boost::shared_ptr<wxStaticText> mText

The output <wxStaticText> control.  Displays the current information for the user.

MessageUI(wxWindow *parent)
The MessageUI constructor.
~MessageUI()
The MessageUI destructor.
virtual void InitializeUI(const GamePtr &game)
Initializes the MessageUI.
virtual void Paint(wxMemoryDC &dc)
Paints the MessageUI.
virtual const TraitsUIPtr &GetTraitsUI()
Provides the TraitsUI object for the MessageUI.
Manages internal element sizes for a BaseUI-derived object.
virtual void ResizeUI()
Resizes the MessageUI.
void OnUpdate(DataObject object)
Updates the text in the MessageUI.
boost::shared_ptr<wxStaticText> mText
The output wxStaticText control.
A generic container for passing any kind of data around.
A generic implementation of the Observer design pattern.
The communication mechanism between the View and the Model.
Still volatile.
A base class for all main screen UI.
Cities3D is a cross-platform implementation of the board game Settlers of Catan with all expansions, including Seafarers, and Cities & Knights.
A basic static text window.