aboutsummaryrefslogtreecommitdiff
path: root/src/game_tab
diff options
context:
space:
mode:
authorLoic Guegan <manzerbredes@mailbox.org>2022-02-27 19:55:30 +0100
committerLoic Guegan <manzerbredes@mailbox.org>2022-02-27 19:55:30 +0100
commit175ce5e10859e2831b0e49a4bf768a9217305d8f (patch)
tree3c40c98231bc17be17366b67f8407427c9c5e01c /src/game_tab
parent3cdb25e54654adcf007c2132fb20114f56c4ae4d (diff)
Debug live engine dialog
Diffstat (limited to 'src/game_tab')
-rw-r--r--src/game_tab/editor/EditorPanel.cpp12
-rw-r--r--src/game_tab/editor/EditorPanel.hpp3
-rw-r--r--src/game_tab/editor/EditorPanelBF.cpp2
-rw-r--r--src/game_tab/editor/EditorPanelBF.h1
-rw-r--r--src/game_tab/editor/LiveEngineDialog.cpp14
-rw-r--r--src/game_tab/editor/LiveEngineDialog.hpp1
6 files changed, 30 insertions, 3 deletions
diff --git a/src/game_tab/editor/EditorPanel.cpp b/src/game_tab/editor/EditorPanel.cpp
index dfbb35f..b29477a 100644
--- a/src/game_tab/editor/EditorPanel.cpp
+++ b/src/game_tab/editor/EditorPanel.cpp
@@ -39,9 +39,21 @@ EditorPanel::EditorPanel(wxFrame *parent, Game *game)
wxID_ANY);
this->Bind(wxEVT_BUTTON, &EditorPanel::OnApply, this, UPDATE_BTN);
this->Bind(wxEVT_BUTTON, &EditorPanel::OnDelete, this, DELETE_BTN);
+ this->Bind(wxEVT_BUTTON, &EditorPanel::OnLiveAnalysis, this,
+ LIVE_ANALYSIS_GAME_BUTTON);
+
ApplyPreferences();
}
+void EditorPanel::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();
+ }
+}
+
void EditorPanel::OnTagSelected(wxListEvent &event) {
wxListItem item = event.GetItem();
std::string key = item.GetText().ToStdString();
diff --git a/src/game_tab/editor/EditorPanel.hpp b/src/game_tab/editor/EditorPanel.hpp
index 8502c14..b0a00ce 100644
--- a/src/game_tab/editor/EditorPanel.hpp
+++ b/src/game_tab/editor/EditorPanel.hpp
@@ -1,9 +1,9 @@
#include "../Game.hpp"
#include "EditorCanvas.hpp"
+#include "EditorPanelBF.h"
#include "ochess.hpp"
#include <wx/listctrl.h>
#include <wx/notebook.h>
-#include "EditorPanelBF.h"
// Local events
wxDECLARE_EVENT(GOTO_MOVE_EVENT, wxCommandEvent);
@@ -36,5 +36,6 @@ public:
void OnDelete(wxCommandEvent &event);
void OnPreviousMove(wxCommandEvent &event);
void OnNextMove(wxCommandEvent &event);
+ void OnLiveAnalysis(wxCommandEvent &event);
void ApplyPreferences();
}; \ No newline at end of file
diff --git a/src/game_tab/editor/EditorPanelBF.cpp b/src/game_tab/editor/EditorPanelBF.cpp
index 8aac38e..8928806 100644
--- a/src/game_tab/editor/EditorPanelBF.cpp
+++ b/src/game_tab/editor/EditorPanelBF.cpp
@@ -88,7 +88,7 @@ EditorPanelBF::EditorPanelBF( wxWindow* parent, wxWindowID id, const wxPoint& po
analyze_game_button = new wxButton( engine_page, wxID_ANY, wxT("Analyze game"), wxDefaultPosition, wxDefaultSize, 0 );
engine_page_sizer->Add( analyze_game_button, 0, wxALL|wxEXPAND, 5 );
- live_analysis_button = new wxButton( engine_page, wxID_ANY, wxT("Live analysis"), wxDefaultPosition, wxDefaultSize, 0 );
+ live_analysis_button = new wxButton( engine_page, LIVE_ANALYSIS_GAME_BUTTON, wxT("Live analysis"), wxDefaultPosition, wxDefaultSize, 0 );
engine_page_sizer->Add( live_analysis_button, 0, wxALL|wxEXPAND, 5 );
diff --git a/src/game_tab/editor/EditorPanelBF.h b/src/game_tab/editor/EditorPanelBF.h
index c5b38d5..b33655e 100644
--- a/src/game_tab/editor/EditorPanelBF.h
+++ b/src/game_tab/editor/EditorPanelBF.h
@@ -32,6 +32,7 @@
#define COMMENT_INPUT_BOX 1000
#define UPDATE_BTN 1001
#define DELETE_BTN 1002
+#define LIVE_ANALYSIS_GAME_BUTTON 1003
///////////////////////////////////////////////////////////////////////////////
/// Class EditorPanelBF
diff --git a/src/game_tab/editor/LiveEngineDialog.cpp b/src/game_tab/editor/LiveEngineDialog.cpp
index 07fd782..0fc85b0 100644
--- a/src/game_tab/editor/LiveEngineDialog.cpp
+++ b/src/game_tab/editor/LiveEngineDialog.cpp
@@ -10,6 +10,7 @@ LiveEngineDialog::LiveEngineDialog(wxWindow *parent, std::string engine_name)
InitEngine();
Bind(wxEVT_BUTTON, &LiveEngineDialog::TogglePauseEngine, this,
LIVE_ENGINE_PAUSE_BUTTON);
+ Bind(wxEVT_CLOSE_WINDOW, &LiveEngineDialog::OnClose, this);
}
void LiveEngineDialog::InitEngine() {
@@ -29,7 +30,7 @@ void LiveEngineDialog::InitEngine() {
wxString optPath = opt_name + "/";
wxString default_value_wxString = conf->Read(optPath + "value");
std::string default_value = default_value_wxString.ToStdString();
- engine->setoption(opt_name.ToStdString(),default_value);
+ engine->setoption(opt_name.ToStdString(), default_value);
} while (conf->GetNextGroup(opt_name, index));
}
@@ -39,6 +40,17 @@ void LiveEngineDialog::InitEngine() {
timer.Bind(wxEVT_TIMER, &LiveEngineDialog::OnTimerTick, this);
}
+void LiveEngineDialog::OnClose(wxCloseEvent &e) {
+ if (engine != NULL) {
+ wxLogDebug("Close live engine!!");
+ timer.Stop();
+ engine->stop();
+ engine->quit();
+ delete engine;
+ }
+ e.Skip();
+}
+
void LiveEngineDialog::SetFEN(std::string fen) {
timer.Stop();
engine->position(fen);
diff --git a/src/game_tab/editor/LiveEngineDialog.hpp b/src/game_tab/editor/LiveEngineDialog.hpp
index 5b9fccb..703abf8 100644
--- a/src/game_tab/editor/LiveEngineDialog.hpp
+++ b/src/game_tab/editor/LiveEngineDialog.hpp
@@ -15,4 +15,5 @@ public:
void TogglePauseEngine(wxCommandEvent &event);
void OnTimerTick(wxTimerEvent &event);
void SetFEN(std::string fen);
+ void OnClose(wxCloseEvent &e);
}; \ No newline at end of file