aboutsummaryrefslogtreecommitdiff
path: root/src/game_tab/left_panel
diff options
context:
space:
mode:
authorLoic Guegan <manzerbredes@mailbox.org>2023-01-11 11:56:21 +0100
committerLoic Guegan <manzerbredes@mailbox.org>2023-01-11 11:56:21 +0100
commitd2f078adb5293536d4c33718923a083f2e4de7fb (patch)
tree8a7137a28eb1f8e501b0f14d4ed8e1663d940f8f /src/game_tab/left_panel
parent93c7cb3d24a2827e776d11d49ee6e5364548f064 (diff)
Improve the binding between LiveEngineDialog and BoardCanvas
Diffstat (limited to 'src/game_tab/left_panel')
-rw-r--r--src/game_tab/left_panel/GameTabLeftPanel.cpp38
-rw-r--r--src/game_tab/left_panel/GameTabLeftPanel.hpp2
2 files changed, 27 insertions, 13 deletions
diff --git a/src/game_tab/left_panel/GameTabLeftPanel.cpp b/src/game_tab/left_panel/GameTabLeftPanel.cpp
index 5a1ae44..c4d8764 100644
--- a/src/game_tab/left_panel/GameTabLeftPanel.cpp
+++ b/src/game_tab/left_panel/GameTabLeftPanel.cpp
@@ -2,7 +2,7 @@
#include <wx/clipbrd.h>
GameTabLeftPanel::GameTabLeftPanel(wxFrame *parent, std::shared_ptr<Game> game)
- : TabGameLeftPanel(parent), game(game), repeat(false) {
+ : TabGameLeftPanel(parent), game(game), repeat(false), is_engine_on(false) {
// Configure toolbar (note that toolbar events are processed into the GameTab class)
game_toolbar->AddTool(0, wxT("Save As"),
@@ -86,20 +86,32 @@ void GameTabLeftPanel::OnPlay(wxCommandEvent &event) {
}
void GameTabLeftPanel::SetEngineEvaluation(EngineEvaluation eval){
- engine_arrows.clear();
- float scale=1;
- unsigned char color=0;
- for(auto const &arrow: eval.best_lines){
- std::string src=arrow.substr(0,2);
- std::string dst=arrow.substr(2,2);
- engine_arrows.push_back({src,dst,wxColour(color,color,color),scale});
- scale=std::max(0.1,scale-0.25);
- color=std::min(255,color+70);
+ if(is_engine_on){
+ engine_arrows.clear();
+ float scale=1;
+ unsigned char color=0;
+ for(auto const &arrow: eval.best_lines){
+ std::string src=arrow.substr(0,2);
+ std::string dst=arrow.substr(2,2);
+ engine_arrows.push_back({src,dst,wxColour(color,color,color),scale});
+ scale=std::max(0.1,scale-0.25);
+ color=std::min(255,color+70);
+ }
+ eval_cp=eval.eval;
+ Notify(true);
}
- eval_cp=eval.eval;
- Notify(true);
}
+void GameTabLeftPanel::SetLiveEngineState(bool isOn){
+ is_engine_on=isOn;
+ if(!is_engine_on){
+ engine_arrows.clear();
+ eval_cp=0;
+ Notify(true);
+ }
+}
+
+
void GameTabLeftPanel::Notify(bool skip_animation) {
// Update fen and captures
std::string fen = game->GetFen();
@@ -138,7 +150,7 @@ void GameTabLeftPanel::Notify(bool skip_animation) {
gs.mat_white=game->IsCheckmate(false);
gs.arrows=engine_arrows;
gs.promotion=promote_on;
- gs.show_evalbar=engine_arrows.size()>0;
+ gs.show_evalbar=is_engine_on;
gs.eval=eval_cp/100;
if(m){
// There should be a valid src_hl or dst_hl ortherwise it explode:
diff --git a/src/game_tab/left_panel/GameTabLeftPanel.hpp b/src/game_tab/left_panel/GameTabLeftPanel.hpp
index d438dc6..fe4176e 100644
--- a/src/game_tab/left_panel/GameTabLeftPanel.hpp
+++ b/src/game_tab/left_panel/GameTabLeftPanel.hpp
@@ -18,6 +18,7 @@ class GameTabLeftPanel : public TabGameLeftPanel {
std::string promote_on;
std::string promotion_move;
float eval_cp;
+ bool is_engine_on;
public:
GameTabLeftPanel(wxFrame *parent, std::shared_ptr<Game> game);
@@ -28,4 +29,5 @@ public:
void ApplyPreferences();
void SetSaveToolEnable(bool state){game_toolbar->EnableTool(0,state);};
void SetEngineEvaluation(EngineEvaluation eval);
+ void SetLiveEngineState(bool isOn);
}; \ No newline at end of file