mirror of
https://github.com/modelec/ihm.git
synced 2026-01-18 16:47:32 +01:00
save spawn point
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include <QPushButton>
|
||||
#include <QVBoxLayout>
|
||||
#include <QWidget>
|
||||
@@ -7,7 +8,7 @@
|
||||
class Homologation : public QWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
Homologation(QWidget* parent = nullptr);
|
||||
explicit Homologation(QWidget* parent = nullptr);
|
||||
|
||||
protected slots:
|
||||
void onDeplierClicked();
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#include "MainWindow.h"
|
||||
|
||||
MainWindow::MainWindow(const char *address, int port, QWidget *parent) : QMainWindow(parent) {
|
||||
this->settings = new QSettings("settings.ini", QSettings::IniFormat);
|
||||
|
||||
this->tcpClient = new MyTCPClient(address, port, this);
|
||||
connect(this->tcpClient, &MyTCPClient::messageReceived, this, &MainWindow::handleMessage);
|
||||
|
||||
@@ -45,8 +47,14 @@ MainWindow::MainWindow(const char *address, int port, QWidget *parent) : QMainWi
|
||||
connect(this->home, &HomePage::testClicked, this, &MainWindow::onTestModePressed);
|
||||
|
||||
this->homologation = new Homologation(centralWidget);
|
||||
connect(this->homologation, &Homologation::deplierClicked, this, &MainWindow::deplierRobot);
|
||||
connect(this->homologation, &Homologation::replierClicked, this, &MainWindow::replierRobot);
|
||||
connect(this->homologation, &Homologation::deplierClicked, this, [&]() {
|
||||
// TODO servo moteur
|
||||
this->tcpClient->sendMessage("ihm;strat;deplier;1");
|
||||
});
|
||||
connect(this->homologation, &Homologation::replierClicked, [&]() {
|
||||
// TODO servo moteur
|
||||
this->tcpClient->sendMessage("ihm;strat;replier;1");
|
||||
});
|
||||
|
||||
this->teamChooser = new TeamChooser(centralWidget);
|
||||
connect(this->teamChooser, &TeamChooser::spawnPointChoose, this, &MainWindow::onSpawnPointChoose);
|
||||
@@ -59,7 +67,7 @@ MainWindow::MainWindow(const char *address, int port, QWidget *parent) : QMainWi
|
||||
emit this->onWaitingForTirette();
|
||||
});
|
||||
connect(this->preparationMatch, &PreparationMatch::askTCPServer, [&](const std::string& message) {
|
||||
this->tcpClient->sendMessage(message.c_str());
|
||||
this->tcpClient->sendMessage(message);
|
||||
});
|
||||
|
||||
this->waintingForTirette = new WaintingForTirette(centralWidget);
|
||||
@@ -71,7 +79,9 @@ MainWindow::MainWindow(const char *address, int port, QWidget *parent) : QMainWi
|
||||
});
|
||||
|
||||
this->testMode = new TestMode(centralWidget);
|
||||
connect(this->testMode, &TestMode::goPressed, this, &MainWindow::moveRobot);
|
||||
connect(this->testMode, &TestMode::goPressed, [&](int x, int y, int theta) {
|
||||
this->tcpClient->sendMessage("ihm;strat;go;" + std::to_string(x) + "," + std::to_string(y) + "," + std::to_string(theta));
|
||||
});
|
||||
|
||||
this->inGame = new InGame(teamChooser);
|
||||
|
||||
@@ -147,6 +157,8 @@ void MainWindow::onTestModePressed()
|
||||
|
||||
void MainWindow::onSpawnPointChoose(int nb)
|
||||
{
|
||||
this->settings->setValue("spawnPoint", nb);
|
||||
this->tcpClient->sendMessage("ihm;strat;spawn;" + std::to_string(nb));
|
||||
this->preparationMatch->clearCheckboxes();
|
||||
this->setWidgetNb(3);
|
||||
}
|
||||
@@ -161,16 +173,6 @@ void MainWindow::onStartGame()
|
||||
this->setWidgetNb(6);
|
||||
}
|
||||
|
||||
void MainWindow::onDeplierRobot()
|
||||
{
|
||||
emit deplierRobot();
|
||||
}
|
||||
|
||||
void MainWindow::onReplierRobot()
|
||||
{
|
||||
emit replierRobot();
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::handleMessage(const std::string& message)
|
||||
{
|
||||
|
||||
12
MainWindow.h
12
MainWindow.h
@@ -4,6 +4,7 @@
|
||||
#include <QWidget>
|
||||
#include <QStackedWidget>
|
||||
#include <QPixmap>
|
||||
#include <QSettings>
|
||||
|
||||
#include "HomePage.h"
|
||||
#include "Homologation.h"
|
||||
@@ -46,18 +47,8 @@ protected slots:
|
||||
|
||||
void onStartGame();
|
||||
|
||||
void onDeplierRobot();
|
||||
|
||||
void onReplierRobot();
|
||||
|
||||
void handleMessage(const std::string& message);
|
||||
|
||||
|
||||
signals:
|
||||
void deplierRobot();
|
||||
void replierRobot();
|
||||
void moveRobot(int x, int y, int theta);
|
||||
|
||||
private:
|
||||
QVBoxLayout* mainLayout;
|
||||
QHBoxLayout* topLayout;
|
||||
@@ -78,4 +69,5 @@ private:
|
||||
DisplayMode displayMode = DisplayMode::WINDOWED;
|
||||
|
||||
MyTCPClient* tcpClient;
|
||||
QSettings* settings;
|
||||
};
|
||||
|
||||
15
main.cpp
15
main.cpp
@@ -34,20 +34,5 @@ int main(int argc, char* argv[]) {
|
||||
|
||||
main->setDisplayMode(mode);
|
||||
|
||||
MainWindow::connect(main, &MainWindow::replierRobot, [=]()
|
||||
{
|
||||
qInfo() << "replier";
|
||||
});
|
||||
|
||||
MainWindow::connect(main, &MainWindow::deplierRobot, [=]()
|
||||
{
|
||||
qInfo() << "deplier";
|
||||
});
|
||||
|
||||
MainWindow::connect(main, &MainWindow::moveRobot, [=](int x, int y, int theta)
|
||||
{
|
||||
qInfo() << "move" << x << y << theta;
|
||||
});
|
||||
|
||||
return QApplication::exec();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user