BankUI

Displays stacks of remaining bank cards.  BankUI sits in the lower-left of the screen and shows the user how much of everything is left in the bank.  On screen, the stacks of bank cards are displayed as a series of wxStaticBitmap images, though the bank stack images themselves are created by rendering them in OpenGL and then converting them to a wxBitmap.  The bank stacks are updated by transmitting a DataObject to the eventPlayerUI Event, since anything that affects player data may also affect bank data, making it so there is no need for a separate bank update Event.  The transmitted DataObject in the eventPlayerUI Event must have the current Game object as its first parameter.

When BankUI is initialized, it queries the IPluginEngine and retrieves all BankData objects supplied by the currently loaded RuleSets.  It then takes those pieces of BankData and creates a set of IDrawObject-derived objects, each of which is responsible for drawing a stack of cards using OpenGL.  BankUI then maintains a link between each wxStaticBitmap and the IDrawObject that creates the bitmap for it.  Whenever the eventPlayerUI Event is triggered, each IDrawObject is sent in to the parent wxSettlersGLCanvas and converted from OpenGL to a wxBitmap.  This bitmap is then set as the wxStaticBitmaps image, allowing the user to always see exactly how many cards are in one stack compared to the others.

The key idea with BankUI is that it knows nothing about any particular cards, making it 100% plugin data.  It just takes the BankData supplied by the loaded RuleSets and turns it into OpenGL-rendered stacks of cards.

Derived From

BaseUI

Project

Cities3D

Include

BankUI.h

Summary
Displays stacks of remaining bank cards.
The BankUI constructor.
The BankUI destructor.
Initializes the BankUI.
Recreates the bank stack bitmaps.
Paints the BankUI.
Provides the TraitsUI object for the BankUI.
Resizes the BankUI.
Updates the bitmaps in the bank stacks.
The std::map of wxStaticBitmaps to the IDrawObjects that render them.

Public

Summary
The BankUI constructor.
The BankUI destructor.
Initializes the BankUI.

Constructors

BankUI

BankUI(wxWindow *parent)

The BankUI constructor.  Makes the BankUI visible and adds OnUpdate as a receiver of the eventPlayerUI Event.

Parameters

parentThe parent window.  Must not be NULL.

Destructor

~BankUI

~BankUI()

The BankUI destructor.  Removes OnUpdate as a receiver of the eventPlayerUI Event.

Virtual Functions

InitializeUI

virtual void InitializeUI(const GamePtr &game)

Initializes the BankUI.  Loads all of the BankData objects from the <Rulesets> in the IPluginEngine and creates IDrawObjects for each of them.  Creates the wxStaticBitmaps needed to display the card stacks and stores each bitmap in a std::map along with its associated IDrawObject.  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
Recreates the bank stack bitmaps.
Paints the BankUI.
Provides the TraitsUI object for the BankUI.
Resizes the BankUI.
Updates the bitmaps in the bank stacks.
The std::map of wxStaticBitmaps to the IDrawObjects that render them.

Functions

RefreshBitmaps

void RefreshBitmaps(const GamePtr &game = GamePtr())

Recreates the bank stack bitmaps.  For each bank stack bitmap in the internal std::map, BankUI calls ConvertGLtoWX on the parent wxSettlersGLCanvas with the IDrawObject for that bitmap, then sets the bitmap to the returned image.  There are optimizations in place to avoid recreating a bitmap if the stack size has not changed.

Parameters

gameThe current Game.

Virtual Functions

Paint

void Paint(wxMemoryDC &dc)

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

Returns

A const reference to the TraitsUI object.

ResizeUI

virtual void ResizeUI()

Resizes the BankUI.  Uses the internal TraitsUI object to set the width and height for the entire UI.  Adjusts the size of all the bank stack bitmaps and calls RefreshBitmaps to ensure that the bitmaps fit the new size.

Game Event Functions

OnUpdate

void OnUpdate(DataObject object)

Updates the bitmaps in the bank stacks.  Triggered by the eventPlayerUI Event.  The given DataObject must have the current Game as its first parameter.  The bitmaps are updated by calling RefreshBitmaps.

Parameters

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

Variables

mStaticMap

StaticMap mStaticMap

The std::map of wxStaticBitmaps to the IDrawObjects that render them.

BankUI(wxWindow *parent)
The BankUI constructor.
~BankUI()
The BankUI destructor.
virtual void InitializeUI(const GamePtr &game)
Initializes the BankUI.
void RefreshBitmaps(const GamePtr &game = GamePtr())
Recreates the bank stack bitmaps.
void Paint(wxMemoryDC &dc)
Paints the BankUI.
virtual const TraitsUIPtr &GetTraitsUI()
Provides the TraitsUI object for the BankUI.
Manages internal element sizes for a BaseUI-derived object.
virtual void ResizeUI()
Resizes the BankUI.
void OnUpdate(DataObject object)
Updates the bitmaps in the bank stacks.
StaticMap mStaticMap
The std::map of wxStaticBitmaps to the IDrawObjects that render them.
The interface for objects that are drawn on screen.
A generic container for passing any kind of data around.
A generic implementation of the Observer design pattern.
Still volatile.
The interface of the plugin engine.
Describes a stack of cards to be drawn in the BankUI.
A repository of all things rules-related.
Renders all game objects in OpenGL.
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.