aboutsummaryrefslogtreecommitdiff
path: root/src
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
parent3cbbd1128d0002cf9cdc4c4cbbc61a8e0d89ff10 (diff)
Debug live engine
Diffstat (limited to 'src')
-rw-r--r--src/game_tab/right_panel/GameTabRightPanel.cpp48
-rw-r--r--src/game_tab/right_panel/GameTabRightPanel.hpp3
-rw-r--r--src/gui.h35
3 files changed, 52 insertions, 34 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() {
diff --git a/src/game_tab/right_panel/GameTabRightPanel.hpp b/src/game_tab/right_panel/GameTabRightPanel.hpp
index c5912dd..021f755 100644
--- a/src/game_tab/right_panel/GameTabRightPanel.hpp
+++ b/src/game_tab/right_panel/GameTabRightPanel.hpp
@@ -1,4 +1,5 @@
#include "../Game.hpp"
+#include "LiveEngineDialog.hpp"
#include "editor/EditorCanvas.hpp"
#include "ochess.hpp"
#include <wx/listctrl.h>
@@ -18,6 +19,7 @@ class GameTabRightPanel : public TabGameRightPanel {
Game *game;
EditorCanvas *editor_canvas;
long selected_item;
+ LiveEngineDialog *live_engine;
public:
GameTabRightPanel(wxFrame *parent, Game *game);
@@ -37,4 +39,5 @@ public:
void OnNextMove(wxCommandEvent &event);
void OnLiveAnalysis(wxCommandEvent &event);
void ApplyPreferences();
+ void OnLiveEngineClose(wxCloseEvent &e);
}; \ No newline at end of file
diff --git a/src/gui.h b/src/gui.h
index e5dae19..c0f8a84 100644
--- a/src/gui.h
+++ b/src/gui.h
@@ -41,22 +41,23 @@
///////////////////////////////////////////////////////////////////////////
-#define LIVE_ENGINE_PAUSE_BUTTON 1000
-#define ID_DIALOG_CANCEL_BUTTON 1001
-#define ID_DIALOG_IMPORT_BUTTON 1002
-#define ENGINE_SAVE_CONF_BUTTON 1003
-#define ENGINE_DELETE_CONF_BUTTON 1004
-#define ID_SAVE_BUTTON 1005
-#define ID_EXPORT_BUTTON 1006
-#define ID_IMPORT_BUTTON 1007
-#define ID_DELETE_BUTTON 1008
-#define SWAP_BTN 1009
-#define ZOOM_IN_BTN 1010
-#define ZOOM_OUT_BTN 1011
-#define COMMENT_INPUT_BOX 1012
-#define UPDATE_BTN 1013
-#define DELETE_BTN 1014
-#define LIVE_ANALYSIS_GAME_BUTTON 1015
+#define ID_LIVE_ENGINE_DIALOG 1000
+#define LIVE_ENGINE_PAUSE_BUTTON 1001
+#define ID_DIALOG_CANCEL_BUTTON 1002
+#define ID_DIALOG_IMPORT_BUTTON 1003
+#define ENGINE_SAVE_CONF_BUTTON 1004
+#define ENGINE_DELETE_CONF_BUTTON 1005
+#define ID_SAVE_BUTTON 1006
+#define ID_EXPORT_BUTTON 1007
+#define ID_IMPORT_BUTTON 1008
+#define ID_DELETE_BUTTON 1009
+#define SWAP_BTN 1010
+#define ZOOM_IN_BTN 1011
+#define ZOOM_OUT_BTN 1012
+#define COMMENT_INPUT_BOX 1013
+#define UPDATE_BTN 1014
+#define DELETE_BTN 1015
+#define LIVE_ANALYSIS_GAME_BUTTON 1016
///////////////////////////////////////////////////////////////////////////////
/// Class MainFrame
@@ -103,7 +104,7 @@ class DialogLiveEngine : public wxDialog
public:
- DialogLiveEngine( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 464,468 ), long style = wxDEFAULT_DIALOG_STYLE );
+ DialogLiveEngine( wxWindow* parent, wxWindowID id = ID_LIVE_ENGINE_DIALOG, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 464,468 ), long style = wxDEFAULT_DIALOG_STYLE );
~DialogLiveEngine();