rosu_memory_lib/reader/beatmap/
common.rs

1use crate::common::GameMode;
2
3#[derive(Debug, Clone)]
4pub struct BeatmapInfo {
5    pub metadata: BeatmapMetadata,
6    pub location: BeatmapLocation,
7    pub stats: BeatmapStats,
8    pub technical: BeatmapTechnicalInfo,
9}
10
11#[derive(Debug, Clone)]
12pub struct BeatmapMetadata {
13    pub author: String,
14    pub creator: String,
15    pub title_romanized: String,
16    pub title_original: String,
17    pub difficulty: String,
18    pub tags: String,
19}
20#[derive(Debug, Clone)]
21pub struct BeatmapTechnicalInfo {
22    pub md5: String,
23    pub id: i32,
24    pub set_id: i32,
25    pub mode: GameMode,
26    pub ranked_status: BeatmapStatus,
27}
28#[derive(Debug, Clone)]
29pub struct BeatmapLocation {
30    pub folder: String,
31    pub filename: String,
32    pub audio: String,
33    pub cover: String,
34}
35
36impl BeatmapLocation {
37    pub fn get_file_path(&self) -> String {
38        format!("{}/{}", self.folder, self.filename)
39    }
40    pub fn get_audio_path(&self) -> String {
41        format!("{}/{}", self.folder, self.audio)
42    }
43    pub fn get_cover_path(&self) -> String {
44        format!("{}/{}", self.folder, self.cover)
45    }
46}
47
48#[derive(Debug, Clone)]
49pub struct BeatmapStarRating {
50    pub no_mod: f64,
51    pub dt: f64,
52    pub ht: f64,
53}
54
55#[derive(Debug, Clone)]
56pub struct BeatmapStats {
57    pub ar: f32,
58    pub od: f32,
59    pub cs: f32,
60    pub hp: f32,
61    pub total_length: i32,
62    pub star_rating: BeatmapStarRating,
63    pub object_count: i32,
64    pub slider_count: i32,
65}
66
67#[derive(Debug, Default, PartialEq, Eq, Copy, Clone)]
68#[repr(i16)]
69pub enum BeatmapStatus {
70    #[default]
71    Unknown = 0,
72    Unsubmitted = 1,
73    Unranked = 2,
74    Unused = 3,
75    Ranked = 4,
76    Approved = 5,
77    Qualified = 6,
78    Loved = 7,
79}
80
81impl BeatmapStatus {
82    #[allow(clippy::inherent_to_string)]
83    pub fn to_string(&self) -> String {
84        match self {
85            BeatmapStatus::Unknown => "unknown".to_string(),
86            BeatmapStatus::Unsubmitted => "unsubmitted".to_string(),
87            BeatmapStatus::Unranked => "unranked".to_string(),
88            BeatmapStatus::Unused => "unused".to_string(),
89            BeatmapStatus::Ranked => "ranked".to_string(),
90            BeatmapStatus::Approved => "approved".to_string(),
91            BeatmapStatus::Qualified => "qualified".to_string(),
92            BeatmapStatus::Loved => "loved".to_string(),
93        }
94    }
95}
96
97impl From<i16> for BeatmapStatus {
98    fn from(value: i16) -> Self {
99        match value {
100            1 => Self::Unsubmitted,
101            2 => Self::Unranked,
102            3 => Self::Unused,
103            4 => Self::Ranked,
104            5 => Self::Approved,
105            6 => Self::Qualified,
106            7 => Self::Loved,
107            _ => Self::Unknown,
108        }
109    }
110}
111
112impl From<i32> for BeatmapStatus {
113    fn from(value: i32) -> Self {
114        Self::from(value as i16)
115    }
116}
117
118pub(crate) struct BeatmapOffset {
119    pub ptr: i32,
120    pub metadata: BeatmapMetadataOffset,
121    pub location: BeatmapLocationOffset,
122    pub stats: BeatmapStatsOffset,
123    pub technical: BeatmapTechnicalOffset,
124}
125
126pub struct BeatmapStatsOffset {
127    pub ar: i32,
128    pub od: i32,
129    pub cs: i32,
130    pub hp: i32,
131    pub object_count: i32,
132    pub total_length: i32,
133    pub drain_time: i32,
134    pub star_rating: i32,
135    pub slider_count: i32,
136}
137
138pub struct BeatmapLocationOffset {
139    pub folder: i32,
140    pub filename: i32,
141    pub audio: i32,
142    pub cover: i32,
143}
144
145pub struct BeatmapTechnicalOffset {
146    pub md5: i32,
147    pub id: i32,
148    pub set_id: i32,
149    pub mode: i32,
150    pub ranked_status: i32,
151}
152
153pub struct BeatmapMetadataOffset {
154    pub author: i32,
155    pub creator: i32,
156    pub title_romanized: i32,
157    pub title_original: i32,
158    pub difficulty: i32,
159    pub tags: i32,
160}