]> git.sesse.net Git - ultimatescore/commitdiff
Make the client capable of setting the clock limit. (Untested right now.)
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 18 Feb 2018 18:30:59 +0000 (19:30 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 18 Feb 2018 18:30:59 +0000 (19:30 +0100)
client/mainwindow.cpp
client/mainwindow.h
client/mainwindow.ui
score.js

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.
index 99b8a34196dd1d2804c690fae7462a738626e496..ae675caa1b9e962700a76bca6efbfcf240b88cb6 100644 (file)
@@ -28,6 +28,7 @@ private:
        void set_all_scorebug_clicked();
        void add_goal(QSpinBox *box, int delta);
        void set_clock_clicked();
+       void set_clock_limit_clicked();
        void start_and_show_clock_clicked();
        void stop_clock_clicked();
        void show_clock_clicked();
index fe5886d475d506220789ca6d90f030b6e8a619e2..28a01a55aa9966bcb7c6f9a5ee3c2192c826cff2 100644 (file)
@@ -6,7 +6,7 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>803</width>
+    <width>805</width>
     <height>597</height>
    </rect>
   </property>
             <verstretch>0</verstretch>
            </sizepolicy>
           </property>
-          <property name="value">
-           <number>30</number>
-          </property>
          </widget>
         </item>
         <item>
         <item>
          <widget class="QPushButton" name="set_clock_btn">
           <property name="text">
-           <string>Set</string>
+           <string>Set clock</string>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="QLabel" name="label_14">
+          <property name="text">
+           <string>Set clock limit to:</string>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="QSpinBox" name="clock_limit_min_box">
+          <property name="sizePolicy">
+           <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+            <horstretch>0</horstretch>
+            <verstretch>0</verstretch>
+           </sizepolicy>
+          </property>
+          <property name="value">
+           <number>30</number>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="QLabel" name="label_15">
+          <property name="sizePolicy">
+           <sizepolicy hsizetype="Fixed" vsizetype="Preferred">
+            <horstretch>0</horstretch>
+            <verstretch>0</verstretch>
+           </sizepolicy>
+          </property>
+          <property name="text">
+           <string>:</string>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="QSpinBox" name="clock_limit_sec_box">
+          <property name="sizePolicy">
+           <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+            <horstretch>0</horstretch>
+            <verstretch>0</verstretch>
+           </sizepolicy>
+          </property>
+          <property name="maximum">
+           <number>59</number>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="QPushButton" name="set_clock_limit_btn">
+          <property name="text">
+           <string>Set limit</string>
           </property>
          </widget>
         </item>
index f2534d114377a2ad9762a5d36f969ebfcdbd88c9..deae9d8ad9824a4da5c7e7e514daaeb1049e193f 100644 (file)
--- a/score.js
+++ b/score.js
@@ -63,6 +63,12 @@ function setclockfromstate()
        setclock(amount);
 }
 
+function setclocklimitfromstate()
+{
+       let amount = parseInt(state['clock_limit_min']) * 60 + parseInt(state['clock_limit_sec']);
+       clock_limit = amount;
+}
+
 function showclock()
 {
        if (clock_visible) return;