~keith-penguin/kdegames/trunk

« back to all changes in this revision

Viewing changes to katomic/gamewidget.h

  • Committer: Keith Worrell
  • Date: 2009-03-18 05:35:28 UTC
  • Revision ID: keith.worrell@gmail.com-20090318053528-mx6x9c0ngmg0kg6p
imported project

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 
 
3
  Copyright (C) 1998   Andreas Wüst (AndreasWuest@gmx.de)
 
4
 
 
5
  This program is free software; you can redistribute it and/or modify
 
6
  it under the terms of the GNU General Public License as published by
 
7
  the Free Software Foundation; either version 2 of the License, or
 
8
  (at your option) any later version.
 
9
 
 
10
  This program is distributed in the hope that it will be useful,
 
11
  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
  GNU General Public License for more details.
 
14
 
 
15
  You should have received a copy of the GNU General Public License
 
16
  along with this program; if not, write to the Free Software
 
17
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
18
 
 
19
  */
 
20
#ifndef GAMEWIDGET_H
 
21
#define GAMEWIDGET_H
 
22
 
 
23
class PlayField;
 
24
class QGraphicsView;
 
25
class QTimer;
 
26
 
 
27
#include <QWidget>
 
28
 
 
29
class KAtomicHighscores;
 
30
 
 
31
class GameWidget : public QWidget
 
32
{
 
33
    Q_OBJECT
 
34
 
 
35
public:
 
36
    GameWidget ( int startingLevel, QWidget *parent );
 
37
    ~GameWidget();
 
38
 
 
39
    void enableSwitchToAnyLevel() { m_allowAnyLevelSwitch = true; }
 
40
    bool switchToAnyLevelAllowed() const { return m_allowAnyLevelSwitch; }
 
41
 
 
42
    PlayField* playfield() { return m_playField; }
 
43
 
 
44
    int currentLevel() const { return m_level; }
 
45
    QString currentMolecule() const;
 
46
    int currentScore() const { return m_moves; }
 
47
    int currentHighScore() const;
 
48
signals:
 
49
    void statsChanged(int level,int score,int highscore);
 
50
    void levelChanged(int level);
 
51
public slots:
 
52
    void prevLevel();
 
53
    void nextLevel();
 
54
 
 
55
    void saveGame();
 
56
    void loadGame();
 
57
 
 
58
    // restart current level
 
59
    void restartLevel();
 
60
 
 
61
    void gameOver(int moves);
 
62
 
 
63
    // use this slot to update the moves continually
 
64
    void updateMoves(int moves);
 
65
 
 
66
    void showHighscores ();
 
67
 
 
68
    void moveUp();
 
69
    void moveDown();
 
70
    void moveLeft();
 
71
    void moveRight();
 
72
private:
 
73
    virtual void resizeEvent( QResizeEvent* );
 
74
    void switchToLevel (int);
 
75
    /**
 
76
     * If on, katomic will allow user to switch to any
 
77
     * level even if she didn't solved it yet.
 
78
     */
 
79
    bool m_allowAnyLevelSwitch;
 
80
 
 
81
    QGraphicsView *m_view;
 
82
    PlayField *m_playField;
 
83
    /**
 
84
     * Manages highscores
 
85
     */
 
86
    KAtomicHighscores *m_highscore;
 
87
 
 
88
    int m_moves;
 
89
    /**
 
90
     * Highscore of the current level
 
91
     */
 
92
    int m_levelHighscore;
 
93
    int m_level;
 
94
    /**
 
95
     * Timer for automatic next level
 
96
     */
 
97
    QTimer *m_timer;
 
98
};
 
99
 
 
100
#endif