mirror of
https://gitlab.com/manzerbredes/ochess.git
synced 2025-04-07 02:26:29 +02:00
Debug engine configuration
This commit is contained in:
parent
2b11848007
commit
1618113e61
6 changed files with 53 additions and 51 deletions
|
@ -122,7 +122,7 @@ void MainWindow::OnMenuItemClick(wxCommandEvent &event) {
|
||||||
if (item->GetId() == id) {
|
if (item->GetId() == id) {
|
||||||
wxLogDebug("Selected %s", item->GetItemLabel());
|
wxLogDebug("Selected %s", item->GetItemLabel());
|
||||||
EngineTab *et = new EngineTab((wxWindow *)notebook,
|
EngineTab *et = new EngineTab((wxWindow *)notebook,
|
||||||
item->GetItemLabel().ToStdString());
|
item->GetId()-100);
|
||||||
AddPage(et,et);
|
AddPage(et,et);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -174,14 +174,15 @@ void MainWindow::OnRefreshEngineList(wxCommandEvent &event) {
|
||||||
// Refresh items
|
// Refresh items
|
||||||
CONFIG_OPEN(conf);
|
CONFIG_OPEN(conf);
|
||||||
conf->SetPath("engines/");
|
conf->SetPath("engines/");
|
||||||
wxString engine_name;
|
wxString engine_id;
|
||||||
long index;
|
long index;
|
||||||
if (conf->GetFirstGroup(engine_name, index)) {
|
if (conf->GetFirstGroup(engine_id, index)) {
|
||||||
std::uint32_t id = 0;
|
std::uint32_t id = 0;
|
||||||
do {
|
do {
|
||||||
|
wxString engine_name=conf->Read(engine_id+"/name");
|
||||||
manageMenu->Append(100 + id, engine_name, "Configure " + engine_name);
|
manageMenu->Append(100 + id, engine_name, "Configure " + engine_name);
|
||||||
id++;
|
id++;
|
||||||
} while (conf->GetNextGroup(engine_name, index));
|
} while (conf->GetNextGroup(engine_id, index));
|
||||||
}
|
}
|
||||||
CONFIG_CLOSE(conf);
|
CONFIG_CLOSE(conf);
|
||||||
ApplyPreferences(); // Propagate informations to the tabs that require it
|
ApplyPreferences(); // Propagate informations to the tabs that require it
|
||||||
|
|
|
@ -1,26 +1,22 @@
|
||||||
#include "EngineTab.hpp"
|
#include "EngineTab.hpp"
|
||||||
|
|
||||||
EngineTab::EngineTab(wxWindow *parent, uciadapter::UCI *engine,
|
EngineTab::EngineTab(wxWindow *parent, uciadapter::UCI *engine,
|
||||||
std::string engine_path_or_name)
|
std::string engine_path)
|
||||||
: TabEngine(parent), TabInfos(TabInfos::ENGINE),
|
: TabEngine(parent), TabInfos(TabInfos::ENGINE),
|
||||||
enginePath(engine_path_or_name), engine(engine) {
|
enginePath(engine_path), engine(engine) {
|
||||||
|
|
||||||
|
// Init engine name and location
|
||||||
SetLabel("New Engine");
|
SetLabel("New Engine");
|
||||||
|
engine_location->SetValue(engine_path);
|
||||||
|
|
||||||
engine_location->SetValue(engine_path_or_name);
|
// Fetch engine id
|
||||||
CONFIG_OPEN(conf);
|
CONFIG_OPEN(conf);
|
||||||
// conf->DeleteGroup(confGroup);
|
conf->SetPath("engines/");
|
||||||
engineName = "NewEngine";
|
engine_id=conf->GetNumberOfGroups();
|
||||||
confGroup = "engines/" + engineName;
|
|
||||||
std::uint32_t key = 2;
|
|
||||||
while (conf->HasGroup(confGroup)) {
|
|
||||||
engineName = "NewEngine" + std::to_string(key);
|
|
||||||
confGroup = "engines/" + engineName;
|
|
||||||
key++;
|
|
||||||
}
|
|
||||||
engine_name->SetValue(engineName);
|
|
||||||
|
|
||||||
// conf->Write(confGroup + "/path", wxString(engine_path_or_name));
|
|
||||||
CONFIG_CLOSE(conf);
|
CONFIG_CLOSE(conf);
|
||||||
|
confGroup = "engines/" + std::to_string(engine_id);
|
||||||
|
|
||||||
|
// Init data
|
||||||
InitConfiguration();
|
InitConfiguration();
|
||||||
LoadConfiguration();
|
LoadConfiguration();
|
||||||
RefreshItemList();
|
RefreshItemList();
|
||||||
|
@ -30,15 +26,21 @@ EngineTab::EngineTab(wxWindow *parent, uciadapter::UCI *engine,
|
||||||
Bind(wxEVT_PG_CHANGED, [p=this](wxPropertyGridEvent& event){p->is_dirty=true;});
|
Bind(wxEVT_PG_CHANGED, [p=this](wxPropertyGridEvent& event){p->is_dirty=true;});
|
||||||
}
|
}
|
||||||
|
|
||||||
EngineTab::EngineTab(wxWindow *parent, std::string name)
|
EngineTab::EngineTab(wxWindow *parent, std::uint32_t id)
|
||||||
: TabEngine(parent), TabInfos(TabInfos::ENGINE), engine(nullptr) {
|
: TabEngine(parent), TabInfos(TabInfos::ENGINE), engine(nullptr) {
|
||||||
SetLabel(name);
|
// Init engine group
|
||||||
engineName = name;
|
std::string id_str=std::to_string(id);
|
||||||
confGroup = "engines/" + engineName;
|
confGroup = "engines/" + std::to_string(id);
|
||||||
engine_name->SetValue(engineName);
|
|
||||||
|
// Fetch name and path
|
||||||
CONFIG_OPEN(conf);
|
CONFIG_OPEN(conf);
|
||||||
|
wxString name=conf->Read(confGroup + "/name");
|
||||||
|
SetLabel(name);
|
||||||
|
engine_name->SetValue(name);
|
||||||
engine_location->SetValue(conf->Read(confGroup + "/path"));
|
engine_location->SetValue(conf->Read(confGroup + "/path"));
|
||||||
CONFIG_CLOSE(conf);
|
CONFIG_CLOSE(conf);
|
||||||
|
|
||||||
|
// Load existing configuration
|
||||||
LoadConfiguration();
|
LoadConfiguration();
|
||||||
|
|
||||||
Bind(wxEVT_BUTTON, &EngineTab::OnSave, this, ENGINE_SAVE_CONF_BUTTON);
|
Bind(wxEVT_BUTTON, &EngineTab::OnSave, this, ENGINE_SAVE_CONF_BUTTON);
|
||||||
|
@ -101,20 +103,10 @@ void EngineTab::LoadConfiguration() {
|
||||||
|
|
||||||
void EngineTab::OnSave(wxCommandEvent &event) {
|
void EngineTab::OnSave(wxCommandEvent &event) {
|
||||||
CONFIG_OPEN(conf2);
|
CONFIG_OPEN(conf2);
|
||||||
wxString new_engine_name = engine_name->GetValue();
|
// Update engine name:
|
||||||
if (new_engine_name != engineName) {
|
conf2->Write(confGroup + "/name", engine_name->GetValue());
|
||||||
conf2->SetPath("engines/");
|
|
||||||
conf2->RenameGroup(engineName, new_engine_name);
|
// Update engine configuration:
|
||||||
engineName = new_engine_name;
|
|
||||||
confGroup = "engines/" + engineName;
|
|
||||||
conf2->SetPath("..");
|
|
||||||
SetLabel(new_engine_name);
|
|
||||||
// First refresh tab title
|
|
||||||
wxCommandEvent refreshTitle(REFRESH_TAB_TITLE, GetId());
|
|
||||||
refreshTitle.SetEventObject(this);
|
|
||||||
wxLogDebug("New engine name is %s",this->GetLabel());
|
|
||||||
ProcessEvent(refreshTitle);
|
|
||||||
}
|
|
||||||
long index;
|
long index;
|
||||||
std::string optsPath = confGroup + "/options";
|
std::string optsPath = confGroup + "/options";
|
||||||
conf2->SetPath(optsPath);
|
conf2->SetPath(optsPath);
|
||||||
|
|
|
@ -9,14 +9,14 @@ wxDECLARE_EVENT(REFRESH_TAB_TITLE, wxCommandEvent);
|
||||||
class EngineTab : public TabEngine, public TabInfos {
|
class EngineTab : public TabEngine, public TabInfos {
|
||||||
uciadapter::UCI *engine;
|
uciadapter::UCI *engine;
|
||||||
std::string confGroup, enginePath;
|
std::string confGroup, enginePath;
|
||||||
std::string engineName;
|
std::uint32_t engine_id;
|
||||||
void InitConfiguration();
|
void InitConfiguration();
|
||||||
void LoadConfiguration();
|
void LoadConfiguration();
|
||||||
void RefreshItemList();
|
void RefreshItemList();
|
||||||
public:
|
public:
|
||||||
EngineTab(wxWindow *parent, uciadapter::UCI *engine,
|
EngineTab(wxWindow *parent, uciadapter::UCI *engine,
|
||||||
std::string engine_path_or_name);
|
std::string engine_path);
|
||||||
EngineTab(wxWindow *parent, std::string name);
|
EngineTab(wxWindow *parent, std::uint32_t id);
|
||||||
~EngineTab();
|
~EngineTab();
|
||||||
void ApplyPreferences() {}
|
void ApplyPreferences() {}
|
||||||
std::shared_ptr<Game> GetGame() { return nullptr; }
|
std::shared_ptr<Game> GetGame() { return nullptr; }
|
||||||
|
|
|
@ -56,7 +56,7 @@ void GameTabRightPanel::OnLiveAnalysis(wxCommandEvent &event) {
|
||||||
ProcessEvent(notifyEvent);
|
ProcessEvent(notifyEvent);
|
||||||
|
|
||||||
live_engine = new LiveEngineDialog(
|
live_engine = new LiveEngineDialog(
|
||||||
this, engine_list->GetString(selection).ToStdString());
|
this, selection);
|
||||||
live_engine->SetFEN(game->GetFen());
|
live_engine->SetFEN(game->GetFen());
|
||||||
live_engine->Show();
|
live_engine->Show();
|
||||||
live_engine->Bind(wxEVT_CLOSE_WINDOW,
|
live_engine->Bind(wxEVT_CLOSE_WINDOW,
|
||||||
|
@ -168,12 +168,12 @@ void GameTabRightPanel::ApplyPreferences() {
|
||||||
engine_list->Clear();
|
engine_list->Clear();
|
||||||
CONFIG_OPEN(conf);
|
CONFIG_OPEN(conf);
|
||||||
conf->SetPath("engines/");
|
conf->SetPath("engines/");
|
||||||
wxString engine_name;
|
wxString engine_id;
|
||||||
long index;
|
long index;
|
||||||
if (conf->GetFirstGroup(engine_name, index)) {
|
if (conf->GetFirstGroup(engine_id, index)) {
|
||||||
do {
|
do {
|
||||||
engine_list->Append(engine_name);
|
engine_list->Append(conf->Read(engine_id+"/name"));
|
||||||
} while (conf->GetNextGroup(engine_name, index));
|
} while (conf->GetNextGroup(engine_id, index));
|
||||||
}
|
}
|
||||||
CONFIG_CLOSE(conf);
|
CONFIG_CLOSE(conf);
|
||||||
editor_canvas->ApplyPreferences();
|
editor_canvas->ApplyPreferences();
|
||||||
|
|
|
@ -1,12 +1,19 @@
|
||||||
#include "LiveEngineDialog.hpp"
|
#include "LiveEngineDialog.hpp"
|
||||||
|
|
||||||
LiveEngineDialog::LiveEngineDialog(wxWindow *parent, std::string engine_name)
|
LiveEngineDialog::LiveEngineDialog(wxWindow *parent, std::uint32_t engine_id)
|
||||||
: DialogLiveEngine(parent), engine_name(engine_name), interval(1000),
|
: DialogLiveEngine(parent), interval(1000),
|
||||||
engine(nullptr) {
|
engine(nullptr) {
|
||||||
lines_list->InsertColumn(0, "#", wxLIST_FORMAT_LEFT, 50);
|
lines_list->InsertColumn(0, "#", wxLIST_FORMAT_LEFT, 50);
|
||||||
lines_list->InsertColumn(1, "CP", wxLIST_FORMAT_LEFT, 70);
|
lines_list->InsertColumn(1, "CP", wxLIST_FORMAT_LEFT, 70);
|
||||||
lines_list->InsertColumn(2, "Line", wxLIST_FORMAT_LEFT, 300);
|
lines_list->InsertColumn(2, "Line", wxLIST_FORMAT_LEFT, 300);
|
||||||
|
|
||||||
|
// Load engine name
|
||||||
|
confGroup="engines/"+std::to_string(engine_id);
|
||||||
|
CONFIG_OPEN(conf);
|
||||||
|
engine_name=conf->Read(confGroup+"/name");
|
||||||
|
CONFIG_CLOSE(conf);
|
||||||
current_engine->SetLabel(engine_name);
|
current_engine->SetLabel(engine_name);
|
||||||
|
|
||||||
InitEngine();
|
InitEngine();
|
||||||
Bind(wxEVT_BUTTON, &LiveEngineDialog::TogglePauseEngine, this,
|
Bind(wxEVT_BUTTON, &LiveEngineDialog::TogglePauseEngine, this,
|
||||||
LIVE_ENGINE_PAUSE_BUTTON);
|
LIVE_ENGINE_PAUSE_BUTTON);
|
||||||
|
@ -25,11 +32,11 @@ void LiveEngineDialog::InitEngine() {
|
||||||
wxLogDebug("Start engine: %s", engine_name);
|
wxLogDebug("Start engine: %s", engine_name);
|
||||||
CONFIG_OPEN(conf);
|
CONFIG_OPEN(conf);
|
||||||
engine = new uciadapter::UCI(
|
engine = new uciadapter::UCI(
|
||||||
conf->Read("engines/" + engine_name + "/path").ToStdString());
|
conf->Read(confGroup + "/path").ToStdString());
|
||||||
engine->ucinewgame();
|
engine->ucinewgame();
|
||||||
|
|
||||||
long index;
|
long index;
|
||||||
std::string optsPath = "engines/" + engine_name + "/options";
|
std::string optsPath = confGroup + "/options";
|
||||||
conf->SetPath(optsPath);
|
conf->SetPath(optsPath);
|
||||||
wxString opt_name;
|
wxString opt_name;
|
||||||
if (conf->GetFirstGroup(opt_name, index)) {
|
if (conf->GetFirstGroup(opt_name, index)) {
|
||||||
|
|
|
@ -15,12 +15,14 @@ typedef struct EngineEvaluation {
|
||||||
class LiveEngineDialog : public DialogLiveEngine {
|
class LiveEngineDialog : public DialogLiveEngine {
|
||||||
uciadapter::UCI *engine;
|
uciadapter::UCI *engine;
|
||||||
std::string engine_name;
|
std::string engine_name;
|
||||||
|
std::string confGroup;
|
||||||
|
|
||||||
wxTimer timer;
|
wxTimer timer;
|
||||||
/// @brief The following time interval definitely need to be configure in the user settings (set to 1s for now)
|
/// @brief The following time interval definitely need to be configure in the user settings (set to 1s for now)
|
||||||
std::uint32_t interval;
|
std::uint32_t interval;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
LiveEngineDialog(wxWindow *parent, std::string engine_name);
|
LiveEngineDialog(wxWindow *parent, std::uint32_t engine_id);
|
||||||
~LiveEngineDialog();
|
~LiveEngineDialog();
|
||||||
void InitEngine();
|
void InitEngine();
|
||||||
void TogglePauseEngine(wxCommandEvent &event);
|
void TogglePauseEngine(wxCommandEvent &event);
|
||||||
|
|
Loading…
Add table
Reference in a new issue