diff options
| author | Loic Guegan <manzerbredes@mailbox.org> | 2023-01-01 14:12:57 +0100 |
|---|---|---|
| committer | Loic Guegan <manzerbredes@mailbox.org> | 2023-01-01 14:12:57 +0100 |
| commit | 679c735596168228ad0df4e42a3768c61c809a40 (patch) | |
| tree | acec93ad61c3ba26a997a3835079c48fcf911d72 /src/game_tab/left_panel | |
| parent | 8bf9e7e7b5b963b8be3916c4926e9cade3064eb8 (diff) | |
Improve game tab
Diffstat (limited to 'src/game_tab/left_panel')
| -rw-r--r-- | src/game_tab/left_panel/GameTabLeftPanel.cpp | 16 | ||||
| -rw-r--r-- | src/game_tab/left_panel/board/BoardCanvas.cpp | 9 | ||||
| -rw-r--r-- | src/game_tab/left_panel/board/BoardCanvas.hpp | 6 |
3 files changed, 16 insertions, 15 deletions
diff --git a/src/game_tab/left_panel/GameTabLeftPanel.cpp b/src/game_tab/left_panel/GameTabLeftPanel.cpp index 50919c0..b1bf516 100644 --- a/src/game_tab/left_panel/GameTabLeftPanel.cpp +++ b/src/game_tab/left_panel/GameTabLeftPanel.cpp @@ -72,14 +72,28 @@ void GameTabLeftPanel::OnPlay(wxCommandEvent &event) { } void GameTabLeftPanel::Notify(bool animate, bool backward) { + wxLogDebug("Called!"); // Update fen and captures std::string fen = game->GetFen(); std::map<char, std::uint8_t> captures; HalfMove *m = game->GetCurrentMove(); + //animate=false; + //backward=false; if (m != nullptr) { captures = m->GetLineCaptures(); + /*HalfMove *parent=m->GetParent(); + if(!parent){ + animate=true; + } + if(last_absolute_move == parent->GetAbsoluteMove()){ + wxLogDebug("Next true!"); + animate=true; + } else if(m->GetAbsoluteMove() == last_absolute_move){ + animate=true; + backward=true; + }*/ } - + // Update board canvas: if(!animate){ if(m){ diff --git a/src/game_tab/left_panel/board/BoardCanvas.cpp b/src/game_tab/left_panel/board/BoardCanvas.cpp index 7f2c38d..1a85176 100644 --- a/src/game_tab/left_panel/board/BoardCanvas.cpp +++ b/src/game_tab/left_panel/board/BoardCanvas.cpp @@ -75,10 +75,6 @@ void BoardCanvas::OnPaint(wxPaintEvent &event) { adata.src.y + adata.frame*(adata.transVect.y/adata.frames), false); // end drawing adata.frame++; - if(adata.frame>=adata.frames){ - adata.reuseBuffer=false; - SetupBoard(adata.final_board, adata.final_is_black_turn, adata.final_captures,white_player,black_player); - } } } @@ -116,10 +112,6 @@ void BoardCanvas::SetupBoard(std::string board, bool is_black_turn, } void BoardCanvas::Animate(const std::string &board, bool is_black_turn, std::map<char, std::uint8_t> captures, std::string src, std::string dst,bool faster){ - adata.final_board=board; - adata.final_is_black_turn=is_black_turn; - adata.final_captures=captures; - std::uint8_t pfile = src[0]-'a'; std::uint8_t prank = src[1]-'1'; adata.piece_moved = this->board[pfile + 8 * (7-prank)]; // Piece to move @@ -172,6 +164,7 @@ void BoardCanvas::Animate(const std::string &board, bool is_black_turn, std::map } adata.duration=faster ? duration_backup : duration_backup; adata.reuseBuffer=false; + SetupBoard(board, is_black_turn, captures,white_player,black_player); } void BoardCanvas::DrawBoard(wxDC &dc) { diff --git a/src/game_tab/left_panel/board/BoardCanvas.hpp b/src/game_tab/left_panel/board/BoardCanvas.hpp index 30f0d06..b26526f 100644 --- a/src/game_tab/left_panel/board/BoardCanvas.hpp +++ b/src/game_tab/left_panel/board/BoardCanvas.hpp @@ -50,12 +50,6 @@ typedef struct AnimState { int duration,duration_fast; /// @brief Animation FPS std::uint8_t fps; - /// @brief Board to draw at the end of the animation - std::string final_board; - /// @brief Which player is to move at the end of the animation - bool final_is_black_turn; - /// @brief Final state of captured pieces at the end of the animation - std::map<char, std::uint8_t> final_captures; /// @brief Current animated piece char piece_moved; /// @brief Starting point of the animated piece |
