-
Notifications
You must be signed in to change notification settings - Fork 0
/
gamedialogs.cpp
159 lines (115 loc) · 4.03 KB
/
gamedialogs.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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
#include "gamedialogs.h"
#include "scaler.h"
#include "gamestock.h"
#include "gamebutton.h"
////////////////////////////////////////////////////////////////////////////////
class GradientButton : public GameButton
{
public:
GradientButton(GamePanel *parent, const QRect &rect, const QString &text) :
GameButton(parent, rect, text)
{
setBackground(Qt::NoBrush);
setPen(QPen(QColor(Qt::white), 2));
setHoverBackground(QColor(0x2076b1));
setTextColor(Qt::white);
setTextHoverColor(Qt::white);
setFont(&gameStock->Font20);
}
};
////////////////////////////////////////////////////////////////////////////////
#define ID_CANCEL 0
#define ID_OK 1
////////////////////////////////////////////////////////////////////////////////
LevelWinDialog::LevelWinDialog(GamePanelControl *panelControl) :
GamePanel(panelControl, QRect(100,10,1024-100*2,768-20-70))
{
setBlocking();
setInsensitive();
//setBackBorderPaint(false);
setOpacity(0.9);
setPen(QPen(QColor(0x00ddff), 1));
setBackground(QColor(0x4b97c4));
setHoverPaint(false);
buttonOk = new GradientButton(this, QRect(1024-100-100-100-250,530,250,75), tr("Next Level"));
buttonOk->setId(ID_OK);
buttonOk->setPicture(&gameStock->Ok);
buttonCancel = new GradientButton(this, QRect(100,530,250,75), tr("Exit to Menu"));
buttonCancel->setId(ID_CANCEL);
buttonCancel->setPicture(&gameStock->Cancel);
}
void LevelWinDialog::paintContent(QPainter &p)
{
GamePanel::paintContent(p);
p.setOpacity(1);
p.setFont(gameStock->Font40);
p.setPen(QPen(QColor(0x030055)));
drawHCentered(p, 50, tr("Level %1 completed!").arg(level));
p.setFont(gameStock->Font20);
const int y30 = DY(40);
const int x1 = DX(300), x2 = DX(380), x3 = DX(600);
const int y1 = DY(250), y2 = DY(350);
p.drawPixmap(x1,y1, gameStock->Clock);
p.drawText(x3,y1+y30, QString("%1:%2").arg(time/60, 2, 10, QChar('0')).arg(time%60, 2, 10, QChar('0')));
p.drawPixmap(x1,y2, gameStock->Score);
p.drawText(x3,y2+y30, QString::number(score));
p.setPen(QPen(Qt::black));
p.drawText(x2,y1+y30, tr("Time left:"));
p.drawText(x2,y2+y30, tr("Score:"));
}
void LevelWinDialog::subcontrolClicked(int id)
{
switch (id)
{
case ID_OK:
emit okClicked();
close();
break;
case ID_CANCEL:
emit cancelClicked();
close();
break;
}
}
////////////////////////////////////////////////////////////////////////////////
LevelFailDialog::LevelFailDialog(GamePanelControl *panelControl) :
LevelWinDialog(panelControl)
{
buttonOk->setText(tr("Restart Level"));
}
void LevelFailDialog::paintContent(QPainter &p)
{
GamePanel::paintContent(p);
p.setOpacity(1);
p.setFont(gameStock->Font40);
p.setPen(QPen(QColor(0x030055)));
drawHCentered(p, 50, tr("Level %1 failed :(").arg(level));
p.setFont(gameStock->Font20);
drawHCentered(p, 250, tr("Hope next time you'll do it better..."));
}
////////////////////////////////////////////////////////////////////////////////
GameWinDialog::GameWinDialog(GamePanelControl *panelControl) :
LevelWinDialog(panelControl)
{
buttonOk->setInvisible();
buttonCancel->setPosition(QPoint((rect().width()-250)/2, buttonCancel->rect().y()));
}
void GameWinDialog::paintContent(QPainter &p)
{
GamePanel::paintContent(p);
p.setOpacity(1);
p.setFont(gameStock->Font60);
p.setPen(QPen(QColor(0x030055)));
drawHCentered(p, 50, tr("You're the Winner!"));
p.setFont(gameStock->Font40);
drawHCentered(p, 200, tr("You finished all the levels!"));
p.setFont(gameStock->Font20);
const int y30 = DY(40);
const int x1 = DX(300), x2 = DX(420), x3 = DX(600);
const int /*y1 = DY(250), */y2 = DY(350)/*, y3 = DY(350)*/;
p.drawPixmap(x1,y2, gameStock->Score);
p.drawText(x3,y2+y30, QString::number(score));
p.setPen(QPen(Qt::black));
p.drawText(x2,y2+y30, tr("Score:"));
}
////////////////////////////////////////////////////////////////////////////////