Update animation trigger

This commit is contained in:
Loic Guegan 2023-01-01 14:46:04 +01:00
parent 0cb695a22b
commit 0c64a5f956

View file

@ -84,20 +84,22 @@ void GameTabLeftPanel::Notify(bool animate, bool backward) {
backward=false; backward=false;
if (m != nullptr) { if (m != nullptr) {
captures = m->GetLineCaptures(); captures = m->GetLineCaptures();
std::string absolute_move= m->GetAbsoluteMove();
// Check if we should animate // Check if we should animate
if(m->GetParent()==last_move){ if(m->GetParent()==last_move){
wxLogDebug("Animate animate next"); wxLogDebug("Animate animate next");
animate=true; std::string absolute_move= m->GetAbsoluteMove();
src=absolute_move.substr(0,2); animate=true;
dst=absolute_move.substr(2,2); src=absolute_move.substr(0,2);
dst=absolute_move.substr(2,2);
} else if (m->GetMainline()==last_move){ } else if (m->GetMainline()==last_move){
wxLogDebug("Animate Previous"); wxLogDebug("Animate Previous");
std::string absolute_move= last_move->GetAbsoluteMove();
animate=true; animate=true;
backward=true; backward=true;
src=absolute_move.substr(2,2); src=absolute_move.substr(2,2);
dst=absolute_move.substr(0,2); dst=absolute_move.substr(0,2);
} else { } else {
std::string absolute_move= last_move->GetAbsoluteMove();
wxLogDebug("Animate Previous"); wxLogDebug("Animate Previous");
for(auto v: m->GetVariations()){ for(auto v: m->GetVariations()){
if(v==last_move){ 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: // Update board canvas:
@ -115,7 +126,7 @@ void GameTabLeftPanel::Notify(bool animate, bool backward) {
board_canvas->SetupBoard(chessarbiter::FENParser::Parse(fen).board, board_canvas->SetupBoard(chessarbiter::FENParser::Parse(fen).board,
game->IsBlackToPlay(), captures, game->IsBlackToPlay(), captures,
game->GetTag("White"),game->GetTag("Black")); game->GetTag("White"),game->GetTag("Black"));
} }
else{ else{
board_canvas->Animate(chessarbiter::FENParser::Parse(fen).board, board_canvas->Animate(chessarbiter::FENParser::Parse(fen).board,
game->IsBlackToPlay(), captures,src,dst,repeat); game->IsBlackToPlay(), captures,src,dst,repeat);