-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathendshow.cpp
More file actions
79 lines (75 loc) · 2.65 KB
/
Copy pathendshow.cpp
File metadata and controls
79 lines (75 loc) · 2.65 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
76
77
78
79
#include "endshow.h"
#include "ui_endshow.h"
#include<QMovie>
#include<QDir>
EndShow::EndShow(QWidget *parent) :
QDialog(parent),
ui(new Ui::EndShow)
{
ui->setupUi(this);
//this->setAttribute(Qt::WA_DeleteOnClose,true);
toolplayer=new QMediaPlayer;
toolplayer2=new QMediaPlayer;
}
void EndShow::otherOperation(){
gameovervoice();gameovervoice2();
QString text="";
integralRecord=winP->Integral;
if(winP->num==2){text="Moon GG!!!\nMoon Integral:";text+=QString::number(loseP->Integral);text+="\nSun Integral:";text+=QString::number(winP->Integral);text+='\n';}
else if(winP->num==1){text="Sun GG!!! \nSun Integral:";text+=QString::number(loseP->Integral);text+="\nMoon Integral:";text+=QString::number(winP->Integral);text+='\n';}
text+="Time Using:";text+=TimeText;
ui->text->setText(text);
QMovie* move = new QMovie(QDir::currentPath()+"/pic/gameovervideo.gif");
ui->moive->setMovie(move);
if(PauseSave::name.length()!=0&&PauseSave::id.length()!=0){
QString cnt="";
cnt+=PauseSave::name;cnt+=" ";cnt+=PauseSave::id;cnt+=" ";cnt+=QString::number(integralRecord);cnt+=" ";cnt+=TimeText;cnt+='\n';
writetoFile(cnt);
}
move->start();
}
void EndShow::gameovervoice(){
toolplayer->setMedia(QUrl::fromLocalFile(QDir::currentPath()+"/music/03.mp3"));
toolplayer->setVolume(24);toolplayer->play();
}
void EndShow::gameovervoice2(){
toolplayer2->setMedia(QUrl::fromLocalFile(QDir::currentPath()+"/music/04.mp3"));
toolplayer2->setVolume(24);toolplayer2->play();
}
void EndShow::writetoFile(QString cnt){
QFile file("RankData.txt");
if(!file.open(QIODevice::Append|QIODevice::Text)){QMessageBox::critical(this,"error","file open abnormal,nothing save","comfirm");return;}
QTextStream out(&file);
out<<cnt;
file.close();
}
EndShow::~EndShow()
{
delete ui;
}
void EndShow::closeEvent(QCloseEvent *event){
toolplayer->stop();toolplayer2->stop();
switch( QMessageBox::information( this, tr("exit tip"), tr("Do you really want exit?"), tr("Yes"), tr("No"), 0, 1 ) )
{
case 0:
event->accept();
break;
case 1:
default:
event->ignore();
break;
}
}
void EndShow::on_pushButton_clicked()//游戏结束,直接结束进程
{
toolplayer->stop();toolplayer2->stop();
gameover=true;
this->close();
}
void EndShow::on_pushButton_3_clicked()//游戏排行榜出现
{
toolplayer->stop();toolplayer2->stop();
Ranking*r=new Ranking;
r->heroeslist();
r->exec();
}