-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgamewinner.cpp
More file actions
77 lines (67 loc) · 3.35 KB
/
Copy pathgamewinner.cpp
File metadata and controls
77 lines (67 loc) · 3.35 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
#include "gamewinner.h"
#include "ui_gamewinner.h"
#include "filepath.h"
GameWinner::GameWinner(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::GameWinner)
{
ui->setupUi(this);
/// this is for show to how set photo on the labels and show on ui ///
markers["BattleMarker"] = "border-image:url(" + QString(BATTLE_MARKER_IMAGE) + ");" + " background-color:transparent";
markers["FavorMarker"] = "border-image:url(" + QString(PEACE_MARKER_IMAGE) + ");" + " background-color:transparent";
markers["blue"] = "border-image:url(" + QString(PLAYER_BLUE_MARKER_IMAGE) + ");" + " background-color:transparent";
markers["green"] = "border-image:url(" + QString(PLAYER_GREEN_MARKER_IMAGE) + ");" + " background-color:transparent";
markers["red"] = "border-image:url(" + QString(PLAYER_RED_MARKER_IMAGE) + ");" + " background-color:transparent";
markers["orange"] = "border-image:url(" + QString(PLAYER_ORANGE_MARKER_IMAGE) + ");" + " background-color:transparent";
markers["gray"] = "border-image:url(" + QString(PLAYER_GRAY_MARKER_IMAGE) + ");" + " background-color:transparent";
markers["brown"] = "border-image:url(" + QString(PLAYER_BROWN_MARKER_IMAGE) + ");" + " background-color:transparent";
stateLabels["HAMEDAN"] = ui->lb_hamedan; //This code is related to phase 3 of the project
stateLabels["BELLA"] = ui->lb_bella;
stateLabels["PLADACI"] = ui->lb_pladaci;
stateLabels["ROLLO"] = ui->lb_rollo;
stateLabels["ELINIA"] = ui->lb_elinia;
stateLabels["CALINE"] = ui->lb_caline;
stateLabels["BORGE"] = ui->lb_borge;
stateLabels["OLIVADI"] = ui->lb_olivadi;
stateLabels["ARMENTO"] = ui->lb_armento;
stateLabels["TALMONE"] = ui->lb_talmone;
stateLabels["ENNA"] = ui->lb_lia; //This code is related to phase 3 of the project //ui->lb_enna
stateLabels["LIA"] = ui->lb_enna; //This code is related to phase 3 of the project //ui->lb_lia
stateLabels["MORINA"] = ui->lb_morina;
stateLabels["DIMASE"] = ui->lb_dimase;
stateLabels["ATELA"] = ui->lb_atela;
}
GameWinner::~GameWinner()
{
delete ui;
}
void GameWinner::declare(const std::vector<Player> &players, const Player &winner)
{
this->show();
for(auto &&label : stateLabels) {
label.second->setStyleSheet("");
label.second->setVisible(false);
}
ui->lb_player_counter->setText("Player " + QString::number(winner.getID() + 1) + " won this game and became the emperor of the world"); // show text for winner
for (auto &&player : players) {
for (auto &&state_name : player.get_states_name()) {
stateLabels[state_name]->setStyleSheet(markers[player.getColor()]); // show color
stateLabels[state_name]->setVisible(true);
}
}
QEventLoop loop;
connect(ui->pushButton_3, SIGNAL(clicked(bool)), &loop, SLOT(quit())); //signal and slots
loop.exec();
disconnect(ui->pushButton_3, SIGNAL(clicked(bool)), &loop, SLOT(quit())); // aignal and slots
this->hide();
}
void GameWinner::on_pushButton_4_clicked()
{
exit(EXIT_SUCCESS);
}
void GameWinner::on_pushButton_3_clicked()
{
QMainWindow *menu = qobject_cast<QMainWindow*>(parent()); /// go to main menu page
menu->show();
this->hide();
}