Beatsaber Rust Utilities: A Beatsaber V3 parsing library.
beatsaber beatmap
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

More documentation.

Also renamed `LooseBool::as_bool` to `is_true` and added `is_false`.

+29 -5
+1
src/difficulty.rs
··· 47 47 #[doc(alias = "keyword_events")] 48 48 #[serde(rename = "basicEventTypesWithKeywords")] 49 49 pub special_events: SpecialEvent, 50 + /// If false, overriding the environment in game will disable all lightshow events. 50 51 #[serde(rename = "useNormalEventsAsCompatibleEvents")] 51 52 pub use_compatible_events: bool, 52 53 }
+2 -2
src/difficulty/lightshow/filter.rs
··· 77 77 pub fn is_in_filter(&self, mut light_id: i32, group_size: i32) -> bool { 78 78 assert!(light_id < group_size); 79 79 80 - if self.reverse.as_bool() { 80 + if self.reverse.is_true() { 81 81 light_id = group_size - light_id - 1; 82 82 } 83 83 ··· 124 124 pub fn get_relative_index(&self, mut light_id: i32, group_size: i32) -> i32 { 125 125 assert!(light_id < group_size); 126 126 127 - if self.reverse.as_bool() { 127 + if self.reverse.is_true() { 128 128 light_id = group_size - light_id; 129 129 } 130 130
+15 -1
src/info.rs
··· 33 33 pub preview_start_time: f32, 34 34 #[serde(rename = "_previewDuration")] 35 35 pub preview_duration: f32, 36 + /// The path to the audio file, relative to the map's folder. 36 37 #[serde(rename = "_songFilename")] 37 38 pub audio_file: String, 39 + /// The path to the cover image file, relative to the map's folder. 38 40 #[serde(rename = "_coverImageFilename")] 39 41 pub cover_image_file: String, 40 42 #[serde(rename = "_environmentName")] 41 43 pub environment: Environment, 44 + /// The environment that will be used for 90 and 360 degree difficulties. 45 + /// 46 + /// Starting in info file V2.1, Individual difficulties can override this using [environment_index](DifficultyInfo::environment_index). 42 47 #[serde(rename = "_allDirectionsEnvironmentName")] 43 48 pub all_directions_environment: AllDirectionEnvironment, 44 49 /// > Only present in info file V2.1 or higher. ··· 136 141 Rotate360 = "360Degree", 137 142 Rotate90 = "90Degree", 138 143 Legacy = "Legacy", 139 - //Custom types. 144 + /// > Modded characteristic. May cause problems in un-modded versions of the game. 140 145 Lawless = "Lawless", 146 + /// > Modded characteristic. May cause problems in un-modded versions of the game. 141 147 Lightshow = "Lightshow", 142 148 } 143 149 } ··· 153 159 pub name: String, 154 160 #[serde(rename = "_difficultyRank")] 155 161 pub rank: DifficultyRank, 162 + /// The path to the difficulty file, relative to the map's folder. 156 163 #[serde(rename = "_beatmapFilename")] 157 164 pub file: String, 158 165 #[doc(alias = "node_jump_speed")] ··· 162 169 #[serde(rename = "_noteJumpStartBeatOffset")] 163 170 pub njd: f32, 164 171 /// > Only present in info file V2.1 or higher. 172 + /// 173 + /// The ID of environment to use from the map's [environment list](Beatmap::environments). 174 + #[serde(rename = "_environmentNameIdx")] 175 + pub environment_index: Option<i32>, 176 + /// > Only present in info file V2.1 or higher. 177 + /// 178 + /// The ID of color scheme to use from the map's [color schemes list](Beatmap::color_schemes). 165 179 #[serde(rename = "_beatmapColorSchemeIdx")] 166 180 pub color_scheme_index: Option<i32>, 167 181 }
+11 -2
src/utils.rs
··· 1 + /// Defines a repr enum that supports any value. If a value does not match any case, it will be parsed as `Unknown`. 1 2 #[macro_export] 2 3 macro_rules! loose_enum { 3 4 // Special case for strings: ··· 141 142 } 142 143 143 144 loose_enum! { 145 + /// An integer repr bool, with 0 being false and 1 being true. Any other value will be saved as `Unknown`. 144 146 #[derive(Default, Copy)] 145 147 LooseBool: i32 { 146 148 #[default] ··· 150 152 } 151 153 152 154 impl LooseBool { 153 - /// Returns as a bool, with unknown values counting as `false`. 154 - pub fn as_bool(&self) -> bool { 155 + pub fn is_true(&self) -> bool { 155 156 match self { 156 157 LooseBool::False => false, 157 158 LooseBool::True => true, 159 + LooseBool::Unknown(_) => false, 160 + } 161 + } 162 + 163 + pub fn is_false(&self) -> bool { 164 + match self { 165 + LooseBool::False => true, 166 + LooseBool::True => false, 158 167 LooseBool::Unknown(_) => false, 159 168 } 160 169 }