diff --git a/InGame.cpp b/InGame.cpp index 1ecaa84..deb9c78 100644 --- a/InGame.cpp +++ b/InGame.cpp @@ -11,6 +11,10 @@ InGame::InGame(QWidget *parent) : QWidget(parent) { this->y->setStyleSheet("font-size: 32px; color: black;"); this->time = new QLabel("Time : 0m0s", this); this->time->setStyleSheet("font-size: 32px; color: black;"); + this->speed = new QLabel("Vitesse : 0", this); + this->speed->setStyleSheet("font-size: 32px; color: black;"); + this->angle = new QLabel("Angle : 0", this); + this->angle->setStyleSheet("font-size: 32px; color: black;"); this->mainLayout->addWidget(pts); @@ -46,6 +50,16 @@ void InGame::updatePos(const std::string x, const std::string y) const this->y->setText("Y : " + QString::fromStdString(y)); } +void InGame::updateSpeed(const std::string speed) const +{ + this->speed->setText("Vitesse : " + QString::fromStdString(speed)); +} + +void InGame::updateAngle(const std::string angle) const +{ + this->angle->setText("Angle : " + QString::fromStdString(angle)); +} + void InGame::showEvent(QShowEvent* event) { @@ -60,4 +74,6 @@ void InGame::updateTime() int sec = this->timeCounter % 60; this->time->setText("Time : " + QString::number(min) + "m" + QString::number(sec) + "s"); emit askTCPServer("ihm;strat;get pos;1"); + emit askTCPServer("ihm;strat;get speed;1"); + emit askTCPServer("ihm;strat;get angle;1"); } diff --git a/InGame.h b/InGame.h index e08c6cc..cfbc9e4 100644 --- a/InGame.h +++ b/InGame.h @@ -13,6 +13,10 @@ public: void updatePos(std::string x, std::string y) const; + void updateSpeed(std::string speed) const; + + void updateAngle(std::string angle) const; + void updateTime(); void showEvent(QShowEvent* event) override; @@ -25,6 +29,8 @@ private: QLabel* x; QLabel* y; QLabel* time; + QLabel* speed; + QLabel* angle; QVBoxLayout* mainLayout; QHBoxLayout* posAndTimeLayout; QVBoxLayout* posLayout; diff --git a/MainWindow.cpp b/MainWindow.cpp index ed6712e..ff8cc97 100644 --- a/MainWindow.cpp +++ b/MainWindow.cpp @@ -237,4 +237,12 @@ void MainWindow::handleMessage(const std::string& message) std::vector msg = TCPSocket::split(list[3], ","); this->inGame->updatePos(std::to_string(std::stoi(msg[0])), std::to_string(std::stoi(msg[1]))); } + else if (list[2] == "set speed") + { + this->inGame->updateSpeed(list[3]); + } + else if (list[2] == "set angle") + { + this->inGame->updateAngle(list[3]); + } }