-
Notifications
You must be signed in to change notification settings - Fork 49
Expand file tree
/
Copy pathsprite.rs
More file actions
64 lines (60 loc) · 2.18 KB
/
sprite.rs
File metadata and controls
64 lines (60 loc) · 2.18 KB
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
use fxhash::{
FxHashMap,
FxHashSet,
};
use logos::Span;
use serde::{
Deserialize,
Serialize,
};
use super::*;
use crate::misc::SmolStr;
#[derive(Debug, Default, Serialize, Deserialize)]
pub struct Sprite {
pub costumes: Vec<Costume>,
pub sounds: Vec<Sound>,
pub procs: FxHashMap<SmolStr, Proc>,
#[serde(skip)]
pub proc_definitions: FxHashMap<SmolStr, Vec<Stmt>>,
pub proc_references: FxHashMap<SmolStr, References>,
pub proc_args: FxHashMap<SmolStr, Vec<Arg>>,
pub funcs: FxHashMap<SmolStr, Func>,
#[serde(skip)]
pub func_definitions: FxHashMap<SmolStr, Vec<Stmt>>,
pub func_references: FxHashMap<SmolStr, References>,
pub func_args: FxHashMap<SmolStr, Vec<Arg>>,
pub enums: FxHashMap<SmolStr, Enum>,
pub structs: FxHashMap<SmolStr, Struct>,
pub vars: FxHashMap<SmolStr, Var>,
pub proc_locals: FxHashMap<SmolStr, FxHashMap<SmolStr, Var>>,
pub func_locals: FxHashMap<SmolStr, FxHashMap<SmolStr, Var>>,
pub lists: FxHashMap<SmolStr, List>,
#[serde(skip)]
pub events: Vec<Event>,
pub used_procs: FxHashSet<SmolStr>,
pub used_funcs: FxHashSet<SmolStr>,
pub volume: Option<(Value, Span)>,
pub layer_order: Option<(Value, Span)>,
pub x_position: Option<(Value, Span)>,
pub y_position: Option<(Value, Span)>,
pub size: Option<(Value, Span)>,
pub direction: Option<(Value, Span)>,
pub rotation_style: RotationStyle,
pub hidden: bool,
}
impl Sprite {
pub fn add_proc(&mut self, proc: Proc, args: Vec<Arg>, stmts: Vec<Stmt>) {
let name = proc.name.clone();
self.procs.insert(name.clone(), proc);
self.proc_args.insert(name.clone(), args);
self.proc_definitions.insert(name.clone(), stmts);
self.proc_references.insert(name, Default::default());
}
pub fn add_func(&mut self, func: Func, args: Vec<Arg>, stmts: Vec<Stmt>) {
let name = func.name.clone();
self.funcs.insert(name.clone(), func);
self.func_args.insert(name.clone(), args);
self.func_definitions.insert(name.clone(), stmts);
self.func_references.insert(name, Default::default());
}
}