KExtHighscore::Manager Class Reference
This class manages highscores and players entries (several players can share the same highscores list if the libkdegame library is built to support a common highscores file; NOTE that to correctly implement such feature we probably need a locking mechanism in KHighscore). More...
#include <kexthighscore.h>
Public Types | |
enum | ScoreTypeBound { ScoreNotBound, ScoreBound } |
enum | ShowMode { AlwaysShow, NeverShow, ShowForHigherScore, ShowForHighestScore } |
enum | ScoreType { Normal, MinuteTime } |
enum | ItemType { ScoreDefault, MeanScoreDefault, BestScoreDefault, ElapsedTime } |
enum | PlayerItemType { MeanScore, BestScore } |
enum | LabelType { Standard, I18N, WW, Icon } |
Public Member Functions | |
Manager (uint nbGameTypes=1, uint maxNbEntries=10) | |
virtual | ~Manager () |
void | setWWHighscores (const KURL &url, const QString &version) |
void | setTrackLostGames (bool track) |
void | setTrackDrawGames (bool track) |
void | setShowStatistics (bool show) |
void | showStatistics (bool show) KDE_DEPRECATED |
void | setShowDrawGamesStatistic (bool show) |
void | setScoreHistogram (const QMemArray< uint > &scores, ScoreTypeBound type) |
void | setShowMode (ShowMode mode) |
void | setScoreType (ScoreType type) |
void | setScoreItem (uint worstScore, Item *item) |
void | addScoreItem (const QString &name, Item *item) |
void | setPlayerItem (PlayerItemType type, Item *item) |
virtual bool | isStrictlyLess (const Score &s1, const Score &s2) const |
virtual QString | gameTypeLabel (uint gameType, LabelType type) const |
Static Public Member Functions | |
static Item * | createItem (ItemType type) |
Protected Member Functions | |
virtual void | convertLegacy (uint gameType) |
void | submitLegacyScore (const Score &score) const |
virtual void | additionalQueryItems (KURL &url, const Score &score) const |
Static Protected Member Functions | |
static void | addToQueryURL (KURL &url, const QString &item, const QString &content) |
Friends | |
class | ManagerPrivate |
Detailed Description
This class manages highscores and players entries (several players can share the same highscores list if the libkdegame library is built to support a common highscores file; NOTE that to correctly implement such feature we probably need a locking mechanism in KHighscore).You need one instance of this class during the application lifetime ; in main() just insert
KExtHighscore::Manager highscoresManager;
This class has three functions :
- Update the highscores list when new entries are submitted
- Display the highscores list and the players list
- Send query to an optionnal web server to support world-wide highscores
The highscores and the players lists contain several items described by the Item class.
The highscores list contains by default :
- the player name (automatically set from the config value)
- the score value
- the time and date of the highscore (automatically set)
The players list contains :
- the player name (as defined by the user in the configuration dialog)
- the number of games played
- the mean score
- the best score
- the best score time and date
- the player comment (as defined by the user in the configuration dialog)
To submit a new score at game end, just construct a Score, set the score data and then call submitScore().
KExtHighscore::Score score(KExtHighscore::Won); score.setScore(myScore); KExtHighscore::submitScore(score, widget);
Definition at line 139 of file kexthighscore.h.
Member Enumeration Documentation
|
Score type (.
Definition at line 231 of file kexthighscore.h. |
|
Some predefined item types.
Definition at line 248 of file kexthighscore.h. |
|
Possible type of label (.
Definition at line 296 of file kexthighscore.h. |
Constructor & Destructor Documentation
|
Constructor.
Definition at line 109 of file kexthighscore.cpp. References KExtHighscore::ManagerPrivate::init(), KExtHighscore::internal, and ManagerPrivate. |
Member Function Documentation
|
Set the world-wide highscores. By default there is no world-wide highscores. Note: should be called at construction time.
Definition at line 150 of file kexthighscore.cpp. References KExtHighscore::internal, KExtHighscore::ManagerPrivate::serverURL, and KExtHighscore::ManagerPrivate::version. |
|
Set if the number of lost games should be track for the world-wide highscores statistics. By default, there is no tracking. False by default. Note: should be called at construction time. Definition at line 125 of file kexthighscore.cpp. References KExtHighscore::internal, and KExtHighscore::ManagerPrivate::trackLostGames. |
|
Definition at line 130 of file kexthighscore.cpp. References KExtHighscore::internal, and KExtHighscore::ManagerPrivate::trackDrawGames. |
|
Definition at line 135 of file kexthighscore.cpp. References KExtHighscore::internal, and KExtHighscore::ManagerPrivate::showStatistics. |
|
Definition at line 140 of file kexthighscore.cpp. References KExtHighscore::internal, and KExtHighscore::ManagerPrivate::showStatistics. |
|
Definition at line 145 of file kexthighscore.cpp. References KExtHighscore::internal, and KExtHighscore::ManagerPrivate::showDrawGames. |
|
Set the ranges for the score histogram. Note: should be called at construction time. Definition at line 162 of file kexthighscore.cpp. References KExtHighscore::PlayerInfos::createHistoItems(), KExtHighscore::internal, KExtHighscore::ManagerPrivate::playerInfos(), and QMemArray::size(). |
|
Set how the highscores dialog is shown at game end. By default, the mode is ShowForHigherScore. Note: should be called at construction time. Definition at line 171 of file kexthighscore.cpp. References KExtHighscore::internal, and KExtHighscore::ManagerPrivate::showMode. |
|
Set score type. Helper method to quickly set the type of score. By default the type is Normal. Note: should be called at construction time. Definition at line 176 of file kexthighscore.cpp. References createItem(), setPlayerItem(), KExtHighscore::Item::setPrettyFormat(), and setScoreItem(). |
|
Create a predefined item.
Definition at line 208 of file kexthighscore.cpp. References KExtHighscore::Item::setPrettyFormat(), and KExtHighscore::Item::setPrettySpecial(). Referenced by KExtHighscore::PlayerInfos::PlayerInfos(), KExtHighscore::ScoreInfos::ScoreInfos(), and setScoreType(). |
|
Replace the default score item in the highscores list by the given one.
Note : This method should be called at construction time. Definition at line 233 of file kexthighscore.cpp. References KExtHighscore::internal, KExtHighscore::ItemContainer::item(), KExtHighscore::ItemArray::item(), KExtHighscore::ManagerPrivate::playerInfos(), KExtHighscore::ManagerPrivate::scoreInfos(), KExtHighscore::Item::setDefaultValue(), and KExtHighscore::ItemArray::setItem(). Referenced by setScoreType(). |
|
Add an item in the highscores list (it will add a column to this list). Note : This method should be called at construction time. Definition at line 243 of file kexthighscore.cpp. References KExtHighscore::ItemArray::addItem(), KExtHighscore::internal, and KExtHighscore::ManagerPrivate::scoreInfos(). |
|
Replace an item in the players list. Note : This method should be called at construction time. Definition at line 248 of file kexthighscore.cpp. References KExtHighscore::Item::defaultValue(), KExtHighscore::internal, KExtHighscore::ItemContainer::item(), KExtHighscore::ItemArray::item(), KExtHighscore::ManagerPrivate::playerInfos(), KExtHighscore::ManagerPrivate::scoreInfos(), KExtHighscore::Item::setDefaultValue(), KExtHighscore::ItemArray::setItem(), and QVariant::toUInt(). Referenced by setScoreType(). |
|
s1<s2since the operator calls this method. Definition at line 203 of file kexthighscore.cpp. References KExtHighscore::Score::score(). Referenced by KExtHighscore::Score::operator<(). |
|
Definition at line 266 of file kexthighscore.cpp. Referenced by KExtHighscore::ManagerPrivate::exportHighscores(), KExtHighscore::HighscoresDialog::HighscoresDialog(), KExtHighscore::ManagerPrivate::queryURL(), and KExtHighscore::ManagerPrivate::setGameType(). |
|
This method is called once for each player (ie for each user). You can reimplement it to convert old style highscores to the new mechanism (
Definition at line 313 of file kexthighscore.h. Referenced by KExtHighscore::ManagerPrivate::setGameType(). |
|
This method should be called from convertLegacy. It is used to submit an old highscore (it will not be send over the network). For each score do something like: Score score(Won); score.setScore(oldScore); score.setData("name", name); submitLegacyScore(score); Definition at line 198 of file kexthighscore.cpp. References KExtHighscore::internal, and KExtHighscore::ManagerPrivate::submitLocal(). |
|
This method is called before submitting a score to the world-wide highscores server. You can reimplement this method to add an entry with addToQueryURL. By default this method does nothing.
Definition at line 338 of file kexthighscore.h. |
|
Add an entry to the url to be submitted (.
Definition at line 280 of file kexthighscore.cpp. References QString::isEmpty(). Referenced by KExtHighscore::ManagerPrivate::modifySettings(), and KExtHighscore::ManagerPrivate::queryURL(). |
The documentation for this class was generated from the following files: