ControlsUI

Displays a set of buttons for user turn actions.  ControlsUI sits at the top of the screen just to the left of the MessageUI.  It holds action buttons that players can use on their turn to undo an action (if possible), trade with each other, trade with the bank, play a card, or end their turn.  ControlsUI can be updated by transmitting a DataObject to the eventControlsUI Event via the Controller.  The transmitted DataObject must have a bool as its first parameter.  If the bool value is false, the ControlsUI hides itself; if the bool value is true, the ControlsUI shows itself and updates each of its buttons via ILogic rules.  The buttons are enabled or disabled depending on the result of the ILogic.  If a user clicks an enabled button, ControlsUI calls the RuleEngine with an IRule to execute.

Derived From

BaseUI

Project

Cities3D

Include

ControlsUI.h

Summary
Displays a set of buttons for user turn actions.
The ControlsUI constructor.
The ControlsUI destructor.
Initializes the ControlsUI.
The wxWidgets event table declaration.
Updates the clickability outline of the ControlsUI.
Paints the ControlsUI.
Provides the TraitsUI object for the ControlsUI.
Resizes the ControlsUI.
Updates the ControlsUI.
Updates the Undo button by checking the IRuleEngine.
Handles any action button click.
The action buttons.
Whether the ControlsUI has a clickable item in it or not.
Pointer to the window the ControlsUI is offset from.

Public

Summary
The ControlsUI constructor.
The ControlsUI destructor.
Initializes the ControlsUI.
The wxWidgets event table declaration.

Constructors

ControlsUI

ControlsUI(wxWindow *parent,
const wxWindow *resizeLink)

The ControlsUI constructor.  Sets the resize window that the ControlsUI depends on to calculate its offset (should be the MessageUI window), and adds OnUpdate as a receiver of the eventControlsUI Event.

Parameters

parentThe parent window.  Must not be NULL.
resizeLinkThe window used to calculate offset properly.  Must not be NULL.  Since ControlsUI is to the left of MessageUI, it must take that into account when locating itself.

Destructor

~ControlsUI

~ControlsUI()

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

Virtual Functions

InitializeUI

virtual void InitializeUI(const GamePtr &game)

Initializes the ControlsUI.  Creates all of the action buttons and sets them to disabled.  Then creates the internal TraitsUI object and calls ResizeUI to set the size of the UI properly.

Variables

DECLARE_EVENT_TABLE

The wxWidgets event table declaration.

Private

Summary
Updates the clickability outline of the ControlsUI.
Paints the ControlsUI.
Provides the TraitsUI object for the ControlsUI.
Resizes the ControlsUI.
Updates the ControlsUI.
Updates the Undo button by checking the IRuleEngine.
Handles any action button click.
The action buttons.
Whether the ControlsUI has a clickable item in it or not.
Pointer to the window the ControlsUI is offset from.

Functions

UpdateClickable

void UpdateClickable()

Updates the clickability outline of the ControlsUI.  If any button is clickable, the whole ControlsUI is outlined in white to draw attention to the fact.

Virtual Functions

Paint

void Paint(wxMemoryDC &dc)

Paints the ControlsUI.  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 ControlsUI.

Returns

A const reference to the TraitsUI object.

ResizeUI

virtual void ResizeUI()

Resizes the ControlsUI.  Uses the internal TraitsUI object to set the width and height for the entire UI.  Sets the offset amount properly based on the resize link.  Resizes all of the action buttons based on the TraitsUI size information.

Game Event Functions

OnUpdate

void OnUpdate(DataObject object)

Updates the ControlsUI.  Triggered by the eventControlsUI Event.  The given DataObject must have a bool as its first parameter.  If the bool is true, the ControlsUI is shown on the screen, if false, the ControlsUI is hidden.  Calls hard-coded Logic for each of the buttons, to determine if the button should be enabled.  Enables or disables the buttons appropriately.  If any of the buttons are enabled, the entire ControlsUI is set to clickable state (and drawn with a white outline), otherwise, it is set to not clickable and drawn with the standard outline.

Parameters

objectThe DataObject containing the update information.  Must have a bool as its first parameter.

OnUpdateUndo

void OnUpdateUndo(wxInt32 dummy)

Updates the Undo button by checking the IRuleEngine.

Parameters

dummyA dummy parameter to satisfy the one parameter requirement for EventsUnused.

Event Message Handling

OnButton

void OnButton(wxCommandEvent &event)

Handles any action button click.  Calls the RuleEngine with a hard-coded Rule for each of the buttons.

Parameters

eventThe button click event.

Variables

mButtons

ClearButtonArray mButtons

The action buttons.  Created as wxClearButtons for a common UI look and feel.

mClickable

bool mClickable

Whether the ControlsUI has a clickable item in it or not.  True if it does, false if not.  If the ControlsUI is clickable, it is outlined in white to notify the user.

mResizeLink

const wxWindow *mResizeLink

Pointer to the window the ControlsUI is offset from.  Queried in ResizeUI to make sure that the proper offset distance from the UI anchor point is maintained.

ControlsUI(wxWindow *parent,
const wxWindow *resizeLink)
The ControlsUI constructor.
~ControlsUI()
The ControlsUI destructor.
virtual void InitializeUI(const GamePtr &game)
Initializes the ControlsUI.
void UpdateClickable()
Updates the clickability outline of the ControlsUI.
void Paint(wxMemoryDC &dc)
Paints the ControlsUI.
virtual const TraitsUIPtr &GetTraitsUI()
Provides the TraitsUI object for the ControlsUI.
Manages internal element sizes for a BaseUI-derived object.
virtual void ResizeUI()
Resizes the ControlsUI.
void OnUpdate(DataObject object)
Updates the ControlsUI.
void OnUpdateUndo(wxInt32 dummy)
Updates the Undo button by checking the IRuleEngine.
The interface for the rule engine.
void OnButton(wxCommandEvent &event)
Handles any action button click.
ClearButtonArray mButtons
The action buttons.
bool mClickable
Whether the ControlsUI has a clickable item in it or not.
const wxWindow *mResizeLink
Pointer to the window the ControlsUI is offset from.
Displays game-related messages to the user.
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.
The interface of a single piece of game logic.
The default implementation of the IRuleEngine interface.
The interface for a single game rule.
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.
The default implementation of ILogic for normal Game actions.
The default implementation of IRule for normal Game actions.
A completely custom-drawn bitmapped button.