mirror of
https://gitlab.com/manzerbredes/ochess.git
synced 2025-04-30 00:47:46 +00:00
Debug engine configuration
This commit is contained in:
parent
2b11848007
commit
1618113e61
6 changed files with 53 additions and 51 deletions
src/engine_tab
|
@ -1,26 +1,22 @@
|
|||
#include "EngineTab.hpp"
|
||||
|
||||
EngineTab::EngineTab(wxWindow *parent, uciadapter::UCI *engine,
|
||||
std::string engine_path_or_name)
|
||||
std::string engine_path)
|
||||
: 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");
|
||||
engine_location->SetValue(engine_path);
|
||||
|
||||
engine_location->SetValue(engine_path_or_name);
|
||||
// Fetch engine id
|
||||
CONFIG_OPEN(conf);
|
||||
// conf->DeleteGroup(confGroup);
|
||||
engineName = "NewEngine";
|
||||
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));
|
||||
conf->SetPath("engines/");
|
||||
engine_id=conf->GetNumberOfGroups();
|
||||
CONFIG_CLOSE(conf);
|
||||
confGroup = "engines/" + std::to_string(engine_id);
|
||||
|
||||
// Init data
|
||||
InitConfiguration();
|
||||
LoadConfiguration();
|
||||
RefreshItemList();
|
||||
|
@ -30,15 +26,21 @@ EngineTab::EngineTab(wxWindow *parent, uciadapter::UCI *engine,
|
|||
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) {
|
||||
SetLabel(name);
|
||||
engineName = name;
|
||||
confGroup = "engines/" + engineName;
|
||||
engine_name->SetValue(engineName);
|
||||
// Init engine group
|
||||
std::string id_str=std::to_string(id);
|
||||
confGroup = "engines/" + std::to_string(id);
|
||||
|
||||
// Fetch name and path
|
||||
CONFIG_OPEN(conf);
|
||||
wxString name=conf->Read(confGroup + "/name");
|
||||
SetLabel(name);
|
||||
engine_name->SetValue(name);
|
||||
engine_location->SetValue(conf->Read(confGroup + "/path"));
|
||||
CONFIG_CLOSE(conf);
|
||||
|
||||
// Load existing configuration
|
||||
LoadConfiguration();
|
||||
|
||||
Bind(wxEVT_BUTTON, &EngineTab::OnSave, this, ENGINE_SAVE_CONF_BUTTON);
|
||||
|
@ -101,20 +103,10 @@ void EngineTab::LoadConfiguration() {
|
|||
|
||||
void EngineTab::OnSave(wxCommandEvent &event) {
|
||||
CONFIG_OPEN(conf2);
|
||||
wxString new_engine_name = engine_name->GetValue();
|
||||
if (new_engine_name != engineName) {
|
||||
conf2->SetPath("engines/");
|
||||
conf2->RenameGroup(engineName, new_engine_name);
|
||||
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);
|
||||
}
|
||||
// Update engine name:
|
||||
conf2->Write(confGroup + "/name", engine_name->GetValue());
|
||||
|
||||
// Update engine configuration:
|
||||
long index;
|
||||
std::string optsPath = confGroup + "/options";
|
||||
conf2->SetPath(optsPath);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue