From c97e151e1be7123d9d15e9ffcff1c46cecbb543a Mon Sep 17 00:00:00 2001 From: Loic Guegan Date: Tue, 27 Dec 2022 15:58:16 +0100 Subject: Improve game import --- src/base_tab/AppendGameDialog.cpp | 47 --------------------------------------- 1 file changed, 47 deletions(-) delete mode 100644 src/base_tab/AppendGameDialog.cpp (limited to 'src/base_tab/AppendGameDialog.cpp') diff --git a/src/base_tab/AppendGameDialog.cpp b/src/base_tab/AppendGameDialog.cpp deleted file mode 100644 index 260ba90..0000000 --- a/src/base_tab/AppendGameDialog.cpp +++ /dev/null @@ -1,47 +0,0 @@ -#include "AppendGameDialog.hpp" -#include "MainWindow.hpp" -#include "ochess.hpp" - -AppendGameDialog::AppendGameDialog(wxWindow *parent, std::shared_ptr base) - : DialogAppendGame(parent), base(base) { - - for (TabInfos *i : wxGetApp().ListTabInfos()) { - if (i->type == TabInfos::GAME || i->type == TabInfos::BASE) { - wxWindow *win = dynamic_cast(i); - game_list->Append(win->GetLabel()); - tinfos.push_back(i); - } - } - - Bind(wxEVT_BUTTON, &AppendGameDialog::OnCancel, this, - ID_DIALOG_CANCEL_BUTTON); - Bind(wxEVT_BUTTON, &AppendGameDialog::OnImport, this, - ID_DIALOG_IMPORT_BUTTON); - Bind(wxEVT_CLOSE_WINDOW, &AppendGameDialog::OnClose, this); -} - -void AppendGameDialog::OnClose(wxCloseEvent &e) { Destroy(); } - -void AppendGameDialog::OnCancel(wxCommandEvent &event) { this->Close(); } - -void AppendGameDialog::OnImport(wxCommandEvent &event) { - std::vector to_ignore; - std::vector> new_games_bases; - std::vector> new_games; - - wxArrayInt selections; - game_list->GetSelections(selections); - - for (int &i : selections) { - TabInfos *tinfo = tinfos[i]; - if (tinfo->type == TabInfos::BASE) { - new_games_bases.push_back(tinfo->GetBase()); - } else if (tinfo->type == TabInfos::GAME) { - new_games.push_back(tinfo->GetGame()); - } - } - - base->Save(to_ignore, new_games_bases, new_games); - - this->Close(); -} \ No newline at end of file -- cgit v1.2.3