mirror of
https://gitlab.com/manzerbredes/ochess.git
synced 2025-04-18 03:42:02 +00:00
Debug pieces animation
This commit is contained in:
parent
756c888145
commit
aa94a41353
6 changed files with 10 additions and 34 deletions
|
@ -57,13 +57,9 @@ MainWindow::MainWindow()
|
||||||
NewGame(std::shared_ptr<Game>(new Game()));
|
NewGame(std::shared_ptr<Game>(new Game()));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Temporary TO REMOVE JUST FOR TESTS:
|
// Temporary TO REMOVE JUST FOR TESTS:
|
||||||
/*BaseTab *bt = new BaseTab((wxFrame *)notebook, "/home/loic/pgn/Milov.pgn");
|
BaseTab *bt = new BaseTab((wxFrame *)notebook, "/home/loic/pgn/twic1467.pgn");
|
||||||
this->AddPage(bt,bt);
|
this->AddPage(bt,bt);
|
||||||
|
|
||||||
bt = new BaseTab((wxFrame *)notebook, "/home/loic/jean.pgn");
|
|
||||||
this->AddPage(bt,bt);*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::AddPage(wxWindow* window, TabInfos* infos){
|
void MainWindow::AddPage(wxWindow* window, TabInfos* infos){
|
||||||
|
|
|
@ -23,7 +23,7 @@ GameTab::GameTab(wxFrame *parent, std::shared_ptr<Game> game)
|
||||||
wxCommandEvent event(REFRESH_TAB_TITLE, GetId());
|
wxCommandEvent event(REFRESH_TAB_TITLE, GetId());
|
||||||
event.SetEventObject(this);
|
event.SetEventObject(this);
|
||||||
OnRefreshTabTitle(event);
|
OnRefreshTabTitle(event);
|
||||||
board_panel->Notify();
|
board_panel->Notify(false, false);
|
||||||
editor_panel->Notify();
|
editor_panel->Notify();
|
||||||
|
|
||||||
Bind(REFRESH_TAB_TITLE, &GameTab::OnRefreshTabTitle, this, wxID_ANY);
|
Bind(REFRESH_TAB_TITLE, &GameTab::OnRefreshTabTitle, this, wxID_ANY);
|
||||||
|
@ -47,7 +47,7 @@ GameTab::GameTab(wxFrame *parent, std::shared_ptr<Game> game)
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameTab::OnGameChange(wxCommandEvent &event) {
|
void GameTab::OnGameChange(wxCommandEvent &event) {
|
||||||
board_panel->Notify();
|
board_panel->Notify(false,false);
|
||||||
editor_panel->Notify();
|
editor_panel->Notify();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -180,7 +180,8 @@ bool HalfMove::IsABlackMove() { return (IsBlack); }
|
||||||
|
|
||||||
void HalfMove::BuildAndVerify(HalfMove *m, std::string fen) {
|
void HalfMove::BuildAndVerify(HalfMove *m, std::string fen) {
|
||||||
arbiter.Setup(fen);
|
arbiter.Setup(fen);
|
||||||
bool work = arbiter.Play(arbiter.ParseSAN(m->move),arbiter.ParseSANPromotion(m->move));
|
m->move_absolute=arbiter.ParseSAN(m->move);
|
||||||
|
bool work = arbiter.Play(m->move_absolute,arbiter.ParseSANPromotion(m->move));
|
||||||
if (!work) {
|
if (!work) {
|
||||||
wxLogDebug("Bug! %s", m->move);
|
wxLogDebug("Bug! %s", m->move);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#include <wx/clipbrd.h>
|
#include <wx/clipbrd.h>
|
||||||
|
|
||||||
GameTabLeftPanel::GameTabLeftPanel(wxFrame *parent, std::shared_ptr<Game> game)
|
GameTabLeftPanel::GameTabLeftPanel(wxFrame *parent, std::shared_ptr<Game> game)
|
||||||
: TabGameLeftPanel(parent), game(game) {
|
: TabGameLeftPanel(parent), game(game), repeat(false) {
|
||||||
|
|
||||||
// Add board
|
// Add board
|
||||||
board_canvas = new BoardCanvas((wxFrame *)this);
|
board_canvas = new BoardCanvas((wxFrame *)this);
|
||||||
|
@ -22,7 +22,6 @@ GameTabLeftPanel::GameTabLeftPanel(wxFrame *parent, std::shared_ptr<Game> game)
|
||||||
Bind(wxEVT_BUTTON, &GameTabLeftPanel::OnZoomOut, this, ZOOM_OUT_BTN);
|
Bind(wxEVT_BUTTON, &GameTabLeftPanel::OnZoomOut, this, ZOOM_OUT_BTN);
|
||||||
Bind(wxEVT_KEY_DOWN, [p=this](wxKeyEvent &e){e.ResumePropagation(1);e.Skip();});
|
Bind(wxEVT_KEY_DOWN, [p=this](wxKeyEvent &e){e.ResumePropagation(1);e.Skip();});
|
||||||
Bind(wxEVT_KEY_UP, [p=this](wxKeyEvent &e){e.ResumePropagation(1);e.Skip();});
|
Bind(wxEVT_KEY_UP, [p=this](wxKeyEvent &e){e.ResumePropagation(1);e.Skip();});
|
||||||
repeat=false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameTabLeftPanel::PreviousMove(bool isKeyDown) {
|
void GameTabLeftPanel::PreviousMove(bool isKeyDown) {
|
||||||
|
@ -79,7 +78,6 @@ void GameTabLeftPanel::OnPlay(wxCommandEvent &event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameTabLeftPanel::Notify(bool animate, bool backward) {
|
void GameTabLeftPanel::Notify(bool animate, bool backward) {
|
||||||
wxLogDebug("Notify");
|
|
||||||
std::string fen = game->GetFen();
|
std::string fen = game->GetFen();
|
||||||
std::map<char, std::uint8_t> captures;
|
std::map<char, std::uint8_t> captures;
|
||||||
HalfMove *m = game->GetCurrentMove();
|
HalfMove *m = game->GetCurrentMove();
|
||||||
|
@ -114,7 +112,6 @@ void GameTabLeftPanel::Notify(bool animate, bool backward) {
|
||||||
game->IsBlackToPlay(), captures,src,dst,repeat);
|
game->IsBlackToPlay(), captures,src,dst,repeat);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If m undefined
|
// If m undefined
|
||||||
if(!m){
|
if(!m){
|
||||||
last_absolute_move="";
|
last_absolute_move="";
|
||||||
|
|
|
@ -16,11 +16,11 @@ BoardCanvas::BoardCanvas(wxFrame *parent)
|
||||||
// The following should be called when using an EVT_PAINT handler
|
// The following should be called when using an EVT_PAINT handler
|
||||||
SetBackgroundStyle(wxBG_STYLE_PAINT);
|
SetBackgroundStyle(wxBG_STYLE_PAINT);
|
||||||
duration=200;
|
duration=200;
|
||||||
duration_fast=100;
|
duration_fast=80;
|
||||||
fps=30;
|
fps=30;
|
||||||
|
|
||||||
Bind(wxEVT_KEY_DOWN, &BoardCanvas::OnKeyEvent, this);
|
Bind(wxEVT_KEY_DOWN, [p=this](wxKeyEvent &e){e.ResumePropagation(1);e.Skip();});
|
||||||
Bind(wxEVT_KEY_UP, &BoardCanvas::OnKeyEvent, this);
|
Bind(wxEVT_KEY_UP, [p=this](wxKeyEvent &e){e.ResumePropagation(1);e.Skip();});
|
||||||
}
|
}
|
||||||
|
|
||||||
BoardCanvas::~BoardCanvas() {
|
BoardCanvas::~BoardCanvas() {
|
||||||
|
@ -123,7 +123,7 @@ void BoardCanvas::Animate(std::string board, bool is_black_turn, std::map<char,
|
||||||
this->board[pfile + 8 * (7-prank)]=' ';
|
this->board[pfile + 8 * (7-prank)]=' ';
|
||||||
wxMemoryDC memDC(*buffer);
|
wxMemoryDC memDC(*buffer);
|
||||||
DrawBoard(memDC);
|
DrawBoard(memDC);
|
||||||
|
|
||||||
// Now compute piece start position and translation vector (Copy paste from DrawBoard())
|
// Now compute piece start position and translation vector (Copy paste from DrawBoard())
|
||||||
std::uint32_t piece_width = t->GetPiecesSizes();
|
std::uint32_t piece_width = t->GetPiecesSizes();
|
||||||
std::uint32_t centrer_offset = (square_width - piece_width) / 2;
|
std::uint32_t centrer_offset = (square_width - piece_width) / 2;
|
||||||
|
@ -369,23 +369,6 @@ void BoardCanvas::Swap() {
|
||||||
Refresh();
|
Refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BoardCanvas::OnKeyEvent(wxKeyEvent &event) {
|
|
||||||
event.ResumePropagation(1);
|
|
||||||
event.Skip();
|
|
||||||
return;
|
|
||||||
wxLogDebug("OnKeyEvent %d",event.GetUnicodeKey());
|
|
||||||
if (event.GetKeyCode() == WXK_LEFT) {
|
|
||||||
wxCommandEvent previousEvent(PREVIOUS_MOVE_EVENT, GetId());
|
|
||||||
//previousEvent.SetEventObject(this);
|
|
||||||
ProcessEvent(previousEvent);
|
|
||||||
} else if (event.GetKeyCode() == WXK_RIGHT) {
|
|
||||||
wxCommandEvent nextEvent(NEXT_MOVE_EVENT, GetId());
|
|
||||||
//nextEvent.SetEventObject(this);
|
|
||||||
ProcessEvent(nextEvent);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void BoardCanvas::SetClockTime(short hours, short min, short sec,
|
void BoardCanvas::SetClockTime(short hours, short min, short sec,
|
||||||
bool IsBlack) {
|
bool IsBlack) {
|
||||||
if (IsBlack) {
|
if (IsBlack) {
|
||||||
|
|
|
@ -75,7 +75,6 @@ public:
|
||||||
void ApplyPreferences();
|
void ApplyPreferences();
|
||||||
void DrawBoard(wxDC &dc);
|
void DrawBoard(wxDC &dc);
|
||||||
void OnPaint(wxPaintEvent &event);
|
void OnPaint(wxPaintEvent &event);
|
||||||
void OnKeyEvent(wxKeyEvent &event);
|
|
||||||
void MouseEvent(wxMouseEvent &event);
|
void MouseEvent(wxMouseEvent &event);
|
||||||
void Zoom(std::int32_t zoom);
|
void Zoom(std::int32_t zoom);
|
||||||
void Swap();
|
void Swap();
|
||||||
|
|
Loading…
Add table
Reference in a new issue