1 #include <QMediaPlayer>
3 #include <QApplication>
7 #include <QInputDialog>
15 #include "mainwindow.h"
16 #include "ui_mainwindow.h"
19 #include "formations.h"
21 #include "video_widget.h"
25 string format_timestamp(uint64_t pos)
35 snprintf(buf, sizeof(buf), "%d:%02d:%02d.%03d", hour, min, sec, ms);
39 string get_video_filename(sqlite3 *db, int match_id)
43 int ret = sqlite3_prepare_v2(db, "SELECT video_filename FROM match WHERE match=?", -1, &stmt, 0);
44 if (ret != SQLITE_OK) {
45 fprintf(stderr, "SELECT prepare: %s\n", sqlite3_errmsg(db));
49 sqlite3_bind_int64(stmt, 1, match_id);
51 ret = sqlite3_step(stmt);
52 if (ret != SQLITE_ROW) {
53 fprintf(stderr, "SELECT step: %s\n", sqlite3_errmsg(db));
57 if (sqlite3_column_type(stmt, 0) != SQLITE_TEXT) {
60 string filename = (const char *)sqlite3_column_text(stmt, 0);
62 ret = sqlite3_finalize(stmt);
63 if (ret != SQLITE_OK) {
64 fprintf(stderr, "SELECT finalize: %s\n", sqlite3_errmsg(db));
70 void save_video_filename(sqlite3 *db, int match_id, const string &filename)
74 int ret = sqlite3_prepare_v2(db, "UPDATE match SET video_filename=? WHERE match=?", -1, &stmt, 0);
75 if (ret != SQLITE_OK) {
76 fprintf(stderr, "SELECT prepare: %s\n", sqlite3_errmsg(db));
80 sqlite3_bind_text(stmt, 1, filename.data(), filename.size(), SQLITE_STATIC);
81 sqlite3_bind_int64(stmt, 2, match_id);
83 ret = sqlite3_step(stmt);
84 if (ret == SQLITE_ROW) {
85 fprintf(stderr, "INSERT step: %s\n", sqlite3_errmsg(db));
89 ret = sqlite3_finalize(stmt);
90 if (ret != SQLITE_OK) {
91 fprintf(stderr, "SELECT finalize: %s\n", sqlite3_errmsg(db));
96 MainWindow::MainWindow(EventsModel *events, PlayersModel *players,
97 FormationsModel *offensive_formations, FormationsModel *defensive_formations,
98 sqlite3 *db, int match_id)
99 : events(events), players(players), offensive_formations(offensive_formations), defensive_formations(defensive_formations), db(db), match_id(match_id)
101 ui = new Ui::MainWindow;
104 string filename = get_video_filename(db, match_id);
105 bool need_save_filename = false;
107 if (!filename.empty() && ui->video->open(filename.c_str())) {
111 // TODO: Probably relativize this path, so that we can move the .db
112 // more easily with the videos.
113 filename = QFileDialog::getOpenFileName(this, "Open video").toUtf8();
114 need_save_filename = true;
116 if (need_save_filename) {
117 save_video_filename(db, match_id, filename);
121 ui->event_view->setModel(events);
122 ui->event_view->setColumnWidth(1, 150);
123 ui->event_view->setColumnWidth(2, 150);
124 connect(ui->event_view->selectionModel(), &QItemSelectionModel::currentRowChanged,
125 [this, events](const QModelIndex ¤t, const QModelIndex &previous) {
126 uint64_t t = events->get_time(current.row());
127 if (t != ui->video->get_position()) {
128 ui->video->seek_absolute(events->get_time(current.row()));
130 // Selection could have changed, so we still need to update.
131 // (Just calling setPosition() would not give us the signal
133 update_ui_from_time(t);
137 ui->player_view->setModel(players);
138 ui->player_view->setColumnWidth(0, 30);
139 ui->player_view->setColumnWidth(1, 20);
140 ui->player_view->horizontalHeader()->setStretchLastSection(true);
142 auto formation_changed = [this](const QModelIndex ¤t, const QModelIndex &previous) {
143 QTimer::singleShot(1, [=]{ // The selection is wrong until the callback actually returns.
144 update_action_buttons(ui->video->get_position());
147 ui->offensive_formation_view->setModel(offensive_formations);
148 ui->defensive_formation_view->setModel(defensive_formations);
149 connect(ui->offensive_formation_view->selectionModel(), &QItemSelectionModel::currentRowChanged, formation_changed);
150 connect(ui->defensive_formation_view->selectionModel(), &QItemSelectionModel::currentRowChanged, formation_changed);
151 connect(ui->offensive_formation_view, &QListView::doubleClicked, [this](const QModelIndex &index) {
152 formation_double_clicked(true, index.row());
154 connect(ui->defensive_formation_view, &QListView::doubleClicked, [this](const QModelIndex &index) {
155 formation_double_clicked(false, index.row());
158 connect(ui->video, &VideoWidget::position_changed, [this](uint64_t pos) {
159 position_changed(pos);
162 // It's not really clear whether PgUp should be forwards or backwards,
163 // but mpv does at least up = forwards, so that's probably standard.
164 QShortcut *pgdown = new QShortcut(QKeySequence(Qt::Key_PageDown), this);
165 connect(pgdown, &QShortcut::activated, [this]() { ui->video->seek(-120000); });
166 QShortcut *pgup = new QShortcut(QKeySequence(Qt::Key_PageUp), this);
167 connect(pgup, &QShortcut::activated, [this]() { ui->video->seek(120000); });
169 connect(ui->minus10s, &QPushButton::clicked, [this]() { ui->video->seek(-10000); });
170 connect(ui->plus10s, &QPushButton::clicked, [this]() { ui->video->seek(10000); });
172 connect(ui->minus2s, &QPushButton::clicked, [this]() { ui->video->seek(-2000); });
173 connect(ui->plus2s, &QPushButton::clicked, [this]() { ui->video->seek(2000); });
174 connect(ui->video, &VideoWidget::mouse_back_clicked, [this]() { ui->video->seek(-2000); });
175 connect(ui->video, &VideoWidget::mouse_forward_clicked, [this]() { ui->video->seek(2000); });
177 connect(ui->minus1f, &QPushButton::clicked, [this]() { ui->video->seek_frames(-1); });
178 connect(ui->plus1f, &QPushButton::clicked, [this]() { ui->video->seek_frames(1); });
180 connect(ui->play_pause, &QPushButton::clicked, [this]() {
183 ui->play_pause->setText("Play (space)");
186 ui->play_pause->setText("Pause (space)");
190 // Needs to be set anew when we modify setText(), evidently.
191 ui->play_pause->setShortcut(QCoreApplication::translate("MainWindow", "Space", nullptr));
194 connect(ui->player_1, &QPushButton::clicked, [this]() { insert_player_event(0); });
195 connect(ui->player_2, &QPushButton::clicked, [this]() { insert_player_event(1); });
196 connect(ui->player_3, &QPushButton::clicked, [this]() { insert_player_event(2); });
197 connect(ui->player_4, &QPushButton::clicked, [this]() { insert_player_event(3); });
198 connect(ui->player_5, &QPushButton::clicked, [this]() { insert_player_event(4); });
199 connect(ui->player_6, &QPushButton::clicked, [this]() { insert_player_event(5); });
200 connect(ui->player_7, &QPushButton::clicked, [this]() { insert_player_event(6); });
203 connect(ui->offense_label, &ClickableLabel::clicked, [this]() { insert_noplayer_event("set_offense"); });
204 connect(ui->catch_, &QPushButton::clicked, [this]() { set_current_event_type("catch"); });
205 connect(ui->throwaway, &QPushButton::clicked, [this, events]() {
206 EventsModel::Status s = events->get_status_at(ui->video->get_position());
207 if (s.attack_state == EventsModel::Status::DEFENSE && s.pull_state == EventsModel::Status::PULL_IN_AIR) {
208 insert_noplayer_event("pull_oob");
210 set_current_event_type("throwaway");
213 connect(ui->drop, &QPushButton::clicked, [this]() { set_current_event_type("drop"); });
214 connect(ui->goal, &QPushButton::clicked, [this]() { set_current_event_type("goal"); });
215 connect(ui->stallout, &QPushButton::clicked, [this]() { set_current_event_type("stallout"); });
216 connect(ui->soft_plus, &QPushButton::clicked, [this, events]() {
217 EventsModel::Status s = events->get_status_at(ui->video->get_position());
218 if (s.attack_state == EventsModel::Status::OFFENSE) {
219 set_current_event_type("offensive_soft_plus");
220 } else if (s.attack_state == EventsModel::Status::DEFENSE) {
221 set_current_event_type("defensive_soft_plus");
224 connect(ui->soft_minus, &QPushButton::clicked, [this, events]() {
225 EventsModel::Status s = events->get_status_at(ui->video->get_position());
226 if (s.attack_state == EventsModel::Status::OFFENSE) {
227 set_current_event_type("offensive_soft_minus");
228 } else if (s.attack_state == EventsModel::Status::DEFENSE) {
229 set_current_event_type("defensive_soft_minus");
232 connect(ui->pull_or_was_d, &QPushButton::clicked, [this, events]() {
233 EventsModel::Status s = events->get_status_at(ui->video->get_position());
234 if (s.pull_state == EventsModel::Status::SHOULD_PULL ||
235 events->get_status_at(ui->video->get_position() - 1).pull_state == EventsModel::Status::SHOULD_PULL) {
236 set_current_event_type("pull");
237 } else if (s.pull_state == EventsModel::Status::PULL_IN_AIR) {
238 insert_noplayer_event("pull_landed");
239 } else if (s.pull_state == EventsModel::Status::NOT_PULLING) {
240 set_current_event_type("was_d");
244 // Defensive events (TODO add more)
245 connect(ui->interception, &QPushButton::clicked, [this]() { set_current_event_type("interception"); });
246 connect(ui->defense_label, &ClickableLabel::clicked, [this]() { insert_noplayer_event("set_defense"); });
247 connect(ui->their_throwaway, &QPushButton::clicked, [this]() { insert_noplayer_event("their_throwaway"); });
248 connect(ui->their_goal, &QPushButton::clicked, [this]() { insert_noplayer_event("their_goal"); });
249 connect(ui->their_pull, &QPushButton::clicked, [this, events]() {
250 EventsModel::Status s = events->get_status_at(ui->video->get_position());
251 if (s.pull_state == EventsModel::Status::SHOULD_PULL) {
252 insert_noplayer_event("their_pull");
255 connect(ui->our_defense, &QPushButton::clicked, [this]() { set_current_event_type("defense"); });
257 connect(ui->offensive_formation, &QPushButton::clicked, [this]() { insert_or_change_formation(/*offense=*/true); });
258 connect(ui->defensive_formation, &QPushButton::clicked, [this]() { insert_or_change_formation(/*offense=*/false); });
261 connect(ui->substitution, &QPushButton::clicked, [this]() { make_substitution(); });
262 connect(ui->stoppage, &QPushButton::clicked, [this, events]() {
263 EventsModel::Status s = events->get_status_at(ui->video->get_position());
265 insert_noplayer_event("restart");
267 insert_noplayer_event("stoppage");
270 connect(ui->unknown, &QPushButton::clicked, [this]() { insert_noplayer_event("unknown"); });
272 QShortcut *key_delete = new QShortcut(QKeySequence(Qt::Key_Delete), this);
273 connect(key_delete, &QShortcut::activated, [this]() { ui->delete_->animateClick(); });
274 connect(ui->delete_, &QPushButton::clicked, [this]() { delete_current_event(); });
277 connect(ui->action_exit, &QAction::triggered, [this] { close(); });
278 connect(ui->action_export_json, &QAction::triggered, [db] { export_to_json(db, "ultimate.json"); });
281 void MainWindow::position_changed(uint64_t pos)
283 ui->timestamp->setText(QString::fromUtf8(format_timestamp(pos)));
285 ui->video->pause(); // We only played to get a picture.
288 QModelIndex row = events->get_last_event_qt(ui->video->get_position());
289 ui->event_view->scrollTo(row, QAbstractItemView::PositionAtCenter);
291 update_ui_from_time(pos);
294 void MainWindow::insert_player_event(int button_id)
296 uint64_t t = ui->video->get_position();
297 vector<int> team = events->sort_team(events->get_team_at(t));
298 if (unsigned(button_id) >= team.size()) {
301 int player_id = team[button_id];
303 EventsModel::Status s = events->get_status_at(t);
305 ui->event_view->selectionModel()->blockSignals(true);
306 if (s.attack_state == EventsModel::Status::OFFENSE) {
307 // TODO: Perhaps not if that player already did the last catch?
308 ui->event_view->selectRow(events->insert_event(t, player_id, nullopt, "catch"));
310 ui->event_view->selectRow(events->insert_event(t, player_id, nullopt));
312 ui->event_view->selectionModel()->blockSignals(false);
314 update_ui_from_time(t);
317 void MainWindow::insert_noplayer_event(const string &type)
319 uint64_t t = ui->video->get_position();
321 ui->event_view->selectionModel()->blockSignals(true);
322 ui->event_view->selectRow(events->insert_event(t, nullopt, nullopt, type));
323 ui->event_view->selectionModel()->blockSignals(false);
325 update_ui_from_time(t);
328 void MainWindow::set_current_event_type(const string &type)
330 QItemSelectionModel *select = ui->event_view->selectionModel();
331 if (!select->hasSelection()) {
334 int row = select->selectedRows().front().row(); // Should only be one, due to our selection behavior.
335 events->set_event_type(row, type);
336 update_ui_from_time(ui->video->get_position());
339 // Formation buttons either modify the existing formation (if we've selected
340 // a formation change event), or insert a new one (if not).
341 void MainWindow::insert_or_change_formation(bool offense)
343 FormationsModel *formations = offense ? offensive_formations : defensive_formations;
344 QListView *formation_view = offense ? ui->offensive_formation_view : ui->defensive_formation_view;
345 if (!formation_view->selectionModel()->hasSelection()) {
346 // This shouldn't happen; the button should not have been enabled.
349 int formation_row = formation_view->selectionModel()->selectedRows().front().row(); // Should only be one, due to our selection behavior.
350 int formation_id = formations->get_formation_id(formation_row);
351 if (formation_id == -1) {
352 // This also shouldn't happen (“Add new…” selected).
356 QItemSelectionModel *select = ui->event_view->selectionModel();
357 if (select->hasSelection()) {
358 int row = select->selectedRows().front().row(); // Should only be one, due to our selection behavior.
359 EventType expected_type = offense ? EventType::FORMATION_OFFENSE : EventType::FORMATION_DEFENSE;
360 if (events->get_event_type(row) == expected_type) {
361 events->set_event_formation(row, formation_id);
362 update_ui_from_time(ui->video->get_position());
367 // Insert a new formation event instead (same as double-click on the selected one).
368 events->set_formation_at(ui->video->get_position(), offense, formation_id);
369 update_ui_from_time(ui->video->get_position());
372 void MainWindow::delete_current_event()
374 QItemSelectionModel *select = ui->event_view->selectionModel();
375 if (!select->hasSelection()) {
378 int row = select->selectedRows().front().row(); // Should only be one, due to our selection behavior.
379 ui->event_view->selectionModel()->blockSignals(true);
380 events->delete_event(row);
381 ui->event_view->selectionModel()->blockSignals(false);
382 update_ui_from_time(ui->video->get_position());
385 void MainWindow::make_substitution()
387 QItemSelectionModel *select = ui->player_view->selectionModel();
389 for (QModelIndex row : select->selectedRows()) {
390 new_team.insert(players->get_player_id(row.row()));
392 events->set_team_at(ui->video->get_position(), new_team);
393 update_player_buttons(ui->video->get_position());
396 void MainWindow::update_ui_from_time(uint64_t t)
399 update_player_buttons(t);
400 update_action_buttons(t);
403 void MainWindow::update_status(uint64_t t)
405 EventsModel::Status s = events->get_status_at(t);
407 std::string formation = "Not started";
408 if (s.attack_state == EventsModel::Status::OFFENSE) {
409 if (s.offensive_formation != 0) {
410 formation = offensive_formations->get_formation_name_by_id(s.offensive_formation);
412 formation = "Offense";
414 } else if (s.attack_state == EventsModel::Status::DEFENSE) {
415 if (s.defensive_formation != 0) {
416 formation = defensive_formations->get_formation_name_by_id(s.defensive_formation);
418 formation = "Defense";
422 snprintf(buf, sizeof(buf), "%d–%d | %s | %d passes, %d sec possession",
423 s.our_score, s.their_score, formation.c_str(), s.num_passes, s.possession_sec);
424 if (s.stoppage_sec > 0) {
426 snprintf(buf2, sizeof(buf2), "%s (plus %d sec stoppage)", buf, s.stoppage_sec);
427 ui->status->setText(buf2);
429 ui->status->setText(buf);
433 void MainWindow::update_player_buttons(uint64_t t)
435 QPushButton *buttons[] = {
444 const char shortcuts[] = "qweasdf";
446 for (int player_id : events->sort_team(events->get_team_at(t))) {
447 QPushButton *btn = buttons[num_players];
448 string label = players->get_player_name_by_id(player_id) + " (&" + shortcuts[num_players] + ")";
449 char shortcut[2] = "";
450 shortcut[0] = toupper(shortcuts[num_players]);
451 btn->setText(QString::fromUtf8(label));
452 btn->setShortcut(QCoreApplication::translate("MainWindow", shortcut, nullptr));
453 btn->setEnabled(true);
454 if (++num_players == 7) {
458 for (int i = num_players; i < 7; ++i) {
459 QPushButton *btn = buttons[i];
460 btn->setText("No player");
461 btn->setEnabled(false);
465 void MainWindow::update_action_buttons(uint64_t t)
468 QItemSelectionModel *select = ui->offensive_formation_view->selectionModel();
469 if (select->hasSelection()) {
470 int row = select->selectedRows().front().row(); // Should only be one, due to our selection behavior.
471 ui->offensive_formation->setEnabled(offensive_formations->get_formation_id(row) != -1);
473 ui->offensive_formation->setEnabled(false);
477 QItemSelectionModel *select = ui->defensive_formation_view->selectionModel();
478 if (select->hasSelection()) {
479 int row = select->selectedRows().front().row(); // Should only be one, due to our selection behavior.
480 ui->defensive_formation->setEnabled(defensive_formations->get_formation_id(row) != -1);
482 ui->defensive_formation->setEnabled(false);
486 EventsModel::Status s = events->get_status_at(t);
488 bool has_selection = false;
489 bool has_selection_with_player = false;
491 QItemSelectionModel *select = ui->event_view->selectionModel();
492 if (select->hasSelection()) {
493 has_selection = true;
494 int row = select->selectedRows().front().row(); // Should only be one, due to our selection behavior.
495 has_selection_with_player = events->get_player_id(row).has_value();
497 ui->delete_->setEnabled(has_selection);
500 ui->stoppage->setText("Restart (&v)");
501 ui->stoppage->setShortcut(QCoreApplication::translate("MainWindow", "V", nullptr));
502 ui->catch_->setEnabled(false);
503 ui->throwaway->setEnabled(false);
504 ui->drop->setEnabled(false);
505 ui->goal->setEnabled(false);
506 ui->stallout->setEnabled(false);
507 ui->soft_plus->setEnabled(false);
508 ui->soft_minus->setEnabled(false);
509 ui->pull_or_was_d->setEnabled(false);
510 ui->interception->setEnabled(false);
511 ui->their_throwaway->setEnabled(false);
512 ui->our_defense->setEnabled(false);
513 ui->their_goal->setEnabled(false);
514 ui->their_pull->setEnabled(false);
517 ui->stoppage->setText("Stoppage (&v)");
518 ui->stoppage->setShortcut(QCoreApplication::translate("MainWindow", "V", nullptr));
521 // Defaults for pull-related buttons.
522 ui->pull_or_was_d->setText("Pull (&p)");
523 ui->their_pull->setText("Their pull (&p)");
524 ui->pull_or_was_d->setShortcut(QCoreApplication::translate("MainWindow", "P", nullptr));
525 ui->their_pull->setShortcut(QCoreApplication::translate("MainWindow", "P", nullptr));
526 ui->throwaway->setText("Throwaway (&t)");
527 ui->throwaway->setShortcut(QCoreApplication::translate("MainWindow", "T", nullptr));
529 if (s.pull_state == EventsModel::Status::SHOULD_PULL ||
530 (has_selection_with_player && events->get_status_at(ui->video->get_position() - 1).pull_state == EventsModel::Status::SHOULD_PULL)) { // Can change this event to pull.
531 ui->pull_or_was_d->setEnabled(s.attack_state == EventsModel::Status::DEFENSE && has_selection_with_player);
532 ui->their_pull->setEnabled(s.attack_state == EventsModel::Status::OFFENSE);
534 ui->catch_->setEnabled(false);
535 ui->throwaway->setEnabled(false);
536 ui->drop->setEnabled(false);
537 ui->goal->setEnabled(false);
538 ui->stallout->setEnabled(false);
539 ui->soft_plus->setEnabled(false);
540 ui->soft_minus->setEnabled(false);
541 ui->interception->setEnabled(false);
542 ui->their_throwaway->setEnabled(false);
543 ui->our_defense->setEnabled(false);
544 ui->their_goal->setEnabled(false);
547 if (s.pull_state == EventsModel::Status::PULL_IN_AIR) {
548 if (s.attack_state == EventsModel::Status::DEFENSE) {
549 ui->pull_or_was_d->setText("Pull landed (&p)");
550 ui->pull_or_was_d->setShortcut(QCoreApplication::translate("MainWindow", "P", nullptr));
551 ui->pull_or_was_d->setEnabled(true);
553 ui->throwaway->setText("Pull OOB (&t)");
554 ui->throwaway->setShortcut(QCoreApplication::translate("MainWindow", "T", nullptr));
555 ui->throwaway->setEnabled(true);
557 ui->pull_or_was_d->setEnabled(false);
558 ui->throwaway->setEnabled(false);
560 ui->their_pull->setEnabled(false); // We don't track their pull landings; only by means of catch etc.
562 ui->catch_->setEnabled(false);
563 ui->drop->setEnabled(false);
564 ui->goal->setEnabled(false);
565 ui->stallout->setEnabled(false);
566 ui->soft_plus->setEnabled(false);
567 ui->soft_minus->setEnabled(false);
568 ui->interception->setEnabled(false);
569 ui->their_throwaway->setEnabled(false);
570 ui->our_defense->setEnabled(false);
571 ui->their_goal->setEnabled(false);
575 // Not pulling, so reuse the pull button for got d-ed.
576 ui->pull_or_was_d->setText("Was d-ed (&z)");
577 ui->pull_or_was_d->setShortcut(QCoreApplication::translate("MainWindow", "Z", nullptr));
578 ui->pull_or_was_d->setEnabled(true);
580 ui->catch_->setEnabled(s.attack_state == EventsModel::Status::OFFENSE && has_selection_with_player);
581 ui->throwaway->setEnabled(s.attack_state == EventsModel::Status::OFFENSE && has_selection_with_player);
582 ui->drop->setEnabled(s.attack_state == EventsModel::Status::OFFENSE && has_selection_with_player);
583 ui->goal->setEnabled(s.attack_state == EventsModel::Status::OFFENSE && has_selection_with_player);
584 ui->stallout->setEnabled(s.attack_state == EventsModel::Status::OFFENSE && has_selection_with_player);
585 ui->soft_plus->setEnabled(s.attack_state != EventsModel::Status::NOT_STARTED && has_selection_with_player);
586 ui->soft_minus->setEnabled(s.attack_state != EventsModel::Status::NOT_STARTED && has_selection_with_player);
587 ui->pull_or_was_d->setEnabled(s.attack_state == EventsModel::Status::OFFENSE && has_selection_with_player); // Was d-ed.
589 ui->interception->setEnabled(s.attack_state == EventsModel::Status::DEFENSE && has_selection_with_player);
590 ui->their_throwaway->setEnabled(s.attack_state == EventsModel::Status::DEFENSE);
591 ui->our_defense->setEnabled(s.attack_state == EventsModel::Status::DEFENSE && has_selection_with_player);
592 ui->their_goal->setEnabled(s.attack_state == EventsModel::Status::DEFENSE);
593 ui->their_pull->setEnabled(false);
596 void MainWindow::formation_double_clicked(bool offense, unsigned row)
598 FormationsModel *formations = offense ? offensive_formations : defensive_formations;
599 int id = formations->get_formation_id(row);
600 if (id == -1) { // “Add new” clicked.
602 QString new_formation_str = QInputDialog::getText(this, "New formation", "Choose name for new formation:", QLineEdit::Normal, "", &ok);
603 if (!ok || new_formation_str.isEmpty()) {
607 id = formations->insert_new(new_formation_str.toStdString());
608 QListView *view = offense ? ui->offensive_formation_view : ui->defensive_formation_view;
609 view->selectionModel()->select(formations->index(formations->get_row_from_id(id), 0), QItemSelectionModel::ClearAndSelect);
610 events->inserted_new_formation(id, new_formation_str.toStdString());
612 events->set_formation_at(ui->video->get_position(), offense, id);
614 update_ui_from_time(ui->video->get_position());