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