]> git.sesse.net Git - ultimatescore/blobdiff - client/mainwindow.cpp
Add a comment about what “Mark game” means.
[ultimatescore] / client / mainwindow.cpp
index 0c2ac48888f953aab19de6086e9c6724903417ed..b6294cf059987dfcabb193170b3e80e5994a5a0f 100644 (file)
@@ -100,10 +100,12 @@ MainWindow::MainWindow(QWidget *parent) :
 
        udp_thread = std::thread(&MainWindow::udp_thread_func, this, 6000);
        udp_thread2 = std::thread(&MainWindow::udp_thread_func, this, 6001);
+       udp_thread3 = std::thread(&MainWindow::udp_thread_func, this, 6002);
 
        connect(ui->ws_disconnect_btn, &QPushButton::clicked, this, &MainWindow::ws_disconnect_clicked);
        connect(ui->set_initials_btn, &QPushButton::clicked, this, &MainWindow::set_initials_clicked);
        connect(ui->set_match_2_initials_btn, &QPushButton::clicked, this, &MainWindow::set_match_2_initials_clicked);
+       connect(ui->set_match_3_initials_btn, &QPushButton::clicked, this, &MainWindow::set_match_3_initials_clicked);
        connect(ui->set_color_btn, &QPushButton::clicked, this, &MainWindow::set_color_clicked);
        connect(ui->set_score_btn, &QPushButton::clicked, this, &MainWindow::set_score_clicked);
        connect(ui->set_all_scorebug_btn, &QPushButton::clicked, this, &MainWindow::set_all_scorebug_clicked);
@@ -120,6 +122,8 @@ MainWindow::MainWindow(QWidget *parent) :
        connect(ui->hide_clock_btn, &QPushButton::clicked, this, &MainWindow::hide_clock_clicked);
        connect(ui->show_match_2_btn, &QPushButton::clicked, this, &MainWindow::show_match_2_clicked);
        connect(ui->hide_match_2_btn, &QPushButton::clicked, this, &MainWindow::hide_match_2_clicked);
+       connect(ui->show_match_3_btn, &QPushButton::clicked, this, &MainWindow::show_match_3_clicked);
+       connect(ui->hide_match_3_btn, &QPushButton::clicked, this, &MainWindow::hide_match_3_clicked);
 
        connect(ui->set_comment_btn, &QPushButton::clicked, this, &MainWindow::set_comment_clicked);
        connect(ui->set_and_show_comment_btn, &QPushButton::clicked, this, &MainWindow::set_and_show_comment_clicked);
@@ -179,6 +183,15 @@ void MainWindow::set_match_2_initials_clicked()
        ws->send_command("eval setteams2()");
 }
 
+void MainWindow::set_match_3_initials_clicked()
+{
+       map<string, string> param;
+       param["team1"] = escape_html(ui->match_3_initials_1_edit->text().toStdString());
+       param["team2"] = escape_html(ui->match_3_initials_2_edit->text().toStdString());
+       ws->send_command("update " + serialize_as_json(param));
+       ws->send_command("eval setteams3()");
+}
+
 void MainWindow::set_color_clicked()
 {
        map<string, string> param;
@@ -259,6 +272,16 @@ void MainWindow::hide_match_2_clicked()
        ws->send_command("eval hidematch2()");
 }
 
+void MainWindow::show_match_3_clicked()
+{
+       ws->send_command("eval showmatch3()");
+}
+
+void MainWindow::hide_match_3_clicked()
+{
+       ws->send_command("eval hidematch3()");
+}
+
 void MainWindow::set_comment_clicked()
 {
        map<string, string> param;
@@ -478,7 +501,11 @@ int parse_score(char ch1, char ch2, char ch3)
 void MainWindow::bt6000_message_received(const string &msg, int port)
 {
        fprintf(stderr, "BT6000 message: '%s' (port %d)\n", msg.c_str(), port);
-       if (port == 6001) {
+       if (port == 6002) {
+               if (!ui->bt6000_3_enable->isChecked()) {
+                       return;
+               }
+       } else if (port == 6001) {
                if (!ui->bt6000_2_enable->isChecked()) {
                        return;
                }
@@ -500,7 +527,14 @@ void MainWindow::bt6000_message_received(const string &msg, int port)
                param["clock_sec"] = to_string(seconds);
                ws->send_command("update " + serialize_as_json(param));
 
-               if (port == 6001) {
+               if (port == 6002) {
+                       ws->send_command("eval adjustclockfromstate(2)");
+                       if (clock_running) {
+                               ws->send_command("eval startclock(2)");
+                       } else {
+                               ws->send_command("eval stopclock(2)");
+                       }
+               } else if (port == 6001) {
                        ws->send_command("eval adjustclockfromstate(1)");
                        if (clock_running) {
                                ws->send_command("eval startclock(1)");
@@ -519,7 +553,13 @@ void MainWindow::bt6000_message_received(const string &msg, int port)
        if (msg.size() >= 10 && msg[0] == 'G' && msg[1] == '0' && msg[2] == '2') {
                int score1 = parse_score(msg[4], msg[5], msg[6]);
                int score2 = parse_score(msg[7], msg[8], msg[9]);
-               if (port == 6001) {
+               if (port == 6002) {
+                       map<string, string> param;
+                       param["score1"] = to_string(score1);
+                       param["score2"] = to_string(score2);
+                       ws->send_command("update " + serialize_as_json(param));
+                       ws->send_command("eval setscore3()");
+               } else if (port == 6001) {
                        map<string, string> param;
                        param["score1"] = to_string(score1);
                        param["score2"] = to_string(score2);