@@ -82,6 +82,7 @@ private enum ScrollDirection
8282 private bool _analyzingReplay ;
8383 private bool _restartingSong ;
8484 private bool _showAdvancedStats ;
85+ private bool _offsetModified ;
8586
8687 private float _horizontalScrollStep ;
8788 private Tween _horizontalScrollTween ;
@@ -403,7 +404,8 @@ private bool AnalyzeReplay(SongEntry songEntry, ReplayInfo? replayEntry)
403404 private NavigationScheme . Entry _showAdvancedButtonEntry ;
404405 private NavigationScheme . Entry _removeFavoriteButtonEntry ;
405406 private NavigationScheme . Entry _addFavoriteButtonEntry ;
406- private NavigationScheme . Entry _applyCalibrationEntry ;
407+ private NavigationScheme . Entry _addOffsetEntry ;
408+ private NavigationScheme . Entry _removeOffsetEntry ;
407409 private NavigationScheme . Entry _scrollLeftEntry ;
408410 private NavigationScheme . Entry _scrollRightEntry ;
409411 private NavigationScheme . Entry _scrollUpEntry ;
@@ -462,27 +464,14 @@ private void SetNavigationScheme()
462464
463465 UpdateShowAdvancedButton ( ) ;
464466
465- _applyOffsetEntry = new NavigationScheme . Entry ( MenuAction . Select , "Apply Song Offset" , ( ) =>
467+ _addOffsetEntry = new NavigationScheme . Entry ( MenuAction . Select , "Add Song Offset" , ( ) =>
466468 {
467- var offset = GlobalVariables . State . ScoreScreenStats . Value . AverageOffset ;
468- var song = GlobalVariables . State . CurrentSong ;
469-
470- if ( song == null )
471- {
472- return ;
473- }
474-
475- if ( song . SubType != EntryType . Ini )
476- {
477- return ;
478- }
479-
480- string iniPath = Path . Combine ( song . ActualLocation , "song.ini" ) ;
469+ AddOffsetToIni ( ) ;
470+ } ) ;
481471
482- if ( File . Exists ( iniPath ) )
483- {
484- SongIniWriter . WriteSongOffset ( iniPath , ( long ) offset ) ;
485- }
472+ _removeOffsetEntry = new NavigationScheme . Entry ( MenuAction . Select , "Remove Song Offset" , ( ) =>
473+ {
474+ AddOffsetToIni ( ) ;
486475 } ) ;
487476
488477 _scrollLeftEntry = new NavigationScheme . Entry ( MenuAction . Left , "Menu.Common.Scroll" , context =>
@@ -564,6 +553,30 @@ private void ToggleAdvancedStats()
564553 UpdateNavigationScheme ( true ) ;
565554 }
566555
556+ private void AddOffsetToIni ( )
557+ {
558+ var song = GlobalVariables . State . CurrentSong ;
559+ var offset = GlobalVariables . State . ScoreScreenStats . Value . AverageOffset ;
560+ if ( song == null ) { return ; }
561+ if ( song . SubType != EntryType . Ini ) { return ; }
562+
563+ string iniPath = Path . Combine ( song . ActualLocation , "song.ini" ) ;
564+ if ( File . Exists ( iniPath ) ) {
565+ if ( _offsetModified )
566+ {
567+ YargLogger . LogInfo ( "Removed offset from delay in .ini file" ) ;
568+ offset = - offset ;
569+ }
570+ else
571+ {
572+ YargLogger . LogInfo ( "Added offset to delay in .ini file" ) ;
573+ }
574+ _offsetModified = ! _offsetModified ;
575+ SongIniWriter . AddSongOffset ( iniPath , ( long ) ( offset * 1000 ) ) ;
576+ UpdateNavigationScheme ( true ) ;
577+ }
578+ }
579+
567580 private void UpdateShowAdvancedButton ( )
568581 {
569582 var key = _showAdvancedStats ? "Menu.ScoreScreen.HideAdvanced" : "Menu.ScoreScreen.ShowAdvanced" ;
@@ -581,7 +594,6 @@ private void UpdateNavigationScheme(bool reset = false)
581594 {
582595 _continueButtonEntry ,
583596 _restartButtonEntry ,
584- _applyOffsetEntry
585597 } ;
586598
587599 var song = GlobalVariables . State . CurrentSong ;
@@ -607,6 +619,15 @@ private void UpdateNavigationScheme(bool reset = false)
607619 buttons . Insert ( 1 , _endEarlyButtonEntry ) ;
608620 }
609621
622+ if ( _offsetModified )
623+ {
624+ buttons . Add ( _removeOffsetEntry ) ;
625+ }
626+ else
627+ {
628+ buttons . Add ( _addOffsetEntry ) ;
629+ }
630+
610631 buttons . Add ( _scrollLeftEntry ) ;
611632 buttons . Add ( _scrollRightEntry ) ;
612633 buttons . Add ( _scrollUpEntry ) ;
0 commit comments