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

use crate::{
    components::{BasicButtonBundle, ButtonTextBundle, QuitButton, Screen},
    styles::{get_title_text_styles, CENTRAL_PANEL_STYLES, IMAGE_STYLE, TITLE_STYLE},
};

use super::{
    components::SettingsUi,
    resources::NetworkSettingsHandle,
    styles::{get_subtitle_text_styles, SECTION_STYLE},
};

pub fn spawn_settings(mut commands: Commands, asset_server: Res<AssetServer>) {
    build_settings(&mut commands, &asset_server);
}

pub fn build_settings(commands: &mut Commands, asset_server: &Res<AssetServer>) -> Entity {
    let settings_entity = commands
        .spawn((
            NodeBundle {
                style: CENTRAL_PANEL_STYLES,
                ..default()
            },
            SettingsUi,
            Screen
        ))
        .with_children(|parent| {
            //====title
            parent
                .spawn(NodeBundle {
                    style: TITLE_STYLE,
                    ..default()
                })
                .with_children(|parent| {
                    // Image 1
                    parent.spawn(ImageBundle {
                        style: IMAGE_STYLE,
                        image: asset_server.load("images/tile_0003.png").into(),
                        ..default()
                    });
                    //Text
                    parent.spawn(TextBundle {
                        text: Text {
                            sections: vec![TextSection::new(
                                "Settings",
                                get_title_text_styles(&asset_server),
                            )],
                            ..default()
                        },
                        ..default()
                    });
                    parent.spawn(ImageBundle {
                        style: IMAGE_STYLE,
                        image: asset_server.load("images/tile_0003.png").into(),
                        ..default()
                    });
                });
            parent
                .spawn(NodeBundle {
                    style: SECTION_STYLE,
                    ..default()
                })
                .with_children(|parent| {
                    //Text
                    parent.spawn(TextBundle {
                        text: Text {
                            sections: vec![TextSection::new(
                                "Render Settings",
                                get_subtitle_text_styles(&asset_server),
                            )],
                            ..default()
                        },
                        ..default()
                    });
                });
            parent.spawn(NodeBundle {
                style: SECTION_STYLE,
                ..default()
            });

            // ====Back button
            parent
                .spawn((BasicButtonBundle::new(), QuitButton))
                .with_children(|parent| {
                    parent.spawn(ButtonTextBundle::new("Back".to_owned(), asset_server));
                });
        })
        .id();
    settings_entity
}