diff --git a/TODO.md b/TODO.md index e2e019f..289e7c5 100644 --- a/TODO.md +++ b/TODO.md @@ -6,12 +6,12 @@ - [x] Ask before closing MainWindow/Tabs if anything is not saved - [x] Disable the save button in GameTab after saving (and re-enable it on new changes) - [ ] Make PGNGameBase use GotoNextGame() instead of ParseNextGame() in the NextGame() method to improve performance - - [ ] Clean and debug DragNDrop in BoardCanvas + - [x] Clean and debug DragNDrop in BoardCanvas ## Additional Features - [ ] Add a live evaluation bar to the BoardCanvas - [x] Be able to draw arrows on the Board - - [ ] Highlight the last played move + - [x] Highlight the last played move - [ ] Be able to play against an engine - [ ] Implement full chess engine game analyzer/annotator - [ ] Handle .si4 databases diff --git a/src/game_tab/left_panel/GameTabLeftPanel.cpp b/src/game_tab/left_panel/GameTabLeftPanel.cpp index 25ded2c..5b8162c 100644 --- a/src/game_tab/left_panel/GameTabLeftPanel.cpp +++ b/src/game_tab/left_panel/GameTabLeftPanel.cpp @@ -107,6 +107,15 @@ void GameTabLeftPanel::Notify(bool skip_animation) { gs.black=game->GetTag("Black"); gs.mat_black=game->IsCheckmate(true); gs.mat_white=game->IsCheckmate(false); + if(m){ + // There should be a valid src_hl or dst_hl ortherwise it explode: + std::string src_hl, dst_hl; + m->GetAbsoluteMove(src_hl,dst_hl); + if(src_hl.size()>0){ // Just in case + gs.squares_hl.push_back(src_hl+"d"); + gs.squares_hl.push_back(dst_hl+"a"); + } + } if(skip_animation || !animate){ board_canvas->SetupBoard(gs); } diff --git a/src/game_tab/left_panel/board/BoardCanvas.cpp b/src/game_tab/left_panel/board/BoardCanvas.cpp index a31b0c6..7cca378 100644 --- a/src/game_tab/left_panel/board/BoardCanvas.cpp +++ b/src/game_tab/left_panel/board/BoardCanvas.cpp @@ -16,7 +16,7 @@ BoardCanvas::BoardCanvas(wxFrame *parent) color_arrows=wxColour(145, 233, 255); is_dragging = false; valid_drag = false; - valid_arrow = false; + arrow_drag = false; arrows_offset = t->GetSquaresSizes()/2.5; // Init animation data adata.duration=100; @@ -229,7 +229,8 @@ void BoardCanvas::DrawBoard(wxDC &dc) { } // Draw highlighted squares - for(const std::string &s:gs.squares_hl){ + for(int i=0;i<(gs.squares_hl.size()+squares_hl.size());i++){ + const std::string &s=i squares_hl; + std::vector arrows; // Various canvas state variables - bool black_side, is_dragging, valid_drag, valid_arrow, is_black_turn; + bool black_side, is_dragging, valid_drag, arrow_drag, is_black_turn; std::uint32_t boardX, boardY, square_width, piece_width, mouseX, mouseY, lastClickX, lastClickY; wxSize canvas_size;