From 5df0b76f1bbb137d91b8db729a60150146129d91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20MARQUET?= Date: Thu, 11 Apr 2024 15:57:45 +0200 Subject: [PATCH] Add functional pos --- InGame.cpp | 8 +++++--- InGame.h | 5 ++++- MainWindow.cpp | 5 +++++ 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/InGame.cpp b/InGame.cpp index e336abb..9e4cde5 100644 --- a/InGame.cpp +++ b/InGame.cpp @@ -40,12 +40,13 @@ void InGame::updateScode(const int score) const this->pts->setText("Points : " + QString::number(score)); } -void InGame::updatePos(const int x, const int y) const +void InGame::updatePos(const std::string x, const std::string y) const { - this->x->setText("X : " + QString::number(x)); - this->y->setText("Y : " + QString::number(y)); + this->x->setText("X : " + QString::fromStdString(x)); + this->y->setText("Y : " + QString::fromStdString(y)); } + void InGame::showEvent(QShowEvent* event) { QWidget::showEvent(event); @@ -58,4 +59,5 @@ void InGame::updateTime() int min = this->timeCounter / 60; int sec = this->timeCounter % 60; this->time->setText("Time : " + QString::number(min) + "m" + QString::number(sec) + "s"); + emit askTCPServer("ihm;start;get pos;1"); } diff --git a/InGame.h b/InGame.h index 63c6b4b..4d2cf23 100644 --- a/InGame.h +++ b/InGame.h @@ -11,12 +11,15 @@ public: void updateScode(int score) const; - void updatePos(int x, int y) const; + void updatePos(std::string x, std::string y) const; void updateTime(); void showEvent(QShowEvent* event) override; +signals: + askTCPServer(const std::string& message); + private: QLabel* pts; QLabel* x; diff --git a/MainWindow.cpp b/MainWindow.cpp index 1b05bd9..ec61b9e 100644 --- a/MainWindow.cpp +++ b/MainWindow.cpp @@ -234,4 +234,9 @@ void MainWindow::handleMessage(const std::string& message) { this->turnOnTheWindow(); } + else if (list[2] == "set pos") + { + auto msg = TCPSocket::split(list[3], ";"); + this->inGame->updatePos(msg[0], msg[1]); + } }