PlayerData

Describes a piece of information that needs to be displayed in the PlayerUI.  A RuleSet may add a number of different pieces of information to the Game that the players will want to have visual represntation of.  The struct PlayerData provides a way for RuleSets to detail to the PlayerUI the information needed to maintain a UI element inside a PlayerUI.

There are two types of PlayerData.  The first uses a bitmap retrieved from an ImageSet as its icon or graphic.  The second uses an image rendered by OpenGL as its icon or graphic (usually stock items since they are actual game objects).  PlayerData must provide an update function that the PlayerUI can call when it needs to recalculate any counter associated with the PlayerData.  It also can optionally provide a color function that returns the text color the counter should be displayed in.  Both the update and the color function are boost::function objects.  All PlayerData is created with a certain category type that tells the PlayerUI where that PlayerData belongs in the screen layout.  The types are given by the PlayerDataType enum.  And finally, a piece of PlayerData may also provide a threshold value.  If the current counter returned by the update function is less than or equal to the threshold value, the UI element is hidden.  A threshold of -1 indicates that the UI element will always remain visible, even if its count goes to zero.

NOTE: PlayerData should be created by either the <IMPLEMENT_PLAYER_IMAGE_DATA> or the <IMPLEMENT_PLAYER_OPENGL_DATA> macro in <RuleSetDatabase>.

Project

RulesCore

Include

PlayerData.h

Summary
Describes a piece of information that needs to be displayed in the PlayerUI.
The ImageSet bitmap PlayerData constructor.
The OpenGL-rendered bitmap PlayerData constructor.
The layout “bucket” the PlayerData falls into.
The counter update function object.
The counter color function object.
The visibility threshold.
The image key group.
The image name.
The IGameObject used to render the PlayerData.
The IDrawObject used to render the PlayerData in OpenGL.

Constructors

PlayerData

PlayerData(const PlayerDataType type,
const PlayerUpdateFunc &update,
const PlayerColorFunc &color,
const wxInt32 threshold,
const wxString &imageKey,
const wxString &imageName) : mPlayerDataType(type), mUpdateFunc(update), mColorFunc(color), mThreshold(threshold), mImageKey(imageKey), mImageName(imageName)

The ImageSet bitmap PlayerData constructor.  Creates a PlayerData that uses the given ImageSet image key and image name to create its screen bitmap.

Parameters

typeThe PlayerUI layout category.
updateThe counter update function.  A boost::function object.
colorThe counter color function.  A boost::function object.
thresholdThe visibility threshold.  See PlayerData remarks.
imageKeyThe ImageSet image group key of the bitmap of the PlayerData.
imageNameThe image name within the group given by the image key.

PlayerData

PlayerData(const PlayerDataType type,
const PlayerUpdateFunc &update,
const PlayerColorFunc &color,
const wxInt32 threshold,
const GameObjectPtr &gameObject,
const DrawObjectPtr &drawObject) : mPlayerDataType(type), mUpdateFunc(update), mColorFunc(color), mThreshold(threshold), mGameObject(gameObject), mDrawObject(drawObject)

The OpenGL-rendered bitmap PlayerData constructor.  Creates a PlayerData that uses the given IGameObject and IDrawObject to create its screen bitmap.

Parameters

typeThe PlayerUI layout category.
updateThe counter update function.  A boost::function object.
colorThe counter color function.  A boost::function object.
thresholdThe visibility threshold.  See PlayerData remarks.
gameObjectThe IGameObject representing the type of model to draw.
drawObjectThe IDrawObject that renders the IGameObject in OpenGL.

Variables

mPlayerDataType

PlayerDataType mPlayerDataType

The layout “bucket” the PlayerData falls into.  The PlayerUI groups all PlayerData by buckets and then lays them out on screen according to its internal logic.

mUpdateFunc

PlayerUpdateFunc mUpdateFunc

The counter update function object.  A boost::function object that must be in the form wxInt32 func(GamePtr, wxInt32).  Should return the current count for the piece of PlayerData.

mColorFunc

PlayerColorFunc mColorFunc

The counter color function object.  Optional.  A boost::function object that must be in the form wxColour func(GamePtr, wxInt32).  If existant, should return the text color for the current cout of the piece of PlayerData.

mThreshold

wxInt32 mThreshold

The visibility threshold.  PlayerData may have a threshold beneath which it should not be visible.  For example, if a player has 0 timber, the timber card in their PlayerUI should be hidden.  By setting mThreshold to 0, this effect is achieved.  A value of -1 means the data is always shown.  A positive value (or zero) means the data is shown only when its update function returns a number greater than the threshold.

mImageKey

wxString mImageKey

The image key group.  If the value is not empty, the PlayerData is assumed to be using the IImageEngine and an ImageSet to produce its screen bitmap.  If empty, the OpenGL fields are used.

mImageName

wxString mImageName

The image name.  Used in conjunction with the image key to retrieve the screen bitmap image from an ImageSet within the IImageEngine.

mGameObject

GameObjectPtr mGameObject

The IGameObject used to render the PlayerData.  An IDrawObject must always have an IGameObject to refer to when it renders itself in OpenGL.

mDrawObject

DrawObjectPtr mDrawObject

The IDrawObject used to render the PlayerData in OpenGL.

Displays game information for one player.
PlayerData(const PlayerDataType type,
const PlayerUpdateFunc &update,
const PlayerColorFunc &color,
const wxInt32 threshold,
const wxString &imageKey,
const wxString &imageName) : mPlayerDataType(type), mUpdateFunc(update), mColorFunc(color), mThreshold(threshold), mImageKey(imageKey), mImageName(imageName)
The ImageSet bitmap PlayerData constructor.
A repository of knowledge about a .tex file.
PlayerDataType mPlayerDataType
The layout “bucket” the PlayerData falls into.
PlayerUpdateFunc mUpdateFunc
The counter update function object.
PlayerColorFunc mColorFunc
The counter color function object.
wxInt32 mThreshold
The visibility threshold.
wxString mImageKey
The image key group.
wxString mImageName
The image name.
GameObjectPtr mGameObject
The IGameObject used to render the PlayerData.
An interface for all game objects.
DrawObjectPtr mDrawObject
The IDrawObject used to render the PlayerData in OpenGL.
The interface for objects that are drawn on screen.
A repository of all things rules-related.
Still volatile.
RulesCore is the HOSS of Cities3D.
The interface of the image engine.