]> git.sesse.net Git - pkanalytics/blobdiff - main.cpp
std::shared_ptr is surprisingly not thread-safe, so we need a mutex.
[pkanalytics] / main.cpp
index 560a9a658676b09723edab126b6230a5ac8c3190..4caeac38c4d839450dd1db7dd16f28677637943d 100644 (file)
--- a/main.cpp
+++ b/main.cpp
@@ -86,7 +86,6 @@ MainWindow::MainWindow(EventsModel *events, PlayersModel *players,
                position_changed(pos);
        });
 
-
        // It's not really clear whether PgUp should be forwards or backwards,
        // but mpv does at least up = forwards, so that's probably standard.
        QShortcut *pgdown = new QShortcut(QKeySequence(Qt::Key_PageDown), this);
@@ -99,6 +98,8 @@ MainWindow::MainWindow(EventsModel *events, PlayersModel *players,
 
        connect(ui->minus2s, &QPushButton::clicked, [this]() { ui->video->seek(-2000); });
        connect(ui->plus2s, &QPushButton::clicked, [this]() { ui->video->seek(2000); });
+       connect(ui->video, &VideoWidget::mouse_back_clicked, [this]() { ui->video->seek(-2000); });
+       connect(ui->video, &VideoWidget::mouse_forward_clicked, [this]() { ui->video->seek(2000); });
 
        connect(ui->minus1f, &QPushButton::clicked, [this]() { ui->video->seek_frames(-1); });
        connect(ui->plus1f, &QPushButton::clicked, [this]() { ui->video->seek_frames(1); });
@@ -140,12 +141,14 @@ MainWindow::MainWindow(EventsModel *events, PlayersModel *players,
        connect(ui->goal, &QPushButton::clicked, [this]() { set_current_event_type("goal"); });
        connect(ui->offensive_soft_plus, &QPushButton::clicked, [this]() { set_current_event_type("offensive_soft_plus"); });
        connect(ui->offensive_soft_minus, &QPushButton::clicked, [this]() { set_current_event_type("offensive_soft_minus"); });
-       connect(ui->pull, &QPushButton::clicked, [this, events]() {
+       connect(ui->pull_or_was_d, &QPushButton::clicked, [this, events]() {
                EventsModel::Status s = events->get_status_at(ui->video->get_position());
                if (s.pull_state == EventsModel::Status::SHOULD_PULL) {
                        set_current_event_type("pull");
                } else if (s.pull_state == EventsModel::Status::PULL_IN_AIR) {
                        insert_noplayer_event("pull_landed");
+               } else if (s.pull_state == EventsModel::Status::NOT_PULLING) {
+                       set_current_event_type("was_d");
                }
        });
 
@@ -296,6 +299,7 @@ void MainWindow::make_substitution()
                new_team.insert(players->get_player_id(row.row()));
        }
        events->set_team_at(ui->video->get_position(), new_team);
+       update_player_buttons(ui->video->get_position());
 }
 
 void MainWindow::update_ui_from_time(uint64_t t)
@@ -410,7 +414,7 @@ void MainWindow::update_action_buttons(uint64_t t)
                ui->goal->setEnabled(false);
                ui->offensive_soft_plus->setEnabled(false);
                ui->offensive_soft_minus->setEnabled(false);
-               ui->pull->setEnabled(false);
+               ui->pull_or_was_d->setEnabled(false);
                ui->interception->setEnabled(false);
                ui->their_throwaway->setEnabled(false);
                ui->our_defense->setEnabled(false);
@@ -425,15 +429,15 @@ void MainWindow::update_action_buttons(uint64_t t)
        }
 
        // Defaults for pull-related buttons.
-       ui->pull->setText("Pull (&p)");
+       ui->pull_or_was_d->setText("Pull (&p)");
        ui->their_pull->setText("Their pull (&p)");
-       ui->pull->setShortcut(QCoreApplication::translate("MainWindow", "P", nullptr));
+       ui->pull_or_was_d->setShortcut(QCoreApplication::translate("MainWindow", "P", nullptr));
        ui->their_pull->setShortcut(QCoreApplication::translate("MainWindow", "P", nullptr));
        ui->throwaway->setText("Throwaway (&t)");
        ui->throwaway->setShortcut(QCoreApplication::translate("MainWindow", "T", nullptr));
 
        if (s.pull_state == EventsModel::Status::SHOULD_PULL) {
-               ui->pull->setEnabled(s.attack_state == EventsModel::Status::DEFENSE && has_selection_with_player);
+               ui->pull_or_was_d->setEnabled(s.attack_state == EventsModel::Status::DEFENSE && has_selection_with_player);
                ui->their_pull->setEnabled(s.attack_state == EventsModel::Status::OFFENSE);
 
                ui->catch_->setEnabled(false);
@@ -452,15 +456,15 @@ void MainWindow::update_action_buttons(uint64_t t)
        }
        if (s.pull_state == EventsModel::Status::PULL_IN_AIR) {
                if (s.attack_state == EventsModel::Status::DEFENSE) {
-                       ui->pull->setText("Pull landed (&p)");
-                       ui->pull->setShortcut(QCoreApplication::translate("MainWindow", "P", nullptr));
-                       ui->pull->setEnabled(true);
+                       ui->pull_or_was_d->setText("Pull landed (&p)");
+                       ui->pull_or_was_d->setShortcut(QCoreApplication::translate("MainWindow", "P", nullptr));
+                       ui->pull_or_was_d->setEnabled(true);
 
                        ui->throwaway->setText("Pull OOB (&t)");
                        ui->throwaway->setShortcut(QCoreApplication::translate("MainWindow", "T", nullptr));
                        ui->throwaway->setEnabled(true);
                } else {
-                       ui->pull->setEnabled(false);
+                       ui->pull_or_was_d->setEnabled(false);
                        ui->throwaway->setEnabled(false);
                }
                ui->their_pull->setEnabled(false);  // We don't track their pull landings; only by means of catch etc.
@@ -479,13 +483,18 @@ void MainWindow::update_action_buttons(uint64_t t)
                return;
        }
 
+       // Not pulling, so reuse the pull button for got d-ed.
+       ui->pull_or_was_d->setText("Was d-ed (&z)");
+       ui->pull_or_was_d->setShortcut(QCoreApplication::translate("MainWindow", "Z", nullptr));
+       ui->pull_or_was_d->setEnabled(true);
+
        ui->catch_->setEnabled(s.attack_state == EventsModel::Status::OFFENSE && has_selection_with_player);
        ui->throwaway->setEnabled(s.attack_state == EventsModel::Status::OFFENSE && has_selection_with_player);
        ui->drop->setEnabled(s.attack_state == EventsModel::Status::OFFENSE && has_selection_with_player);
        ui->goal->setEnabled(s.attack_state == EventsModel::Status::OFFENSE && has_selection_with_player);
        ui->offensive_soft_plus->setEnabled(s.attack_state == EventsModel::Status::OFFENSE && has_selection_with_player);
        ui->offensive_soft_minus->setEnabled(s.attack_state == EventsModel::Status::OFFENSE && has_selection_with_player);
-       ui->pull->setEnabled(false);
+       ui->pull_or_was_d->setEnabled(s.attack_state == EventsModel::Status::OFFENSE && has_selection_with_player);  // Was d-ed.
 
        ui->interception->setEnabled(s.attack_state == EventsModel::Status::DEFENSE && has_selection_with_player);
        ui->their_throwaway->setEnabled(s.attack_state == EventsModel::Status::DEFENSE);