From 4adb5ff056d4a5a35cd7f76a9785c5cab57fdc03 Mon Sep 17 00:00:00 2001 From: Loic Guegan Date: Fri, 25 Feb 2022 09:21:26 +0100 Subject: Improve game base panel --- src/MainWindow.cpp | 30 ++++-------------------------- 1 file changed, 4 insertions(+), 26 deletions(-) (limited to 'src/MainWindow.cpp') diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index 5c1a87f..afca91e 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -51,12 +51,6 @@ MainWindow::MainWindow() notebook = new wxAuiNotebook(this, wxID_ANY); NewGame(new Game()); - // Test base tab - BaseTab *bt = new BaseTab((wxFrame *)notebook); - bt->SetLabel("New Base"); - notebook->AddPage(bt, bt->GetLabel()); - notebook->SetSelection(notebook->GetPageIndex(bt)); - Bind(wxEVT_AUINOTEBOOK_PAGE_CHANGED, &MainWindow::OnPageChange, this, wxID_ANY); Bind(REFRESH_TAB_TITLE, &MainWindow::OnRefreshTabTitle, this, wxID_ANY); @@ -112,26 +106,10 @@ void MainWindow::OnOpen(wxCommandEvent &event) { wxFD_OPEN | wxFD_FILE_MUST_EXIST); if (openFileDialog.ShowModal() != wxID_CANCEL) { std::string path = openFileDialog.GetPath().ToStdString(); - pgnp::PGN pgn; - try { - pgn.FromFile(path); - pgn.ParseNextGame(); - pgnp::HalfMove *pgnp_moves = new pgnp::HalfMove(); - pgn.GetMoves(pgnp_moves); - std::string fen = - "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1"; - if (pgn.HasTag("FEN")) { - fen = pgn.GetTagValue("FEN"); - } - HalfMove *m = new HalfMove(pgnp_moves, fen); - Game *g = new Game(m, fen); - for (std::string &s : pgn.GetTagList()) { - g->SetTag(s, pgn.GetTagValue(s)); - } - NewGame(g); - } catch (std::exception &e) { - SHOW_DIALOG_ERROR("Invalid PGN file: " + std::string(e.what())); - } + // Test base tab + BaseTab *bt = new BaseTab((wxFrame *)notebook, path); + notebook->AddPage(bt, bt->GetLabel()); + notebook->SetSelection(notebook->GetPageIndex(bt)); } } -- cgit v1.2.3