Add angle and speed display

This commit is contained in:
2024-04-19 11:19:47 +02:00
parent a62173b317
commit 8fe3aea13f
3 changed files with 30 additions and 0 deletions

View File

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

View File

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

View File

@@ -237,4 +237,12 @@ void MainWindow::handleMessage(const std::string& message)
std::vector<std::string> 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]);
}
}