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
use rinecs::{Entities, Resources, Write};
use std::fmt::{self, Display, Debug};
use std::path::PathBuf;
#[derive(Clone,Debug,Component,Eq,PartialEq, Serialize, Deserialize)]
pub struct Name(pub String);
impl Display for Name{
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result{
Display::fmt(&self.0, fmt)
}
}
#[derive(Clone,Debug,Component,Eq,PartialEq, Serialize, Deserialize)]
pub struct Visible{
visible: bool,
has_changed: bool
}
impl Visible{
pub fn new(visible: bool) -> Visible{
Visible{
visible,
has_changed: true,
}
}
pub fn is_visible(&self) -> bool{
self.visible
}
pub fn show(&mut self){
self.has_changed = true;
self.visible = true;
}
pub fn hide(&mut self){
self.has_changed = true;
self.visible = false;
}
pub fn set(&mut self, visible: bool){
self.has_changed = true;
self.visible = visible;
}
pub fn has_changed(&self) -> bool{
self.has_changed
}
}
pub(crate) fn reset_visible_changed(entities: Entities, _: Resources){
for visible in entities.iter_for::<Write<Visible>>(){
visible.has_changed = false;
}
}
#[cfg(any(feature="freeimage", feature="image"))]
mod image{
use rin::graphics::image;
#[derive(Component)]
#[debug_as_string]
pub struct Image(pub image::Image);
}
#[cfg(any(feature="freeimage", feature="image"))]
pub use self::image::Image;
#[cfg(any(feature="freeimage", feature="image"))]
impl Debug for Image{
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result{
fmt.write_str("Image")
}
}
#[derive(Clone,Copy,Debug,Component,Eq,PartialEq, Serialize, Deserialize)]
pub enum Ty{
Model,
Light,
Armature,
Empty,
Mesh,
Bone,
}
#[derive(Component, Eq, PartialEq, Debug, Ord, PartialOrd, Hash, Clone, Serialize, Deserialize)]
pub struct SourcePath(pub PathBuf);