aboutsummaryrefslogtreecommitdiff
path: root/src/game_tab/left_panel/board/Theme.cpp
diff options
context:
space:
mode:
authorLoic Guegan <manzerbredes@mailbox.org>2023-01-02 12:02:11 +0100
committerLoic Guegan <manzerbredes@mailbox.org>2023-01-02 12:02:11 +0100
commite40f98ccda04da3bb9811b354b770fb8c6b563e5 (patch)
tree3b0258e0cb3eca9f979d79d71da938fa7efb4bc8 /src/game_tab/left_panel/board/Theme.cpp
parentd05093513ec5124feed0dc6140789f48218b45c9 (diff)
parent042f6ca17012414d13235d3e04ea9012ff49f79c (diff)
Improve game tab
Diffstat (limited to 'src/game_tab/left_panel/board/Theme.cpp')
-rw-r--r--src/game_tab/left_panel/board/Theme.cpp17
1 files changed, 15 insertions, 2 deletions
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) {