use crate::data::{BoneId, SkinKey, SlotId};
use crate::math::Color;
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]
pub enum BlendMode {
#[default]
Normal,
Additive,
Multiply,
Screen,
}
#[derive(Debug, Clone, PartialEq)]
pub struct SlotData {
pub index: SlotId,
pub name: String,
pub bone: BoneId,
pub color: Color,
pub dark_color: Option<Color>,
pub attachment_name: Option<String>,
pub attachment_key: Option<SkinKey>,
pub blend_mode: BlendMode,
pub visible: bool,
pub path: String,
}
impl SlotData {
#[must_use]
pub fn new(index: SlotId, name: impl Into<String>, bone: BoneId) -> Self {
Self {
index,
name: name.into(),
bone,
color: Color::WHITE,
dark_color: None,
attachment_name: None,
attachment_key: None,
blend_mode: BlendMode::Normal,
visible: true,
path: String::new(),
}
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn new_slot_defaults() {
let s = SlotData::new(SlotId(3), "body", BoneId(1));
assert_eq!(s.color, Color::WHITE);
assert!(s.dark_color.is_none());
assert!(s.attachment_name.is_none());
assert_eq!(s.blend_mode, BlendMode::Normal);
assert!(s.visible);
}
}