From 45c38ca40bb25cbe64b23b7f5bd7fd293ea407f9 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Tue, 15 Oct 2019 00:40:37 +0200 Subject: [PATCH] Add a third clock. --- carousel.js | 14 +++++++ client/mainwindow.cpp | 29 +++++++++++++- client/mainwindow.h | 4 ++ client/mainwindow.ui | 88 ++++++++++++++++++++++++++++++++++--------- score.html | 12 ++++++ score.js | 18 ++++++++- score.scss | 24 ++++++++---- 7 files changed, 160 insertions(+), 29 deletions(-) diff --git a/carousel.js b/carousel.js index aa195c6..7066ba4 100644 --- a/carousel.js +++ b/carousel.js @@ -752,3 +752,17 @@ function hidematch2() document.getElementById('scorebug2').style = css; document.getElementById('clockbug2').style = css; } + +function showmatch3() +{ + let css = "-webkit-animation: fade-in 1.0s ease; -webkit-animation-fill-mode: both;"; + document.getElementById('scorebug3').style = css; + document.getElementById('clockbug3').style = css; +} + +function hidematch3() +{ + let css = "-webkit-animation: fade-out 1.0s ease; -webkit-animation-fill-mode: both;"; + document.getElementById('scorebug3').style = css; + document.getElementById('clockbug3').style = css; +} diff --git a/client/mainwindow.cpp b/client/mainwindow.cpp index 0c2ac48..7e96d22 100644 --- a/client/mainwindow.cpp +++ b/client/mainwindow.cpp @@ -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 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 setteams2()"); +} + void MainWindow::set_color_clicked() { map 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 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; } diff --git a/client/mainwindow.h b/client/mainwindow.h index 968ef4d..e215da5 100644 --- a/client/mainwindow.h +++ b/client/mainwindow.h @@ -27,6 +27,7 @@ private: void ws_disconnect_clicked(); void set_initials_clicked(); void set_match_2_initials_clicked(); + void set_match_3_initials_clicked(); void set_color_clicked(); void set_score_clicked(); void set_all_scorebug_clicked(); @@ -39,6 +40,8 @@ private: void hide_clock_clicked(); void show_match_2_clicked(); void hide_match_2_clicked(); + void show_match_3_clicked(); + void hide_match_3_clicked(); void set_comment_clicked(); void set_and_show_comment_clicked(); void hide_comment_clicked(); @@ -63,6 +66,7 @@ private: std::thread udp_thread; std::thread udp_thread2; + std::thread udp_thread3; }; #endif // MAINWINDOW_H diff --git a/client/mainwindow.ui b/client/mainwindow.ui index 2ce9b6a..8831891 100644 --- a/client/mainwindow.ui +++ b/client/mainwindow.ui @@ -6,7 +6,7 @@ 0 0 - 805 + 891 597 @@ -94,6 +94,16 @@ + + + + Score 3 UDP + + + true + + + @@ -174,7 +184,7 @@ - + @@ -205,10 +215,10 @@ - + - + Set @@ -222,14 +232,14 @@ - + PCL - + @@ -253,31 +263,31 @@ - + red - + - + Team 2 - + Team 1 - + TFK @@ -291,28 +301,28 @@ - + Set - + yellow - + Set - + Set all @@ -326,27 +336,55 @@ - + PCL - + TFK - + Set + + + + Match 3 + + + + + + + PCL + + + + + + + TFK + + + + + + + Set + + + @@ -509,6 +547,20 @@ + + + + Show match 3 + + + + + + + Hide match 3 + + + diff --git a/score.html b/score.html index bc39b5a..c4cdc5a 100644 --- a/score.html +++ b/score.html @@ -41,6 +41,18 @@ 0:00 + + + + + + + + + + + +
Call on the field: Foul diff --git a/score.js b/score.js index bedb829..394bb55 100644 --- a/score.js +++ b/score.js @@ -1,9 +1,10 @@ 'use strict'; -let num_clocks = 2; +let num_clocks = 3; let clocks = [ { 'running': false, 'elapsed': 0, 'origin': undefined, 'id': 'clock' }, - { 'running': false, 'elapsed': 0, 'origin': undefined, 'id': 'clock2' } + { 'running': false, 'elapsed': 0, 'origin': undefined, 'id': 'clock2' }, + { 'running': false, 'elapsed': 0, 'origin': undefined, 'id': 'clock3' } ]; let clock_visible = false; @@ -29,6 +30,12 @@ function setteams2() document.getElementById('score2_team2').innerHTML = state['team2']; } +function setteams3() +{ + document.getElementById('score3_team1').innerHTML = state['team1']; + document.getElementById('score3_team2').innerHTML = state['team2']; +} + function setcolors() { document.getElementById('team1color').style.backgroundColor = state['team1color']; @@ -49,6 +56,13 @@ function setscore2() document.getElementById('score2_score').innerHTML = scoreA + " â€“ " + scoreB; } +function setscore3() +{ + scoreA = state['score1']; + scoreB = state['score2']; + document.getElementById('score3_score').innerHTML = scoreA + " â€“ " + scoreB; +} + function startclock(num) { if (!clocks[num].running) { diff --git a/score.scss b/score.scss index e010092..ca6e177 100644 --- a/score.scss +++ b/score.scss @@ -60,12 +60,10 @@ body { border: 1px solid #ccc; } } -.scorebug2 td { +.scorebug2 td, .scorebug3 td { border: 1px solid #ccc8; } .scorebug2 { - /*top: 52px; */ - /* left: 22px; */ left: 1275px; top: 13px; font-size: 20px; @@ -75,6 +73,16 @@ body { top: 13px; font-size: 20px; } +.scorebug3 { + left: 1275px; + top: 47px; + font-size: 20px; +} +#clockbug3 { + left: 1360px; + top: 47px; + font-size: 20px; +} .team1color, .team2color { width: 12px; margin: 5px; @@ -107,14 +115,14 @@ body { } padding-top: var(--main-padding-top-adjust); } -#score2_team1, #score2_team2 { +#score2_team1, #score2_team2, #score3_team1, #score3_team2 { @if $trondisk { background: linear-gradient(to bottom, #00a8, #0088); } @else { background: linear-gradient(to bottom, #fff8, #eee8); } } -#score2_team1, #score2_team2, #score2_score { +#score2_team1, #score2_team2, #score2_score, #score3_team1, #score3_team2, #score3_score { height: 30px; } .score { @@ -128,7 +136,7 @@ body { height: 35px; padding-top: var(--main-padding-top-adjust); } -#score2_score { +#score2_score, #score3_score { @if $trondisk { background: linear-gradient(to bottom, #00c8, #00a8); } @else { @@ -137,7 +145,7 @@ body { } /* Clock, to the right of score */ -.clockbug, .clockbug2 { +.clockbug, .clockbug2, .clockbug3 { position: fixed; font-size: 25px; left: 352px; @@ -163,7 +171,7 @@ body { padding-top: var(--main-padding-top-adjust); width: 90px; } -#clock2 { +#clock2, #clock3 { border: 1px solid #ccc8; @if $trondisk { background: linear-gradient(to bottom, #00a8, #0088); -- 2.39.2