From 4e0bfdd823a798c2397a2a16bf523f9db2985678 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Tue, 2 May 2023 00:24:21 +0200 Subject: [PATCH] Fix pull button availability. --- events.cpp | 10 ++++++++++ events.h | 1 + main.cpp | 6 +++--- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/events.cpp b/events.cpp index a87d83c..bf16202 100644 --- a/events.cpp +++ b/events.cpp @@ -232,6 +232,7 @@ EventsModel::Status EventsModel::get_status_at(uint64_t t) s.their_score = 0; s.offense = true; s.stoppage = false; + s.should_pull = true; uint64_t last_gained_possession = 0; uint64_t last_stoppage = 0; uint64_t time_spent_in_stoppage = 0; @@ -240,6 +241,15 @@ EventsModel::Status EventsModel::get_status_at(uint64_t t) if (e.t > t) { break; } + + if (e.type == "goal" || e.type == "their_goal") { + s.should_pull = true; + } else if (e.type == "in" || e.type == "out" || e.type == "stoppage" || e.type == "restart" || e.type == "unknown") { + // No effect on pull status. + } else { + s.should_pull = false; + } + if (e.type == "goal") { ++s.our_score; s.offense = false; diff --git a/events.h b/events.h index cd77004..c125557 100644 --- a/events.h +++ b/events.h @@ -35,6 +35,7 @@ public: unsigned our_score, their_score; bool offense; bool stoppage; + bool should_pull; unsigned num_passes; unsigned possession_sec; unsigned stoppage_sec; diff --git a/main.cpp b/main.cpp index a01b572..f6d289d 100644 --- a/main.cpp +++ b/main.cpp @@ -339,8 +339,8 @@ void MainWindow::update_action_buttons(uint64_t t) ui->offensive_soft_minus->setEnabled(s.offense && has_selection_with_player); // TODO: be stricter - ui->pull->setEnabled(s.offense && has_selection_with_player); - ui->pull_landed->setEnabled(s.offense && has_selection_with_player); + ui->pull->setEnabled(!s.offense && s.should_pull && has_selection_with_player); + ui->pull_landed->setEnabled(!s.offense && has_selection_with_player); ui->interception->setEnabled(!s.offense && has_selection_with_player); ui->their_throwaway->setEnabled(!s.offense); @@ -348,7 +348,7 @@ void MainWindow::update_action_buttons(uint64_t t) ui->their_goal->setEnabled(!s.offense); ui->defensive_soft_plus->setEnabled(!s.offense && has_selection_with_player); ui->defensive_soft_minus->setEnabled(!s.offense && has_selection_with_player); - ui->their_pull->setEnabled(!s.offense); + ui->their_pull->setEnabled(s.offense && s.should_pull); ui->our_foul->setEnabled(!s.offense && has_selection_with_player); } -- 2.39.5