From 0c64a5f9567b23fde5480975bf393d46f3203786 Mon Sep 17 00:00:00 2001 From: Loic Guegan Date: Sun, 1 Jan 2023 14:46:04 +0100 Subject: [PATCH] Update animation trigger --- src/game_tab/left_panel/GameTabLeftPanel.cpp | 23 +++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/game_tab/left_panel/GameTabLeftPanel.cpp b/src/game_tab/left_panel/GameTabLeftPanel.cpp index 2553d30..8b44e28 100644 --- a/src/game_tab/left_panel/GameTabLeftPanel.cpp +++ b/src/game_tab/left_panel/GameTabLeftPanel.cpp @@ -84,20 +84,22 @@ void GameTabLeftPanel::Notify(bool animate, bool backward) { backward=false; if (m != nullptr) { captures = m->GetLineCaptures(); - std::string absolute_move= m->GetAbsoluteMove(); // Check if we should animate if(m->GetParent()==last_move){ - wxLogDebug("Animate animate next"); - animate=true; - src=absolute_move.substr(0,2); - dst=absolute_move.substr(2,2); + wxLogDebug("Animate animate next"); + std::string absolute_move= m->GetAbsoluteMove(); + animate=true; + src=absolute_move.substr(0,2); + dst=absolute_move.substr(2,2); } else if (m->GetMainline()==last_move){ wxLogDebug("Animate Previous"); + std::string absolute_move= last_move->GetAbsoluteMove(); animate=true; backward=true; src=absolute_move.substr(2,2); dst=absolute_move.substr(0,2); } else { + std::string absolute_move= last_move->GetAbsoluteMove(); wxLogDebug("Animate Previous"); for(auto v: m->GetVariations()){ if(v==last_move){ @@ -108,6 +110,15 @@ void GameTabLeftPanel::Notify(bool animate, bool backward) { } } } + }else if(last_move!=nullptr) { + if(last_move->GetParent()==nullptr){ + wxLogDebug("Animate Previous"); + std::string absolute_move= last_move->GetAbsoluteMove(); + animate=true; + backward=true; + src=absolute_move.substr(2,2); + dst=absolute_move.substr(0,2); + } } // Update board canvas: @@ -115,7 +126,7 @@ void GameTabLeftPanel::Notify(bool animate, bool backward) { board_canvas->SetupBoard(chessarbiter::FENParser::Parse(fen).board, game->IsBlackToPlay(), captures, game->GetTag("White"),game->GetTag("Black")); - } +} else{ board_canvas->Animate(chessarbiter::FENParser::Parse(fen).board, game->IsBlackToPlay(), captures,src,dst,repeat);