mirror of
https://gitlab.com/manzerbredes/ochess.git
synced 2025-04-19 04:09:41 +00:00
Improve game base panel
This commit is contained in:
parent
416ab7635d
commit
4adb5ff056
6 changed files with 401 additions and 198 deletions
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue