aboutsummaryrefslogtreecommitdiff
path: root/src/base_tab
diff options
context:
space:
mode:
Diffstat (limited to 'src/base_tab')
-rw-r--r--src/base_tab/BaseTab.cpp10
-rw-r--r--src/base_tab/BaseTab.hpp3
-rw-r--r--src/base_tab/gamebase/PGNGameBase.cpp4
3 files changed, 12 insertions, 5 deletions
diff --git a/src/base_tab/BaseTab.cpp b/src/base_tab/BaseTab.cpp
index f1fd107..29b6fc3 100644
--- a/src/base_tab/BaseTab.cpp
+++ b/src/base_tab/BaseTab.cpp
@@ -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"));
diff --git a/src/base_tab/BaseTab.hpp b/src/base_tab/BaseTab.hpp
index 5a71cd7..26ee8c1 100644
--- a/src/base_tab/BaseTab.hpp
+++ b/src/base_tab/BaseTab.hpp
@@ -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;
diff --git a/src/base_tab/gamebase/PGNGameBase.cpp b/src/base_tab/gamebase/PGNGameBase.cpp
index 08c8803..8f9974d 100644
--- a/src/base_tab/gamebase/PGNGameBase.cpp
+++ b/src/base_tab/gamebase/PGNGameBase.cpp
@@ -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));