aboutsummaryrefslogtreecommitdiff
path: root/src/game_tab
diff options
context:
space:
mode:
Diffstat (limited to 'src/game_tab')
-rw-r--r--src/game_tab/left_panel/board/BoardCanvas.cpp8
-rw-r--r--src/game_tab/left_panel/board/BoardCanvas.hpp10
-rw-r--r--src/game_tab/left_panel/board/Theme.cpp10
-rw-r--r--src/game_tab/left_panel/board/Theme.hpp1
4 files changed, 28 insertions, 1 deletions
diff --git a/src/game_tab/left_panel/board/BoardCanvas.cpp b/src/game_tab/left_panel/board/BoardCanvas.cpp
index 6581934..4617f3d 100644
--- a/src/game_tab/left_panel/board/BoardCanvas.cpp
+++ b/src/game_tab/left_panel/board/BoardCanvas.cpp
@@ -116,6 +116,12 @@ void BoardCanvas::ApplyPreferences() {
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) {
+ gs.board = board;
+ gs.is_black_turn = is_black_turn;
+ gs.captures = captures;
+ gs.white=white_player;
+ gs.black=black_player;
+
this->board = board;
this->is_black_turn = is_black_turn;
this->captures = captures;
@@ -241,6 +247,8 @@ void BoardCanvas::DrawBoard(wxDC &dc) {
}
if (piece != ' ') {
dc.DrawBitmap(*t->Get(piece), px, py, false);
+ if(piece == 'k' || piece == 'K')
+ dc.DrawBitmap(*t->Get('#'), x+square_width/2+centrer_offset, y+centrer_offset, false);
}
}
}
diff --git a/src/game_tab/left_panel/board/BoardCanvas.hpp b/src/game_tab/left_panel/board/BoardCanvas.hpp
index 9a00262..5d7c76d 100644
--- a/src/game_tab/left_panel/board/BoardCanvas.hpp
+++ b/src/game_tab/left_panel/board/BoardCanvas.hpp
@@ -58,6 +58,15 @@ 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;
+} GameState;
+
class BoardCanvas : public wxPanel {
// *t is theme for board+pieces and
// *t_captures is theme for captured pieces (scale down version of t)
@@ -78,6 +87,7 @@ class BoardCanvas : public wxPanel {
// Current animation state
AnimState adata;
+ GameState gs;
public:
BoardCanvas(wxFrame *parent);
diff --git a/src/game_tab/left_panel/board/Theme.cpp b/src/game_tab/left_panel/board/Theme.cpp
index 6c662dc..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));
+ }
}
}
diff --git a/src/game_tab/left_panel/board/Theme.hpp b/src/game_tab/left_panel/board/Theme.hpp
index b896d09..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"