/*************************************************************************** Description : KPuzzle - A KDE Jigsaw Puzzle Game Version : 0.2 Copyright : (C) 2000-2001 by Michael Wand EMail : mwand@gmx.de ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #ifndef HIGHSCORE_H #define HIGHSCORE_H #include #include #include #include #include #include #include #define MAX_HIGHSCORES 5 /* This class encapsulates a list element in the highscore list */ class CListElement { public: CListElement(int s, QString n) { _score = s; _name = n; } int _score; QString _name; }; /* This class encapsulates the highscore dialog. It may appear in two different * ways, either automatically after a game, or manually called by the user. In * the first case, a "Your score" widget will appear in the dialog. */ class CHighscoreDialog : public QDialog { Q_OBJECT public: /* Constructor with the additional parameter ys (the number which must * be shown in the "Your Score" field). The "Your Score" field will be * invisible if ys == 0. * Additionally, if ys != 0, the initializeDialog() function will prompt * for the player's name if necessary. * This function only creates the widget structure for the dialog, * all data is initialized by the initializeDialog() function. */ CHighscoreDialog(QWidget* parent,int ys); /* Initializes all dialog data. Prompts for the player's name if * he has earned a place in the highscore list. */ void initializeDialog(); /* Destructor. */ virtual ~CHighscoreDialog(); protected: /* Show a dialog which prompts the user for his name, and * return this name. */ QString nameDialog(); /* unused XXX */ void getHighscoreFile(QString& name); /* Read the highscore list from a file, return the position * of the player in the list (with respect to _yourScore). * The filename is QDir::homeDirPath() + HIGHSCORE_FILE_NAME. */ char readList(); /* Writes the highscore list to a file. */ bool writeList(); /* The score of the current player. If this variable is 0, it * means that the dialog has been called manually by the player. */ int _yourScore; /* The component widgets. */ QLabel* _yourResult; QListBox* _listBox; QPushButton* _ok; QVBoxLayout* _vbox; /* The very highscore list. */ QPtrList* _list; }; #endif /* HIGHSCORE_H */