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
use amethyst_assets::Processor;
use amethyst_core::bundle::{Result, SystemBundle};
use amethyst_core::specs::prelude::DispatcherBuilder;
use std::hash::Hash;
use std::marker::PhantomData;
use super::*;
pub struct UiBundle<A, B> {
_marker1: PhantomData<A>,
_marker2: PhantomData<B>,
}
impl<A, B> UiBundle<A, B> {
pub fn new() -> Self {
UiBundle {
_marker1: PhantomData,
_marker2: PhantomData,
}
}
}
impl<'a, 'b, A, B> SystemBundle<'a, 'b> for UiBundle<A, B>
where
A: Send + Sync + Eq + Hash + Clone + 'static,
B: Send + Sync + Eq + Hash + Clone + 'static,
{
fn build(self, builder: &mut DispatcherBuilder<'a, 'b>) -> Result<()> {
builder.add(Processor::<FontAsset>::new(), "font_processor", &[]);
builder.add(UiSystem::new(), "ui_system", &["font_processor"]);
builder.add(ResizeSystem::new(), "ui_resize_system", &[]);
builder.add(UiMouseSystem::<A, B>::new(), "ui_mouse_system", &[]);
builder.add(UiLayoutSystem::new(), "ui_layout", &["ui_system"]);
builder.add(
UiParentSystem::default(),
"ui_parent",
&["transform_system", "ui_layout"],
);
Ok(())
}
}