Improve live engine analysis dialog

This commit is contained in:
Loic Guegan 2022-02-28 10:38:56 +01:00
parent 175ce5e108
commit ff6b1980c9
5 changed files with 463 additions and 21 deletions

View file

@ -31,6 +31,11 @@ void LiveEngineDialog::InitEngine() {
wxString default_value_wxString = conf->Read(optPath + "value");
std::string default_value = default_value_wxString.ToStdString();
engine->setoption(opt_name.ToStdString(), default_value);
if (opt_name.Lower() == "multipv") {
multipv->SetLabel(default_value_wxString);
} else if (opt_name.Lower() == "threads") {
threads->SetLabel(default_value_wxString);
}
} while (conf->GetNextGroup(opt_name, index));
}
@ -52,20 +57,36 @@ void LiveEngineDialog::OnClose(wxCloseEvent &e) {
}
void LiveEngineDialog::SetFEN(std::string fen) {
timer.Stop();
StopEngine();
engine->position(fen);
uciadapter::Go args;
engine->go(args);
timer.Start(interval);
StartEngine();
}
void LiveEngineDialog::TogglePauseEngine(wxCommandEvent &event) {
if (timer.IsRunning()) {
timer.Stop();
engine_pause_button->SetLabel("Continue");
StopEngine();
engine_stop_button->SetLabel("Restart");
depth->Enable(true);
} else {
engine_stop_button->SetLabel("Stop");
depth->Enable(false);
StartEngine();
}
}
void LiveEngineDialog::StopEngine() {
if (timer.IsRunning()) {
timer.Stop();
}
engine->stop();
};
void LiveEngineDialog::StartEngine() {
uciadapter::Go args;
args.depth = depth->GetValue();
engine->go(args);
if (!timer.IsRunning()) {
timer.Start(interval);
engine_pause_button->SetLabel("Pause");
}
}

View file

@ -15,5 +15,7 @@ public:
void TogglePauseEngine(wxCommandEvent &event);
void OnTimerTick(wxTimerEvent &event);
void SetFEN(std::string fen);
void StopEngine();
void StartEngine();
void OnClose(wxCloseEvent &e);
};

View file

@ -30,12 +30,43 @@ LiveEngineDialogFB::LiveEngineDialogFB( wxWindow* parent, wxWindowID id, const w
current_engine_sizer->Add( 0, 0, 1, wxEXPAND, 5 );
engine_pause_button = new wxButton( this, LIVE_ENGINE_PAUSE_BUTTON, wxT("Pause"), wxDefaultPosition, wxDefaultSize, 0 );
current_engine_sizer->Add( engine_pause_button, 0, wxALL, 5 );
engine_stop_button = new wxButton( this, LIVE_ENGINE_PAUSE_BUTTON, wxT("Stop"), wxDefaultPosition, wxDefaultSize, 0 );
current_engine_sizer->Add( engine_stop_button, 0, wxALL, 5 );
main_sizer->Add( current_engine_sizer, 0, wxEXPAND, 5 );
wxGridSizer* infos_sizer;
infos_sizer = new wxGridSizer( 0, 6, 0, 0 );
multipv_label = new wxStaticText( this, wxID_ANY, wxT("MultiPV:"), wxDefaultPosition, wxDefaultSize, 0 );
multipv_label->Wrap( -1 );
infos_sizer->Add( multipv_label, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
multipv = new wxStaticText( this, wxID_ANY, wxT("?"), wxDefaultPosition, wxDefaultSize, 0 );
multipv->Wrap( -1 );
infos_sizer->Add( multipv, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
threads_label = new wxStaticText( this, wxID_ANY, wxT("Threads:"), wxDefaultPosition, wxDefaultSize, 0 );
threads_label->Wrap( -1 );
infos_sizer->Add( threads_label, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
threads = new wxStaticText( this, wxID_ANY, wxT("?"), wxDefaultPosition, wxDefaultSize, 0 );
threads->Wrap( -1 );
infos_sizer->Add( threads, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
m_staticText13 = new wxStaticText( this, wxID_ANY, wxT("Depth:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText13->Wrap( -1 );
infos_sizer->Add( m_staticText13, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
depth = new wxSpinCtrl( this, wxID_ANY, wxT("30"), wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 1, 10000, 0 );
depth->Enable( false );
infos_sizer->Add( depth, 0, wxALL, 5 );
main_sizer->Add( infos_sizer, 0, 0, 5 );
lines_list = new wxListCtrl( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_REPORT );
main_sizer->Add( lines_list, 1, wxALL|wxEXPAND, 5 );

View file

@ -20,6 +20,7 @@
#include <wx/image.h>
#include <wx/icon.h>
#include <wx/sizer.h>
#include <wx/spinctrl.h>
#include <wx/listctrl.h>
#include <wx/dialog.h>
@ -37,7 +38,13 @@ class LiveEngineDialogFB : public wxDialog
protected:
wxStaticText* current_engine_label;
wxStaticText* current_engine;
wxButton* engine_pause_button;
wxButton* engine_stop_button;
wxStaticText* multipv_label;
wxStaticText* multipv;
wxStaticText* threads_label;
wxStaticText* threads;
wxStaticText* m_staticText13;
wxSpinCtrl* depth;
wxListCtrl* lines_list;
public: