]> git.sesse.net Git - pkanalytics/commitdiff
Fix pull button availability.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Mon, 1 May 2023 22:24:21 +0000 (00:24 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Mon, 1 May 2023 22:24:21 +0000 (00:24 +0200)
events.cpp
events.h
main.cpp

index a87d83c8d60c7c7efb3a66c05b0fa89f48ddd969..bf16202289f650913f49a1f1470149193966f33f 100644 (file)
@@ -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;
index cd77004f50e9871968257954c8aa769e6cf174eb..c1255578a50710de618e1b61ecdf6e938e54a4cd 100644 (file)
--- 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;
index a01b572db4243fea29eaacd439f1980d309da543..f6d289d201d97616bf7d2501eb176a29796210e7 100644 (file)
--- 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);
 }