[Kde-games-devel] A new highscore manager - KScoreManager

Parker Coates parker.coates at gmail.com
Tue Apr 29 22:37:17 CEST 2008


2008/4/29 Matt Williams <matt at milliams.com>:
> On Tuesday 29 April 2008 17:50:49 Parker Coates wrote:
>  > KScoreManager::self()->addField(KScoreDialog::Custom1, i18n(Moves Taken));
>  > KScoreManager::self()->setDisplayFields(KScoreDialog::Name |
>  > KScoreDialog::Score | KScoreDialog::Custom1);
>  >
>  > KScoreManager::ScoreInfo scoreInfo;
>  > scoreInfo[KScoreDialog::Name] = playerName;
>  > scoreInfo[KScoreDialog::Score] = playerScore;
>  > scoreInfo[KScoreDialog::Custom1] = numberOfMovesTaken;
>  >
>  > if ( KScoreManager::self()->addScore(scoreInfo) )
>  > {
>  >     KScoreDialog scoreDialog( KScoreManager::self() );
>  >     scoreDialog.show();
>  >
>  >     // OR
>  >
>  >     KGraphicsScoreItem scoreItem( KScoreManager::self() );
>  >     m_scene->addItem( scoreItem );
>  > }
>
>  Any ideas about how name entry would work, when the score board should be
>  show, who should handle the name entry, etc.? For example, in the snippet you
>  posted above, the call to addScore() is made before any UI frontend is
>  created and so the frontend won't be able to handle adding the name.
>
>  Any thoughts?

Well, what if the following methods were added to KScoreManager?

int newestScoreIndex()
QByteArray newestScoreGroup()
bool waitingForPlayerName()

The first two could be used to determine the most recently added
score. (Ignoring the problem at hand, these would still be handy for
highlighting the newest score. They could return a null value if
nothing has been added recently.) And the last method would let you
know if the KScoreManager was expecting a player name. When the
display is created/shown, it could check these, and do the right
thing. Combined with the signals and slots I mentioned in my previous
email, I think this would be sufficient to handle adding the name.

But then again there might be other problems, I'm not seeing. You're
the one doing the hard work of actually flushing these ideas out. I'm
just the guy trying to make suggestions on his lunch break. :)

Parker


More information about the kde-games-devel mailing list