Skip to content

Commit

Permalink
Allow forced hard seeking in Practice SetSongPosition & Fix Unpause Sync
Browse files Browse the repository at this point in the history
pausing, seeking, then unpausing cause some issues
we can get around it in a mildly hacky way by forcing a rewind of .01 seconds per unpause which isnt TOO noticeable but bigger than nothing
  • Loading branch information
poco0317 committed Nov 5, 2019
1 parent 44a4999 commit b8ae11a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -951,7 +951,7 @@ local function duminput(event)
elseif event.type == "InputEventType_FirstPress" then
if event.DeviceInput.button == "DeviceButton_backspace" then
if bookmarkPosition ~= nil then
SCREENMAN:GetTopScreen():SetSongPosition(bookmarkPosition, 1)
SCREENMAN:GetTopScreen():SetSongPosition(bookmarkPosition, 1, false)
if GAMESTATE:IsPaused() then
SCREENMAN:GetTopScreen():TogglePause()
end
Expand All @@ -967,13 +967,13 @@ local function duminput(event)
if GAMESTATE:IsPaused() then
local pos = SCREENMAN:GetTopScreen():GetSongPosition()
local dir = GAMESTATE:GetPlayerState(PLAYER_1):GetCurrentPlayerOptions():UsingReverse() and 1 or -1
SCREENMAN:GetTopScreen():SetSongPosition(pos + dir * 0.05,0)
SCREENMAN:GetTopScreen():SetSongPosition(pos + dir * 0.05, 0, false)
end
elseif event.DeviceInput.button == "DeviceButton_mousewheel down" then
if GAMESTATE:IsPaused() then
local pos = SCREENMAN:GetTopScreen():GetSongPosition()
local dir = GAMESTATE:GetPlayerState(PLAYER_1):GetCurrentPlayerOptions():UsingReverse() and 1 or -1
SCREENMAN:GetTopScreen():SetSongPosition(pos - dir * 0.05,0)
SCREENMAN:GetTopScreen():SetSongPosition(pos - dir * 0.05, 0, false)
end
end
end
Expand Down Expand Up @@ -1070,7 +1070,7 @@ pm[#pm + 1] =
end,
MouseLeftClickMessageCommand = function(self)
if isOver(self) then
SCREENMAN:GetTopScreen():SetSongPosition(self:GetX() * musicratio, 0)
SCREENMAN:GetTopScreen():SetSongPosition(self:GetX() * musicratio, 0, false)
end
end,
MouseRightClickMessageCommand = function(self)
Expand Down
12 changes: 7 additions & 5 deletions src/Etterna/Screen/Gameplay/ScreenGameplayPractice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ ScreenGameplayPractice::TogglePause()
fSecondsToStartTransitioningOut);

RageSoundParams p = m_pSoundMusic->GetParams();
p.m_StartSecond = fSeconds;
p.m_StartSecond = fSeconds - 0.01f;
p.m_fSpeed = rate;
if (fSecondsToStartFadingOutMusic <
GAMESTATE->m_pCurSong->m_fMusicLengthSeconds) {
Expand All @@ -206,20 +206,21 @@ ScreenGameplayPractice::TogglePause()
p.m_bAccurateSync = true;
// Go
m_pSoundMusic->Play(false, &p);
} else {
}

m_pSoundMusic->Pause(newPause);
GAMESTATE->SetPaused(newPause);
}

void
ScreenGameplayPractice::SetSongPosition(float newSongPositionSeconds,
float noteDelay)
float noteDelay,
bool hardSeek)
{
bool isPaused = GAMESTATE->GetPaused();

RageSoundParams p = m_pSoundMusic->GetParams();
p.m_bAccurateSync = !isPaused;
p.m_bAccurateSync = !isPaused || hardSeek;
m_pSoundMusic->SetParams(p);

SOUND->SetSoundPosition(m_pSoundMusic, newSongPositionSeconds - noteDelay);
Expand Down Expand Up @@ -304,7 +305,8 @@ class LunaScreenGameplayPractice : public Luna<ScreenGameplayPractice>
{
float position = FArg(1);
float delay = FArg(2);
p->SetSongPosition(position, delay);
bool hardseek = BArg(3);
p->SetSongPosition(position, delay, hardseek);
return 0;
}

Expand Down
4 changes: 3 additions & 1 deletion src/Etterna/Screen/Gameplay/ScreenGameplayPractice.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ class ScreenGameplayPractice : public ScreenGameplay
// Add to the playback rate in the middle of gameplay
float AddToRate(float amountAdded);
// Move the current position of the song in the middle of gameplay
void SetSongPosition(float newSongPositionSeconds, float noteDelay = 0.f);
void SetSongPosition(float newSongPositionSeconds,
float noteDelay = 0.f,
bool hardSeek = false);
// Toggle pause
void TogglePause();

Expand Down

0 comments on commit b8ae11a

Please sign in to comment.