mirror of
https://gitlab.com/manzerbredes/ochess.git
synced 2025-04-07 02:26:29 +02:00
Debug PGN import
This commit is contained in:
parent
ce941c146a
commit
a3c24f27f0
4 changed files with 12 additions and 8 deletions
|
@ -97,9 +97,13 @@ void MainWindow::OnOpen(wxCommandEvent &event) {
|
||||||
fen = pgn.GetTagValue("FEN");
|
fen = pgn.GetTagValue("FEN");
|
||||||
}
|
}
|
||||||
HalfMove *m = new HalfMove(pgnp_moves, fen);
|
HalfMove *m = new HalfMove(pgnp_moves, fen);
|
||||||
NewGame(new Game(m));
|
Game *g=new Game(m,fen);
|
||||||
} catch (...) {
|
for(std::string &s:pgn.GetTagList()){
|
||||||
SHOW_DIALOG_ERROR("Invalid PGN file");
|
g->SetTag(s,pgn.GetTagValue(s));
|
||||||
|
}
|
||||||
|
NewGame(g);
|
||||||
|
} catch (std::exception &e) {
|
||||||
|
SHOW_DIALOG_ERROR("Invalid PGN file: " + std::string(e.what()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,10 +15,10 @@ Game::Game(std::string fen) : current(NULL), moves(NULL) {
|
||||||
board = chessarbiter::FENParser::Parse(fen).board;
|
board = chessarbiter::FENParser::Parse(fen).board;
|
||||||
}
|
}
|
||||||
|
|
||||||
Game::Game(HalfMove *m) {
|
Game::Game(HalfMove *m, std::string initial_fen) {
|
||||||
moves = m;
|
moves = m;
|
||||||
current = m;
|
current = m;
|
||||||
initial_fen = m->GetFen();
|
this->initial_fen = initial_fen;
|
||||||
board = chessarbiter::FENParser::Parse(initial_fen).board;
|
board = chessarbiter::FENParser::Parse(initial_fen).board;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ bool Game::Play(std::string move) {
|
||||||
if (moves == NULL) {
|
if (moves == NULL) {
|
||||||
moves = m;
|
moves = m;
|
||||||
}
|
}
|
||||||
wxLogDebug("%s",GetPGN());
|
wxLogDebug("%s", GetPGN());
|
||||||
return (true);
|
return (true);
|
||||||
}
|
}
|
||||||
return (false);
|
return (false);
|
||||||
|
|
|
@ -16,7 +16,7 @@ class Game {
|
||||||
public:
|
public:
|
||||||
Game();
|
Game();
|
||||||
Game(std::string fen);
|
Game(std::string fen);
|
||||||
Game(HalfMove *m);
|
Game(HalfMove *m, std::string initial_fen);
|
||||||
|
|
||||||
std::string GetBoard();
|
std::string GetBoard();
|
||||||
std::string GetTag(std::string tagname);
|
std::string GetTag(std::string tagname);
|
||||||
|
|
|
@ -48,7 +48,7 @@ EditorPanel::EditorPanel(wxFrame *parent, Game *game)
|
||||||
tag_panel_sizer->Add(tag_edit_panel, 0, wxEXPAND);
|
tag_panel_sizer->Add(tag_edit_panel, 0, wxEXPAND);
|
||||||
tags_list = new wxListCtrl(tag_panel, wxID_ANY, wxDefaultPosition,
|
tags_list = new wxListCtrl(tag_panel, wxID_ANY, wxDefaultPosition,
|
||||||
wxDefaultSize, wxLC_REPORT);
|
wxDefaultSize, wxLC_REPORT);
|
||||||
tags_list->InsertColumn(0, L"Name");
|
tags_list->InsertColumn(0, L"Name", wxLIST_FORMAT_LEFT, 200);
|
||||||
tags_list->InsertColumn(1, L"Value", wxLIST_FORMAT_LEFT, 500);
|
tags_list->InsertColumn(1, L"Value", wxLIST_FORMAT_LEFT, 500);
|
||||||
RefreshTagsList();
|
RefreshTagsList();
|
||||||
tag_panel_sizer->Add(tags_list, 1, wxEXPAND);
|
tag_panel_sizer->Add(tags_list, 1, wxEXPAND);
|
||||||
|
|
Loading…
Add table
Reference in a new issue