From 73f7be6c0366fd4334e70d68f0376c64357edd80 Mon Sep 17 00:00:00 2001 From: Loic Guegan Date: Mon, 2 Jan 2023 10:56:27 +0100 Subject: Add mat icon --- src/game_tab/left_panel/board/BoardCanvas.cpp | 8 ++++++++ src/game_tab/left_panel/board/BoardCanvas.hpp | 10 ++++++++++ src/game_tab/left_panel/board/Theme.cpp | 10 +++++++++- src/game_tab/left_panel/board/Theme.hpp | 1 + 4 files changed, 28 insertions(+), 1 deletion(-) (limited to 'src/game_tab') 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 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 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 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" -- cgit v1.2.3