aboutsummaryrefslogtreecommitdiff
path: root/src/game_tab/right_panel/GameTabRightPanel.cpp
diff options
context:
space:
mode:
authorLoic Guegan <manzerbredes@mailbox.org>2022-02-28 15:52:19 +0100
committerLoic Guegan <manzerbredes@mailbox.org>2022-02-28 15:52:19 +0100
commit8f1e8fa106107c61c7ac62fa0f13340537ba4d23 (patch)
treeebff4736441faef551b683db0267bf4e29382976 /src/game_tab/right_panel/GameTabRightPanel.cpp
parent3cbbd1128d0002cf9cdc4c4cbbc61a8e0d89ff10 (diff)
Debug live engine
Diffstat (limited to 'src/game_tab/right_panel/GameTabRightPanel.cpp')
-rw-r--r--src/game_tab/right_panel/GameTabRightPanel.cpp48
1 files changed, 31 insertions, 17 deletions
diff --git a/src/game_tab/right_panel/GameTabRightPanel.cpp b/src/game_tab/right_panel/GameTabRightPanel.cpp
index f7c9b1b..f34dd59 100644
--- a/src/game_tab/right_panel/GameTabRightPanel.cpp
+++ b/src/game_tab/right_panel/GameTabRightPanel.cpp
@@ -1,5 +1,4 @@
#include "GameTabRightPanel.hpp"
-#include "LiveEngineDialog.hpp"
wxDEFINE_EVENT(GOTO_MOVE_EVENT, wxCommandEvent);
wxDEFINE_EVENT(DELETE_MOVE_EVENT, wxCommandEvent);
@@ -9,7 +8,8 @@ wxDEFINE_EVENT(PREVIOUS_MOVE_EVENT, wxCommandEvent);
wxDEFINE_EVENT(NEXT_MOVE_EVENT, wxCommandEvent);
GameTabRightPanel::GameTabRightPanel(wxFrame *parent, Game *game)
- : TabGameRightPanel(parent), game(game), selected_item(-1) {
+ : TabGameRightPanel(parent), game(game), selected_item(-1),
+ live_engine(NULL) {
editor_canvas = new EditorCanvas((wxFrame *)editor_page);
editor_canvas_sizer->Add(editor_canvas, 1, wxEXPAND);
tags_list->InsertColumn(0, L"Name", wxLIST_FORMAT_LEFT, 200);
@@ -17,26 +17,25 @@ GameTabRightPanel::GameTabRightPanel(wxFrame *parent, Game *game)
tagTextCtrl->SetHint("Tag");
valueTextCtrl->SetHint("Value");
- /*LiveEngineDialog *diag=new LiveEngineDialog(this, "Stockfish");
- diag->SetFEN("rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1");
-
- diag->Show();*/
RefreshTagsList();
// Bind events
this->Bind(wxEVT_TEXT, &GameTabRightPanel::OnCommentChange, this,
COMMENT_INPUT_BOX);
this->Bind(GOTO_MOVE_EVENT, &GameTabRightPanel::OnGotoMove, this, wxID_ANY);
- this->Bind(DELETE_MOVE_EVENT, &GameTabRightPanel::OnMoveDelete, this, wxID_ANY);
- this->Bind(PROMOTE_MOVE_EVENT, &GameTabRightPanel::OnMovePromote, this, wxID_ANY);
- this->Bind(SET_AS_MAINLINE_EVENT, &GameTabRightPanel::OnMoveSetAsMainline, this,
+ this->Bind(DELETE_MOVE_EVENT, &GameTabRightPanel::OnMoveDelete, this,
+ wxID_ANY);
+ this->Bind(PROMOTE_MOVE_EVENT, &GameTabRightPanel::OnMovePromote, this,
wxID_ANY);
+ this->Bind(SET_AS_MAINLINE_EVENT, &GameTabRightPanel::OnMoveSetAsMainline,
+ this, wxID_ANY);
this->Bind(NEXT_MOVE_EVENT, &GameTabRightPanel::OnNextMove, this, wxID_ANY);
- this->Bind(PREVIOUS_MOVE_EVENT, &GameTabRightPanel::OnPreviousMove, this, wxID_ANY);
- this->Bind(wxEVT_LIST_ITEM_SELECTED, &GameTabRightPanel::OnTagSelected, this,
+ this->Bind(PREVIOUS_MOVE_EVENT, &GameTabRightPanel::OnPreviousMove, this,
wxID_ANY);
- this->Bind(wxEVT_LIST_ITEM_DESELECTED, &GameTabRightPanel::OnTagDeselected, this,
+ this->Bind(wxEVT_LIST_ITEM_SELECTED, &GameTabRightPanel::OnTagSelected, this,
wxID_ANY);
+ this->Bind(wxEVT_LIST_ITEM_DESELECTED, &GameTabRightPanel::OnTagDeselected,
+ this, wxID_ANY);
this->Bind(wxEVT_BUTTON, &GameTabRightPanel::OnApply, this, UPDATE_BTN);
this->Bind(wxEVT_BUTTON, &GameTabRightPanel::OnDelete, this, DELETE_BTN);
this->Bind(wxEVT_BUTTON, &GameTabRightPanel::OnLiveAnalysis, this,
@@ -46,11 +45,17 @@ GameTabRightPanel::GameTabRightPanel(wxFrame *parent, Game *game)
}
void GameTabRightPanel::OnLiveAnalysis(wxCommandEvent &event) {
- int selection = engine_list->GetSelection();
- if (selection != wxNOT_FOUND) {
- LiveEngineDialog *diag = new LiveEngineDialog(this, engine_list->GetString(selection).ToStdString());
- diag->SetFEN("rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1");
- diag->Show();
+ if (live_engine == NULL) {
+ int selection = engine_list->GetSelection();
+ if (selection != wxNOT_FOUND) {
+ live_engine = new LiveEngineDialog(
+ this, engine_list->GetString(selection).ToStdString());
+ live_engine->SetFEN(game->GetFen());
+ live_engine->Show();
+ live_engine->Bind(wxEVT_CLOSE_WINDOW,
+ &GameTabRightPanel::OnLiveEngineClose, this,
+ ID_LIVE_ENGINE_DIALOG);
+ }
}
}
@@ -76,6 +81,11 @@ void GameTabRightPanel::NotifyBoard() {
ProcessEvent(previousEvent);
}
+void GameTabRightPanel::OnLiveEngineClose(wxCloseEvent &e) {
+ live_engine = NULL;
+ e.Skip();
+}
+
void GameTabRightPanel::OnCommentChange(wxCommandEvent &event) {
wxLogDebug("GameTabRightPanel: comment input change");
HalfMove *m = game->GetCurrentMove();
@@ -152,6 +162,10 @@ void GameTabRightPanel::Notify() {
m->GetComment()); // ChangeValue do not raise events
}
editor_canvas->SetMoves(game->GetMoves(), m);
+ // Put it here for now:
+ if (live_engine != NULL) {
+ live_engine->SetFEN(game->GetFen());
+ }
}
void GameTabRightPanel::ApplyPreferences() {