-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathleaderboardnamerequest.cpp
More file actions
53 lines (48 loc) · 1.28 KB
/
Copy pathleaderboardnamerequest.cpp
File metadata and controls
53 lines (48 loc) · 1.28 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
#include "leaderboardnamerequest.h"
#include "ui_leaderboardnamerequest.h"
#include "gamedialog.h"
#include <QtDebug>
#include <QTextStream>
namespace game{
LeaderBoardNameRequest::LeaderBoardNameRequest(QString filename, game::GameDialog* gDialog, QWidget* parent) :
QDialog(parent),
ui(new Ui::leaderBoardNameRequest), filename(filename), gDialog(gDialog)
{
ui->setupUi(this);
}
LeaderBoardNameRequest::~LeaderBoardNameRequest()
{
delete ui;
}
void LeaderBoardNameRequest::on_buttonBox_accepted()
{
// prepare the string to append to
QString str;
// name
str += ui->nameTextInput->text();
// token between each string
str += "=:=";
// stage number
str += "Stage " + QString::number(gDialog->curStageNum);
// token between each string
str += "=:=";
// score
str += QString::number(gDialog->gameScore);
// new line
str += "\r\n";
// append to file
QFile file(filename);
QTextStream out(&file);
if(file.open(QIODevice::WriteOnly | QIODevice::Append)){
out << str;
}
out.flush();
// return to title screen
gDialog->commandGoToLeaderBoardMode->execute();
}
// override close event
void LeaderBoardNameRequest::reject() {
gDialog->commandGoToTitleScreenMode->execute();
QDialog::reject();
}
}