blob: bfa33f3902bc6580228eeaa24e123c42990c9d8b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
#include "AppendGameDialog.hpp"
#include "MainWindow.hpp"
#include "ochess.hpp"
AppendGameDialog::AppendGameDialog(wxWindow *parent, GameBase *base)
: AppendGameDialogBF(parent), base(base) {
tinfos = MAINWIN->ListTabInfos();
for (TabInfos *i : tinfos) {
wxWindow *win = dynamic_cast<wxWindow *>(i);
game_list->Append(win->GetLabel());
}
Bind(wxEVT_BUTTON, &AppendGameDialog::OnCancel, this,
ID_DIALOG_CANCEL_BUTTON);
Bind(wxEVT_BUTTON, &AppendGameDialog::OnImport, this,
ID_DIALOG_IMPORT_BUTTON);
}
void AppendGameDialog::OnCancel(wxCommandEvent &event) { this->Close(); }
void AppendGameDialog::OnImport(wxCommandEvent &event) {
std::vector<std::uint32_t> to_ignore;
std::vector<GameBase *> new_games_bases;
std::vector<Game *> 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(static_cast<GameBase *>(tinfo->GetBase()));
} else if (tinfo->type == TabInfos::GAME) {
new_games.push_back(static_cast<Game *>(tinfo->GetGame()));
}
}
base->Save(to_ignore, new_games_bases, new_games);
this->Close();
}
|