20#include "kexthighscore.h"
26#include "kexthighscore_internal.h"
27#include "kexthighscore_gui.h"
30namespace KExtHighscore
34ManagerPrivate *internal = 0;
38 internal->checkFirst();
39 return internal->gameType();
42void setGameType(uint type)
44 internal->setGameType(type);
47bool configure(TQWidget *parent)
49 internal->checkFirst();
50 ConfigDialog *cd =
new ConfigDialog(parent);
52 bool saved = cd->hasBeenSaved();
57void show(TQWidget *parent,
int rank)
59 HighscoresDialog *hd =
new HighscoresDialog(rank, parent);
64void submitScore(
const Score &score, TQWidget *widget)
66 int rank = internal->submitScore(score, widget,
69 switch (internal->showMode) {
74 if ( rank!=-1) show(widget, rank);
77 if ( rank==0 ) show(widget, rank);
84void show(TQWidget *widget)
86 internal->checkFirst();
92 internal->checkFirst();
93 internal->hsConfig().readCurrentConfig();
94 uint nb = internal->scoreInfos().maxNbEntries();
95 return internal->readScore(nb-1);
100 internal->checkFirst();
101 internal->hsConfig().readCurrentConfig();
102 return internal->readScore(0);
109 Q_ASSERT(nbGameTypes);
110 Q_ASSERT(maxNbEntries);
112 kdFatal(11002) <<
"A highscore object already exists" << endl;
113 internal =
new ManagerPrivate(nbGameTypes, *
this);
114 internal->init(maxNbEntries);
125 internal->trackLostGames = track;
130 internal->trackDrawGames = track;
135 internal->showStatistics = show;
140 internal->showStatistics = show;
145 internal->showDrawGames = show;
151 Q_ASSERT( scores.size()>=2 );
152 for (uint i=0; i<scores.size()-1; i++)
153 Q_ASSERT( scores[i]<scores[i+1] );
154 internal->playerInfos().createHistoItems(scores, type==ScoreBound);
159 internal->showMode = mode;
186 internal->submitLocal(score);
199 item =
new Item((uint)0, i18n(
"Score"), TQt::AlignRight);
201 case MeanScoreDefault:
202 item =
new Item((
double)0, i18n(
"Mean Score"), TQt::AlignRight);
206 case BestScoreDefault:
207 item =
new Item((uint)0, i18n(
"Best Score"), TQt::AlignRight);
211 item =
new Item((uint)0, i18n(
"Elapsed Time"), TQt::AlignRight);
222 internal->scoreInfos().setItem(
"score", item);
223 internal->playerInfos().item(
"mean score")
224 ->item()->setDefaultValue(
double(worstScore));
225 internal->playerInfos().item(
"best score")
226 ->item()->setDefaultValue(worstScore);
231 internal->scoreInfos().addItem(name, item,
true);
236 const Item *scoreItem = internal->scoreInfos().item(
"score")->item();
249 internal->playerInfos().setItem(name, item);
255 kdFatal(11002) <<
"You need to reimplement KExtHighscore::Manager for "
256 <<
"multiple game types" << endl;
261 case WW:
return "normal";
This class defines how to convert and how to display a highscore element (such as the score,...
void setDefaultValue(const TQVariant &value)
Set default value.
const TQVariant & defaultValue() const
void setPrettyFormat(Format format)
Set the display format.
void setPrettySpecial(Special special)
Set the special value for display.
void setTrackDrawGames(bool track)
void setPlayerItem(PlayerItemType type, Item *item)
Replace an item in the players list.
void setShowMode(ShowMode mode)
Set how the highscores dialog is shown at game end.
ShowMode
Enumerate different conditions under which to show the high score dialog.
@ AlwaysShow
Always show the dialog.
@ NeverShow
Never show the dialog.
@ ShowForHighestScore
Only for the top spot.
@ ShowForHigherScore
Show if score has improved.
ItemType
Some predefined item types.
void setTrackLostGames(bool track)
Set if the number of lost games should be track for the world-wide highscores statistics.
LabelType
Possible type of label (.
void setScoreItem(uint worstScore, Item *item)
Replace the default score item in the highscores list by the given one.
void setShowStatistics(bool show)
static Item * createItem(ItemType type)
Create a predefined item.
virtual bool isStrictlyLess(const Score &s1, const Score &s2) const
Manager(uint nbGameTypes=1, uint maxNbEntries=10)
Constructor.
virtual TQString gameTypeLabel(uint gameType, LabelType type) const
void showStatistics(bool show) TDE_DEPRECATED
void addScoreItem(const TQString &name, Item *item)
Add an item in the highscores list (it will add a column to this list).
void setScoreHistogram(const TQMemArray< uint > &scores, ScoreTypeBound type)
Set the ranges for the score histogram.
void setScoreType(ScoreType type)
Set score type.
void submitLegacyScore(const Score &score) const
This method should be called from convertLegacy.
void setShowDrawGamesStatistic(bool show)
This class contains data for a score.