diff options
| author | Loic Guegan <manzerbredes@mailbox.org> | 2022-02-27 17:02:21 +0100 |
|---|---|---|
| committer | Loic Guegan <manzerbredes@mailbox.org> | 2022-02-27 17:02:21 +0100 |
| commit | 40a56b72feaad057499e43807b88c7c7463c2938 (patch) | |
| tree | e262edf786ce81b7e9d09f0c6ba3ed1daa2f40ca /src | |
| parent | 0e18d4ac8718414fd6192cc2983b7cd44f5fd28a (diff) | |
Improve live engine dialog
Diffstat (limited to 'src')
| -rw-r--r-- | src/game_tab/editor/EditorPanel.cpp | 2 | ||||
| -rw-r--r-- | src/game_tab/editor/LiveEngineDialog.cpp | 30 | ||||
| -rw-r--r-- | src/game_tab/editor/LiveEngineDialog.hpp | 13 | ||||
| -rw-r--r-- | src/game_tab/editor/LiveEngineDialogFB.cpp | 10 | ||||
| -rw-r--r-- | src/game_tab/editor/LiveEngineDialogFB.h | 6 |
5 files changed, 51 insertions, 10 deletions
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 <wx/timer.h> 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 <wx/font.h> #include <wx/colour.h> #include <wx/settings.h> +#include <wx/button.h> +#include <wx/bitmap.h> +#include <wx/image.h> +#include <wx/icon.h> #include <wx/sizer.h> #include <wx/listctrl.h> #include <wx/dialog.h> /////////////////////////////////////////////////////////////////////////// +#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: |
