mirror of
https://gitlab.com/manzerbredes/ochess.git
synced 2025-04-06 01:56:28 +02:00
Improve live engine dialog
This commit is contained in:
parent
0e18d4ac87
commit
40a56b72fe
6 changed files with 135 additions and 11 deletions
|
@ -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();
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
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!"); }
|
|
@ -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);
|
||||
};
|
|
@ -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 );
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -133,7 +133,7 @@
|
|||
</object>
|
||||
<object class="sizeritem" expanded="1">
|
||||
<property name="border">5</property>
|
||||
<property name="flag">wxALL</property>
|
||||
<property name="flag">wxALIGN_CENTER_VERTICAL|wxALL</property>
|
||||
<property name="proportion">0</property>
|
||||
<object class="wxStaticText" expanded="1">
|
||||
<property name="BottomDockable">1</property>
|
||||
|
@ -192,6 +192,89 @@
|
|||
<property name="wrap">-1</property>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem" expanded="1">
|
||||
<property name="border">5</property>
|
||||
<property name="flag">wxEXPAND</property>
|
||||
<property name="proportion">1</property>
|
||||
<object class="spacer" expanded="1">
|
||||
<property name="height">0</property>
|
||||
<property name="permission">protected</property>
|
||||
<property name="width">0</property>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem" expanded="1">
|
||||
<property name="border">5</property>
|
||||
<property name="flag">wxALL</property>
|
||||
<property name="proportion">0</property>
|
||||
<object class="wxButton" expanded="1">
|
||||
<property name="BottomDockable">1</property>
|
||||
<property name="LeftDockable">1</property>
|
||||
<property name="RightDockable">1</property>
|
||||
<property name="TopDockable">1</property>
|
||||
<property name="aui_layer"></property>
|
||||
<property name="aui_name"></property>
|
||||
<property name="aui_position"></property>
|
||||
<property name="aui_row"></property>
|
||||
<property name="auth_needed">0</property>
|
||||
<property name="best_size"></property>
|
||||
<property name="bg"></property>
|
||||
<property name="bitmap"></property>
|
||||
<property name="caption"></property>
|
||||
<property name="caption_visible">1</property>
|
||||
<property name="center_pane">0</property>
|
||||
<property name="close_button">1</property>
|
||||
<property name="context_help"></property>
|
||||
<property name="context_menu">1</property>
|
||||
<property name="current"></property>
|
||||
<property name="default">0</property>
|
||||
<property name="default_pane">0</property>
|
||||
<property name="disabled"></property>
|
||||
<property name="dock">Dock</property>
|
||||
<property name="dock_fixed">0</property>
|
||||
<property name="docking">Left</property>
|
||||
<property name="enabled">1</property>
|
||||
<property name="fg"></property>
|
||||
<property name="floatable">1</property>
|
||||
<property name="focus"></property>
|
||||
<property name="font"></property>
|
||||
<property name="gripper">0</property>
|
||||
<property name="hidden">0</property>
|
||||
<property name="id">LIVE_ENGINE_PAUSE_BUTTON</property>
|
||||
<property name="label">Pause</property>
|
||||
<property name="margins"></property>
|
||||
<property name="markup">0</property>
|
||||
<property name="max_size"></property>
|
||||
<property name="maximize_button">0</property>
|
||||
<property name="maximum_size"></property>
|
||||
<property name="min_size"></property>
|
||||
<property name="minimize_button">0</property>
|
||||
<property name="minimum_size"></property>
|
||||
<property name="moveable">1</property>
|
||||
<property name="name">engine_pause_button</property>
|
||||
<property name="pane_border">1</property>
|
||||
<property name="pane_position"></property>
|
||||
<property name="pane_size"></property>
|
||||
<property name="permission">protected</property>
|
||||
<property name="pin_button">1</property>
|
||||
<property name="pos"></property>
|
||||
<property name="position"></property>
|
||||
<property name="pressed"></property>
|
||||
<property name="resize">Resizable</property>
|
||||
<property name="show">1</property>
|
||||
<property name="size"></property>
|
||||
<property name="style"></property>
|
||||
<property name="subclass">; ; forward_declare</property>
|
||||
<property name="toolbar_pane">0</property>
|
||||
<property name="tooltip"></property>
|
||||
<property name="validator_data_type"></property>
|
||||
<property name="validator_style">wxFILTER_NONE</property>
|
||||
<property name="validator_type">wxDefaultValidator</property>
|
||||
<property name="validator_variable"></property>
|
||||
<property name="window_extra_style"></property>
|
||||
<property name="window_name"></property>
|
||||
<property name="window_style"></property>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem" expanded="1">
|
||||
|
|
Loading…
Add table
Reference in a new issue