Design of the leaderboard, rules

# To do:
- Dasagne
- Easter egg
- I'm a teapot
This commit is contained in:
2024-05-07 15:31:17 +02:00
parent 51f97a7aeb
commit 8d71cbe5cf
3 changed files with 48 additions and 6 deletions

View File

@@ -7,13 +7,41 @@
#include <QSqlDatabase>
Leaderboard::Leaderboard(QWidget *parent) : QGraphicsScene(parent) {
auto* title = new QGraphicsTextItem();
title->setPlainText("Poulpes de l'espace: La dernière ligne de défense");
QGraphicsTextItem* leaderboardLabel = new QGraphicsTextItem("Leaderboard");
leaderboardLabel->setPlainText("Leaderboard");
QFont font;
font.setPointSize(20);
font.setBold(true);
leaderboardLabel->setFont(font);
leaderboardLabel->setDefaultTextColor(QColor(158, 177, 189));
title->setFont(font);
title->setDefaultTextColor(QColor(0, 231, 255));
title->setPos(0, -50);
leaderboardLabel->setPos(0, 20);
addItem(title);
addItem(leaderboardLabel);
// Add the table
leaderboardTable = new QTableView();
leaderboardTable->setStyleSheet("QTableView {"
"border: 1px solid #0A5688;" // Couleur des bordures
"color: #9EB1BD;" // Couleur du texte
"background-color: #071A22;" // Couleur de fond
"}"
"QHeaderView::section {"
"background-color: #071A22;" // Couleur de fond des en-têtes
"color: #9EB1BD;" // Couleur du texte des en-têtes
"border: 1px solid #0A5688;" // Couleur des bordures des en-têtes
"}");
// Access the corner widget
QWidget* cornerWidget = leaderboardTable->findChild<QWidget*>("qt_scrollarea_corner");
if (cornerWidget) {
// Apply the stylesheet to the corner widget
cornerWidget->setStyleSheet("background-color: #071A22;"); // Set the color to match your table's background color
}
QGraphicsProxyWidget* proxy = this->addWidget(leaderboardTable);
proxy->setPos(0, leaderboardLabel->boundingRect().height());
proxy->setPos(0, leaderboardLabel->boundingRect().height() + 50);
QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
db.setDatabaseName("leaderboard.db");
if (!db.open()) {
@@ -29,8 +57,9 @@ Leaderboard::Leaderboard(QWidget *parent) : QGraphicsScene(parent) {
leaderboardTable->setModel(leaderboardModel);
// Add the return to menu button
auto* returnButton = new QPushButton("Return to menu");
returnButton->setStyleSheet("background-color: #0A385A; color: #9EB1BD; font-size: 40px; font-weight: bold;");
QGraphicsProxyWidget* returnProxy = this->addWidget(returnButton);
returnProxy->setPos(0, leaderboardLabel->boundingRect().height() + leaderboardTable->height());
returnProxy->setPos(0, leaderboardLabel->boundingRect().height() + leaderboardTable->height() + 150);
// Connect the return to menu button to the returnToMenu slot
connect(returnButton, &QPushButton::clicked, this, &Leaderboard::returnToMenu);
}

View File

@@ -12,7 +12,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
QAction* actionHelp = new QAction(tr("&About"), this);
connect(actionHelp, SIGNAL(triggered()), this, SLOT(slot_aboutMenu()));
helpMenu->addAction(actionHelp);
this->setStyleSheet("background-color: #071A22;");
this->setStyleSheet("background-color: #071A22; color: #9EB1BD;");
}
MainWindow::~MainWindow(){
@@ -29,13 +29,13 @@ void MainWindow::slot_aboutMenu(){
"This game was made for the C++ course at the ISEN Nantes.<br><br>"
"The ships design is mainly inspired by the game Star Citizen.<br><br>"
"The game is open source and can be found on GitHub at the following link:<br>"
"<a href='https://github.com/BreizhHardware/Poulpes-de-l-Espace-La-derniere-ligne-de-Defense'>https://github.com/BreizhHardware/Poulpes-de-l-Espace-La-derniere-ligne-de-Defense</a><br><br>"
"<a style='color: white;' href='https://github.com/BreizhHardware/Poulpes-de-l-Espace-La-derniere-ligne-de-Defense'>https://github.com/BreizhHardware/Poulpes-de-l-Espace-La-derniere-ligne-de-Defense</a><br><br>"
"Enjoy the game!<br><br>"
"Star Citizen is a game by Cloud Imperium Games.<br>"
"This game is not affiliated with Star Citizen or Cloud Imperium Games.");
// This is needed to interpret the text as HTML
msgBox.setTextFormat(Qt::RichText);
msgBox.setStyleSheet("background-color: #071A22;");
msgBox.setStyleSheet("background-color: #071A22; color: #9EB1BD;");
msgBox.setModal(true);
msgBox.exec();
}

View File

@@ -6,16 +6,29 @@
Rules::Rules(QObject* parent) : QGraphicsScene(parent) {
auto* rulesText = new QGraphicsTextItem();
auto* title = new QGraphicsTextItem();
title->setPlainText("Poulpes de l'espace: La dernière ligne de défense");
QFont font;
font.setPointSize(20);
font.setBold(true);
rulesText->setFont(font);
rulesText->setDefaultTextColor(QColor(158, 177, 189));
rulesText->setPlainText("Rules are simple:\n"
" - You have to defend your base from the incoming waves of enemies.\n"
" - You can place towers on the map to help you defend.\n"
" - You can also move your personnal ship to help defend using the arrow key.\n"
" - Good luck!");
title->setFont(font);
title->setDefaultTextColor(QColor(0, 231, 255));
title->setPos(0, -50);
rulesText->setPos(0, 20);
addItem(title);
addItem(rulesText);
// Add the return to menu button
auto* returnButton = new QPushButton("Return to menu");
returnButton->setStyleSheet("background-color: #0A385A; color: #9EB1BD; font-size: 40px; font-weight: bold;");
QGraphicsProxyWidget* proxy = this->addWidget(returnButton);
proxy->setPos(0, rulesText->boundingRect().height());
proxy->setPos(0, rulesText->boundingRect().height() + 50);
// Connect the return to menu button to the returnToMenu slot
connect(returnButton, &QPushButton::clicked, this, &Rules::returnToMenu);
}