mirror of
https://github.com/modelec/ihm.git
synced 2026-01-18 16:47:32 +01:00
Add angle and speed display
This commit is contained in:
16
InGame.cpp
16
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");
|
||||
}
|
||||
|
||||
6
InGame.h
6
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;
|
||||
|
||||
@@ -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]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user