@@ -15,14 +15,15 @@ use crate::{
1515 Anim , AnimVector , BezierTween , BpmList , Chart , ChartExtra , ChartSettings , ClampedTween , CtrlObject , JudgeLine , JudgeLineCache , JudgeLineKind ,
1616 Keyframe , Note , NoteKind , Object , StaticTween , Tweenable , UIElement ,
1717 } ,
18- judge:: JudgeStatus ,
18+ judge:: { HitSound , JudgeStatus } ,
1919 parse:: process_lines,
2020} ;
2121use anyhow:: { bail, Result } ;
2222use byteorder:: { LittleEndian as LE , ReadBytesExt , WriteBytesExt } ;
2323use macroquad:: { prelude:: Color , texture:: Texture2D } ;
2424use std:: {
2525 cell:: RefCell ,
26+ collections:: HashMap ,
2627 io:: { Read , Write } ,
2728 ops:: Deref ,
2829 rc:: Rc ,
@@ -315,18 +316,22 @@ impl BinaryData for CtrlObject {
315316
316317impl BinaryData for Note {
317318 fn read_binary < R : Read > ( r : & mut BinaryReader < R > ) -> Result < Self > {
318- Ok ( Self {
319- object : r. read ( ) ?,
320- kind : match r. read :: < u8 > ( ) ? {
321- 0 => NoteKind :: Click ,
322- 1 => NoteKind :: Hold {
323- end_time : r. read ( ) ?,
324- end_height : r. read ( ) ?,
325- } ,
326- 2 => NoteKind :: Flick ,
327- 3 => NoteKind :: Drag ,
328- _ => bail ! ( "invalid note kind" ) ,
319+ let object = r. read ( ) ?;
320+ let kind = match r. read :: < u8 > ( ) ? {
321+ 0 => NoteKind :: Click ,
322+ 1 => NoteKind :: Hold {
323+ end_time : r. read ( ) ?,
324+ end_height : r. read ( ) ?,
329325 } ,
326+ 2 => NoteKind :: Flick ,
327+ 3 => NoteKind :: Drag ,
328+ _ => bail ! ( "invalid note kind" ) ,
329+ } ;
330+ let hitsound = HitSound :: default_from_kind ( & kind) ;
331+ Ok ( Self {
332+ object,
333+ kind,
334+ hitsound,
330335 time : r. time ( ) ?,
331336 height : r. read ( ) ?,
332337 speed : if r. read ( ) ? { r. read :: < f32 > ( ) ? } else { 1. } ,
@@ -374,6 +379,7 @@ impl BinaryData for JudgeLine {
374379 1 => JudgeLineKind :: Texture ( Texture2D :: empty ( ) . into ( ) , r. read ( ) ?) ,
375380 2 => JudgeLineKind :: Text ( r. read ( ) ?) ,
376381 3 => JudgeLineKind :: Paint ( r. read ( ) ?, RefCell :: default ( ) ) ,
382+ 4 => unimplemented ! ( ) ,
377383 _ => bail ! ( "invalid judge line kind" ) ,
378384 } ;
379385 let height = r. read ( ) ?;
@@ -423,6 +429,9 @@ impl BinaryData for JudgeLine {
423429 w. write_val ( 3_u8 ) ?;
424430 w. write ( events) ?;
425431 }
432+ JudgeLineKind :: TextureGif ( ..) => {
433+ bail ! ( "gif texture binary not supported" ) ;
434+ }
426435 }
427436 w. write ( & self . height ) ?;
428437 w. array ( & self . notes ) ?;
@@ -461,7 +470,7 @@ impl BinaryData for Chart {
461470 let mut lines = r. array ( ) ?;
462471 process_lines ( & mut lines) ;
463472 let settings = r. read ( ) ?;
464- Ok ( Chart :: new ( offset, lines, BpmList :: new ( vec ! [ ( 0. , 60. ) ] ) , settings, ChartExtra :: default ( ) ) )
473+ Ok ( Chart :: new ( offset, lines, BpmList :: new ( vec ! [ ( 0. , 60. ) ] ) , settings, ChartExtra :: default ( ) , HashMap :: new ( ) ) )
465474 }
466475
467476 fn write_binary < W : Write > ( & self , w : & mut BinaryWriter < W > ) -> Result < ( ) > {
0 commit comments