summaryrefslogtreecommitdiffstats
path: root/kpacman/score.h
blob: fc0da45711e2958106eb056aa8ae14c4abfd7082 (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 <tqwidget.h>
#include <tqstring.h>
#include <tqpoint.h>
#include <tqrect.h>
#include <tqfile.h>
#include <tqfileinfo.h>
#include <tqdatetime.h>

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

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

class Score : public TQWidget
{
    Q_OBJECT
public:
    Score (TQWidget *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(TQTimerEvent *);
    void paintEvent(TQPaintEvent *);
    void keyPressEvent(TQKeyEvent *);

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

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

private:
    Bitfont *bitfont;

    TQRect rect(int col, float row, TQString str, int align = AlignCenter);
    int x(int col);
    int y(float row);

    TQString formatDate(TQDate date);

		/**
		 * Ermittelt die zu benutzende "highscore"-Datei, in die auch geschrieben werden kann.
		 * Über den "highscoreFilePath"-TDEConfig-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.
		 */
    TQFileInfo 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];
    TQString playerName[maxPlayer];

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

    int cursorBlinkTimer;
    bool scrollRepeat;

    struct {
        int points;
        int levels;
        TQTime duration;
        TQDateTime moment;
        TQString name;
    } hallOfFame[10];

    TQFileInfo systemHighscoreFileInfo;
    TQFileInfo privateHighscoreFileInfo;

    TQFile highscoreFile;

    int scheme;
    int mode;
};

#endif // SCORE_H