11using System ;
22using System . Collections . Generic ;
33using System . Linq ;
4- using Aquatrax ;
54
65namespace Server . OsuManiaLoader ;
76
8- class TmpTimeline
9- {
10- public int BarIndex ;
11- public int NodeIndex ;
12- }
13-
14- class TmpNote
7+ internal class TmpNote
158{
169 public int Key ;
1710 public int Action ;
@@ -20,17 +13,17 @@ class TmpNote
2013 public int NodeIndex ;
2114}
2215
23- class InvaxionTrack
16+ internal class InvaxionTrack
2417{
2518 public Dictionary < int , InvaxionNode > Nodes ;
2619}
2720
28- class InvaxionNode
21+ internal class InvaxionNode
2922{
3023 public int Action ;
3124}
3225
33- class InvaxionBar
26+ internal class InvaxionBar
3427{
3528 public Dictionary < int , InvaxionTrack > Tracks ;
3629}
@@ -69,7 +62,7 @@ public class OsuMania
6962 public int BeatDivisor ;
7063
7164 public int KeyCount ;
72- public float OverallDifficulty ;
65+ public int OverallDifficulty ;
7366
7467 public List < ( string , float ) > FloatBpms = new ( ) ;
7568 public List < OsuTimingPoint > TimingPoints = new ( ) ;
@@ -190,295 +183,6 @@ public override int GetTypeValue()
190183 }
191184}
192185
193- public class Fraction
194- {
195- // https://gist.github.com/fidelsoto/b4c0f14b800c58e137ad5757f35cacd6
196- public float Numerator ;
197- public float Denominator ;
198-
199- public Fraction ( float numerator , float denominator )
200- {
201- Numerator = numerator ;
202- Denominator = denominator ;
203- }
204-
205- public Fraction ( Fraction fraction )
206- {
207- Numerator = fraction . Numerator ;
208- Denominator = fraction . Denominator ;
209- }
210-
211- public override bool Equals ( object obj )
212- {
213- if ( obj == null ) return false ;
214-
215- var other = ( Fraction ) obj ;
216- return Math . Abs ( Numerator - other . Numerator ) < 0.1 && Math . Abs ( Denominator - other . Denominator ) < 0.1 ;
217- }
218-
219- public static bool operator == ( Fraction f1 , Fraction f2 )
220- {
221- return f1 . Equals ( f2 ) ;
222- }
223-
224- public static bool operator == ( Fraction f1 , int f2 )
225- {
226- return f1 . Equals ( new Fraction ( f2 , 1 ) ) ;
227- }
228-
229- public static bool operator != ( Fraction f1 , Fraction f2 )
230- {
231- return ! ( f1 == f2 ) ;
232- }
233-
234- public static bool operator != ( Fraction f1 , int f2 )
235- {
236- return ! ( f1 == f2 ) ;
237- }
238-
239- public static Fraction operator * ( Fraction f1 , float f2 )
240- {
241- var f3 = new Fraction ( f1 ) ;
242- f3 . Numerator *= f2 ;
243- f3 . Denominator *= f2 ;
244- return f3 ;
245- }
246-
247- public static Fraction operator / ( Fraction f1 , float f2 )
248- {
249- var f3 = new Fraction ( f1 ) ;
250- f3 . Numerator /= f2 ;
251- f3 . Denominator /= f2 ;
252- return f3 ;
253- }
254-
255- public static Fraction operator + ( Fraction f1 , float f2 )
256- {
257- var f3 = new Fraction ( f1 . Numerator , f1 . Denominator ) ;
258- f3 . Numerator += f2 * f3 . Denominator ;
259- return f3 ;
260- }
261-
262- public static Fraction operator - ( Fraction f1 , float f2 )
263- {
264- var f3 = new Fraction ( f1 . Numerator , f1 . Denominator ) ;
265- f3 . Numerator -= f2 * f3 . Denominator ;
266- return f3 ;
267- }
268-
269- public static float operator + ( float f1 , Fraction f2 )
270- {
271- return f1 + f2 . ToFloat ( ) ;
272- }
273-
274- public static float operator - ( float f1 , Fraction f2 )
275- {
276- return f1 - f2 . ToFloat ( ) ;
277- }
278-
279- public static float operator + ( int f1 , Fraction f2 )
280- {
281- return f1 + f2 . ToFloat ( ) ;
282- }
283-
284- public static float operator - ( int f1 , Fraction f2 )
285- {
286- return f1 - f2 . ToFloat ( ) ;
287- }
288-
289- public static Fraction operator + ( Fraction f1 , Fraction f2 )
290- {
291- var a = f1 . Denominator >= f2 . Denominator ? f1 : f2 ;
292- var b = f1 . Denominator < f2 . Denominator ? f1 : f2 ;
293- var difference = a . Denominator / b . Denominator ;
294-
295- return new Fraction ( a . Numerator + ( b . Numerator * difference ) , a . Denominator ) ;
296- }
297-
298- public static Fraction operator - ( Fraction f1 , Fraction f2 )
299- {
300- var a = f1 . Denominator >= f2 . Denominator ? f1 : f2 ;
301- var b = f1 . Denominator < f2 . Denominator ? f1 : f2 ;
302- var difference = a . Denominator / b . Denominator ;
303-
304- return new Fraction ( a . Numerator - ( b . Numerator * difference ) , a . Denominator ) ;
305- }
306-
307- public static bool operator > ( Fraction f1 , Fraction f2 )
308- {
309- return ( f1 . Numerator / f1 . Denominator ) > ( f2 . Numerator / f2 . Denominator ) ;
310- }
311-
312- public static bool operator < ( Fraction f1 , Fraction f2 )
313- {
314- return ( f1 . Numerator / f1 . Denominator ) < ( f2 . Numerator / f2 . Denominator ) ;
315- }
316-
317- public static bool operator <= ( Fraction f1 , Fraction f2 )
318- {
319- return ( f1 . Numerator / f1 . Denominator ) <= ( f2 . Numerator / f2 . Denominator ) ;
320- }
321-
322- public static bool operator >= ( Fraction f1 , Fraction f2 )
323- {
324- return ( f1 . Numerator / f1 . Denominator ) >= ( f2 . Numerator / f2 . Denominator ) ;
325- }
326-
327- public static bool operator > ( Fraction f1 , float f2 )
328- {
329- return ( f1 . Numerator / f1 . Denominator ) > f2 ;
330- }
331-
332- public static bool operator < ( Fraction f1 , float f2 )
333- {
334- return ( f1 . Numerator / f1 . Denominator ) < f2 ;
335- }
336-
337- public static bool operator <= ( Fraction f1 , float f2 )
338- {
339- return ( f1 . Numerator / f1 . Denominator ) <= f2 ;
340- }
341-
342- public static bool operator >= ( Fraction f1 , float f2 )
343- {
344- return ( f1 . Numerator / f1 . Denominator ) >= f2 ;
345- }
346-
347- public static bool operator > ( Fraction f1 , int f2 )
348- {
349- return ( f1 . Numerator / f1 . Denominator ) > f2 ;
350- }
351-
352- public static bool operator < ( Fraction f1 , int f2 )
353- {
354- return ( f1 . Numerator / f1 . Denominator ) < f2 ;
355- }
356-
357- public static bool operator <= ( Fraction f1 , int f2 )
358- {
359- return ( f1 . Numerator / f1 . Denominator ) <= f2 ;
360- }
361-
362- public static bool operator >= ( Fraction f1 , int f2 )
363- {
364- return ( f1 . Numerator / f1 . Denominator ) >= f2 ;
365- }
366-
367- public override int GetHashCode ( )
368- {
369- // i dunno, some weird stuff, its not like we care
370- return base . GetHashCode ( ) ;
371- }
372-
373- public override string ToString ( )
374- {
375- return Numerator + "/" + Denominator ;
376- }
377-
378- public float ToFloat ( )
379- {
380- return Numerator / Denominator ;
381- }
382-
383- //Helper function, simplifies a fraction.
384- public Fraction Simplify ( )
385- {
386- for ( var divideBy = Denominator ; divideBy > 0 ; divideBy -- )
387- {
388- var divisible = ( Math . Abs ( ( int ) ( Numerator / divideBy ) * divideBy - Numerator ) < 0.1 ) &&
389- ( Math . Abs ( ( int ) ( Denominator / divideBy ) * divideBy - Denominator ) < 0.1 ) ;
390-
391- if ( ! divisible ) continue ;
392-
393- Numerator /= divideBy ;
394- Denominator /= divideBy ;
395- }
396- return this ;
397- }
398- }
399-
400- public class BmsMeasure
401- {
402- public string MeasureNumber ;
403- public List < BMSMainDataLine > Lines = new ( ) ;
404-
405- public override string ToString ( )
406- {
407- return Lines . Aggregate ( "" , ( current , line ) => current + $ "#{ MeasureNumber } { line . Channel } :{ line . Data } \n ") ;
408- }
409-
410- public void CreateDataLine ( string channel , int bits , List < ( int , object ) > locations )
411- {
412- var chars = new Dictionary < int , string > ( ) ;
413- var locations_ = locations . Select ( loc => loc . Item1 ) . ToArray ( ) ;
414-
415- foreach ( var loc in locations )
416- {
417- if ( loc . Item2 is OsuHitObject ) chars [ loc . Item1 ] = "ZZ" ;
418- else chars [ loc . Item1 ] = ( string ) loc . Item2 ;
419- }
420-
421- Lines . Add ( new ( channel , bits , chars , locations_ , MeasureNumber ) ) ;
422- }
423-
424- public void CreateMeasureLengthChange ( float numOfBeats )
425- {
426- Lines . Add ( new ( "02" , 1 , new ( ) { { 0 , ( ( int ) numOfBeats ) . ToString ( "X4" ) . ToUpper ( ) } } , new int [ ] { 0 } , MeasureNumber ) ) ;
427- }
428-
429- public void CreateBpmChangeLine ( float bpm )
430- {
431- Lines . Add ( new ( "03" , 1 , new ( ) { { 0 , ( ( int ) bpm ) . ToString ( "X4" ) . ToUpper ( ) } } , new int [ ] { 0 } , MeasureNumber ) ) ;
432- }
433-
434- public void CreateBpmExtendedChangeLine ( float BPM , ( string , float ) [ ] BPMs )
435- {
436- ( string , float ) tuple = ( null , 0 ) ;
437- foreach ( var bpm in BPMs )
438- {
439- if ( Math . Abs ( bpm . Item2 - BPM ) < 0.1 )
440- {
441- tuple = bpm ;
442- }
443- }
444- Lines . Add ( new ( "08" , 1 , new ( ) { { 0 , tuple . Item1 } } , new [ ] { 0 } , MeasureNumber ) ) ;
445- }
446- }
447-
448- public class BMSMainDataLine
449- {
450- public BMSMainDataLine ( string channel , int bits , Dictionary < int , string > characters , int [ ] locations , string measureNumber )
451- {
452- Channel = channel ;
453- Data = BuildData ( bits , characters , locations ) ;
454- MeasureNumber = measureNumber ;
455- }
456-
457- public string Channel ;
458- public string Data ;
459- public string MeasureNumber ;
460-
461- private static string BuildData ( int bits , Dictionary < int , string > characters , int [ ] locations )
462- {
463- var output = "" ;
464- var index = 0 ;
465-
466- for ( var i = 0 ; i < bits ; i ++ )
467- {
468- if ( i == locations [ index ] )
469- {
470- output += characters [ i ] ;
471- if ( ! ( index >= locations . Length - 1 ) ) index ++ ;
472- }
473- else output += "00" ;
474- }
475-
476- return output ;
477- }
478-
479- public override string ToString ( ) => $ "#{ MeasureNumber } { Channel } :{ Data } ";
480- }
481-
482186public static class Base36
483187{
484188 private static readonly char [ ] Alphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" . ToArray ( ) ;
@@ -499,19 +203,6 @@ public static string Encode(int number)
499203
500204internal static class Stuff
501205{
502- public static float GreatestCommonDenominator ( float a , float b )
503- {
504- while ( a != 0 && b != 0 )
505- {
506- if ( a > b )
507- a %= b ;
508- else
509- b %= a ;
510- }
511-
512- return a == 0 ? b : a ;
513- }
514-
515206 public static string GetCurrentHsCount ( int sampleNum )
516207 {
517208 var ret = Base36 . Encode ( sampleNum ) ;
0 commit comments