diff options
| author | Loic Guegan <manzerbredes@mailbox.org> | 2022-02-26 21:43:09 +0100 |
|---|---|---|
| committer | Loic Guegan <manzerbredes@mailbox.org> | 2022-02-26 21:43:09 +0100 |
| commit | 6c34ef20fb217d240c790b24ea330592679ac010 (patch) | |
| tree | bd684043d7aeb22f578d525e4f4a71c05eb5577b /src/engine_tab/EngineTab.cpp | |
| parent | e601902dd5a9f023594fef6a0f4995e59b4d9a0e (diff) | |
Now engines can be added
Diffstat (limited to 'src/engine_tab/EngineTab.cpp')
| -rw-r--r-- | src/engine_tab/EngineTab.cpp | 57 |
1 files changed, 43 insertions, 14 deletions
diff --git a/src/engine_tab/EngineTab.cpp b/src/engine_tab/EngineTab.cpp index ca2880f..ca5f2e9 100644 --- a/src/engine_tab/EngineTab.cpp +++ b/src/engine_tab/EngineTab.cpp @@ -22,7 +22,46 @@ EngineTab::EngineTab(wxWindow *parent, uciadapter::UCI *engine, // conf->Write(confGroup + "/path", wxString(engine_path_or_name)); CONFIG_CLOSE(conf); InitConfiguration(); + LoadConfiguration(); + RefreshItemList(); + Bind(wxEVT_BUTTON, &EngineTab::OnSave, this, ENGINE_SAVE_CONF_BUTTON); + Bind(wxEVT_BUTTON, &EngineTab::OnDelete, this, ENGINE_DELETE_CONF_BUTTON); +} + +EngineTab::EngineTab(wxWindow *parent, std::string name) + : EngineTabBF(parent), TabInfos(TabInfos::ENGINE) { + SetLabel(name); + engineName = name; + confGroup = "engines/" + engineName; + engine_name->SetValue(engineName); + CONFIG_OPEN(conf); + engine_location->SetValue(conf->Read(confGroup + "/path")); + CONFIG_CLOSE(conf); + LoadConfiguration(); + + Bind(wxEVT_BUTTON, &EngineTab::OnSave, this, ENGINE_SAVE_CONF_BUTTON); + Bind(wxEVT_BUTTON, &EngineTab::OnDelete, this, ENGINE_DELETE_CONF_BUTTON); +} + +void EngineTab::OnDelete(wxCommandEvent &event) { + CONFIG_OPEN(conf); + conf->DeleteGroup(confGroup); + CONFIG_CLOSE(conf); + RefreshItemList(); + + wxCommandEvent closeTabEvent(CLOSE_TAB_EVENT, GetId()); + closeTabEvent.SetEventObject(this); + ProcessEvent(closeTabEvent); +} + +void EngineTab::RefreshItemList() { + wxCommandEvent refreshEngineList(REFRESH_ENGINE_LIST, GetId()); + refreshEngineList.SetEventObject(this); + ProcessEvent(refreshEngineList); +} + +void EngineTab::LoadConfiguration() { // Build wxPropertyGrid according to engine configuration CONFIG_OPEN(conf2); long index; @@ -48,28 +87,17 @@ EngineTab::EngineTab(wxWindow *parent, uciadapter::UCI *engine, } while (conf2->GetNextGroup(opt_name, index)); } CONFIG_CLOSE(conf2); - - Bind(wxEVT_BUTTON, &EngineTab::OnSave, this, ENGINE_SAVE_CONF_BUTTON); - Bind(wxEVT_BUTTON, &EngineTab::OnDelete, this, ENGINE_DELETE_CONF_BUTTON); -} - -void EngineTab::OnDelete(wxCommandEvent &event) { - CONFIG_OPEN(conf); - conf->DeleteGroup(confGroup); - CONFIG_CLOSE(conf); - - wxCommandEvent closeTabEvent(CLOSE_TAB_EVENT, GetId()); - closeTabEvent.SetEventObject(this); - ProcessEvent(closeTabEvent); } void EngineTab::OnSave(wxCommandEvent &event) { CONFIG_OPEN(conf2); wxString new_engine_name = engine_name->GetValue(); if (new_engine_name != engineName) { - conf2->RenameGroup(confGroup, "engines/" + new_engine_name); + conf2->SetPath("engines/"); + conf2->RenameGroup(engineName, new_engine_name); engineName = new_engine_name; confGroup = "engines/" + engineName; + conf2->SetPath(".."); } long index; std::string optsPath = confGroup + "/options"; @@ -91,6 +119,7 @@ void EngineTab::OnSave(wxCommandEvent &event) { } while (conf2->GetNextGroup(opt_name, index)); } CONFIG_CLOSE(conf2); + RefreshItemList(); } void EngineTab::InitConfiguration() { |
