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.

Started trying to document everything.

+90 -3
+4
src/difficulty.rs
··· 1 + //! Defines the structure of a map's difficulty file(s) (i.e. `ExpertStandard.dat`). 2 + 1 3 pub mod gameplay_event; 2 4 pub mod lightshow; 3 5 pub mod playfield; ··· 28 30 /// | 3.2 | Translation events. | Yes | 29 31 /// | 3.3 | More strobe functionality. | No | 30 32 /// | 4.X | New template-like format. | No | 33 + /// 34 + /// [^1]: Not supported by experimental lighting calculation methods. 31 35 pub version: String, 32 36 pub bpm_events: Vec<BpmEvent>, 33 37 #[serde(rename = "rotationEvents")]
+2
src/difficulty/gameplay_event.rs
··· 1 + //! Events that effect gameplay and aren't purely visual. 2 + 1 3 use crate::{impl_timed, loose_enum}; 2 4 use serde::{Deserialize, Serialize}; 3 5
+2
src/difficulty/lightshow.rs
··· 1 + //! Events that have no effect on gameplay. 2 + 1 3 pub mod basic; 2 4 pub mod boxes; 3 5 pub mod easing;
+48 -2
src/difficulty/playfield.rs
··· 1 + //! The interactable objects of a difficulty. 2 + 1 3 use crate::{impl_duration, impl_timed, loose_enum}; 2 4 use serde::{Deserialize, Serialize}; 3 5 6 + /// The standard block/note. 4 7 #[doc(alias = "Block")] 5 8 #[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)] 6 9 #[cfg_attr( ··· 9 12 reflect(Debug, Clone, PartialEq) 10 13 )] 11 14 pub struct Note { 15 + /// The position of the object in time. 12 16 #[serde(rename = "b")] 13 17 pub beat: f32, 18 + /// A value representing the vertical position of the object. 19 + /// In the range 0..2 inclusive, with zero being the bottom and two being the top row. 14 20 #[serde(rename = "y")] 15 21 pub row: i32, 22 + /// A value representing the horizontal position of the object. 23 + /// In the range 0..3 inclusive, with zero being the far left and three being the far right column. 16 24 #[serde(rename = "x")] 17 25 pub col: i32, 18 26 #[serde(rename = "c")] 19 27 pub color: NoteColor, 20 28 #[serde(rename = "d")] 21 29 pub direction: CutDirection, 30 + /// The number of degrees counter-clockwise to offset the object by. 22 31 #[serde(rename = "a")] 23 32 pub angle_offset: f32, 24 33 } ··· 26 35 impl_timed!(Note::beat); 27 36 28 37 loose_enum! { 38 + /// The color of a note, which determines which saber should be used to cut it. 29 39 #[derive(Default, Copy)] 30 40 NoteColor: i32 { 31 41 #[default] ··· 35 45 } 36 46 37 47 loose_enum! { 48 + /// The direction a note should be cut. 38 49 #[derive(Default, Copy)] 39 50 CutDirection: i32 { 40 51 #[default] ··· 51 62 } 52 63 53 64 impl CutDirection { 54 - /// Returns the number of degrees a note is rotated, with zero degrees being downward note. 55 - /// Returns zero if the cut direction is unknown. 65 + /// Returns the number of degrees a note is rotated, with zero degrees being a downward note. 66 + /// 67 + /// Returns zero if the cut direction is unknown/any. 56 68 pub fn get_degrees(&self) -> f32 { 57 69 match self { 58 70 CutDirection::Up => 180.0, ··· 76 88 reflect(Debug, Clone, PartialEq) 77 89 )] 78 90 pub struct Bomb { 91 + /// The position of the object in time. 79 92 #[serde(rename = "b")] 80 93 pub beat: f32, 94 + /// A value representing the vertical position of the object. 95 + /// In the range 0..2 inclusive, with zero being the bottom and two being the top row. 81 96 #[serde(rename = "y")] 82 97 pub row: i32, 98 + /// A value representing the horizontal position of the object. 99 + /// In the range 0..3 inclusive, with zero being the far left and three being the far right column. 83 100 #[serde(rename = "x")] 84 101 pub col: i32, 85 102 } ··· 94 111 reflect(Debug, Clone, PartialEq) 95 112 )] 96 113 pub struct Wall { 114 + /// The start position of the object in time. 97 115 #[serde(rename = "b")] 98 116 pub beat: f32, 117 + /// The length (in beats) that an object takes place. 99 118 #[serde(rename = "d")] 100 119 pub duration: f32, 120 + /// A value representing the vertical position of the object. 121 + /// In the range 0..2 inclusive, with zero being the bottom and two being the top row. 101 122 #[serde(rename = "y")] 102 123 pub row: i32, 124 + /// A value representing the horizontal position of the object. 125 + /// In the range 0..3 inclusive, with zero being the far left and three being the far right column. 103 126 #[serde(rename = "x")] 104 127 pub col: i32, 105 128 #[serde(rename = "w")] ··· 131 154 reflect(Debug, Clone, PartialEq) 132 155 )] 133 156 pub struct Arc { 157 + /// The start position of the object in time. 134 158 #[serde(rename = "b")] 135 159 pub beat: f32, 160 + /// A value representing the vertical starting position of the object. 161 + /// In the range 0..2 inclusive, with zero being the bottom and two being the top row. 136 162 #[serde(rename = "y")] 137 163 pub row: i32, 164 + /// A value representing the horizontal starting position of the object. 165 + /// In the range 0..3 inclusive, with zero being the far left and three being the far right column. 138 166 #[serde(rename = "x")] 139 167 pub col: i32, 140 168 #[serde(rename = "c")] 141 169 pub color: NoteColor, 142 170 #[serde(rename = "d")] 143 171 pub direction: CutDirection, 172 + /// Controls how far away the starting bezier control point is in [cut direction](Self::direction). 144 173 #[serde(rename = "mu")] 145 174 pub control_point: f32, 146 175 176 + /// The end position of the object in time. 147 177 #[serde(rename = "tb")] 148 178 pub tail_beat: f32, 179 + /// A value representing the vertical ending position of the object. 180 + /// In the range 0..2 inclusive, with zero being the bottom and two being the top row. 149 181 #[serde(rename = "ty")] 150 182 pub tail_row: i32, 183 + /// A value representing the horizontal ending position of the object. 184 + /// In the range 0..3 inclusive, with zero being the far left and three being the far right column. 151 185 #[serde(rename = "tx")] 152 186 pub tail_col: i32, 153 187 #[serde(rename = "tc")] 154 188 pub tail_direction: CutDirection, 189 + /// Controls how far away the ending bezier control point is in [tail cut direction](Self::tail_direction). 155 190 #[serde(rename = "tmu")] 156 191 pub tail_control_point: f32, 157 192 ··· 198 233 reflect(Debug, Clone, PartialEq) 199 234 )] 200 235 pub struct Chain { 236 + /// The start position of the object in time. 201 237 #[serde(rename = "b")] 202 238 pub beat: f32, 239 + /// A value representing the vertical starting position of the object. 240 + /// In the range 0..2 inclusive, with zero being the bottom and two being the top row. 203 241 #[serde(rename = "y")] 204 242 pub row: i32, 243 + /// A value representing the horizontal starting position of the object. 244 + /// In the range 0..3 inclusive, with zero being the far left and three being the far right column. 205 245 #[serde(rename = "x")] 206 246 pub col: i32, 207 247 #[serde(rename = "c")] ··· 209 249 #[serde(rename = "d")] 210 250 pub direction: CutDirection, 211 251 252 + /// The end position of the object in time. 212 253 #[serde(rename = "tb")] 213 254 pub tail_beat: f32, 255 + /// A value representing the vertical ending position of the object. 256 + /// In the range 0..2 inclusive, with zero being the bottom and two being the top row. 214 257 #[serde(rename = "ty")] 215 258 pub tail_row: i32, 259 + /// A value representing the horizontal ending position of the object. 260 + /// In the range 0..3 inclusive, with zero being the far left and three being the far right column. 216 261 #[serde(rename = "tx")] 217 262 pub tail_col: i32, 218 263 264 + /// The number of links the chain has, including the connected [`Note`]. 219 265 #[serde(rename = "sc")] 220 266 pub link_count: i32, 221 267 #[serde(rename = "s")]
+17 -1
src/info.rs
··· 1 + //! Defines the structure of a map's `Info.dat` file. 2 + 1 3 pub mod color_scheme; 2 4 3 5 pub use color_scheme::*; ··· 14 16 pub struct Beatmap { 15 17 /// The info file version, in the form of `2.1.0`. 16 18 /// 17 - /// ### Info File 19 + /// ### Version Support 18 20 /// 19 21 /// | Version | Description | Supported | 20 22 /// |---------|-----------------------------------------------|-----------| ··· 67 69 } 68 70 69 71 loose_enum! { 72 + /// The world that surrounds the player and defines which lights are available. 73 + /// 74 + /// For 90/360 degree mode, see [`AllDirectionEnvironment`]. 70 75 #[derive(Default)] 71 76 Environment: String { 72 77 #[default] ··· 121 126 } 122 127 123 128 loose_enum! { 129 + /// The world that surrounds the player while playing 90/360 degree mode. 130 + /// 131 + /// For standard mode, see [`Environment`]. 124 132 #[derive(Default)] 125 133 AllDirectionEnvironment: String { 126 134 #[default] ··· 128 136 } 129 137 } 130 138 139 + /// Describes a group of difficulties, all with the same [characteristic/mode](Characteristic). 131 140 #[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)] 132 141 #[cfg_attr( 133 142 feature = "bevy_reflect", ··· 142 151 } 143 152 144 153 loose_enum! { 154 + /// Describes the type/game mode of a difficulty. 155 + /// 156 + /// Note that [`Lawless`](Self::Lawless) and [`Lightshow`](Self::Lightshow) are modded characteristics, 157 + /// and may cause problems in un-modded versions of the game. 145 158 #[derive(Default)] 146 159 Characteristic: String { 147 160 #[default] ··· 158 171 } 159 172 } 160 173 174 + /// Describes the settings for a difficulty. 175 + /// 176 + /// Note that a difficulties [characteristic](Characteristic) is defined by its [`DifficultySet`]. 161 177 #[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)] 162 178 #[cfg_attr( 163 179 feature = "bevy_reflect",
+11
src/info/color_scheme.rs
··· 18 18 pub color_scheme: ColorScheme, 19 19 } 20 20 21 + /// Describes the colors of objects a lights for an environment/map. 22 + /// 23 + /// This does *not* currently support while light color overrides. 21 24 #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] 22 25 #[cfg_attr( 23 26 feature = "bevy_reflect", ··· 26 29 )] 27 30 #[serde(rename_all = "camelCase")] 28 31 pub struct ColorScheme { 32 + /// The name of the color scheme. 29 33 #[serde(rename = "colorSchemeId")] 30 34 pub id: String, 35 + /// The color for the left saber/notes. Default is red. 31 36 #[doc(alias = "saber_left")] 32 37 #[serde(rename = "saberAColor")] 33 38 pub note_left: Color, 39 + /// The color for the right saber/notes. Default is blue. 34 40 #[doc(alias = "saber_right")] 35 41 #[serde(rename = "saberBColor")] 36 42 pub note_right: Color, 37 43 44 + /// The color of walls/obstacles. 38 45 #[doc(alias = "obstacle")] 39 46 #[serde(rename = "obstaclesColor")] 40 47 pub wall: Color, 41 48 49 + /// The primary light color, often matching the [left note color](Self::note_left). 42 50 #[doc(alias = "environment0")] 43 51 #[serde(rename = "environmentColor0")] 44 52 pub light_primary: Color, 53 + /// The secondary light color, often matching the [right note color](Self::note_right). 45 54 #[doc(alias = "environment1")] 46 55 #[serde(rename = "environmentColor1")] 47 56 pub light_secondary: Color, 48 57 58 + /// The primary light color when [boost colors](crate::ColorBoostEvent) are enabled. 49 59 #[doc(alias = "environment_boost_0")] 50 60 #[serde(rename = "environmentColor0Boost")] 51 61 pub boost_light_primary: Color, 62 + /// The secondary light color when [boost colors](crate::ColorBoostEvent) are enabled. 52 63 #[doc(alias = "environment_boost_1")] 53 64 #[serde(rename = "environmentColor1Boost")] 54 65 pub boost_light_secondary: Color,
+4
src/info/color_scheme/presets.rs
··· 57 57 } 58 58 59 59 impl Environment { 60 + /// Returns the default color scheme for an environment. 61 + /// 60 62 /// Values taken from [the wiki](https://bsmg.wiki/mapping/lighting-defaults.html#current-colors) 61 63 /// and Kival Evan's [Typescript library](https://github.com/KivalEvan/BeatSaber-JSMap/blob/ef8afc42ab90e2f1100f1a163fa810ec56b6a9f8/src/beatmap/shared/colorScheme.ts). 62 64 /// ··· 404 406 } 405 407 406 408 impl AllDirectionEnvironment { 409 + /// Returns the default color scheme for a 90/360 degree environment. 410 + /// 407 411 /// Value taken from [the wiki](https://bsmg.wiki/mapping/lighting-defaults.html#current-colors). 408 412 /// 409 413 /// ChatGPT was used to help translate between formats, so there could be hallucinations.
+2
src/timing_traits.rs
··· 1 + //! Traits that are used to get an object's position in time and duration. 2 + 1 3 /// Represents any beatmap object that happens at a specific beat. 2 4 pub trait Timed { 3 5 /// Returns the beat that an object takes place.