ass_editor/commands/event_commands/
effect.rs1#[cfg(not(feature = "std"))]
4use alloc::{string::String, vec::Vec};
5
6#[derive(Debug, Clone)]
8pub struct EventEffectCommand {
9 pub event_indices: Vec<usize>,
10 pub effect: String,
11 pub operation: EffectOperation,
12 pub description: Option<String>,
13}
14
15#[derive(Debug, Clone, PartialEq, Eq)]
16pub enum EffectOperation {
17 Set, Append, Prepend, Clear, }
22
23impl EventEffectCommand {
24 pub fn new(event_indices: Vec<usize>, effect: String, operation: EffectOperation) -> Self {
26 Self {
27 event_indices,
28 effect,
29 operation,
30 description: None,
31 }
32 }
33
34 pub fn set_effect(event_indices: Vec<usize>, effect: String) -> Self {
36 Self::new(event_indices, effect, EffectOperation::Set)
37 }
38
39 pub fn clear_effect(event_indices: Vec<usize>) -> Self {
41 Self::new(event_indices, String::new(), EffectOperation::Clear)
42 }
43
44 pub fn append_effect(event_indices: Vec<usize>, effect: String) -> Self {
46 Self::new(event_indices, effect, EffectOperation::Append)
47 }
48
49 #[must_use]
51 pub fn with_description(mut self, description: String) -> Self {
52 self.description = Some(description);
53 self
54 }
55}