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.
BankUI.h
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. |
|
The BankUI constructor. Makes the BankUI visible and adds OnUpdate as a receiver of the eventPlayerUI Event.
| parent | The parent window. Must not be NULL. |
| ~BankUI() |
The BankUI destructor. Removes OnUpdate as a receiver of the eventPlayerUI Event.
|
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.
| game | The current Game. |
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. |
|
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.
| game | The current Game. |
| 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.
|
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.
| object | The DataObject containing the update information. Must have a Game object as its first parameter. |
| StaticMap mStaticMap |
The std::map of wxStaticBitmaps to the IDrawObjects that render them.
|
| ~BankUI() |
|
|
|
| virtual const TraitsUIPtr &GetTraitsUI() |
| virtual void ResizeUI() |
|
| StaticMap mStaticMap |