]> git.sesse.net Git - ultimatescore/blobdiff - client/mainwindow.cpp
Make the client capable of setting the clock limit. (Untested right now.)
[ultimatescore] / client / mainwindow.cpp
index e92653a9cc4ec8e58dde659a95b01c6d4151b79a..b47a9e6d4e858731f0fba99914193536341064ad 100644 (file)
@@ -107,6 +107,7 @@ MainWindow::MainWindow(QWidget *parent) :
        connect(ui->ungoal_2_btn, &QPushButton::clicked, this, [this]() { add_goal(ui->score_2_box, -1); });
 
        connect(ui->set_clock_btn, &QPushButton::clicked, this, &MainWindow::set_clock_clicked);
+       connect(ui->set_clock_limit_btn, &QPushButton::clicked, this, &MainWindow::set_clock_limit_clicked);
        connect(ui->start_and_show_clock_btn, &QPushButton::clicked, this, &MainWindow::start_and_show_clock_clicked);
        connect(ui->stop_clock_btn, &QPushButton::clicked, this, &MainWindow::stop_clock_clicked);
        connect(ui->show_clock_btn, &QPushButton::clicked, this, &MainWindow::show_clock_clicked);
@@ -202,6 +203,15 @@ void MainWindow::set_clock_clicked()
        acmp->send_command("cg 1 invoke 1 setclockfromstate");
 }
 
+void MainWindow::set_clock_limit_clicked()
+{
+       map<string, string> param;
+       param["clock_limit_min"] = to_string(ui->clock_limit_min_box->value());
+       param["clock_limit_sec"] = to_string(ui->clock_limit_sec_box->value());
+       acmp->send_command("cg 1 update 1 \"" + escape_quotes(serialize_as_json(param)) + "\"");
+       acmp->send_command("cg 1 invoke 1 setclocklimitfromstate");
+}
+
 void MainWindow::start_and_show_clock_clicked()
 {
        acmp->send_command("cg 1 invoke 1 startclock");  // Also shows.