mirror of
https://gitlab.com/manzerbredes/ochess.git
synced 2025-04-19 04:09:41 +00:00
Improve engine support
This commit is contained in:
parent
0e4814e727
commit
ca6c1b1e75
5 changed files with 26 additions and 5 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue