-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathminesweeper.h
More file actions
75 lines (63 loc) · 2.1 KB
/
Copy pathminesweeper.h
File metadata and controls
75 lines (63 loc) · 2.1 KB
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
#ifndef MINESWEEPER_H
#define MINESWEEPER_H
#include <qdialog.h>
#include <qpushbutton.h>
#include <qslider.h>
#include <qlabel.h>
#include <qobject.h>
#include "boardgame.h"
class Minesweeper : public BoardGame
{
Q_OBJECT
public:
Minesweeper(QObject *parent) : BoardGame(parent) {}
~Minesweeper(void) {constructed = false;}
virtual void reset(void);
virtual void refresh(QPixmap *cache);
// Game type information
virtual QSize size(void) const {return QSize(info.w, info.h);}
virtual int playerCount(void) const {return 1;}
virtual QString gameName(void) const {return tr("Minesweeper");}
virtual QString winMessage(const int player, const QString msg) const;
virtual bool aiAvailable(void) const {return false;}
virtual QSize displaySize(const QSize& disp) const;
virtual int win(void);
virtual bool mouseReleaseEvent(const ButtonState button, const QPoint& point, const int player);
protected:
virtual bool place(const QPoint& point, const int player);
virtual void paintPoint(QPainter *painter, const QRect& rect, const int id);
virtual void drawHover(QPixmap *hover, QPainter *painter, const int player);
// Game type information
virtual BoardTypes boardType(void) const {return NoLine;}
virtual QColor playerColor(int player) const {return idColor(player);}
private:
int mineCount(const QPoint& point) const;
int flagCount(const QPoint& point) const;
QColor idColor(int index) const;
enum IDs {Empty = 0, ID1, ID2, ID3, ID4, ID5, ID6, ID7, ID8, Mine, FlagBG, FlagFG, Uncovered, Background, TotalIDs, \
UncoveredPosition = 0x01000000, FlaggedPosition = 0x10000000};
static bool constructed;
struct {
bool first, died;
int w, h, total, remaining;
QPixmap flag, mine;
} info;
static const QColor idColors[TotalIDs];
};
class MinesweeperSelector : public QDialog
{
Q_OBJECT
friend class Minesweeper;
public:
MinesweeperSelector(QWidget *parent);
private slots:
void easy(void);
void medium(void);
void expert(void);
void sliderUpdate(int);
private:
QLabel *lWidth, *lHeight, *lMines;
QSlider *sWidth, *sHeight, *sMines;
QPushButton *pbEasy, *pbMedium, *pbExpert, *pbAccept;
};
#endif