Skip to content

Commit c10f35c

Browse files
feat: custom piece styles (#218)
* feat: custom piece styles Signed-off-by: Thomas Mauran <thomasmauran@yahoo.com> * chore: fmt Signed-off-by: Thomas Mauran <thomasmauran@yahoo.com> --------- Signed-off-by: Thomas Mauran <thomasmauran@yahoo.com>
1 parent 85a5bb7 commit c10f35c

File tree

14 files changed

+773
-412
lines changed

14 files changed

+773
-412
lines changed

src/app.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use crate::game_logic::opponent::{Opponent, OpponentKind};
1010
use crate::game_logic::puzzle::PuzzleGame;
1111
use crate::lichess::LichessClient;
1212
use crate::server::game_server::GameServer;
13-
use crate::skin::Skin;
13+
use crate::skin::{PieceStyle, Skin};
1414
use crate::utils::flip_square_if_needed;
1515
use log::LevelFilter;
1616
use shakmaty::{Color, Move, Position};
@@ -62,6 +62,8 @@ pub struct App {
6262
pub loaded_skin: Option<Skin>,
6363
/// Available skins loaded from skins.json
6464
pub available_skins: Vec<Skin>,
65+
/// Available Piece Styles
66+
pub available_piece_styles: Vec<PieceStyle>,
6567
/// Selected skin name
6668
pub selected_skin_name: String,
6769
/// Lichess API token
@@ -119,6 +121,7 @@ impl Default for App {
119121
error_message: None,
120122
loaded_skin: None,
121123
available_skins: Vec::new(),
124+
available_piece_styles: Vec::new(),
122125
selected_skin_name: "Default".to_string(),
123126
lichess_token: None,
124127
lichess_seek_receiver: None,
@@ -1327,9 +1330,10 @@ impl App {
13271330

13281331
self.game.logic.bot = bot;
13291332
self.game.logic.opponent = opponent;
1330-
// Restore skin and display mode
1333+
// Restore skin, display mode and piece styles
13311334
self.game.ui.skin = current_skin;
13321335
self.game.ui.display_mode = display_mode;
1336+
self.game.ui.available_piece_styles = self.available_piece_styles.clone();
13331337
self.current_popup = None;
13341338

13351339
// Re-initialize clock for local games and bot games
@@ -1531,6 +1535,10 @@ impl App {
15311535
pub fn reset(&mut self) {
15321536
let loaded_skin = self.loaded_skin.clone();
15331537
self.game = Game::default();
1538+
self.game.ui.available_piece_styles = self.available_piece_styles.clone();
1539+
if let Some(ref skin) = loaded_skin {
1540+
self.game.ui.skin = skin.clone();
1541+
}
15341542
self.current_popup = None;
15351543
self.selected_color = None;
15361544
self.hosting = None;
@@ -1774,10 +1782,11 @@ impl App {
17741782
// Clear puzzle state
17751783
self.puzzle_game = None;
17761784

1777-
// Reset game completely but preserve display mode and skin preference
1785+
// Reset game completely but preserve display mode, skin and piece styles
17781786
self.game = Game::default();
17791787
self.game.ui.display_mode = display_mode;
17801788
self.game.ui.skin = current_skin;
1789+
self.game.ui.available_piece_styles = self.available_piece_styles.clone();
17811790
self.end_screen_dismissed = false;
17821791
self.clock_form_cursor = 3; // Reset to default (Rapid)
17831792
self.custom_time_minutes = 10; // Reset custom time

src/default_skins.json

Lines changed: 184 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -1,95 +1,186 @@
11
{
2-
"skins": [
3-
{
4-
"name": "Default",
5-
"board_white_color": {"Rgb": [160, 160, 160]},
6-
"board_black_color": {"Rgb": [128, 95, 69]},
7-
"piece_white_color": "White",
8-
"piece_black_color": "Black",
9-
"cursor_color": "LightBlue",
10-
"selection_color": "LightGreen",
11-
"last_move_color": "LightGreen"
12-
},
13-
{
14-
"name": "Matrix",
15-
"board_white_color": {"Rgb": [60, 60, 60]},
16-
"board_black_color": {"Rgb": [30, 30, 30]},
17-
"piece_white_color": {"Rgb": [150, 255, 255]},
18-
"piece_black_color": {"Rgb": [100, 200, 100]},
19-
"cursor_color": {"Rgb": [120, 220, 220]},
20-
"selection_color": {"Rgb": [100, 200, 200]},
21-
"last_move_color": {"Rgb": [80, 180, 180]}
22-
},
23-
{
24-
"name": "Ocean",
25-
"board_white_color": {"Rgb": [200, 220, 235]},
26-
"board_black_color": {"Rgb": [100, 140, 170]},
27-
"piece_white_color": {"Rgb": [245, 250, 255]},
28-
"piece_black_color": {"Rgb": [50, 80, 120]},
29-
"cursor_color": {"Rgb": [150, 200, 230]},
30-
"selection_color": {"Rgb": [120, 180, 220]},
31-
"last_move_color": {"Rgb": [100, 160, 200]}
32-
},
33-
{
34-
"name": "Forest",
35-
"board_white_color": {"Rgb": [200, 230, 200]},
36-
"board_black_color": {"Rgb": [100, 150, 100]},
37-
"piece_white_color": {"Rgb": [250, 255, 250]},
38-
"piece_black_color": {"Rgb": [60, 100, 60]},
39-
"cursor_color": {"Rgb": [150, 220, 150]},
40-
"selection_color": {"Rgb": [120, 200, 120]},
41-
"last_move_color": {"Rgb": [200, 220, 120]}
42-
},
43-
{
44-
"name": "Sunset",
45-
"board_white_color": {"Rgb": [255, 235, 210]},
46-
"board_black_color": {"Rgb": [200, 140, 120]},
47-
"piece_white_color": {"Rgb": [255, 250, 245]},
48-
"piece_black_color": {"Rgb": [150, 80, 60]},
49-
"cursor_color": {"Rgb": [255, 220, 150]},
50-
"selection_color": {"Rgb": [255, 200, 120]},
51-
"last_move_color": {"Rgb": [255, 180, 100]}
52-
},
53-
{
54-
"name": "Midnight",
55-
"board_white_color": {"Rgb": [100, 100, 120]},
56-
"board_black_color": {"Rgb": [50, 50, 70]},
57-
"piece_white_color": {"Rgb": [220, 220, 240]},
58-
"piece_black_color": {"Rgb": [140, 140, 180]},
59-
"cursor_color": {"Rgb": [180, 160, 220]},
60-
"selection_color": {"Rgb": [160, 140, 200]},
61-
"last_move_color": {"Rgb": [140, 120, 200]}
62-
},
63-
{
64-
"name": "Classic",
65-
"board_white_color": {"Rgb": [240, 217, 181]},
66-
"board_black_color": {"Rgb": [181, 136, 99]},
67-
"piece_white_color": {"Rgb": [250, 250, 250]},
68-
"piece_black_color": {"Rgb": [40, 40, 40]},
69-
"cursor_color": {"Rgb": [150, 200, 255]},
70-
"selection_color": {"Rgb": [120, 220, 120]},
71-
"last_move_color": {"Rgb": [100, 200, 100]}
72-
},
73-
{
74-
"name": "Neon",
75-
"board_white_color": {"Rgb": [40, 40, 40]},
76-
"board_black_color": {"Rgb": [20, 20, 20]},
77-
"piece_white_color": {"Rgb": [255, 150, 255]},
78-
"piece_black_color": {"Rgb": [150, 255, 255]},
79-
"cursor_color": {"Rgb": [255, 255, 150]},
80-
"selection_color": {"Rgb": [220, 150, 220]},
81-
"last_move_color": {"Rgb": [150, 255, 150]}
82-
},
83-
{
84-
"name": "Retro",
85-
"board_white_color": "White",
86-
"board_black_color": "Black",
87-
"piece_white_color": {"Rgb": [100, 150, 255]},
88-
"piece_black_color": {"Rgb": [200, 80, 80]},
89-
"cursor_color": {"Rgb": [255, 200, 0]},
90-
"selection_color": {"Rgb": [100, 200, 100]},
91-
"last_move_color": {"Rgb": [150, 200, 150]}
92-
}
93-
]
2+
"piece_styles": [
3+
{
4+
"name": "SIMPLE",
5+
"small": {
6+
"bishop": "s",
7+
"king": "s",
8+
"knight": "s",
9+
"pawn": "s",
10+
"queen": "s",
11+
"rook": "s"
12+
},
13+
"compact": {
14+
"bishop": "c",
15+
"king": "c",
16+
"knight": "c",
17+
"pawn": "c",
18+
"queen": "c",
19+
"rook": "c"
20+
},
21+
"extended": {
22+
"bishop": "e",
23+
"king": "e",
24+
"knight": "e",
25+
"pawn": "e",
26+
"queen": "e",
27+
"rook": "e"
28+
},
29+
"large": {
30+
"bishop": "l",
31+
"king": "l",
32+
"knight": "l",
33+
"pawn": "l",
34+
"queen": "l",
35+
"rook": "l"
36+
}
37+
},
38+
{
39+
"name": "MINIMAL",
40+
"small": {
41+
"pawn": "",
42+
"bishop": "",
43+
"knight": "",
44+
"rook": "",
45+
"queen": "",
46+
"king": ""
47+
},
48+
"compact": {
49+
"pawn": "\n\n ",
50+
"bishop": "\n\n ",
51+
"knight": "\n\n ",
52+
"rook": "\n\n",
53+
"queen": "\n░▓░\n ",
54+
"king": "\n\n"
55+
},
56+
"extended": {
57+
"pawn": "\n\n ",
58+
"bishop": "\n ░╲ \n ",
59+
"knight": " ▓▓ \n\n ",
60+
"rook": " ▓ ▓ \n ▓▓▓ \n ",
61+
"queen": " ▓ ▓ \n ▓▓ \n ",
62+
"king": "\n ▓ ▓ \n "
63+
},
64+
"large": {
65+
"pawn": "\n ░░░ \n ░░░ \n ░░░░░ \n ░░░░░ \n",
66+
"bishop": "\n ▓ ▓ \n ░▓░ \n ▓▓▓▓▓ \n ░▓▓▓░ \n",
67+
"knight": "\n ▞▀▀▀▚ \n ▙▄█▄▟ \n ▐█▀█▌ \n ▗████▖\n",
68+
"rook": " ▓ ▓ ▓ \n ▓▓▓▓▓ \n ▓ ▓ ▓ \n ▓ ▓ ▓ \n ▓▓▓▓▓ \n",
69+
"queen": "\n ▓▓▓ \n ▓▓▓▓▓ \n ▓ ▓ ▓ \n ▓▓▓▓▓ \n",
70+
"king": "\n ▞▀▄▀▚ \n ▙▄█▄▟ \n ▐███▌ \n ▗█████▖\n"
71+
}
72+
}
73+
],
74+
"skins": [
75+
{
76+
"name": "Default",
77+
"piece_style": "DEFAULT",
78+
"board_white_color": { "Rgb": [160, 160, 160] },
79+
"board_black_color": { "Rgb": [128, 95, 69] },
80+
"piece_white_color": { "Rgb": [245, 245, 245] },
81+
"piece_black_color": { "Rgb": [20, 20, 20] },
82+
"cursor_color": "LightBlue",
83+
"selection_color": "LightGreen",
84+
"last_move_color": "LightGreen"
85+
},
86+
{
87+
"name": "Matrix",
88+
"piece_style": "DEFAULT",
89+
"board_white_color": { "Rgb": [60, 60, 60] },
90+
"board_black_color": { "Rgb": [30, 30, 30] },
91+
"piece_white_color": { "Rgb": [220, 255, 255] },
92+
"piece_black_color": { "Rgb": [80, 200, 80] },
93+
"cursor_color": { "Rgb": [120, 220, 220] },
94+
"selection_color": { "Rgb": [100, 200, 200] },
95+
"last_move_color": { "Rgb": [80, 180, 180] }
96+
},
97+
{
98+
"name": "Ocean",
99+
"piece_style": "DEFAULT",
100+
"board_white_color": { "Rgb": [200, 220, 235] },
101+
"board_black_color": { "Rgb": [100, 140, 170] },
102+
"piece_white_color": { "Rgb": [235, 240, 245] },
103+
"piece_black_color": { "Rgb": [15, 40, 75] },
104+
"cursor_color": { "Rgb": [150, 200, 230] },
105+
"selection_color": { "Rgb": [120, 180, 220] },
106+
"last_move_color": { "Rgb": [100, 160, 200] }
107+
},
108+
{
109+
"name": "Forest",
110+
"piece_style": "DEFAULT",
111+
"board_white_color": { "Rgb": [200, 230, 200] },
112+
"board_black_color": { "Rgb": [100, 150, 100] },
113+
"piece_white_color": { "Rgb": [235, 245, 235] },
114+
"piece_black_color": { "Rgb": [10, 40, 10] },
115+
"cursor_color": { "Rgb": [150, 220, 150] },
116+
"selection_color": { "Rgb": [120, 200, 120] },
117+
"last_move_color": { "Rgb": [200, 220, 120] }
118+
},
119+
{
120+
"name": "Midnight",
121+
"piece_style": "DEFAULT",
122+
"board_white_color": { "Rgb": [100, 100, 120] },
123+
"board_black_color": { "Rgb": [50, 50, 70] },
124+
"piece_white_color": { "Rgb": [245, 245, 255] },
125+
"piece_black_color": { "Rgb": [120, 120, 210] },
126+
"cursor_color": { "Rgb": [180, 160, 220] },
127+
"selection_color": { "Rgb": [160, 140, 200] },
128+
"last_move_color": { "Rgb": [140, 120, 200] }
129+
},
130+
{
131+
"name": "Sunset",
132+
"piece_style": "DEFAULT",
133+
"board_white_color": { "Rgb": [255, 235, 210] },
134+
"board_black_color": { "Rgb": [200, 140, 120] },
135+
"piece_white_color": { "Rgb": [255, 255, 255] },
136+
"piece_black_color": { "Rgb": [60, 20, 15] },
137+
"cursor_color": { "Rgb": [255, 220, 150] },
138+
"selection_color": { "Rgb": [255, 200, 120] },
139+
"last_move_color": { "Rgb": [255, 180, 100] }
140+
},
141+
{
142+
"name": "Classic",
143+
"piece_style": "DEFAULT",
144+
"board_white_color": { "Rgb": [240, 217, 181] },
145+
"board_black_color": { "Rgb": [181, 136, 99] },
146+
"piece_white_color": { "Rgb": [255, 255, 255] },
147+
"piece_black_color": { "Rgb": [20, 20, 20] },
148+
"cursor_color": { "Rgb": [150, 200, 255] },
149+
"selection_color": { "Rgb": [120, 220, 120] },
150+
"last_move_color": { "Rgb": [100, 200, 100] }
151+
},
152+
{
153+
"name": "Neon",
154+
"piece_style": "DEFAULT",
155+
"board_white_color": { "Rgb": [40, 40, 40] },
156+
"board_black_color": { "Rgb": [20, 20, 20] },
157+
"piece_white_color": { "Rgb": [255, 180, 255] },
158+
"piece_black_color": { "Rgb": [120, 255, 255] },
159+
"cursor_color": { "Rgb": [255, 255, 150] },
160+
"selection_color": { "Rgb": [220, 150, 220] },
161+
"last_move_color": { "Rgb": [150, 255, 150] }
162+
},
163+
{
164+
"name": "Retro",
165+
"piece_style": "DEFAULT",
166+
"board_white_color": { "Rgb": [245, 245, 245] },
167+
"board_black_color": { "Rgb": [15, 15, 15] },
168+
"piece_white_color": { "Rgb": [70, 120, 255] },
169+
"piece_black_color": { "Rgb": [220, 60, 60] },
170+
"cursor_color": { "Rgb": [255, 200, 0] },
171+
"selection_color": { "Rgb": [100, 200, 100] },
172+
"last_move_color": { "Rgb": [150, 200, 150] }
173+
},
174+
{
175+
"name": "Terminal",
176+
"piece_style": "MINIMAL",
177+
"board_white_color": { "Rgb": [32, 32, 32] },
178+
"board_black_color": { "Rgb": [18, 18, 18] },
179+
"piece_white_color": { "Rgb": [220, 220, 220] },
180+
"piece_black_color": { "Rgb": [90, 90, 90] },
181+
"cursor_color": { "Rgb": [120, 180, 255] },
182+
"selection_color": { "Rgb": [80, 140, 200] },
183+
"last_move_color": { "Rgb": [100, 160, 120] }
184+
}
185+
]
94186
}
95-

0 commit comments

Comments
 (0)