Displays game information for one player. The PlayerUI windows start at the top left of the screen and continue down the left side. PlayerUIs are the most complicated of all the UI pieces. They display the player’s current resource cards, current development or progress cards, stock items, points from various means, special flags, and modify themselves in different modes of the game. For instance, the current player in hotseat mode can see their cards, but when the current player changes, the PlayerUIs must update themselves so that only the new current player’s cards are visible. A PlayerUI is updated by transmitting a DataObject to the eventPlayerUI Event via the Controller. The transmitted DataObject must have the current Game as its first parameter, and a wxInt32 as its second parameter. The wxInt32 flag specifys which player’s data needs to be updated, or -1 to update all, or -2 to update which player’s turn it is.
When a PlayerUI is initialized, it queries the IPluginEngine and retrieves all PlayerData objects supplied by the currently loaded RuleSets. It then takes these pieces of PlayerData and builds a layout of icons representing cards, stock, and point information from them. Some PlayerData objects may require OpenGL rendered bitmaps, namely the stock items. In those cases, the associated IDrawObjects are sent to the parent wxSettlersGLCanvas and converted from OpenGL to a wxBitmap. The PlayerUI keeps track of all of these bits of information and handles laying them out in a more or less generalized fashion so that different RuleSets can add new items to the player display windows without difficulty.
The key idea with PlayerUI is that it knows nothing about any particular piece of knowledge in the game, making it 100% plugin data. It just takes the PlayerData supplied by the loaded RuleSets, groups it by categories, and lays it out in the window.
PlayerUI.h
Displays game information for one player. | |
The PlayerUI constructor. | |
The PlayerUI destructor. | |
Recalculates the proper width of the PlayerUI. | |
Initializes the PlayerUI. | |
Paints the PlayerUI. | |
Provides the TraitsUI object for the PlayerUI. | |
Resizes the PlayerUI. | |
Updates the player UI elements by calling each of their own Update functions. | |
Updates the player UI color and name if and when the players are reordered during the game. | |
The index of the player this PlayerUI represnets. | |
The index of current player. | |
The color used to draw this player’s text and outline. | |
The TraitsUI object for this PlayerUI. | |
The static text control displaying the player’s name. | |
Pointer to the window the PlayerUI is offset from. | |
The points in the UI where vertical lines are drawn. | |
The individual elements in the UI. |
|
The PlayerUI constructor. Makes the PlayerUI visible and adds OnUpdate as a receiver of the eventPlayerUI Event. Adds OnPlayerReorder as a receiver of the eventPlayerReorder Event.
| parent | The parent window. Must not be NULL. |
| ~PlayerUI() |
The PlayerUI destructor. Removes OnUpdate as a receiver of the eventPlayerUI Event.
| void CalculateWidth() |
Recalculates the proper width of the PlayerUI. Takes into account many factors which affect the width. When finished, sets the Width value in the TraitsUI object.
|
Initializes the PlayerUI. Loads all of the PlayerData objects from the <Rulesets> in the IPluginEngine and creates inidividual elements out of them. Creates the wxBaseStaticText object that holds the player’s name. Sets the outline color and text colors based on the player’s selected colors. Then creates the internal TraitsUI object and calls ResizeUI to set the size of the UI properly.
| game | The current Game. |
Paints the PlayerUI. | |
Provides the TraitsUI object for the PlayerUI. | |
Resizes the PlayerUI. | |
Updates the player UI elements by calling each of their own Update functions. | |
Updates the player UI color and name if and when the players are reordered during the game. | |
The index of the player this PlayerUI represnets. | |
The index of current player. | |
The color used to draw this player’s text and outline. | |
The TraitsUI object for this PlayerUI. | |
The static text control displaying the player’s name. | |
Pointer to the window the PlayerUI is offset from. | |
The points in the UI where vertical lines are drawn. | |
The individual elements in the UI. |
| virtual void ResizeUI() |
Resizes the PlayerUI. Uses the internal TraitsUI object to set the width and height for the entire UI. Adjusts every single element in the UI to new dimensions based on its type and recomputes the layout. \ Recalculates the fonts for all the elements and for the player’s name.
|
Updates the player UI elements by calling each of their own Update functions. Each player UI element is responsible for showing/hiding itself and updating its color and counter properly. Shows and hides various components if required by a change in turn.
| object | The DataObject containing the update information. Must have a Game object as its first parameter, and a wxInt32 as the second parameter. |
|
Updates the player UI color and name if and when the players are reordered during the game.
| game | The current Game. |
| TraitsUIPtr mTraitsUI |
The TraitsUI object for this PlayerUI.
|
| ~PlayerUI() |
| void CalculateWidth() |
|
|
| virtual const TraitsUIPtr &GetTraitsUI() |
| virtual void ResizeUI() |
|
|
| wxInt32 mIndex |
| wxInt32 mDrawIndex |
| wxColour mTextColor |
| TraitsUIPtr mTraitsUI |
| boost::shared_ptr<wxStaticText> mpName |
| const wxWindow *mResizeLink |
| PointList mLineList |
| ElementHash mElements |