]> git.sesse.net Git - pkanalytics/blobdiff - main.cpp
Make explicit offense/defense markers, by clicking.
[pkanalytics] / main.cpp
index 46a0d1c666a02aa401e40dc25784ab486cf2c36f..ab5cf5c85dac4c9fa50edf0172f996e15c511515 100644 (file)
--- a/main.cpp
+++ b/main.cpp
@@ -89,6 +89,7 @@ MainWindow::MainWindow(EventsModel *events, PlayersModel *players) : events(even
        connect(ui->player_7, &QPushButton::clicked, [this]() { insert_event(7); });
 
        // Offensive events
+       connect(ui->offense_label, &ClickableLabel::clicked, [this]() { insert_noplayer_event("set_offense"); });
        connect(ui->catch_, &QPushButton::clicked, [this]() { set_current_event_type("catch"); });
        connect(ui->throwaway, &QPushButton::clicked, [this]() { set_current_event_type("throwaway"); });
        connect(ui->drop, &QPushButton::clicked, [this]() { set_current_event_type("drop"); });
@@ -99,6 +100,7 @@ MainWindow::MainWindow(EventsModel *events, PlayersModel *players) : events(even
        connect(ui->pull_landed, &QPushButton::clicked, [this]() { insert_noplayer_event("pull_landed"); });
 
        // Defensive events (TODO add more)
+       connect(ui->defense_label, &ClickableLabel::clicked, [this]() { insert_noplayer_event("set_defense"); });
        connect(ui->their_throwaway, &QPushButton::clicked, [this]() { insert_noplayer_event("their_throwaway"); });
        connect(ui->their_goal, &QPushButton::clicked, [this]() { insert_noplayer_event("their_goal"); });
        connect(ui->their_pull, &QPushButton::clicked, [this]() { insert_noplayer_event("their_pull"); });
@@ -226,8 +228,16 @@ void MainWindow::update_status(uint64_t t)
 {
        EventsModel::Status s = events->get_status_at(t);
        char buf[256];
+       const char *offense = "not started";
+       if (s.offense) {
+               assert(!s.defense);
+               offense = "offense";
+       } else if (s.defense) {
+               offense = "defense";
+       }
+
        snprintf(buf, sizeof(buf), "%d–%d | %s | %d passes, %d sec possession",
-               s.our_score, s.their_score, s.offense ? "offense" : "defense", s.num_passes, s.possession_sec);
+               s.our_score, s.their_score, offense, s.num_passes, s.possession_sec);
        if (s.stoppage_sec > 0) {
                char buf2[256];
                snprintf(buf2, sizeof(buf2), "%s (plus %d sec stoppage)", buf, s.stoppage_sec);
@@ -318,17 +328,17 @@ 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 && 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);
-       ui->our_defense->setEnabled(!s.offense && has_selection_with_player);
-       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->pull->setEnabled(s.defense && s.should_pull && has_selection_with_player);
+       ui->pull_landed->setEnabled(s.defense && has_selection_with_player);
+
+       ui->interception->setEnabled(s.defense && has_selection_with_player);
+       ui->their_throwaway->setEnabled(s.defense);
+       ui->our_defense->setEnabled(s.defense && has_selection_with_player);
+       ui->their_goal->setEnabled(s.defense);
+       ui->defensive_soft_plus->setEnabled(s.defense && has_selection_with_player);
+       ui->defensive_soft_minus->setEnabled(s.defense && has_selection_with_player);
        ui->their_pull->setEnabled(s.offense && s.should_pull);
-       ui->our_foul->setEnabled(!s.offense && has_selection_with_player);
+       ui->our_foul->setEnabled(s.defense && has_selection_with_player);
 }
 
 sqlite3 *open_db(const char *filename)