mirror of
https://gitlab.com/manzerbredes/ochess.git
synced 2025-07-03 02:37:39 +00:00
Add mat icon
This commit is contained in:
parent
3e40032109
commit
73f7be6c03
8 changed files with 186 additions and 1 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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"
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue