summaryrefslogtreecommitdiffstats
path: root/kpacman/score.h
blob: 8f6a644f97ed6a204f653774b154efd196500599 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#ifndef SCORE_H
#define SCORE_H

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <kapp.h>
#include <qwidget.h>
#include <qstring.h>
#include <qpoint.h>
#include <qrect.h>
#include <qfile.h>

#include <qfileinfo.h>
#include <qdatetime.h>

#include "painter.h"
#include "bitfont.h"

#define maxPlayer 1
#define minPlayerNameLength 3
#define highscoreName "highscore"

class Score : public QWidget
{
    Q_OBJECT
public:
    Score (QWidget *parent=0, const char *name=0, int scheme=-1, int mode=-1, Bitfont *font=0);
    ~Score();

public slots:
    void setScheme(int scheme, int mode, Bitfont *font=0);

    void set(int score);
    void set(int score, int player);
    void setScore(int level, int player);
    void setPause(bool paused);

    void initKeys();

private slots:
    void read();
    void write();
    void end();

signals:
    void gameFinished();
    void gameHighscores();

protected:
    void timerEvent(QTimerEvent *);
    void paintEvent(QPaintEvent *);
    void keyPressEvent(QKeyEvent *);

    void focusInEvent(QFocusEvent *) { ; }
    void focusOutEvent(QFocusEvent *) { ; }

    void confScheme();
    void confTiming(bool defGroup=TRUE);

private:
    Bitfont *bitfont;

    QRect rect(int col, float row, QString str, int align = AlignCenter);
    int x(int col);
    int y(float row);

    QString formatDate(QDate date);

		/**
		 * Ermittelt die zu benutzende "highscore"-Datei, in die auch geschrieben werden kann.
		 * �ber den "highscoreFilePath"-KConfig-Eintrag, kann abweichend von der Standardlokation
		 * der Standort der "highscore"-Datei spezifiziert werden.
		 * Wenn die systemweite "globale" Datei nicht beschrieben werden kann, wird mit einer
		 * privaten Datei gearbeitet.
		 */
    QFileInfo locateHighscoreFilePath();

    int cursorBlinkMS;
    int hallOfFameMS;
    int afterPauseMS;

    bool paused;

    uint UpKey;
    uint DownKey;
    uint RightKey;
    uint LeftKey;

    int lastScore;
    int lastPlayer;
    int HighScore;
    int playerScore[maxPlayer];
    QString playerName[maxPlayer];

    struct {
        int x;
        int y;
        QChar chr;
        bool on;
    } cursor;

    int cursorBlinkTimer;
    bool scrollRepeat;

    struct {
        int points;
        int levels;
        QTime duration;
        QDateTime moment;
        QString name;
    } hallOfFame[10];

    QFileInfo systemHighscoreFileInfo;
    QFileInfo privateHighscoreFileInfo;

    QFile highscoreFile;

    int scheme;
    int mode;
};

#endif // SCORE_H