mirror of
https://gitlab.com/manzerbredes/ochess.git
synced 2025-07-04 19:27:40 +00:00
Update chessarbiter and improve pgn loader
This commit is contained in:
parent
f99a7b699a
commit
829525acb9
8 changed files with 29 additions and 10 deletions
|
@ -22,10 +22,13 @@ void BaseTab::OnBim(wxCommandEvent &event) {
|
|||
|
||||
void BaseTab::OnOpenGame(wxListEvent &event) {
|
||||
wxLogDebug("Open!");
|
||||
long id=std::stoi(event.GetItem().GetText().ToStdString());
|
||||
long id = std::stoi(event.GetItem().GetText().ToStdString());
|
||||
Game *g = base->GetGame(id);
|
||||
if (g != NULL) {
|
||||
wxLogDebug("Open game: %s", g->GetTag("White"));
|
||||
wxCommandEvent newGameEvent(NEW_GAME_EVENT, GetId());
|
||||
newGameEvent.SetEventObject(this);
|
||||
newGameEvent.SetClientData(g);
|
||||
ProcessEvent(newGameEvent);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -41,7 +44,8 @@ void BaseTab::LoadFile(std::string path) {
|
|||
if (base != NULL) {
|
||||
long id = 0;
|
||||
while (base->NextGame()) {
|
||||
long index = game_list->InsertItem(0, std::to_string(id)); // want this for col. 1
|
||||
long index =
|
||||
game_list->InsertItem(0, std::to_string(id)); // want this for col. 1
|
||||
game_list->SetItem(index, 1, base->GetTag("White"));
|
||||
game_list->SetItem(index, 2, base->GetTag("Black"));
|
||||
game_list->SetItem(index, 3, base->GetTag("Event"));
|
||||
|
|
|
@ -4,6 +4,9 @@
|
|||
#include "gamebase/PGNGameBase.hpp"
|
||||
#include "ochess.hpp"
|
||||
|
||||
// Foreign events
|
||||
wxDECLARE_EVENT(NEW_GAME_EVENT, wxCommandEvent);
|
||||
|
||||
class BaseTab : public BasePanelBF, public TabInfos {
|
||||
GameBase *base;
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ void PGNGameBase::Reset() {
|
|||
Game *PGNGameBase::GetGame(std::uint32_t id) {
|
||||
Reset();
|
||||
std::uint32_t curid = 0;
|
||||
while(NextGame()) {
|
||||
while (NextGame()) {
|
||||
if (id == curid) {
|
||||
pgnp::HalfMove *pgnp_moves = new pgnp::HalfMove();
|
||||
pgn->GetMoves(pgnp_moves);
|
||||
|
@ -41,7 +41,7 @@ Game *PGNGameBase::GetGame(std::uint32_t id) {
|
|||
if (pgn->HasTag("FEN")) {
|
||||
fen = pgn->GetTagValue("FEN");
|
||||
}
|
||||
HalfMove *m = new HalfMove(pgnp_moves, 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));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue