-
Notifications
You must be signed in to change notification settings - Fork 0
/
gamehistory.cpp
63 lines (58 loc) · 1.48 KB
/
gamehistory.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
#include "gamehistory.h"
#include "ui_gamehistory.h"
#include <fstream>
#include <iostream>
using namespace std;
GameHistory::GameHistory(QString n1, QString n2, int row, QWidget *parent) :
QDialog(parent),
ui(new Ui::GameHistory)
{
ui->setupUi(this);
check(row);
ui->label->setText(n1);
ui->label_2->setText(n2);
}
GameHistory::~GameHistory()
{
delete ui;
}
void GameHistory::check(int row){
ifstream file("History.txt");
for(int i = 0; i < 3 + (4 * row); i++)
file.ignore(std::numeric_limits<std::streamsize>::max(),'\n');
int t;
file >> t;
showGameHistory(ui->pushButton, t);
file >> t;
showGameHistory(ui->pushButton_2, t);
file >> t;
showGameHistory(ui->pushButton_3, t);
file >> t;
showGameHistory(ui->pushButton_4, t);
file >> t;
showGameHistory(ui->pushButton_5, t);
file >> t;
showGameHistory(ui->pushButton_6, t);
file >> t;
showGameHistory(ui->pushButton_7, t);
file >> t;
showGameHistory(ui->pushButton_8, t);
file >> t;
showGameHistory(ui->pushButton_9, t);
file.close();
}
void GameHistory::showGameHistory(QPushButton *n, int t)
{
if(t == 1){
QPixmap pixmap(":/shape/2.png");
QIcon ButtonIcon(pixmap);
n->setIcon(ButtonIcon);
n->setIconSize(QSize(100,100));
}
else if(t == 2){
QPixmap pixmap(":/shape/1.png");
QIcon ButtonIcon(pixmap);
n->setIcon(ButtonIcon);
n->setIconSize(QSize(100,100));
}
}