From a1c69b4e40b476ea6b0878b439f8699658953351 Mon Sep 17 00:00:00 2001 From: Barinade Date: Thu, 31 Oct 2019 21:58:16 -0500 Subject: [PATCH] Rename GameplayPractice functions in more sane ways also allow more fine usage of SetSongPosition --- .../WifeJudgmentSpotting.lua | 10 ++--- .../Gameplay/ScreenGameplayPractice.cpp | 43 +++++++++++++------ .../Screen/Gameplay/ScreenGameplayPractice.h | 15 ++++--- 3 files changed, 42 insertions(+), 26 deletions(-) diff --git a/Themes/Til Death/BGAnimations/ScreenGameplay overlay/WifeJudgmentSpotting.lua b/Themes/Til Death/BGAnimations/ScreenGameplay overlay/WifeJudgmentSpotting.lua index 82d743dcb1..6308895fb0 100644 --- a/Themes/Til Death/BGAnimations/ScreenGameplay overlay/WifeJudgmentSpotting.lua +++ b/Themes/Til Death/BGAnimations/ScreenGameplay overlay/WifeJudgmentSpotting.lua @@ -948,12 +948,12 @@ local function duminput(event) MESSAGEMAN:Broadcast("MouseRightClick") elseif event.DeviceInput.button == "DeviceButton_backspace" and event.type == "InputEventType_FirstPress" then if bookmarkPosition ~= nil then - SCREENMAN:GetTopScreen():SetPreviewNoteFieldMusicPosition(bookmarkPosition) + SCREENMAN:GetTopScreen():SetSongPosition(bookmarkPosition) end elseif event.button == "EffectUp" and event.type == "InputEventType_FirstPress" then - SCREENMAN:GetTopScreen():AddToPracticeRate(0.05) + SCREENMAN:GetTopScreen():AddToRate(0.05) elseif event.button == "EffectDown" and event.type == "InputEventType_FirstPress" then - SCREENMAN:GetTopScreen():AddToPracticeRate(-0.05) + SCREENMAN:GetTopScreen():AddToRate(-0.05) end return false end @@ -1047,7 +1047,7 @@ pm[#pm + 1] = end, MouseLeftClickMessageCommand = function(self) if isOver(self) then - SCREENMAN:GetTopScreen():SetPreviewNoteFieldMusicPosition(self:GetX() * musicratio) + SCREENMAN:GetTopScreen():SetSongPosition(self:GetX() * musicratio) end end, MouseRightClickMessageCommand = function(self) @@ -1056,7 +1056,7 @@ pm[#pm + 1] = self:GetParent():GetChild("BookmarkPos"):queuecommand("Set") else if not (allowedCustomization) then - SCREENMAN:GetTopScreen():TogglePracticePause() + SCREENMAN:GetTopScreen():TogglePause() end end end diff --git a/src/Etterna/Screen/Gameplay/ScreenGameplayPractice.cpp b/src/Etterna/Screen/Gameplay/ScreenGameplayPractice.cpp index e107751b55..59b1f926ff 100644 --- a/src/Etterna/Screen/Gameplay/ScreenGameplayPractice.cpp +++ b/src/Etterna/Screen/Gameplay/ScreenGameplayPractice.cpp @@ -118,7 +118,9 @@ ScreenGameplayPractice::Update(float fDeltaTime) } void -ScreenGameplayPractice::SetupNoteDataFromRow(Steps* pSteps, int row) +ScreenGameplayPractice::SetupNoteDataFromRow(Steps* pSteps, + int minRow, + int maxRow) { NoteData originalNoteData; pSteps->GetNoteData(originalNoteData); @@ -128,6 +130,10 @@ ScreenGameplayPractice::SetupNoteDataFromRow(Steps* pSteps, int row) pStyle->GetTransformedNoteDataForStyle( m_vPlayerInfo.GetStepsAndTrailIndex(), originalNoteData, ndTransformed); + m_vPlayerInfo.GetPlayerState()->Update(0); + + NoteDataUtil::RemoveAllButRange(ndTransformed, minRow, maxRow); + // load player { m_vPlayerInfo.m_NoteData = ndTransformed; @@ -165,7 +171,7 @@ ScreenGameplayPractice::SetupNoteDataFromRow(Steps* pSteps, int row) } void -ScreenGameplayPractice::TogglePracticePause() +ScreenGameplayPractice::TogglePause() { // True if we were paused before now bool oldPause = GAMESTATE->GetPaused(); @@ -202,13 +208,22 @@ ScreenGameplayPractice::TogglePracticePause() } void -ScreenGameplayPractice::SetPracticeSongPosition(float newPositionSeconds) +ScreenGameplayPractice::SetSongPosition(float newSongPositionSeconds, + float noteDelay) { - SOUND->SetSoundPosition(m_pSoundMusic, newPositionSeconds); + SOUND->SetSoundPosition(m_pSoundMusic, newSongPositionSeconds - noteDelay); + UpdateSongPosition(0); bool isPaused = GAMESTATE->GetPaused(); m_pSoundMusic->Pause(isPaused); + Steps* pSteps = GAMESTATE->m_pCurSteps; + TimingData* pTiming = pSteps->GetTimingData(); + const float fSongBeat = GAMESTATE->m_Position.m_fSongBeat; + const float fNotesBeat = + pTiming->GetBeatFromElapsedTime(newSongPositionSeconds); + const int rowNow = BeatToNoteRow(fNotesBeat); + SetupNoteDataFromRow(pSteps, rowNow); m_vPlayerInfo.m_pPlayer->RenderAllNotesIgnoreScores(); // curwifescore sent via judgment msgs is stored in player @@ -243,7 +258,7 @@ ScreenGameplayPractice::SetPracticeSongPosition(float newPositionSeconds) } float -ScreenGameplayPractice::AddToPracticeRate(float amountAdded) +ScreenGameplayPractice::AddToRate(float amountAdded) { float rate = GAMESTATE->m_SongOptions.GetCurrent().m_fMusicRate; @@ -295,31 +310,31 @@ ScreenGameplayPractice::AddToPracticeRate(float amountAdded) class LunaScreenGameplayPractice : public Luna { public: - static int SetPreviewNoteFieldMusicPosition(T* p, lua_State* L) + static int SetSongPosition(T* p, lua_State* L) { float given = FArg(1); - p->SetPracticeSongPosition(given); + p->SetSongPosition(given); return 0; } - static int AddToPracticeRate(T* p, lua_State* L) + static int AddToRate(T* p, lua_State* L) { float rate = FArg(1); - lua_pushnumber(L, p->AddToPracticeRate(rate)); + lua_pushnumber(L, p->AddToRate(rate)); return 1; } - static int TogglePracticePause(T* p, lua_State* L) + static int TogglePause(T* p, lua_State* L) { - p->TogglePracticePause(); + p->TogglePause(); return 0; } LunaScreenGameplayPractice() { - ADD_METHOD(SetPreviewNoteFieldMusicPosition); - ADD_METHOD(AddToPracticeRate); - ADD_METHOD(TogglePracticePause); + ADD_METHOD(SetSongPosition); + ADD_METHOD(AddToRate); + ADD_METHOD(TogglePause); } }; diff --git a/src/Etterna/Screen/Gameplay/ScreenGameplayPractice.h b/src/Etterna/Screen/Gameplay/ScreenGameplayPractice.h index ad55379bb6..187fe5970f 100644 --- a/src/Etterna/Screen/Gameplay/ScreenGameplayPractice.h +++ b/src/Etterna/Screen/Gameplay/ScreenGameplayPractice.h @@ -25,16 +25,17 @@ class ScreenGameplayPractice : public ScreenGameplay // Set the playback rate in the middle of gameplay float SetRate(float newRate); - // Set the playback rate in the middle of gameplay, in practice mode only - float AddToPracticeRate(float amountAdded); - // Move the current position of the song in the middle of gameplay, in - // practice mode only - void SetPracticeSongPosition(float newPositionSeconds); + // 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); // Toggle pause - void TogglePracticePause(); + void TogglePause(); protected: - void SetupNoteDataFromRow(Steps* pSteps, int row) override; + void SetupNoteDataFromRow(Steps* pSteps, + int minRow = 0, + int maxrow = MAX_NOTE_ROW); }; #endif