aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/binres/binres.cpp2
-rw-r--r--src/binres/binres.hpp1
-rw-r--r--src/binres/mat.pngbin0 -> 1833 bytes
-rw-r--r--src/binres/mat_png.hpp155
-rw-r--r--src/game_tab/Game.cpp14
-rw-r--r--src/game_tab/Game.hpp2
-rw-r--r--src/game_tab/GameTab.cpp3
-rw-r--r--src/game_tab/HalfMove.cpp39
-rw-r--r--src/game_tab/HalfMove.hpp9
-rw-r--r--src/game_tab/left_panel/GameTabLeftPanel.cpp78
-rw-r--r--src/game_tab/left_panel/GameTabLeftPanel.hpp4
-rw-r--r--src/game_tab/left_panel/board/BoardCanvas.cpp112
-rw-r--r--src/game_tab/left_panel/board/BoardCanvas.hpp20
-rw-r--r--src/game_tab/left_panel/board/Theme.cpp17
-rw-r--r--src/game_tab/left_panel/board/Theme.hpp3
-rw-r--r--src/game_tab/right_panel/GameTabRightPanel.cpp61
-rw-r--r--src/game_tab/right_panel/GameTabRightPanel.hpp9
-rw-r--r--src/game_tab/right_panel/editor/EditorCanvas.cpp53
-rw-r--r--src/game_tab/right_panel/editor/EditorCanvas.hpp13
19 files changed, 386 insertions, 209 deletions
diff --git a/src/binres/binres.cpp b/src/binres/binres.cpp
index 963a714..14a2077 100644
--- a/src/binres/binres.cpp
+++ b/src/binres/binres.cpp
@@ -19,6 +19,8 @@ wxBitmap LoadPNG(std::string icon) {
return (wxBITMAP_PNG(chesscom_8bits));
} else if (icon == "hide") {
return (wxBITMAP_PNG(hide));
+ } else if (icon == "mat") {
+ return (wxBITMAP_PNG(mat));
}
return (wxNullBitmap);
} \ No newline at end of file
diff --git a/src/binres/binres.hpp b/src/binres/binres.hpp
index 6db39fd..8551932 100644
--- a/src/binres/binres.hpp
+++ b/src/binres/binres.hpp
@@ -7,6 +7,7 @@
#include "cburnett_png.hpp"
#include "chesscom_8bits_png.hpp"
#include "hide_png.hpp"
+#include "mat_png.hpp"
wxBitmap LoadPNG(std::string icon, wxSize size);
wxBitmap LoadPNG(std::string icon); \ No newline at end of file
diff --git a/src/binres/mat.png b/src/binres/mat.png
new file mode 100644
index 0000000..54b4b9c
--- /dev/null
+++ b/src/binres/mat.png
Binary files differ
diff --git a/src/binres/mat_png.hpp b/src/binres/mat_png.hpp
new file mode 100644
index 0000000..c00391c
--- /dev/null
+++ b/src/binres/mat_png.hpp
@@ -0,0 +1,155 @@
+static unsigned char mat_png[] = {
+0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d,
+0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x00, 0x32,
+0x08, 0x06, 0x00, 0x00, 0x00, 0x1e, 0x3f, 0x88, 0xb1, 0x00, 0x00, 0x00,
+0x09, 0x70, 0x48, 0x59, 0x73, 0x00, 0x00, 0x0f, 0x33, 0x00, 0x00, 0x0f,
+0x33, 0x01, 0x61, 0xf4, 0x31, 0x43, 0x00, 0x00, 0x00, 0x19, 0x74, 0x45,
+0x58, 0x74, 0x53, 0x6f, 0x66, 0x74, 0x77, 0x61, 0x72, 0x65, 0x00, 0x77,
+0x77, 0x77, 0x2e, 0x69, 0x6e, 0x6b, 0x73, 0x63, 0x61, 0x70, 0x65, 0x2e,
+0x6f, 0x72, 0x67, 0x9b, 0xee, 0x3c, 0x1a, 0x00, 0x00, 0x06, 0xb6, 0x49,
+0x44, 0x41, 0x54, 0x68, 0x81, 0xd5, 0x5a, 0x6b, 0x4c, 0x1c, 0x55, 0x14,
+0xfe, 0xce, 0x9d, 0xd9, 0xa5, 0xb2, 0x50, 0xd0, 0x82, 0xd5, 0x1f, 0x0a,
+0xb5, 0x04, 0xdc, 0x56, 0xbb, 0x50, 0x8d, 0x68, 0xb1, 0x65, 0x60, 0x11,
+0xc5, 0x3f, 0xda, 0xc4, 0x47, 0xac, 0xb6, 0xc6, 0x47, 0x2d, 0x1a, 0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0x1e, 0x6f,
+0x3b, 0x0f, 0xba, 0xa8, 0x63, 0x88, 0x4b, 0x21, 0x8c, 0x0a, 0x80, 0x4a,
+0x01, 0x14, 0xc1, 0x74, 0xf1, 0x0c, 0x87, 0x88, 0xb1, 0x97, 0x09, 0xfd,
+0x64, 0x70, 0x97, 0x41, 0x6a, 0x54, 0xd3, 0xb4, 0x5f, 0xb2, 0xd1, 0xfe,
+0xdf, 0x10, 0xf6, 0x83, 0xdb, 0x46, 0x42, 0xfd, 0xc8, 0x00, 0x00, 0x00,
+0x00, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82,
+};
diff --git a/src/game_tab/Game.cpp b/src/game_tab/Game.cpp
index fdc754a..53be08f 100644
--- a/src/game_tab/Game.cpp
+++ b/src/game_tab/Game.cpp
@@ -92,6 +92,14 @@ void Game::SetMoveAsMainline(HalfMove *m) {
}
}
+bool Game::IsCheckmate(bool forBlack){
+ arbiter.Setup(GetFen());
+ if(forBlack){
+ return arbiter.IsBlackTurn() && arbiter.IsCheckMate();
+ }
+ return !arbiter.IsBlackTurn() && arbiter.IsCheckMate();
+}
+
bool Game::Play(std::string move) {
wxLogDebug("Playing move %s", move);
std::string fen = GetFen();
@@ -142,6 +150,12 @@ void Game::Next() {
}
}
+HalfMove *Game::GetNextMove(){
+ if(current!=nullptr)
+ return current->GetMainline();
+ return moves;
+}
+
void Game::SetCurrent(HalfMove *m) { current = m; }
std::string Game::GetFen() {
diff --git a/src/game_tab/Game.hpp b/src/game_tab/Game.hpp
index 25284ee..0590027 100644
--- a/src/game_tab/Game.hpp
+++ b/src/game_tab/Game.hpp
@@ -25,11 +25,13 @@ public:
void SetTag(std::string tagname, std::string value);
void DeleteTag(std::string tagname);
HalfMove *GetCurrentMove();
+ HalfMove *GetNextMove();
HalfMove *GetMoves();
std::string GetFen();
std::string GetResult();
bool Play(std::string move);
bool IsBlackToPlay();
+ bool IsCheckmate(bool forBlack);
void Previous();
void Next();
void DeleteMove(HalfMove *m);
diff --git a/src/game_tab/GameTab.cpp b/src/game_tab/GameTab.cpp
index 20196f3..32534fd 100644
--- a/src/game_tab/GameTab.cpp
+++ b/src/game_tab/GameTab.cpp
@@ -21,7 +21,7 @@ GameTab::GameTab(wxFrame *parent, std::shared_ptr<Game> game)
// Refresh panels
RefreshTabTitle();
- board_panel->Notify(false, false);
+ board_panel->Notify();
editor_panel->Notify();
board_panel->Bind(wxEVT_TOOL,&GameTab::OnToolClick,this);
@@ -57,6 +57,7 @@ void GameTab::OnGameChange(wxCommandEvent &event) {
else {
editor_panel->Notify();
board_panel->Notify();
+ RefreshTabTitle();
}
}
diff --git a/src/game_tab/HalfMove.cpp b/src/game_tab/HalfMove.cpp
index 7f19480..32924e1 100644
--- a/src/game_tab/HalfMove.cpp
+++ b/src/game_tab/HalfMove.cpp
@@ -1,13 +1,13 @@
#include "HalfMove.hpp"
HalfMove::HalfMove(std::string move_absolute,std::string move_san) : capture(' ') {
- this->move_absolute=move_absolute;
+ SetAbsoluteMove(move_absolute);
this->move = move_san;
fen = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1";
}
HalfMove::HalfMove(std::string move_absolute, std::string move_san, std::string fen) : fen(fen), capture(' ') {
- this->move_absolute=move_absolute;
+ SetAbsoluteMove(move_absolute);
this->move = move_san;
}
@@ -21,7 +21,8 @@ HalfMove::~HalfMove() {
}
HalfMove::HalfMove(HalfMove *m){
- move_absolute=m->move_absolute;
+ src=m->src;
+ dst=m->dst;
move=m->move;
fen=m->fen;
capture=m->capture;
@@ -137,6 +138,11 @@ void HalfMove::SetAsMainline() {
HalfMove *HalfMove::GetMainline() { return (mainline); }
+void HalfMove::SetAbsoluteMove(const std::string &move_absolute){
+ this->src=move_absolute.substr(0,2);
+ this->dst=move_absolute.substr(2,2);
+}
+
HalfMove::HalfMove(pgnp::HalfMove *m) : capture(' ') {
this->move = m->move;
this->nag = m->NAG;
@@ -151,6 +157,11 @@ HalfMove::HalfMove(pgnp::HalfMove *m) : capture(' ') {
}
}
+void HalfMove::GetAbsoluteMove(std::string &src,std::string &dst){
+ src=this->src;
+ dst=this->dst;
+}
+
void HalfMove::SetFen(std::string fen) { this->fen = fen; }
void HalfMove::Promote() {
@@ -177,6 +188,23 @@ void HalfMove::Promote() {
}
}
+bool HalfMove::HasParent(HalfMove*m){
+ return m==parent;
+}
+
+bool HalfMove::HasChild(HalfMove*m){
+ if(m==nullptr)
+ return false;
+ if(mainline==m){
+ return true;
+ }
+ for(auto var: variations){
+ if(var == m)
+ return true;
+ }
+ return false;
+}
+
bool HalfMove::IsVariation() {
HalfMove *m = this;
HalfMove *p = HalfMove::parent;
@@ -198,8 +226,9 @@ bool HalfMove::IsABlackMove() { return (IsBlack); }
void HalfMove::BuildAndVerify(HalfMove *m, std::string fen) {
arbiter.Setup(fen);
- m->move_absolute=arbiter.ParseSAN(m->move);
- bool work = arbiter.Play(m->move_absolute,arbiter.ParseSANPromotion(m->move));
+ std::string move_absolute=arbiter.ParseSAN(m->move);
+ m->SetAbsoluteMove(move_absolute);
+ bool work = arbiter.Play(move_absolute,arbiter.ParseSANPromotion(m->move));
if (!work) {
wxLogDebug("Bug! %s", m->move);
}
diff --git a/src/game_tab/HalfMove.hpp b/src/game_tab/HalfMove.hpp
index 3d5177e..9775c3e 100644
--- a/src/game_tab/HalfMove.hpp
+++ b/src/game_tab/HalfMove.hpp
@@ -21,11 +21,9 @@ class HalfMove : public cgeditor::CGEHalfMove {
std::string fen;
char capture;
void BuildAndVerify(HalfMove *m, std::string fen);
- std::string move_absolute;
+ std::string src,dst;
public:
-
-
HalfMove(HalfMove *m);
HalfMove(std::string move_absolute,std::string move_san);
HalfMove(std::string move_absolute,std::string move_san, std::string fen);
@@ -46,6 +44,8 @@ public:
/// @brief Check if current half move is within a variation
bool IsVariation();
/// @brief Get the root of a variation
+ bool HasParent(HalfMove*m);
+ bool HasChild(HalfMove*m);
HalfMove *GetRoot();
/// @brief Get parent of the current move
HalfMove *GetParent();
@@ -60,7 +60,8 @@ public:
void SetFen(std::string fen);
void SetCapture(char c);
bool IsABlackMove();
- std::string GetAbsoluteMove(){return move_absolute;};
+ void GetAbsoluteMove(std::string &src,std::string &dst);
+ void SetAbsoluteMove(const std::string &move_absolute);
/**
* @brief Build current move
diff --git a/src/game_tab/left_panel/GameTabLeftPanel.cpp b/src/game_tab/left_panel/GameTabLeftPanel.cpp
index 50919c0..25ded2c 100644
--- a/src/game_tab/left_panel/GameTabLeftPanel.cpp
+++ b/src/game_tab/left_panel/GameTabLeftPanel.cpp
@@ -21,6 +21,7 @@ GameTabLeftPanel::GameTabLeftPanel(wxFrame *parent, std::shared_ptr<Game> game)
// Configure FEN field
fen_text_field->SetFont(wxFont(*wxNORMAL_FONT).Bold().Larger());
+ last_move=game->GetCurrentMove();
// Bind events:
Bind(PLAY_MOVE_EVENT, &GameTabLeftPanel::OnPlay, this, wxID_ANY);
@@ -31,11 +32,11 @@ GameTabLeftPanel::GameTabLeftPanel(wxFrame *parent, std::shared_ptr<Game> game)
Bind(wxEVT_KEY_DOWN, [p=this](wxKeyEvent &e){
if(e.GetKeyCode() == WXK_RIGHT){
p->game->Next();
- p->Notify(true,false);
+ p->Notify();
p->repeat=true;
} else if(e.GetKeyCode() == WXK_LEFT){
p->game->Previous();
- p->Notify(true,true);
+ p->Notify();
p->repeat=true;
}
// Notify other classes
@@ -46,10 +47,10 @@ GameTabLeftPanel::GameTabLeftPanel(wxFrame *parent, std::shared_ptr<Game> game)
Bind(wxEVT_MOUSEWHEEL, [p=this](wxMouseEvent& e){
if(e.GetWheelRotation()<0){
p->game->Next();
- p->Notify(true,false);
+ p->Notify();
}else {
p->game->Previous();
- p->Notify(true,true);
+ p->Notify();
}
// Notify other classes
wxCommandEvent event(GAME_CHANGE, p->GetId());
@@ -67,54 +68,53 @@ void GameTabLeftPanel::OnPlay(wxCommandEvent &event) {
event.SetEventObject(this);
ProcessEvent(event);
}
- // Refresh board canvas:
- Notify();
+ Notify(true); // Redraw event is move failed! Otherwise piece not resets to it initial position after dragging
}
-void GameTabLeftPanel::Notify(bool animate, bool backward) {
+void GameTabLeftPanel::Notify(bool skip_animation) {
// Update fen and captures
std::string fen = game->GetFen();
std::map<char, std::uint8_t> captures;
+ bool animate=false;
HalfMove *m = game->GetCurrentMove();
- if (m != nullptr) {
+ std::string src,dst;
+ // Update capture and check if we should to animations during moves change:
+ if (m){
captures = m->GetLineCaptures();
+ if(m->HasParent(last_move)){
+ m->GetAbsoluteMove(src,dst);
+ animate=true;
+ }else if(m->HasChild(last_move)){
+ // Accessing last_move here is safe since it is still
+ // in the tree of moves (since HasChild found it so not deleted)
+ last_move->GetAbsoluteMove(dst,src);
+ animate=true;
+ }
+ } else if(game->GetNextMove()){ // First move animation
+ HalfMove *next=game->GetNextMove();
+ if(next==last_move){
+ game->GetNextMove()->GetAbsoluteMove(dst,src);
+ animate=true;
+ }
}
// Update board canvas:
- if(!animate){
- if(m){
- last_absolute_move=m->GetAbsoluteMove();
- }
- board_canvas->SetupBoard(chessarbiter::FENParser::Parse(fen).board,
- game->IsBlackToPlay(), captures,
- game->GetTag("White"),game->GetTag("Black"));
+ GameState gs;
+ gs.board=chessarbiter::FENParser::Parse(fen).board;
+ gs.is_black_turn=game->IsBlackToPlay();
+ gs.captures=captures;
+ gs.white=game->GetTag("White");
+ gs.black=game->GetTag("Black");
+ gs.mat_black=game->IsCheckmate(true);
+ gs.mat_white=game->IsCheckmate(false);
+ if(skip_animation || !animate){
+ board_canvas->SetupBoard(gs);
}
else{
- if(backward && last_absolute_move.size()>0){
- std::string dst=last_absolute_move.substr(0,2);
- std::string src=last_absolute_move.substr(2,2);
- board_canvas->Animate(chessarbiter::FENParser::Parse(fen).board,
- game->IsBlackToPlay(), captures,src,dst,repeat);
- if(m){
- last_absolute_move=m->GetAbsoluteMove();
- }
- }
- else if(!backward && m){
- std::string new_absolute_move=m->GetAbsoluteMove();
- if(last_absolute_move!=new_absolute_move){
- last_absolute_move=new_absolute_move;
- std::string src=last_absolute_move.substr(0,2);
- std::string dst=last_absolute_move.substr(2,2);
- board_canvas->Animate(chessarbiter::FENParser::Parse(fen).board,
- game->IsBlackToPlay(), captures,src,dst,repeat);
- }
- }
- // If m undefined
- if(!m){
- last_absolute_move="";
- }
+ board_canvas->Animate(gs, src,dst,repeat);
}
-
+ // Update last move
+ last_move=m;
// Update fen field:
fen_text_field->SetValue(game->GetFen());
}
diff --git a/src/game_tab/left_panel/GameTabLeftPanel.hpp b/src/game_tab/left_panel/GameTabLeftPanel.hpp
index b22d6fc..56297d8 100644
--- a/src/game_tab/left_panel/GameTabLeftPanel.hpp
+++ b/src/game_tab/left_panel/GameTabLeftPanel.hpp
@@ -11,12 +11,12 @@ wxDECLARE_EVENT(GAME_CHANGE, wxCommandEvent);
class GameTabLeftPanel : public TabGameLeftPanel {
std::shared_ptr<Game> game;
BoardCanvas *board_canvas;
- std::string last_absolute_move;
bool repeat;
+ HalfMove *last_move;
public:
GameTabLeftPanel(wxFrame *parent, std::shared_ptr<Game> game);
- void Notify(bool animate=false,bool backward=false);
+ void Notify(bool skip_animation=false);
void OnPlay(wxCommandEvent &event);
void OnGotoMove(wxCommandEvent &event);
void OnRefreshBoard(wxCommandEvent &event);
diff --git a/src/game_tab/left_panel/board/BoardCanvas.cpp b/src/game_tab/left_panel/board/BoardCanvas.cpp
index 1a85176..f6846f1 100644
--- a/src/game_tab/left_panel/board/BoardCanvas.cpp
+++ b/src/game_tab/left_panel/board/BoardCanvas.cpp
@@ -3,25 +3,50 @@
wxDEFINE_EVENT(PLAY_MOVE_EVENT, wxCommandEvent);
BoardCanvas::BoardCanvas(wxFrame *parent)
- : wxPanel(parent), black_side(false), is_black_turn(true), frozen(false),
+ : wxPanel(parent), black_side(false), frozen(false),
lock_square_size(false), t(new Theme()), t_captures(new Theme()) {
- board = "rnbqkbnrpppppppp PPPPPPPPRNBQKBNR";
is_dragging = false;
valid_drag = false;
+ // Init animation data
+ adata.duration=200;
+ adata.duration_fast=80;
+ adata.fps=30;
+ adata.buffer=new wxBitmap(500,500,32);
adata.reuseBuffer=false;
adata.buffer=nullptr;
- t_captures->ResizePieces(t->GetPiecesSizes() * CAPTURE_FACTOR);
+ // Init game state
+ gs.is_black_turn=false;
+ gs.board = "rnbqkbnrpppppppp PPPPPPPPRNBQKBNR";
+ gs.mat_black=false;
+ gs.mat_white=false;
+ // Init clocks
SetClockTime(-1, -1, -1, false);
SetClockTime(-1, -1, -1, true);
+ // Init capture pieces
+ t_captures->ResizePieces(t->GetPiecesSizes() * CAPTURE_FACTOR);
+ // Load preferences
ApplyPreferences();
// The following should be called when using an EVT_PAINT handler
SetBackgroundStyle(wxBG_STYLE_PAINT);
- adata.duration=200;
- adata.duration_fast=80;
- adata.fps=30;
// Let GameTableLeftPanel process keyboard events:
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_PAINT, &BoardCanvas::OnPaint, this);
+ Bind(wxEVT_SIZE, &BoardCanvas::OnResize, this);
+ // Mouse events:
+ Bind(wxEVT_MOTION, &BoardCanvas::MouseEvent, this);
+ Bind(wxEVT_LEFT_DOWN, &BoardCanvas::MouseEvent, this);
+ Bind(wxEVT_LEFT_UP, &BoardCanvas::MouseEvent, this);
+}
+
+void BoardCanvas::OnResize(wxSizeEvent &e){
+ wxSize size=e.GetSize();
+ if(size.x>100 && size.y>100){
+ // Setup buffer (use for animations)
+ if(adata.buffer!=nullptr)
+ free(adata.buffer);
+ adata.buffer=new wxBitmap(size.x,size.y,32);
+ }
}
BoardCanvas::~BoardCanvas() {
@@ -43,7 +68,6 @@ BoardCanvas::BoardCanvas(wxFrame *parent, std::uint32_t square_width,
void BoardCanvas::OnPaint(wxPaintEvent &event) {
wxBufferedPaintDC dc(this);
dc.SetBackground(*wxWHITE_BRUSH);
- dc.Clear();
if(!adata.reuseBuffer){
// Setting up required attributes
@@ -56,12 +80,8 @@ void BoardCanvas::OnPaint(wxPaintEvent &event) {
boardX = 0;
if (boardY > canvas_size.y)
boardY = 0;
-
- // Setup buffer (later use for animations)
- if(adata.buffer!=nullptr)
- free(adata.buffer);
- adata.buffer=new wxBitmap(canvas_size.x,canvas_size.y,32);
wxMemoryDC memDC(*adata.buffer);
+ memDC.Clear();
DrawBoard(memDC);
dc.Blit(0,0,canvas_size.x,canvas_size.y,(wxDC*)&memDC,0,0);
}
@@ -73,7 +93,7 @@ void BoardCanvas::OnPaint(wxPaintEvent &event) {
dc.DrawBitmap(*t->Get(adata.piece_moved),
adata.src.x + adata.frame*(adata.transVect.x/adata.frames),
adata.src.y + adata.frame*(adata.transVect.y/adata.frames), false);
- // end drawing
+ // End drawing
adata.frame++;
}
}
@@ -100,24 +120,26 @@ void BoardCanvas::ApplyPreferences() {
Refresh();
}
-void BoardCanvas::SetupBoard(std::string board, bool is_black_turn,
- std::map<char, std::uint8_t> captures,
- std::string white_player, std::string black_player) {
- this->board = board;
- this->is_black_turn = is_black_turn;
- this->captures = captures;
- this->white_player=white_player;
- this->black_player=black_player;
+void BoardCanvas::SetupBoard(const GameState &new_gs) {
+ gs.board = new_gs.board;
+ gs.is_black_turn = new_gs.is_black_turn;
+ gs.captures = new_gs.captures;
+ gs.white=new_gs.white;
+ gs.black=new_gs.black;
+ gs.mat_white=new_gs.mat_white;
+ gs.mat_black=new_gs.mat_black;
+ gs.black_time=new_gs.black_time;
+ gs.white_time=new_gs.white_time;
Refresh();
}
-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){
+void BoardCanvas::Animate(const GameState &new_gs, std::string src, std::string dst, bool faster){
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
+ adata.piece_moved = gs.board[pfile + 8 * (7-prank)]; // Piece to move
// Now remove the piece that will be moved
- this->board[pfile + 8 * (7-prank)]=' ';
+ gs.board[pfile + 8 * (7-prank)]=' ';
wxMemoryDC memDC(*adata.buffer);
DrawBoard(memDC);
@@ -164,7 +186,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);
+ SetupBoard(new_gs);
}
void BoardCanvas::DrawBoard(wxDC &dc) {
@@ -217,7 +239,7 @@ void BoardCanvas::DrawBoard(wxDC &dc) {
}
std::uint32_t px = x + centrer_offset;
std::uint32_t py = y + centrer_offset;
- char piece = board[(7 - pfile) + 8 * prank];
+ char piece = gs.board[(7 - pfile) + 8 * prank];
if (is_dragging && (7 - pfile) == active_square.x &&
(7 - prank) == active_square.y) {
dp = piece;
@@ -228,6 +250,8 @@ void BoardCanvas::DrawBoard(wxDC &dc) {
}
if (piece != ' ') {
dc.DrawBitmap(*t->Get(piece), px, py, false);
+ if((piece == 'k' && gs.mat_black) || (piece == 'K' && gs.mat_white))
+ dc.DrawBitmap(*t->Get('#'), x+square_width/2+centrer_offset, y+centrer_offset, false);
}
}
}
@@ -236,7 +260,7 @@ void BoardCanvas::DrawBoard(wxDC &dc) {
dc.SetPen(wxPen(*wxBLACK, 3));
std::uint32_t badgeY = boardY;
std::uint32_t badgeWidth = square_width / 2;
- if (is_black_turn) {
+ if (gs.is_black_turn) {
dc.SetBrush(*wxBLACK_BRUSH);
if (black_side) {
badgeY = boardY + (8 * square_width) - badgeWidth;
@@ -265,15 +289,15 @@ void BoardCanvas::DrawBoard(wxDC &dc) {
offsetYPlayerName = offsetY+captures_size;
}
for (char p : {'P', 'N', 'B', 'R', 'Q'}) {
- if (captures.find(p) != captures.end()) {
- for (std::uint8_t i = 0; i < captures[p]; i++) {
+ if (gs.captures.find(p) != gs.captures.end()) {
+ for (std::uint8_t i = 0; i < gs.captures[p]; i++) {
dc.DrawBitmap(*t_captures->Get(p), boardX + offsetX, boardY + offsetY);
offsetX += captures_size / 2;
}
offsetX += captures_size / 2;
}
}
- dc.DrawText(wxString(black_player),boardX,boardY + offsetYPlayerName);
+ dc.DrawText(wxString(gs.black),boardX,boardY + offsetYPlayerName);
// Black (white's captures):
offsetX = 0;
if (black_side) {
@@ -284,15 +308,15 @@ void BoardCanvas::DrawBoard(wxDC &dc) {
offsetYPlayerName = offsetY+captures_size;
}
for (char p : {'p', 'n', 'b', 'r', 'q'}) {
- if (captures.find(p) != captures.end()) {
- for (std::uint8_t i = 0; i < captures[p]; i++) {
+ if (gs.captures.find(p) != gs.captures.end()) {
+ for (std::uint8_t i = 0; i < gs.captures[p]; i++) {
dc.DrawBitmap(*t_captures->Get(p), boardX + offsetX, boardY + offsetY);
offsetX += captures_size / 2;
}
offsetX += captures_size / 2;
}
}
- dc.DrawText(wxString(white_player),boardX,boardY + offsetYPlayerName);
+ dc.DrawText(wxString(gs.white),boardX,boardY + offsetYPlayerName);
// Draw dragging piece
if (DrawDraggingPiece) {
@@ -306,9 +330,9 @@ void BoardCanvas::DrawBoard(wxDC &dc) {
}
// Draw Clocks
- if (std::get<0>(black_time) >= 0) {
+ if (std::get<0>(gs.black_time) >= 0) {
wxFont font = dc.GetFont();
- ClockTime clock = black_side ? white_time : black_time;
+ ClockTime clock = black_side ? gs.white_time : gs.black_time;
wxString time =
wxString::Format("%ds", std::get<1>(clock), std::get<2>(clock));
if (std::get<0>(clock) > 0) {
@@ -321,7 +345,7 @@ void BoardCanvas::DrawBoard(wxDC &dc) {
dc.GetTextExtent(time, &width, &height);
dc.DrawText(time,
wxPoint(boardX + square_width * 8 - width, boardY - height - numbers_size.y*2));
- clock = black_side ? black_time : white_time;
+ clock = black_side ? gs.black_time : gs.white_time;
time = wxString::Format("%ds", std::get<1>(clock), std::get<2>(clock));
if (std::get<0>(clock) > 0) {
time = wxString::Format("%d:%d", std::get<0>(clock), std::get<1>(clock));
@@ -359,6 +383,9 @@ void BoardCanvas::MouseEvent(wxMouseEvent &event) {
((char)('a' + file)) + std::to_string(rank + 1);
event.SetString(move);
ProcessEvent(event);
+ } else {
+ // If square not valid just redraw (place piece back to its square)
+ Refresh();
}
}
if (event.LeftDown()) {
@@ -370,7 +397,7 @@ void BoardCanvas::MouseEvent(wxMouseEvent &event) {
if (IsCurrentSquareValid) {
active_square.x = file;
active_square.y = rank;
- if (board[(7 - rank) * 8 + file] != ' ') {
+ if (gs.board[(7 - rank) * 8 + file] != ' ') {
wxLogDebug("Drag start on square (%d,%d)", file, rank);
valid_drag = true;
}
@@ -385,7 +412,8 @@ void BoardCanvas::MouseEvent(wxMouseEvent &event) {
}
void BoardCanvas::Zoom(std::int32_t zoom) {
- t->Zoom(zoom);
+ if(!t->Zoom(zoom))
+ return;
t_captures->ResizePieces(t->GetPiecesSizes() * CAPTURE_FACTOR);
Refresh();
}
@@ -398,12 +426,8 @@ void BoardCanvas::Swap() {
void BoardCanvas::SetClockTime(short hours, short min, short sec,
bool IsBlack) {
if (IsBlack) {
- black_time = std::make_tuple(hours, min, sec);
+ gs.black_time = std::make_tuple(hours, min, sec);
} else {
- white_time = std::make_tuple(hours, min, sec);
+ gs.white_time = std::make_tuple(hours, min, sec);
}
}
-
-wxBEGIN_EVENT_TABLE(BoardCanvas, wxPanel) EVT_PAINT(BoardCanvas::OnPaint)
- EVT_MOUSE_EVENTS(BoardCanvas::MouseEvent)
- wxEND_EVENT_TABLE()
diff --git a/src/game_tab/left_panel/board/BoardCanvas.hpp b/src/game_tab/left_panel/board/BoardCanvas.hpp
index b26526f..7b6ccf7 100644
--- a/src/game_tab/left_panel/board/BoardCanvas.hpp
+++ b/src/game_tab/left_panel/board/BoardCanvas.hpp
@@ -58,6 +58,16 @@ typedef struct AnimState {
wxPoint transVect;
} AnimState;
+typedef struct GameState {
+ std::string white, black;
+ std::string board;
+ std::map<char, std::uint8_t> captures;
+ bool is_black_turn;
+ bool mat_black;
+ bool mat_white;
+ ClockTime black_time, white_time;
+} GameState;
+
class BoardCanvas : public wxPanel {
// *t is theme for board+pieces and
// *t_captures is theme for captured pieces (scale down version of t)
@@ -73,11 +83,11 @@ class BoardCanvas : public wxPanel {
wxSize canvas_size;
wxPoint active_square;
std::map<char, std::uint8_t> captures;
- ClockTime black_time, white_time;
bool frozen,lock_square_size;
// Current animation state
AnimState adata;
+ GameState gs;
public:
BoardCanvas(wxFrame *parent);
@@ -89,10 +99,8 @@ public:
void MouseEvent(wxMouseEvent &event);
void Zoom(std::int32_t zoom);
void Swap();
- void SetupBoard(std::string board, bool is_black_turn,
- std::map<char, std::uint8_t> captures,
- std::string white_player, std::string black_player);
- void Animate(const std::string &board, bool is_black_turn, std::map<char, std::uint8_t> captures, std::string src, std::string dst,bool faster);
+ void OnResize(wxSizeEvent &e);
+ void SetupBoard(const GameState &new_gs);
+ void Animate(const GameState &new_gs, std::string src, std::string dst,bool faster);
void SetClockTime(short hours, short min, short sec, bool IsBlack);
- DECLARE_EVENT_TABLE()
};
diff --git a/src/game_tab/left_panel/board/Theme.cpp b/src/game_tab/left_panel/board/Theme.cpp
index 6ecbafc..f72dfab 100644
--- a/src/game_tab/left_panel/board/Theme.cpp
+++ b/src/game_tab/left_panel/board/Theme.cpp
@@ -11,6 +11,8 @@ Theme::Theme() : square_radius(10) {
config->Read("board/theme/squares/path", "default").ToStdString();
wxFileName square_file(square);
CONFIG_CLOSE(config);
+ // Mat
+ skin['#']=LoadPNG("mat").ConvertToImage();
// Piece
if (piece == "default" || !piece_file.FileExists()) {
wxLogDebug("Loading piece skin from binres");
@@ -95,12 +97,18 @@ wxBitmap *Theme::Get(char c) { return (skin_scaled[c]); }
void Theme::ResizePieces(std::uint32_t width) {
for (std::pair<char, wxImage> c : skin) {
- if (c.first != 's' && c.first != 'S') {
+ if (c.first != 's' && c.first != 'S' && c.first != '#') {
if (skin_scaled.count(c.first))
delete skin_scaled[c.first];
skin_scaled[c.first] =
new wxBitmap(c.second.Scale(width, width, wxIMAGE_QUALITY_HIGH));
}
+ else if(c.first == '#'){
+ if (skin_scaled.count(c.first))
+ delete skin_scaled[c.first];
+ skin_scaled[c.first] =
+ new wxBitmap(c.second.Scale(width*MAT_SIZE_FACTOR, width*MAT_SIZE_FACTOR, wxIMAGE_QUALITY_HIGH));
+ }
}
}
@@ -130,10 +138,15 @@ void Theme::ResizeSquares(std::uint32_t width) {
skin_scaled['3']->SetMask(RoundedMask(width, 3));
}
-void Theme::Zoom(int amount) {
+bool Theme::Zoom(int amount) {
double width = skin_scaled['s']->GetWidth() + amount;
+ if(width<=20)
+ return false;
+ if(width>=180)
+ return false;
ResizeSquares(std::max(width, 1.0));
ResizePieces(std::max(width * PIECE_SIZE_FACTOR, 1.0));
+ return true;
}
void Theme::SetSquareRadius(std::uint8_t radius) {
diff --git a/src/game_tab/left_panel/board/Theme.hpp b/src/game_tab/left_panel/board/Theme.hpp
index 88036d8..c3acf10 100644
--- a/src/game_tab/left_panel/board/Theme.hpp
+++ b/src/game_tab/left_panel/board/Theme.hpp
@@ -8,6 +8,7 @@
#define ELT_DIM 200
#define DEFAULT_SIZE 80
#define PIECE_SIZE_FACTOR 0.8 // Should be between 0 and 1
+#define MAT_SIZE_FACTOR 0.4
#define DEFAULT_PIECE_THEME "assets/pieces/cburnett.png"
#define DEFAULT_SQUARE_THEME "assets/boards/chesscom_8bits.png"
@@ -29,7 +30,7 @@ public:
void ResizeSquaresAndPieces(std::uint32_t width);
void SetSquareRadius(std::uint8_t radius);
std::uint8_t GetSquareRadius();
- void Zoom(int amount);
+ bool Zoom(int amount);
double GetPiecesSizes();
double GetSquaresSizes();
diff --git a/src/game_tab/right_panel/GameTabRightPanel.cpp b/src/game_tab/right_panel/GameTabRightPanel.cpp
index c88202b..dd0ebca 100644
--- a/src/game_tab/right_panel/GameTabRightPanel.cpp
+++ b/src/game_tab/right_panel/GameTabRightPanel.cpp
@@ -10,7 +10,7 @@ wxDEFINE_EVENT(NEXT_MOVE_EVENT, wxCommandEvent);
GameTabRightPanel::GameTabRightPanel(wxFrame *parent, std::shared_ptr<Game> game)
: TabGameRightPanel(parent), game(game), selected_item(-1),
live_engine(nullptr) {
- editor_canvas = new EditorCanvas((wxFrame *)editor_page);
+ editor_canvas = new EditorCanvas((wxFrame *)editor_page,game);
editor_canvas_sizer->Add(editor_canvas, 1, wxEXPAND);
tags_list->InsertColumn(0, L"Name", wxLIST_FORMAT_LEFT, 200);
tags_list->InsertColumn(1, L"Value", wxLIST_FORMAT_LEFT, 500);
@@ -22,16 +22,6 @@ GameTabRightPanel::GameTabRightPanel(wxFrame *parent, std::shared_ptr<Game> game
// Bind events
this->Bind(wxEVT_TEXT, &GameTabRightPanel::OnCommentChange, this,
COMMENT_INPUT_BOX);
- this->Bind(GOTO_MOVE_EVENT, &GameTabRightPanel::OnGotoMove, this, wxID_ANY);
- this->Bind(DELETE_MOVE_EVENT, &GameTabRightPanel::OnMoveDelete, this,
- wxID_ANY);
- this->Bind(PROMOTE_MOVE_EVENT, &GameTabRightPanel::OnMovePromote, this,
- wxID_ANY);
- this->Bind(SET_AS_MAINLINE_EVENT, &GameTabRightPanel::OnMoveSetAsMainline,
- this, wxID_ANY);
- /*this->Bind(NEXT_MOVE_EVENT, &GameTabRightPanel::OnNextMove, this, wxID_ANY);
- this->Bind(PREVIOUS_MOVE_EVENT, &GameTabRightPanel::OnPreviousMove, this,
- wxID_ANY);*/
this->Bind(wxEVT_LIST_ITEM_SELECTED, &GameTabRightPanel::OnTagSelected, this,
wxID_ANY);
this->Bind(wxEVT_LIST_ITEM_DESELECTED, &GameTabRightPanel::OnTagDeselected,
@@ -90,12 +80,6 @@ void GameTabRightPanel::OnTagDeselected(wxListEvent &event) {
delete_button->Enable(false);
}
-void GameTabRightPanel::NotifyBoard() {
- wxCommandEvent previousEvent(GAME_CHANGE, GetId());
- previousEvent.SetEventObject(this);
- ProcessEvent(previousEvent);
-}
-
void GameTabRightPanel::OnLiveEngineClose(wxCloseEvent &e) {
live_engine = nullptr;
e.Skip();
@@ -105,7 +89,12 @@ void GameTabRightPanel::OnCommentChange(wxCommandEvent &event) {
wxLogDebug("GameTabRightPanel: comment input change");
HalfMove *m = game->GetCurrentMove();
if (m != nullptr) {
- m->comment=event.GetString().ToStdString();
+ m->comment=event.GetString().Trim().ToStdString();
+ // Remove newlines:
+ for(char &c:m->comment){
+ if(c=='\n')
+ c=' ';
+ }
}
editor_canvas->Refresh();
}
@@ -143,29 +132,6 @@ void GameTabRightPanel::OnDelete(wxCommandEvent &event) {
}
}
-void GameTabRightPanel::OnGotoMove(wxCommandEvent &event) {
- wxLogDebug("GameTabRightPanel: received GOTO_MOVE_EVENT");
- game->SetCurrent((HalfMove *)event.GetClientData());
- Notify();
-}
-
-void GameTabRightPanel::OnMoveDelete(wxCommandEvent &event) {
- game->DeleteMove((HalfMove *)event.GetClientData());
- Notify();
-}
-
-void GameTabRightPanel::OnMovePromote(wxCommandEvent &event) {
- wxLogDebug("GameTabRightPanel: promote move called");
- game->PromoteMove((HalfMove *)event.GetClientData());
- Notify();
-}
-
-void GameTabRightPanel::OnMoveSetAsMainline(wxCommandEvent &event) {
- wxLogDebug("GameTabRightPanel: set move as mainline called");
- game->SetMoveAsMainline((HalfMove *)event.GetClientData());
- Notify();
-}
-
void GameTabRightPanel::Notify() {
HalfMove *m = game->GetCurrentMove();
if (m != nullptr) {
@@ -177,7 +143,6 @@ void GameTabRightPanel::Notify() {
if (live_engine != nullptr) {
live_engine->SetFEN(game->GetFen());
}
- NotifyBoard();
}
void GameTabRightPanel::ApplyPreferences() {
@@ -206,18 +171,6 @@ void GameTabRightPanel::RefreshTagsList() {
}
}
-void GameTabRightPanel::OnPreviousMove(wxCommandEvent &event) {
- game->Previous();
- Notify();
- NotifyBoard();
-}
-
-void GameTabRightPanel::OnNextMove(wxCommandEvent &event) {
- game->Next();
- Notify();
- NotifyBoard();
-}
-
std::string GameTabRightPanel::GetNagFromStr(std::string str){
// TODO: Bind more NAG!
if(str=="!")
diff --git a/src/game_tab/right_panel/GameTabRightPanel.hpp b/src/game_tab/right_panel/GameTabRightPanel.hpp
index 0a353b6..6f3aaaa 100644
--- a/src/game_tab/right_panel/GameTabRightPanel.hpp
+++ b/src/game_tab/right_panel/GameTabRightPanel.hpp
@@ -1,3 +1,5 @@
+#include <algorithm>
+
#include "../Game.hpp"
#include "LiveEngineDialog.hpp"
#include "editor/EditorCanvas.hpp"
@@ -23,20 +25,13 @@ class GameTabRightPanel : public TabGameRightPanel {
public:
GameTabRightPanel(wxFrame *parent, std::shared_ptr<Game> game);
- void NotifyBoard();
void Notify();
void OnCommentChange(wxCommandEvent &event);
- void OnGotoMove(wxCommandEvent &event);
- void OnMoveDelete(wxCommandEvent &event);
- void OnMovePromote(wxCommandEvent &event);
- void OnMoveSetAsMainline(wxCommandEvent &event);
void RefreshTagsList();
void OnTagSelected(wxListEvent &event);
void OnTagDeselected(wxListEvent &event);
void OnApply(wxCommandEvent &event);
void OnDelete(wxCommandEvent &event);
- void OnPreviousMove(wxCommandEvent &event);
- void OnNextMove(wxCommandEvent &event);
void OnLiveAnalysis(wxCommandEvent &event);
void ApplyPreferences();
void OnLiveEngineClose(wxCloseEvent &e);
diff --git a/src/game_tab/right_panel/editor/EditorCanvas.cpp b/src/game_tab/right_panel/editor/EditorCanvas.cpp
index ae0c096..19d81ec 100644
--- a/src/game_tab/right_panel/editor/EditorCanvas.cpp
+++ b/src/game_tab/right_panel/editor/EditorCanvas.cpp
@@ -1,7 +1,7 @@
#include "EditorCanvas.hpp"
-EditorCanvas::EditorCanvas(wxFrame *parent)
- : wxPanel(parent), NeedRedraw(false) {
+EditorCanvas::EditorCanvas(wxFrame *parent, std::shared_ptr<Game> game)
+ : wxPanel(parent), game(game) {
hide_icon = LoadPNG("hide", wxSize(CGEditor::status.MoveIconWidth,
CGEditor::status.MoveIconWidth));
t.ResizePieces(CGEditor::status.MoveIconWidth);
@@ -14,13 +14,17 @@ EditorCanvas::EditorCanvas(wxFrame *parent)
color_comments_bg=wxColour(255, 255, 204);
color_current_move_bg=wxColour(216, 216, 216);
color_menu_item_bg=wxColour(216, 216, 216);
-
+ // The following should be called when using an EVT_PAINT handler
+ SetBackgroundStyle(wxBG_STYLE_PAINT);
+
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();});
}
void EditorCanvas::OnPaint(wxPaintEvent &event) {
wxPaintDC current_dc(this);
+ current_dc.SetBackground(*wxWHITE_BRUSH);
+ current_dc.Clear();
dc = &current_dc;
// Refresh canvas size
@@ -173,28 +177,18 @@ void EditorCanvas::DrawElement(const cgeditor::Element &e) {
}
}
void EditorCanvas::HandleEvent(const cgeditor::Event &e) {
- wxLogDebug("Editor event!");
if (e.type == cgeditor::Event::Goto) {
- wxCommandEvent event(GOTO_MOVE_EVENT, GetId());
- event.SetEventObject(this);
- event.SetClientData(e.move);
- ProcessEvent(event);
+ game->SetCurrent((HalfMove *)e.move);
} else if (e.type == cgeditor::Event::Delete) {
- wxCommandEvent event(DELETE_MOVE_EVENT, GetId());
- event.SetEventObject(this);
- event.SetClientData(e.move);
- ProcessEvent(event);
+ game->DeleteMove((HalfMove *)e.move);
} else if (e.type == cgeditor::Event::Promote) {
- wxCommandEvent event(PROMOTE_MOVE_EVENT, GetId());
- event.SetEventObject(this);
- event.SetClientData(e.move);
- ProcessEvent(event);
+ game->PromoteMove((HalfMove *)e.move);
} else if (e.type == cgeditor::Event::SetAsMainline) {
- wxCommandEvent event(SET_AS_MAINLINE_EVENT, GetId());
- event.SetEventObject(this);
- event.SetClientData(e.move);
- ProcessEvent(event);
+ game->SetMoveAsMainline((HalfMove *)e.move);
}
+ wxCommandEvent event(GAME_CHANGE, GetId());
+ event.SetEventObject(this);
+ ProcessEvent(event);
}
void EditorCanvas::MouseEvent(wxMouseEvent &event) {
@@ -220,10 +214,11 @@ void EditorCanvas::MouseEvent(wxMouseEvent &event) {
Refresh();
}
- // Should another draw of CGEditor be made?
- if (NeedRedraw) {
+ // Handle editor events
+ Update();
+ if(ProcessEvents()){
Refresh();
- NeedRedraw = false;
+ Update();
}
}
@@ -234,17 +229,5 @@ void EditorCanvas::SetMoves(HalfMove *moves, HalfMove *current) {
Refresh();
}
-void EditorCanvas::OnKeyEvent(wxKeyEvent &event) {
- /*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);
- }*/
-}
-
wxBEGIN_EVENT_TABLE(EditorCanvas, wxPanel) EVT_PAINT(EditorCanvas::OnPaint)
EVT_MOUSE_EVENTS(EditorCanvas::MouseEvent) wxEND_EVENT_TABLE()
diff --git a/src/game_tab/right_panel/editor/EditorCanvas.hpp b/src/game_tab/right_panel/editor/EditorCanvas.hpp
index 05d6258..740a6a1 100644
--- a/src/game_tab/right_panel/editor/EditorCanvas.hpp
+++ b/src/game_tab/right_panel/editor/EditorCanvas.hpp
@@ -4,22 +4,18 @@
#include "CGEditor.hpp"
#include "ochess.hpp"
#include "../../left_panel/board/Theme.hpp"
+#include "game_tab/Game.hpp"
// Foreign events
-wxDECLARE_EVENT(GOTO_MOVE_EVENT, wxCommandEvent);
-wxDECLARE_EVENT(PREVIOUS_MOVE_EVENT, wxCommandEvent);
-wxDECLARE_EVENT(NEXT_MOVE_EVENT, wxCommandEvent);
-wxDECLARE_EVENT(DELETE_MOVE_EVENT, wxCommandEvent);
-wxDECLARE_EVENT(PROMOTE_MOVE_EVENT, wxCommandEvent);
-wxDECLARE_EVENT(SET_AS_MAINLINE_EVENT, wxCommandEvent);
+wxDECLARE_EVENT(GAME_CHANGE, wxCommandEvent);
class EditorCanvas : public wxPanel, public cgeditor::CGEditor {
wxPaintDC *dc;
- bool NeedRedraw;
wxPoint Middle(cgeditor::Element e);
wxBitmap hide_icon;
Theme t;
wxFont default_font;
+ std::shared_ptr<Game> game;
wxColour color_scrollbar_bg;
wxColour color_scrollbar;
@@ -29,13 +25,12 @@ class EditorCanvas : public wxPanel, public cgeditor::CGEditor {
wxColour color_menu_item_bg;
public:
- EditorCanvas(wxFrame *parent);
+ EditorCanvas(wxFrame *parent, std::shared_ptr<Game> game);
void OnPaint(wxPaintEvent &event);
void MouseEvent(wxMouseEvent &event);
void DrawElement(const cgeditor::Element &e);
void HandleEvent(const cgeditor::Event &e);
void SetMoves(HalfMove *moves, HalfMove *current);
- void OnKeyEvent(wxKeyEvent &event);
DECLARE_EVENT_TABLE()
};