Debug live engine

This commit is contained in:
Loic Guegan 2022-02-28 15:52:19 +01:00
parent 3cbbd1128d
commit 8f1e8fa106
4 changed files with 53 additions and 35 deletions

View file

@ -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(PREVIOUS_MOVE_EVENT, &GameTabRightPanel::OnPreviousMove, this,
wxID_ANY);
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_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() {

View file

@ -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);
};