-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpausewidget.cpp
109 lines (94 loc) · 2.39 KB
/
pausewidget.cpp
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
#include "pausewidget.h"
#include <QPainter>
#include <QPixmap>
#include "basicpainter.h"
#include "gamecommonitems.h"
#include "othergameinit.h"
#include "abstractrule.h"
#define LOGICAL_WIDTH 1024
#define LOGICAL_HEIGHT 600
PauseWidget::PauseWidget()
{
// Create the items and initialize them
pauseHint = new StringItem(316);
pauseHint->setPos(QPointF(0.5, 0.5));
pauseHint->setHint("Press anywhere to continue");
myItems.push_back(pauseHint);
}
void PauseWidget::makePixmap(
#ifdef USE_PIXMAP
QPixmap& pixmap,
#else
QPainter* painter,
#endif
int width,
int height)
{
#ifdef USE_PIXMAP
makeBasicPixmap(pixmap, width, height);
addEffect(pixmap, width, height);
#else
makeBasicPixmap(painter, width, height);
addEffect(painter, width, height);
#endif
}
// void PauseWidget::init();
void PauseWidget::makeBasicPixmap(
#ifdef USE_PIXMAP
QPixmap& pixmap,
#else
QPainter* painter,
#endif
int width,
int height)
{
#ifdef USE_PIXMAP
pixmap = QPixmap(width, height);
// Fill the pixmap with black background
pixmap.fill(Qt::black);
// Get the painter
QPainter *painter = new QPainter(&pixmap);
#else
painter->fillRect(0,0,width,height,QColor(0,0,0));
#endif
// Paint the items
BasicPainter::paintItems(painter,
myItems,
width,
height,
0);
#ifdef USE_PIXMAP
// End the paint and release the space
painter->end();
delete painter;
#endif
}
void PauseWidget::addEffect(
#ifdef USE_PIXMAP
QPixmap& pixmap,
#else
QPainter* painter,
#endif
int width,
int height){}
QPointF PauseWidget::toScene(double xRate, double yRate)
{
return QPointF(xRate * LOGICAL_WIDTH,
yRate * LOGICAL_HEIGHT);
}
void PauseWidget::dealPressed(QPointF mousePos, Qt::MouseButton button){}
void PauseWidget::dealMoved(QPointF mousePos, Qt::MouseButton button){}
void PauseWidget::dealReleased(QPointF mousePos, Qt::MouseButton button)
{
// Exit
emit resume();
emit giveControlTo(NULL, true);
delete this;
return;
}
PauseWidget::~PauseWidget()
{
// Release the space
for (int i = 0;i < myItems.size();++i)
delete myItems[i];
}