1111using Nucleus ;
1212using Nucleus . Audio ;
1313using Nucleus . Common . Audio ;
14+ using Nucleus . Types ;
1415using OdinSerializer ;
1516using Raylib_cs ;
1617using System . Collections . Concurrent ;
@@ -41,6 +42,24 @@ public class MuseDashSongInfoJSON
4142 [ JsonPropertyName ( "difficulty3" ) ] public string Difficulty3 { get ; set ; } = "" ;
4243 [ JsonPropertyName ( "difficulty4" ) ] public string Difficulty4 { get ; set ; } = "" ;
4344 [ JsonPropertyName ( "difficulty5" ) ] public string Difficulty5 { get ; set ; } = "" ;
45+
46+ public void CloneInto ( MuseDashSongInfoJSON into ) {
47+ into . UID = UID ;
48+ into . Name = Name ;
49+ into . Author = Author ;
50+ into . BPM = BPM ;
51+ into . Music = Music ;
52+ into . Demo = Demo ;
53+ into . Cover = Cover ;
54+ into . NoteJSON = NoteJSON ;
55+ into . Scene = Scene ;
56+ into . LevelDesigner = LevelDesigner ;
57+ into . Difficulty1 = Difficulty1 ;
58+ into . Difficulty2 = Difficulty2 ;
59+ into . Difficulty3 = Difficulty3 ;
60+ into . Difficulty4 = Difficulty4 ;
61+ into . Difficulty5 = Difficulty5 ;
62+ }
4463}
4564
4665public delegate void ChartCoverAvailableToMainThreadFn ( MD1_SongCover ? cover ) ;
@@ -52,8 +71,6 @@ public class MD1_Song : ISong, IHasLowToHighDifficulties
5271
5372 public MD1_SongInfo ? Info ;
5473
55- public string Name = "" ;
56- public string Author = "" ;
5774
5875 protected IAudioClip ? AudioTrack ;
5976 protected IAudioClip ? DemoTrack ;
@@ -194,20 +211,25 @@ public List<MD1_SongChart> LoadSheets() {
194211 return null ;
195212 }
196213
214+ public SongMetadata FetchMetadata ( ) => FetchMetadata ( HumanLanguage . GetCurrentLanguage ( ) ) ;
197215 public SongMetadata FetchMetadata ( HumanLanguage desiredLanguage ) {
198- GetInfo ( ) ; // This is annoying: it fixes an issue with custom albums, didnt feel like it would be a good idea to differentiate them though..
199- // TODO: language
200- return new ( ) {
201- Name = Name ,
202- Author = Author
203- } ;
216+ if ( __jsonInfoLanguages . TryGetValue ( desiredLanguage , out MuseDashSongInfoJSON ? languageInfo ) )
217+ return new ( ) {
218+ Name = languageInfo . Name ?? __jsonInfo . Name ,
219+ Author = languageInfo . Author ?? __jsonInfo . Author
220+ } ;
221+ else
222+ return new ( ) {
223+ Name = __jsonInfo . Name ,
224+ Author = __jsonInfo . Author
225+ } ;
204226 }
205227
206228 public IReadOnlyList < ISongChart > GetCharts ( ) => LoadSheets ( ) ;
207229 public bool IsAsynchronouslyLoading ( ) => DeferringDemoToAsyncHandler ;
208230 public void WaitForAsynchronousLoad ( OnAsynchronousLoadingCompleteFn callback ) => throw new NotImplementedException ( ) ;
209231
210- public IAudioClip ? GetDemoAudio ( ) {
232+ public IAudioClip ? GetDemoAudio ( ) {
211233 return GetDemoTrack ( ) ;
212234 }
213235 public SongCoverInfo GetCoverTexture ( ) {
@@ -230,11 +252,20 @@ public SongCoverInfo GetCoverTexture() {
230252 } ) ;
231253 }
232254
233- private MuseDashSongInfoJSON __jsonInfo ;
234- public MD1_Song ( MuseDashSongInfoJSON info ) {
235- __jsonInfo = info ;
236- // Debug.Assert(info.Difficulty5 == "");
255+ private readonly MuseDashSongInfoJSON __jsonInfo = new ( ) ;
256+ private readonly Dictionary < HumanLanguage , MuseDashSongInfoJSON > __jsonInfoLanguages = [ ] ;
257+
258+ public void AddBaseJSONInfo ( MuseDashSongInfoJSON baseInfo ) {
259+ baseInfo . CloneInto ( __jsonInfo ) ;
260+ }
261+
262+ public void AddLocalizedJSONInfo ( HumanLanguage lang , string ? name , string ? author ) {
263+ __jsonInfoLanguages [ lang ] = new ( ) {
264+ Name = name ! ,
265+ Author = author !
266+ } ;
237267 }
268+
238269 public static string ? GetFixedFilename ( string givenBase , string fileName , [ NotNullWhen ( true ) ] bool throwExp = true ) {
239270 return
240271 MuseDash1Compatibility . StreamingFiles . FirstOrDefault ( x => x . Contains ( fileName . Replace ( "{name}" , givenBase ) ) )
@@ -248,7 +279,10 @@ public MD1_Song(MuseDashSongInfoJSON info) {
248279
249280 [ JsonIgnore ]
250281 public string BaseName => GetInfo ( ) ! . Music . Substring ( 0 , GetInfo ( ) ! . Music . Length - 6 ) ;
251- public override string ToString ( ) => $ "{ Name } by { Author } ";
282+ public override string ToString ( ) {
283+ SongMetadata metadata = FetchMetadata ( ) ;
284+ return $ "{ metadata . Name } by { metadata . Author } ";
285+ }
252286
253287
254288 public AssetsManager AssetsFile { get ; private set ; } = null ;
@@ -269,7 +303,7 @@ private void LoadAssetFile() {
269303 DemoFile = new ( ) ;
270304 DemoFile . LoadFiles ( filepath ) ;
271305 }
272- else Logs . Warn ( $ "CloneDash: MuseDashSong.LoadAssetFile could not generate a demo filepath for { Name } .") ;
306+ else Logs . Warn ( $ "CloneDash: MuseDashSong.LoadAssetFile could not generate a demo filepath for { __jsonInfo . Name } .") ;
273307 }
274308 }
275309
@@ -334,7 +368,7 @@ protected virtual void ProduceCover(ChartCoverAvailableToMainThreadFn callback)
334368 if ( DashSheetOverrides . TryGetValue ( mapID , out MD1_SongChart ? sheet ) )
335369 return sheet ;
336370
337- LoadAssetFile ( ) ;
371+ LoadAssetFile ( ) ;
338372 Interlude . Spin ( ) ;
339373
340374 MD1_SongChart chart = new MD1_SongChart ( this , mapID ) ;
@@ -344,7 +378,7 @@ protected virtual void ProduceCover(ChartCoverAvailableToMainThreadFn callback)
344378 /// <summary>
345379 /// Called from charts only!!!
346380 /// </summary>
347- public virtual MD1_GamemodeData ? ProduceGamemodeData ( MD1_SongChart chart , int mapID ) {
381+ public virtual MD1_GamemodeData ? ProduceGamemodeData ( MD1_SongChart chart , int mapID ) {
348382 //MonoBehaviour map = (MonoBehaviour)AssetsFile.assetsFileList[0].Objects.First(x => x is MonoBehaviour mB && mB.m_Name.EndsWith($"_map{mapID}"));
349383 MonoBehaviour ? map = MuseDash1Compatibility . StreamingAssets . LoadAsset < MonoBehaviour > ( $ "Assets/Static Resources/Data/Configs/StageInfos/{ __jsonInfo . NoteJSON } { mapID } .asset") . GetResult ( ) ;
350384 if ( map == null )
@@ -373,9 +407,6 @@ protected virtual void ProduceCover(ChartCoverAvailableToMainThreadFn callback)
373407 protected virtual MD1_SongInfo ? ProduceInfo ( ) {
374408 List < string > SearchTags = [ ] ;
375409
376- Name = __jsonInfo . Name ;
377- Author = __jsonInfo . Author ;
378-
379410 SearchTags . AddRange ( __jsonInfo . Name . Split ( ' ' ) ) ;
380411 MD1_SongInfo info = new MD1_SongInfo ( ) {
381412 BPM = __jsonInfo . BPM ,
@@ -399,4 +430,11 @@ protected virtual void ProduceCover(ChartCoverAvailableToMainThreadFn callback)
399430 bool IHasLowToHighDifficulties . GetDifficulties ( Span < int > difficulties ) {
400431 return Difficulties . AsSpan ( ) . TryCopyTo ( difficulties ) ;
401432 }
433+
434+ public IEnumerable < MuseDashSongInfoJSON > GetAvailableInfo ( ) {
435+ if ( __jsonInfo != null )
436+ yield return __jsonInfo ;
437+ foreach ( var info in __jsonInfoLanguages )
438+ yield return info . Value ;
439+ }
402440}
0 commit comments