mirror of
https://gitlab.com/manzerbredes/ochess.git
synced 2025-07-01 09:47:39 +00:00
Improve LiveEngineDialog
This commit is contained in:
parent
1618113e61
commit
35caa1aa4c
5 changed files with 410 additions and 387 deletions
|
@ -46,7 +46,8 @@ void LiveEngineDialog::InitEngine() {
|
|||
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);
|
||||
optmultipv=opt_name;
|
||||
multipv->SetValue(std::stoi(default_value_wxString.ToStdString()));
|
||||
} else if (opt_name.Lower() == "threads") {
|
||||
threads->SetLabel(default_value_wxString);
|
||||
}
|
||||
|
@ -55,6 +56,8 @@ void LiveEngineDialog::InitEngine() {
|
|||
|
||||
CONFIG_CLOSE(conf);
|
||||
}
|
||||
depth->Enable(false);
|
||||
multipv->Enable(false);
|
||||
timer.Start(interval);
|
||||
timer.Bind(wxEVT_TIMER, &LiveEngineDialog::OnTimerTick, this);
|
||||
}
|
||||
|
@ -84,9 +87,11 @@ void LiveEngineDialog::TogglePauseEngine(wxCommandEvent &event) {
|
|||
StopEngine();
|
||||
engine_stop_button->SetLabel("Restart");
|
||||
depth->Enable(true);
|
||||
multipv->Enable(true);
|
||||
} else {
|
||||
engine_stop_button->SetLabel("Stop");
|
||||
depth->Enable(false);
|
||||
multipv->Enable(false);
|
||||
StartEngine();
|
||||
}
|
||||
}
|
||||
|
@ -101,6 +106,8 @@ void LiveEngineDialog::StopEngine() {
|
|||
void LiveEngineDialog::StartEngine() {
|
||||
uciadapter::Go args;
|
||||
args.depth = depth->GetValue();
|
||||
if(optmultipv.size()>0)
|
||||
engine->setoption(optmultipv, std::to_string(multipv->GetValue()));
|
||||
engine->go(args);
|
||||
if (!timer.IsRunning()) {
|
||||
timer.Start(interval);
|
||||
|
|
|
@ -16,6 +16,7 @@ class LiveEngineDialog : public DialogLiveEngine {
|
|||
uciadapter::UCI *engine;
|
||||
std::string engine_name;
|
||||
std::string confGroup;
|
||||
std::string optmultipv;
|
||||
|
||||
wxTimer timer;
|
||||
/// @brief The following time interval definitely need to be configure in the user settings (set to 1s for now)
|
||||
|
|
30
src/gui.cpp
30
src/gui.cpp
|
@ -74,36 +74,41 @@ DialogLiveEngine::DialogLiveEngine( wxWindow* parent, wxWindowID id, const wxStr
|
|||
|
||||
main_sizer->Add( current_engine_sizer, 0, wxEXPAND, 5 );
|
||||
|
||||
wxGridSizer* infos_sizer;
|
||||
infos_sizer = new wxGridSizer( 0, 6, 0, 0 );
|
||||
wxBoxSizer* infos_sizer;
|
||||
infos_sizer = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
wxBoxSizer* infos_sizer_row1;
|
||||
infos_sizer_row1 = new wxBoxSizer( wxHORIZONTAL );
|
||||
|
||||
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 );
|
||||
infos_sizer_row1->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 );
|
||||
multipv = new wxSpinCtrl( this, wxID_ANY, wxT("1"), wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 1, 100, 1 );
|
||||
infos_sizer_row1->Add( multipv, 0, 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 );
|
||||
infos_sizer_row1->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 );
|
||||
infos_sizer_row1->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 );
|
||||
infos_sizer_row1->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 = new wxSpinCtrl( this, wxID_ANY, wxT("1"), wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 1, 10000, 1 );
|
||||
depth->Enable( false );
|
||||
|
||||
infos_sizer->Add( depth, 0, wxALL, 5 );
|
||||
infos_sizer_row1->Add( depth, 0, wxALL, 5 );
|
||||
|
||||
|
||||
main_sizer->Add( infos_sizer, 0, 0, 5 );
|
||||
infos_sizer->Add( infos_sizer_row1, 0, wxEXPAND, 5 );
|
||||
|
||||
|
||||
main_sizer->Add( infos_sizer, 0, wxEXPAND, 5 );
|
||||
|
||||
lines_list = new wxListCtrl( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_REPORT );
|
||||
main_sizer->Add( lines_list, 1, wxALL|wxEXPAND, 5 );
|
||||
|
@ -111,6 +116,7 @@ DialogLiveEngine::DialogLiveEngine( wxWindow* parent, wxWindowID id, const wxStr
|
|||
|
||||
this->SetSizer( main_sizer );
|
||||
this->Layout();
|
||||
main_sizer->Fit( this );
|
||||
|
||||
this->Centre( wxBOTH );
|
||||
}
|
||||
|
|
|
@ -103,7 +103,7 @@ class DialogLiveEngine : public wxDialog
|
|||
wxStaticText* current_engine;
|
||||
wxButton* engine_stop_button;
|
||||
wxStaticText* multipv_label;
|
||||
wxStaticText* multipv;
|
||||
wxSpinCtrl* multipv;
|
||||
wxStaticText* threads_label;
|
||||
wxStaticText* threads;
|
||||
wxStaticText* m_staticText13;
|
||||
|
@ -112,7 +112,7 @@ class DialogLiveEngine : public wxDialog
|
|||
|
||||
public:
|
||||
|
||||
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( wxWindow* parent, wxWindowID id = ID_LIVE_ENGINE_DIALOG, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE );
|
||||
|
||||
~DialogLiveEngine();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue