1
// This file is part of hnefatafl-copenhagen.
2
//
3
// hnefatafl-copenhagen is free software: you can redistribute it and/or modify
4
// it under the terms of the GNU Affero General Public License as published by
5
// the Free Software Foundation, either version 3 of the License, or
6
// (at your option) any later version.
7
//
8
// hnefatafl-copenhagen is distributed in the hope that it will be useful,
9
// but WITHOUT ANY WARRANTY; without even the implied warranty of
10
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
// GNU Affero General Public License for more details.
12
//
13
// You should have received a copy of the GNU Affero General Public License
14
// along with this program.  If not, see <https://www.gnu.org/licenses/>.
15

            
16
use hnefatafl_copenhagen::board::BoardSize;
17

            
18
use crate::enums::Size;
19

            
20
#[derive(Clone, Debug)]
21
pub(crate) struct Dimensions {
22
    pub board_dimension: u32,
23
    pub letter_size: u32,
24
    pub piece_size: u32,
25
    pub spacing: u32,
26
}
27

            
28
impl Dimensions {
29
    pub(crate) fn new(board_size: BoardSize, screen_size: &Size) -> Self {
30
        let (board_dimension, letter_size, piece_size, spacing) = match board_size {
31
            BoardSize::_11 => match screen_size {
32
                Size::Large | Size::Giant => (75, 55, 60, 6),
33
                Size::Medium => (65, 45, 50, 8),
34
                Size::Small => (55, 35, 40, 11),
35
                Size::Tiny | Size::TinyWide => (40, 20, 25, 16),
36
            },
37
            BoardSize::_13 => match screen_size {
38
                Size::Large | Size::Giant => (65, 45, 50, 8),
39
                Size::Medium => (58, 38, 43, 10),
40
                Size::Small => (50, 30, 35, 12),
41
                Size::Tiny | Size::TinyWide => (40, 20, 25, 15),
42
            },
43
        };
44

            
45
        Dimensions {
46
            board_dimension,
47
            letter_size,
48
            piece_size,
49
            spacing,
50
        }
51
    }
52
}