Skip to main content

ass_editor/commands/event_commands/
effect.rs

1//! Command type and constructors for modifying event effects.
2
3#[cfg(not(feature = "std"))]
4use alloc::{string::String, vec::Vec};
5
6/// Command to modify event effects
7#[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,     // Replace current effect
18    Append,  // Add to existing effect
19    Prepend, // Add before existing effect
20    Clear,   // Remove all effects
21}
22
23impl EventEffectCommand {
24    /// Create a new effect command
25    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    /// Set effect for specific events
35    pub fn set_effect(event_indices: Vec<usize>, effect: String) -> Self {
36        Self::new(event_indices, effect, EffectOperation::Set)
37    }
38
39    /// Clear effects for specific events
40    pub fn clear_effect(event_indices: Vec<usize>) -> Self {
41        Self::new(event_indices, String::new(), EffectOperation::Clear)
42    }
43
44    /// Append effect to specific events
45    pub fn append_effect(event_indices: Vec<usize>, effect: String) -> Self {
46        Self::new(event_indices, effect, EffectOperation::Append)
47    }
48
49    /// Set a custom description for this command
50    #[must_use]
51    pub fn with_description(mut self, description: String) -> Self {
52        self.description = Some(description);
53        self
54    }
55}