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
use crate::prelude::*;

pub mod main_menu;
pub mod map_select;
pub mod notification;
pub mod pause_menu;
pub mod player_image;
pub mod scoring;

#[cfg(not(target_arch = "wasm32"))]
pub mod network_game;

#[derive(HasSchema, Clone, Debug)]
#[repr(C)]
pub struct UiTheme {
    pub scale: f64,
    pub colors: UiThemeColors,
    pub widgets: UiThemeWidgets,
    pub fonts: SVec<Handle<Font>>,
    pub font_styles: UiThemeFontStyles,
    pub buttons: UiThemeButtons,
    pub panel: UiThemePanel,
    pub editor: UiThemeEditor,
}

impl Default for UiTheme {
    fn default() -> Self {
        Self {
            scale: 1.0,
            colors: default(),
            widgets: default(),
            fonts: default(),
            buttons: default(),
            font_styles: default(),
            panel: default(),
            editor: default(),
        }
    }
}

#[derive(HasSchema, Debug, Default, Clone)]
#[repr(C)]
pub struct ImageMeta {
    image: Handle<Image>,
    image_size: Vec2,
}

#[derive(HasSchema, Default, Debug, Clone)]
#[repr(C)]
pub struct UiThemeColors {
    pub positive: Color,
    pub negative: Color,
}

#[derive(HasSchema, Default, Debug, Clone)]
#[repr(C)]
pub struct UiThemeWidgets {
    pub border_radius: f32,
    pub default: UiThemeWidgetColors,
    pub hovered: UiThemeWidgetColors,
    pub active: UiThemeWidgetColors,
    pub noninteractive: UiThemeWidgetColors,
    pub menu: UiThemeWidgetColors,
    pub window_fill: Color,
    pub panel: UiThemePanel,
}

#[derive(HasSchema, Default, Debug, Clone)]
#[repr(C)]
pub struct UiThemeWidgetColors {
    pub bg_fill: Color,
    pub bg_stroke: Color,
    pub text: Color,
}

#[derive(HasSchema, Default, Debug, Clone)]
#[repr(C)]
pub struct UiThemeFontStyles {
    pub heading: FontMeta,
    pub bigger: FontMeta,
    pub normal: FontMeta,
    pub smaller: FontMeta,
}

#[derive(HasSchema, Default, Debug, Clone)]
#[repr(C)]
pub struct UiThemeButtons {
    pub normal: ButtonThemeMeta,
    pub small: ButtonThemeMeta,
}

#[derive(HasSchema, Default, Debug, Clone)]
#[repr(C)]
pub struct UiThemePanel {
    pub font_color: Color,
    pub padding: MarginMeta,
    pub border: BorderImageMeta,
}

#[derive(HasSchema, Default, Debug, Clone)]
#[repr(C)]
pub struct UiThemeEditor {
    pub icons: UiThemeEditorIcons,
}

#[derive(HasSchema, Debug, Default, Clone)]
#[repr(C)]
pub struct UiThemeEditorIcons {
    pub elements: ImageMeta,
    pub tiles: ImageMeta,
    pub collisions: ImageMeta,
    pub select: ImageMeta,
}