#[derive(Debug, Clone, PartialEq)]
pub struct HitObjectInfo {
pub start_time: f32,
pub lane: i32,
pub end_time: f32,
pub hit_sound: HitSounds,
pub key_sounds: Vec<KeySoundInfo>,
pub editor_layer: i32,
pub timing_group: String,
pub is_editable_in_lua_script: bool,
}
impl HitObjectInfo {
pub fn is_long_note(&self) -> bool {
self.end_time > 0.0
}
pub fn get_timing_point<'a>(&self, timing_points: &'a [TimingPointInfo]) -> Option<&'a TimingPointInfo> {
timing_points.iter()
.find(|tp| tp.start_time <= self.start_time)
.or_else(|| timing_points.first())
}
pub fn set_start_time(&mut self, time: f32) -> Result<(), String> {
self.check_editable()?;
self.start_time = time;
Ok(())
}
pub fn set_end_time(&mut self, time: f32) -> Result<(), String> {
self.check_editable()?;
self.end_time = time;
Ok(())
}
pub fn set_lane(&mut self, lane: i32) -> Result<(), String> {
self.check_editable()?;
self.lane = lane;
Ok(())
}
pub fn set_hit_sounds(&mut self, hit_sounds: HitSounds) -> Result<(), String> {
self.check_editable()?;
self.hit_sound = hit_sounds;
Ok(())
}
fn check_editable(&self) -> Result<(), String> {
if !self.is_editable_in_lua_script {
Err("Value is not allowed to be edited in lua scripts.".to_string())
} else {
Ok(())
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum HitSounds {
None = 0,
Normal = 1,
Whistle = 2,
Finish = 4,
Clap = 8,
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct KeySoundInfo {
pub sample_set: String,
pub addition_set: String,
pub custom_index: i32,
pub sample_volume: i32,
pub filename: String,
}
#[derive(Debug, Clone, PartialEq)]
pub struct TimingPointInfo {
pub start_time: f32,
pub bpm: f32,
pub signature: i32,
}
pub const DEFAULT_SCROLL_GROUP_ID: &str = "default";