aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLoic Guegan <manzerbredes@mailbox.org>2022-02-26 19:21:52 +0100
committerLoic Guegan <manzerbredes@mailbox.org>2022-02-26 19:21:52 +0100
commitca6c1b1e75e771e3bea596367e502b77dea2c3aa (patch)
tree0e1a2ac8540a35c4f63e97e7d7786a9c6571ba8c
parent0e4814e72712c43dbf0d7dbc1bb75efaa76a94a0 (diff)
Improve engine support
m---------libs/uciadapter0
-rw-r--r--src/MainWindow.cpp19
-rw-r--r--src/MainWindow.hpp1
-rw-r--r--src/engine_tab/EngineTab.cpp6
-rw-r--r--src/engine_tab/EngineTab.hpp3
5 files changed, 25 insertions, 4 deletions
diff --git a/libs/uciadapter b/libs/uciadapter
-Subproject 3b0556669ca6285090a36c12ad0b41953b81c36
+Subproject cce0131c30a1f5fb4e3930dc03091bf238d9e80
diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp
index b3ed9c4..efe3f06 100644
--- a/src/MainWindow.cpp
+++ b/src/MainWindow.cpp
@@ -1,5 +1,6 @@
#include "MainWindow.hpp"
#include "ChessArbiter.hpp"
+#include "UCI.hpp"
#include "engine_tab/EngineTab.hpp"
#include "pgnp.hpp"
#include "preferences/preferences.hpp"
@@ -44,6 +45,7 @@ MainWindow::MainWindow()
// Engine menu
wxMenu *engineMenu = new wxMenu;
engineMenu->Append(6, "New", "Create a new engine configuration");
+ Bind(wxEVT_MENU, &MainWindow::OnNewEngine, this, 6);
/// Menu bar
menuBar = new wxMenuBar;
@@ -72,6 +74,23 @@ MainWindow::MainWindow()
notebook->SetSelection(notebook->GetPageIndex(bt));*/
}
+void MainWindow::OnNewEngine(wxCommandEvent &event) {
+ wxFileDialog openFileDialog(this, _("Use engine"), "", "", "Executable|*",
+ wxFD_OPEN | wxFD_FILE_MUST_EXIST);
+ if (openFileDialog.ShowModal() != wxID_CANCEL) {
+ std::string path = openFileDialog.GetPath().ToStdString();
+ uciadapter::UCI *engine;
+ try {
+ engine = new uciadapter::UCI(path);
+ EngineTab *bt = new EngineTab((wxWindow *)notebook, engine, path);
+ notebook->AddPage(bt, bt->GetLabel());
+ notebook->SetSelection(notebook->GetPageIndex(bt));
+ } catch (...) {
+ SHOW_DIALOG_ERROR("Could not communicate with the engine");
+ }
+ }
+}
+
void MainWindow::OnSettings(wxCommandEvent &event) {
if (prefsEditor != NULL) {
delete prefsEditor;
diff --git a/src/MainWindow.hpp b/src/MainWindow.hpp
index 9a9fc41..918dc8a 100644
--- a/src/MainWindow.hpp
+++ b/src/MainWindow.hpp
@@ -26,6 +26,7 @@ class MainWindow : public wxFrame {
void OnRefreshTabTitle(wxCommandEvent &event);
void NewGame(Game *game);
void OnSettings(wxCommandEvent &event);
+ void OnNewEngine(wxCommandEvent &event);
public:
MainWindow();
diff --git a/src/engine_tab/EngineTab.cpp b/src/engine_tab/EngineTab.cpp
index 760b416..ae9b447 100644
--- a/src/engine_tab/EngineTab.cpp
+++ b/src/engine_tab/EngineTab.cpp
@@ -1,10 +1,10 @@
#include "EngineTab.hpp"
-EngineTab::EngineTab(wxWindow *parent, std::string engine_path_or_name)
+EngineTab::EngineTab(wxWindow *parent, uciadapter::UCI *engine,std::string engine_path_or_name)
: EngineTabBF(parent), TabInfos(TabInfos::ENGINE),
- enginePath(engine_path_or_name) {
+ enginePath(engine_path_or_name), engine(engine) {
SetLabel("New Engine");
- engine = new uciadapter::UCI(engine_path_or_name);
+
engine_location->SetValue(engine_path_or_name);
confGroup = "engines/bob";
CONFIG_OPEN(conf);
diff --git a/src/engine_tab/EngineTab.hpp b/src/engine_tab/EngineTab.hpp
index 2792bc6..c4e8a52 100644
--- a/src/engine_tab/EngineTab.hpp
+++ b/src/engine_tab/EngineTab.hpp
@@ -9,7 +9,8 @@ class EngineTab : public EngineTabBF, public TabInfos {
void InitConfiguration();
public:
- EngineTab(wxWindow *parent, std::string engine_path_or_name);
+ EngineTab(wxWindow *parent, uciadapter::UCI *engine,
+ std::string engine_path_or_name);
void ApplyPreferences() {}
void *GetGame() { return (NULL); }
void *GetBase() { return (NULL); }