1+ using System . Globalization ;
12using System . Text ;
23using MuConvert . utils ;
34
@@ -85,11 +86,40 @@ private void _putKey(string? key, StringBuilder content)
8586 return ( levels , infos ) ;
8687 }
8788
88- public string Title => this . GetValueOrDefault ( "title" , "" ) ;
89- public string Artist => this . GetValueOrDefault ( "artist" , "" ) ;
90- public float ? WholeBpm => float . TryParse ( this . GetValueOrDefault ( "wholebpm" , "" ) , out var wholebpm ) ? wholebpm : null ;
91- public float First => float . TryParse ( this . GetValueOrDefault ( "first" , "" ) , out var first ) ? first : 0f ;
92- public int ClockCount => int . TryParse ( this . GetValueOrDefault ( "clock_count" , "" ) , out var clockCount ) ? clockCount : 4 ;
89+ public string Title
90+ {
91+ get => this . GetValueOrDefault ( "title" , "" ) ;
92+ set => this [ "title" ] = value ?? "" ;
93+ }
94+
95+ public string Artist
96+ {
97+ get => this . GetValueOrDefault ( "artist" , "" ) ;
98+ set => this [ "artist" ] = value ?? "" ;
99+ }
100+
101+ public float ? WholeBpm
102+ {
103+ get => float . TryParse ( this . GetValueOrDefault ( "wholebpm" , "" ) , out var wholebpm ) ? wholebpm : null ;
104+ set
105+ {
106+ if ( value is null ) Remove ( "wholebpm" ) ;
107+ else this [ "wholebpm" ] = value . Value . ToString ( CultureInfo . InvariantCulture ) ;
108+ }
109+ }
110+
111+ public float First
112+ {
113+ get => float . TryParse ( this . GetValueOrDefault ( "first" , "" ) , out var first ) ? first : 0f ;
114+ set => this [ "first" ] = $ "{ value : 0.####} ";
115+ }
116+
117+ public int ClockCount
118+ {
119+ get => int . TryParse ( this . GetValueOrDefault ( "clock_count" , "" ) , out var clockCount ) ? clockCount : 4 ;
120+ set => this [ "clock_count" ] = value . ToString ( ) ;
121+ }
122+
93123 public ( float , float ? ) ? Demo
94124 {
95125 get
@@ -98,6 +128,20 @@ private void _putKey(string? key, StringBuilder content)
98128 float ? demoLen = float . TryParse ( this . GetValueOrDefault ( "demo_len" , "" ) , out var v ) ? v : null ;
99129 return ( demoStart , demoLen ) ;
100130 }
131+ set
132+ {
133+ if ( value is null )
134+ {
135+ Remove ( "demo_seek" ) ;
136+ Remove ( "demo_len" ) ;
137+ return ;
138+ }
139+
140+ var ( start , len ) = value . Value ;
141+ this [ "demo_seek" ] = $ "{ start : 0.####} ";
142+ if ( len is null ) Remove ( "demo_len" ) ;
143+ else this [ "demo_len" ] = $ "{ len : 0.####} ";
144+ }
101145 }
102146
103147 public override string ToString ( )
0 commit comments