diff --git a/src/game_tab/editor/EditorPanel.cpp b/src/game_tab/editor/EditorPanel.cpp index 31fd33c..846c0d7 100644 --- a/src/game_tab/editor/EditorPanel.cpp +++ b/src/game_tab/editor/EditorPanel.cpp @@ -17,7 +17,7 @@ EditorPanel::EditorPanel(wxFrame *parent, Game *game) tagTextCtrl->SetHint("Tag"); valueTextCtrl->SetHint("Value"); - LiveEngineDialog *diag=new LiveEngineDialog(this); + LiveEngineDialog *diag=new LiveEngineDialog(this, "stockfish"); diag->Show(); RefreshTagsList(); diff --git a/src/game_tab/editor/LiveEngineDialog.cpp b/src/game_tab/editor/LiveEngineDialog.cpp index 9c5c43c..cad3fdd 100644 --- a/src/game_tab/editor/LiveEngineDialog.cpp +++ b/src/game_tab/editor/LiveEngineDialog.cpp @@ -1,7 +1,27 @@ #include "LiveEngineDialog.hpp" -LiveEngineDialog::LiveEngineDialog(wxWindow *parent) - : LiveEngineDialogFB(parent) { - lines_list->InsertColumn(0, "#"); - lines_list->InsertColumn(1, "Moves",wxLIST_FORMAT_LEFT, 500); -} \ No newline at end of file +LiveEngineDialog::LiveEngineDialog(wxWindow *parent, std::string engine_name) + : LiveEngineDialogFB(parent), engine_name(engine_name) { + lines_list->InsertColumn(0, "#", wxLIST_FORMAT_LEFT, 50); + lines_list->InsertColumn(1, "Moves", wxLIST_FORMAT_LEFT, 300); + current_engine->SetLabel(engine_name); + StartEngine(); + Bind(wxEVT_BUTTON, &LiveEngineDialog::TogglePauseEngine, this, LIVE_ENGINE_PAUSE_BUTTON); +} + +void LiveEngineDialog::StartEngine() { + timer.Start(1000); + timer.Bind(wxEVT_TIMER, &LiveEngineDialog::OnTimerTick, this); +} + +void LiveEngineDialog::TogglePauseEngine(wxCommandEvent &event) { + if (timer.IsRunning()) { + timer.Stop(); + engine_pause_button->SetLabel("Continue"); + } else { + timer.Start(1000); + engine_pause_button->SetLabel("Pause"); + } +} + +void LiveEngineDialog::OnTimerTick(wxTimerEvent &event) { wxLogDebug("Tick!"); } \ No newline at end of file diff --git a/src/game_tab/editor/LiveEngineDialog.hpp b/src/game_tab/editor/LiveEngineDialog.hpp index 90b1b9f..96155bb 100644 --- a/src/game_tab/editor/LiveEngineDialog.hpp +++ b/src/game_tab/editor/LiveEngineDialog.hpp @@ -1,7 +1,16 @@ -#include "ochess.hpp" #include "LiveEngineDialogFB.h" +#include "UCI.hpp" +#include "ochess.hpp" +#include class LiveEngineDialog : public LiveEngineDialogFB { + uciadapter::UCI *engine; + std::string engine_name; + wxTimer timer; + public: - LiveEngineDialog(wxWindow *parent); + LiveEngineDialog(wxWindow *parent, std::string engine_name); + void StartEngine(); + void TogglePauseEngine(wxCommandEvent &event); + void OnTimerTick(wxTimerEvent &event); }; \ No newline at end of file diff --git a/src/game_tab/editor/LiveEngineDialogFB.cpp b/src/game_tab/editor/LiveEngineDialogFB.cpp index 4d96ed4..11234dd 100644 --- a/src/game_tab/editor/LiveEngineDialogFB.cpp +++ b/src/game_tab/editor/LiveEngineDialogFB.cpp @@ -25,13 +25,19 @@ LiveEngineDialogFB::LiveEngineDialogFB( wxWindow* parent, wxWindowID id, const w current_engine = new wxStaticText( this, wxID_ANY, wxT("???"), wxDefaultPosition, wxDefaultSize, 0 ); current_engine->Wrap( -1 ); - current_engine_sizer->Add( current_engine, 0, wxALL, 5 ); + current_engine_sizer->Add( current_engine, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); + + + current_engine_sizer->Add( 0, 0, 1, wxEXPAND, 5 ); + + engine_pause_button = new wxButton( this, LIVE_ENGINE_PAUSE_BUTTON, wxT("Pause"), wxDefaultPosition, wxDefaultSize, 0 ); + current_engine_sizer->Add( engine_pause_button, 0, wxALL, 5 ); main_sizer->Add( current_engine_sizer, 0, wxEXPAND, 5 ); lines_list = new wxListCtrl( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_REPORT ); - main_sizer->Add( lines_list, 0, wxALL|wxEXPAND, 5 ); + main_sizer->Add( lines_list, 1, wxALL|wxEXPAND, 5 ); this->SetSizer( main_sizer ); diff --git a/src/game_tab/editor/LiveEngineDialogFB.h b/src/game_tab/editor/LiveEngineDialogFB.h index 307eae1..8c9c061 100644 --- a/src/game_tab/editor/LiveEngineDialogFB.h +++ b/src/game_tab/editor/LiveEngineDialogFB.h @@ -15,12 +15,17 @@ #include #include #include +#include +#include +#include +#include #include #include #include /////////////////////////////////////////////////////////////////////////// +#define LIVE_ENGINE_PAUSE_BUTTON 1000 /////////////////////////////////////////////////////////////////////////////// /// Class LiveEngineDialogFB @@ -32,6 +37,7 @@ class LiveEngineDialogFB : public wxDialog protected: wxStaticText* current_engine_label; wxStaticText* current_engine; + wxButton* engine_pause_button; wxListCtrl* lines_list; public: diff --git a/tools/wxframebuilder/LiveEngineDialog.fbp b/tools/wxframebuilder/LiveEngineDialog.fbp index 7c401c7..13c549a 100644 --- a/tools/wxframebuilder/LiveEngineDialog.fbp +++ b/tools/wxframebuilder/LiveEngineDialog.fbp @@ -133,7 +133,7 @@ 5 - wxALL + wxALIGN_CENTER_VERTICAL|wxALL 0 1 @@ -192,6 +192,89 @@ -1 + + 5 + wxEXPAND + 1 + + 0 + protected + 0 + + + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + 0 + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 1 + + 1 + + + 0 + 0 + LIVE_ENGINE_PAUSE_BUTTON + Pause + + 0 + + 0 + + + 0 + + 1 + engine_pause_button + 1 + + + protected + 1 + + + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + +