Add functional pos

This commit is contained in:
2024-04-11 15:57:45 +02:00
parent bcbc644fcf
commit 5df0b76f1b
3 changed files with 14 additions and 4 deletions

View File

@@ -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");
}

View File

@@ -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;

View File

@@ -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]);
}
}