Skip to content

Commit

Permalink
Merge pull request #799 from TheNotary/TheNotary-patch-1-1
Browse files Browse the repository at this point in the history
reset the active lyric line's progress when restart command is invoked
  • Loading branch information
barbeque-squared authored Dec 31, 2023
2 parents 34564e7 + 1e924a4 commit 148ec02
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ __history
aclocal.m4
/autom4te.cache/
/CMakeFiles/
link.res
link*.res
ppaslink.sh
/UltraStarDeluxe.app/*
/dists/autogen/config.guess
Expand Down
1 change: 1 addition & 0 deletions src/base/ULyrics.pas
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ destructor TLyricEngine.Destroy;
*}
procedure TLyricEngine.Clear(cBPM: real; cResolution: integer);
begin
UpperLine.CurWord := -1;
BPM := cBPM;
Resolution := cResolution;
LCounter := 0;
Expand Down
51 changes: 37 additions & 14 deletions src/screens/controllers/UScreenSingController.pas
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,12 @@ TMusicSyncSource = class(TSyncSource)
type
TScreenSingController = class(TMenu)
private

StartNote, EndNote: TPos;

procedure LoadNextSong();

procedure SongError();
procedure ResetLinesAndLyrics();
procedure ClearLyricEngines();
public
CheckPlayerConfigOnNextSong: boolean;
eSongLoaded: THookableEvent; //< event is called after lyrics of a song are loaded on OnShow
Expand Down Expand Up @@ -248,7 +248,7 @@ function TScreenSingController.ParseInput(PressedKey: Cardinal; CharCode: UCS4Ch
Exit;
end;

//Restart and pause song
// restart song
SDLK_R:
begin
if ScreenSong.Mode = smMedley then Exit;
Expand Down Expand Up @@ -283,7 +283,12 @@ function TScreenSingController.ParseInput(PressedKey: Cardinal; CharCode: UCS4Ch
begin
Scores.AddPlayer(Tex_ScoreBG[i1], Color);
end;

LyricsState.SetCurrentTime(CurrentSong.Start);
LyricsState.UpdateBeats();
ClearLyricEngines;
ResetLinesAndLyrics;

Scores.Init;
Exit;
end;
Expand Down Expand Up @@ -536,17 +541,17 @@ function TScreenSingController.ParseInput(PressedKey: Cardinal; CharCode: UCS4Ch
SDLK_RIGHT:
begin
if (SDL_ModState = KMOD_LCTRL) then // seek 5 seconds forward
AudioPlayback.SetPosition(AudioPlayback.Position + 5.0);
AudioPlayback.SetPosition(AudioPlayback.Position + 5.0);
if (Assigned(fCurrentVideo)) then
fCurrentVideo.Position := AudioPlayback.Position + 5.0;
end;

SDLK_LEFT:
begin
if (SDL_ModState = KMOD_LCTRL) then // seek 5 seconds backward and reset scores to avoid cheating
begin
if (AudioPlayback.Position < 20.0) then
exit;
begin
if (AudioPlayback.Position < 20.0) then
exit;
for i1 := 0 to High(Player) do
with Player[i1] do
begin
Expand All @@ -571,12 +576,12 @@ function TScreenSingController.ParseInput(PressedKey: Cardinal; CharCode: UCS4Ch
begin
Scores.AddPlayer(Tex_ScoreBG[i1], Color);
end;
Scores.Init;
Scores.Init;

AudioPlayback.SetPosition(AudioPlayback.Position - 5.0);
LyricsState.SetCurrentTime(AudioPlayback.Position - 5.0);
Lyrics.Clear(CurrentSong.BPM[0].BPM, CurrentSong.Resolution);
LyricsState.UpdateBeats();
LyricsState.SetCurrentTime(AudioPlayback.Position - 5.0);
ClearLyricEngines;
LyricsState.UpdateBeats();
if (Assigned(fCurrentVideo)) then
fCurrentVideo.Position := AudioPlayback.Position - 5.0;
end;
Expand Down Expand Up @@ -1179,9 +1184,7 @@ procedure TScreenSingController.LoadNextSong();
AudioInput.CaptureStart;

// main text
Lyrics.Clear(CurrentSong.BPM[0].BPM, CurrentSong.Resolution);
LyricsDuetP1.Clear(CurrentSong.BPM[0].BPM, CurrentSong.Resolution);
LyricsDuetP2.Clear(CurrentSong.BPM[0].BPM, CurrentSong.Resolution);
ClearLyricEngines;

if (CurrentSong.isDuet) and (PlayersPlay <> 1) then
begin
Expand Down Expand Up @@ -1242,6 +1245,26 @@ procedure TScreenSingController.LoadNextSong();
onShowFinish;
end;

// Forces the notes (lines) and lyrics to reset to the start of the song
procedure TScreenSingController.ResetLinesAndLyrics();
var
i1: integer;

begin
for i1 := 0 to PlayersPlay - 1 do
begin
Tracks[i1].CurrentLine := 0;
OnSentenceChange(i1, 0);
end;
end;

procedure TScreenSingController.ClearLyricEngines();
begin
Lyrics.Clear(CurrentSong.BPM[0].BPM, CurrentSong.Resolution);
LyricsDuetP1.Clear(CurrentSong.BPM[0].BPM, CurrentSong.Resolution);
LyricsDuetP2.Clear(CurrentSong.BPM[0].BPM, CurrentSong.Resolution);
end;

procedure TScreenSingController.ClearSettings;
begin
Settings.Finish := False;
Expand Down

0 comments on commit 148ec02

Please sign in to comment.