1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
//! Describe theme available in the game

use ggez::graphics::Color;

use crate::{NUM_COLORS, NUM_PIECES};

/// Dust theme.
pub const THEME_DUST: Theme = Theme {
    background_color: Color::new(0.09, 0.09, 0.11, 1.0),
    board_color: [
        Color::new(0.7969, 0.7148, 0.6797, 1.0),
        Color::new(0.4375, 0.3984, 0.4648, 1.0),
    ],
    piece_path: [
        [
            "/images/pieces/white_pawn.png",
            "/images/pieces/white_knight.png",
            "/images/pieces/white_bishop.png",
            "/images/pieces/white_rook.png",
            "/images/pieces/white_queen.png",
            "/images/pieces/white_king.png",
        ],
        [
            "/images/pieces/black_pawn.png",
            "/images/pieces/black_knight.png",
            "/images/pieces/black_bishop.png",
            "/images/pieces/black_rook.png",
            "/images/pieces/black_queen.png",
            "/images/pieces/black_king.png",
        ],
    ],
    valid_moves_color: Some(Color::new(0.25, 0.75, 0.25, 0.5)),
    piece_pinned_color: Some(Color::new(0.75, 0.25, 0.25, 0.5)),
    piece_pinned_path: Some("/images/pin.png"),
    theme_icon_path: Some("/images/theme_icon_white.png"),
    font_path: "/fonts/LiberationMono-Regular.ttf",
    font_scale: 20.0,
};

/// Coral theme.
pub const THEME_CORAL: Theme = Theme {
    board_color: [
        Color::new(177.0 / 256.0, 228.0 / 256.0, 185.0 / 256.0, 1.0),
        Color::new(112.0 / 256.0, 162.0 / 256.0, 163.0 / 256.0, 1.0),
    ],
    ..THEME_DUST
};

/// Marine theme.
pub const THEME_MARINE: Theme = Theme {
    board_color: [
        Color::new(157.0 / 256.0, 172.0 / 256.0, 255.0 / 256.0, 1.0),
        Color::new(111.0 / 256.0, 115.0 / 256.0, 210.0 / 256.0, 1.0),
    ],
    ..THEME_DUST
};

/// Wheat theme.
pub const THEME_WHEAT: Theme = Theme {
    board_color: [
        Color::new(234.0 / 256.0, 240.0 / 256.0, 206.0 / 256.0, 1.0),
        Color::new(187.0 / 256.0, 190.0 / 256.0, 100.0 / 256.0, 1.0),
    ],
    ..THEME_DUST
};

/// Emerald theme.
pub const THEME_EMERALD: Theme = Theme {
    board_color: [
        Color::new(173.0 / 256.0, 189.0 / 256.0, 143.0 / 256.0, 1.0),
        Color::new(111.0 / 256.0, 143.0 / 256.0, 114.0 / 256.0, 1.0),
    ],
    ..THEME_DUST
};

/// Sandcastle theme.
pub const THEME_SANDCASTLE: Theme = Theme {
    board_color: [
        Color::new(227.0 / 256.0, 193.0 / 256.0, 111.0 / 256.0, 1.0),
        Color::new(184.0 / 256.0, 139.0 / 256.0, 74.0 / 256.0, 1.0),
    ],
    ..THEME_DUST
};

/// Index of the current theme if using roll theme.
pub(crate) static mut INDEX_THEME: usize = 0;

/// Numbers of [`Theme`].
pub const NUM_THEMES: usize = 6;

/// Enumerate all [`Theme`].
pub const THEMES: [Theme; NUM_THEMES] = [
    THEME_DUST,
    THEME_CORAL,
    THEME_MARINE,
    THEME_WHEAT,
    THEME_EMERALD,
    THEME_SANDCASTLE,
];

/// Describe the theme of the chess game (GUI).
///
/// RootPath is `resources/` (changed by [`ggez::ContextBuilder::add_resource_path`]).
///
/// # Examples
///
/// ```
/// use chess::{Theme, THEME_DUST};
///
/// const THEME:Theme = Theme {
///     font_path: "/fonts/font.ttf", // located in resources/fonts/font.ttf
///     ..THEME_DUST
/// };
/// ```
#[derive(Copy, Clone, PartialEq, Debug)]
pub struct Theme {
    pub background_color: Color,
    pub board_color: [Color; NUM_COLORS],
    pub piece_path: [[&'static str; NUM_PIECES]; NUM_COLORS],
    pub valid_moves_color: Option<Color>,
    pub piece_pinned_color: Option<Color>,
    pub piece_pinned_path: Option<&'static str>,
    pub theme_icon_path: Option<&'static str>,
    pub font_path: &'static str,
    pub font_scale: f32,
}

impl Default for Theme {
    fn default() -> Self {
        THEME_DUST
    }
}