OChess v0.0.2
Programmer's Manual
Theme.hpp
1#pragma once
2
3#include "ochess.hpp"
4
5#include <string>
6#include <unordered_map>
7
8#define ELT_DIM 200
9#define DEFAULT_SIZE 80
10#define PIECE_SIZE_FACTOR 0.8 // Should be between 0 and 1
11#define MAT_SIZE_FACTOR 0.4
12#define DEFAULT_PIECE_THEME "assets/pieces/cburnett.png"
13#define DEFAULT_SQUARE_THEME "assets/boards/chesscom_8bits.png"
14
19class Theme {
20private:
21 std::unordered_map<char, wxImage> skin;
22 std::unordered_map<char, wxBitmap *> skin_scaled;
23 std::uint8_t square_radius;
24 wxMask *RoundedMask(std::uint32_t width, std::uint8_t corner);
25
26public:
27 Theme();
29 Theme(std::string piece, std::string square);
30 ~Theme();
32 void LoadPiecesSkin(wxImage skin);
34 void LoadSquaresSkin(wxImage iskin);
36 void ResizePieces(std::uint32_t width);
38 void ResizeSquares(std::uint32_t width);
40 void ResizeSquaresAndPieces(std::uint32_t width);
42 void SetSquareRadius(std::uint8_t radius);
43 std::uint8_t GetSquareRadius();
44 bool Zoom(int amount);
45 double GetPiecesSizes();
46 double GetSquaresSizes();
53 wxBitmap *Get(char c);
54};
The in memory board theme (used by BoardCanvas)
Definition: Theme.hpp:19
void LoadSquaresSkin(wxImage iskin)
Load square skin image (break the 2 square tiles into individual squares)
Definition: Theme.cpp:83
void LoadPiecesSkin(wxImage skin)
Load piece skin image (break image tile into individual pieces)
Definition: Theme.cpp:49
void ResizeSquares(std::uint32_t width)
Set squares width.
Definition: Theme.cpp:120
wxBitmap * Get(char c)
Get bitmap of an element.
Definition: Theme.cpp:96
void ResizeSquaresAndPieces(std::uint32_t width)
Set square width and adjust piece size accordingly.
Definition: Theme.cpp:115
void ResizePieces(std::uint32_t width)
Set pieces width.
Definition: Theme.cpp:98
void SetSquareRadius(std::uint8_t radius)
Having rounded corners on squares.
Definition: Theme.cpp:152
double GetPiecesSizes()
Definition: Theme.cpp:161
double GetSquaresSizes()
Definition: Theme.cpp:167