From 278c3c83306dbca4da5775098b82ef11a49731a4 Mon Sep 17 00:00:00 2001 From: Vezxe Date: Tue, 24 Sep 2024 05:25:43 +0000 Subject: [PATCH] Add and implement hitsound option --- Themes/_fallback/Languages/en.ini | 2 ++ Themes/_fallback/metrics.ini | 3 ++- src/Etterna/Actor/Gameplay/Player.cpp | 9 ++++++++- src/Etterna/Actor/Gameplay/Player.h | 1 + src/Etterna/Screen/Options/ScreenOptionsMasterPrefs.cpp | 1 + 5 files changed, 14 insertions(+), 2 deletions(-) diff --git a/Themes/_fallback/Languages/en.ini b/Themes/_fallback/Languages/en.ini index f09ab226f0..0f9c2f4b28 100644 --- a/Themes/_fallback/Languages/en.ini +++ b/Themes/_fallback/Languages/en.ini @@ -313,6 +313,7 @@ EffectsReceptor=Add alternative behaviors to the receptors and notes. EffectsArrow=Add alternative behaviors to the receptors and notes. EnableAttackSounds=If enabled, a sound effect will play when an attack begins or ends. EnableMineHitSound=If enabled, a sound will play when a mine is stepped on. +HitsoundsEnabled=If enabled, a sound will play when you hit a note successfully. EnablePitchRates=If enabled, changing the rate of a song will change the pitch accordingly. If not enabled, the pitch is not modified. EventMode=When set to &oq;ON&cq;, and you can continue playing forever. Failing will also take you back to the the Select Music or Select Course screen. Exit= @@ -905,6 +906,7 @@ EffectsReceptor=Effects EffectsArrow= EnableAttackSounds=Attack Sounds EnableMineHitSound=Mine Sounds +HitsoundsEnabled=Hitsounds EnablePitchRates=Pitch On Rates Entry %d=Entry %d EventMode=Event Mode diff --git a/Themes/_fallback/metrics.ini b/Themes/_fallback/metrics.ini index c1714968e6..b2d6d283cc 100644 --- a/Themes/_fallback/metrics.ini +++ b/Themes/_fallback/metrics.ini @@ -2206,9 +2206,10 @@ Line14="conf,ShowStats" Line16="conf,AttractSoundFrequency" Line17="lua,SoundVolumeControl()" Line19="conf,EnableMineHitSound" +Line20="conf,HitsoundsEnabled" LineFRGlobal="lua,FrameLimitGlobal()" LineFRGameplay="lua,FrameLimitGameplay()" -Line20="lua,VisualDelaySeconds()" +Line21="lua,VisualDelaySeconds()" LineGO="lua,GlobalOffsetSeconds()" [ScreenOptionsAdvanced] diff --git a/src/Etterna/Actor/Gameplay/Player.cpp b/src/Etterna/Actor/Gameplay/Player.cpp index 00c4f0deee..9effc84630 100644 --- a/src/Etterna/Actor/Gameplay/Player.cpp +++ b/src/Etterna/Actor/Gameplay/Player.cpp @@ -97,6 +97,7 @@ static Preference m_fTimingWindowScale("TimingWindowScale", 1.0F); static Preference1D m_fTimingWindowSeconds(TimingWindowSecondsInit, NUM_TimingWindow); static Preference g_bEnableMineSoundPlayback("EnableMineHitSound", true); +static Preference g_bEnableHitsound("HitsoundsEnabled", false); // moved out of being members of player.h static ThemeMetric GRAY_ARROWS_Y_STANDARD; @@ -348,6 +349,7 @@ Player::Init(const std::string& sType, RageSoundLoadParams SoundParams; SoundParams.m_bSupportPan = true; m_soundMine.Load(THEME->GetPathS(sType, "mine"), true, &SoundParams); + m_soundHit.Load(THEME->GetPathS(sType, "hitsound"), true, &SoundParams); // calculate M-mod speed here, so we can adjust properly on a per-song // basis. @@ -568,7 +570,7 @@ Player::Load() const HighScore* pb = SCOREMAN->GetChartPBAt( GAMESTATE->m_pCurSteps->GetChartKey(), GAMESTATE->m_SongOptions.GetCurrent().m_fMusicRate); - + // the latter condition checks for Grade_Failed, NUM_Grade, Grade_Invalid if (pb == nullptr || pb->GetGrade() >= Grade_Failed) { wifescorepersonalbest = m_pPlayerState->playertargetgoal; @@ -2133,6 +2135,11 @@ Player::Step(int col, MISS_WINDOW_BEGIN_SEC)) { score = TNS_W5; } + if (g_bEnableHitsound){ + if (fSecondsFromExact <= GetWindowSeconds(TW_W3)) { // Play hitsound if player did not cb + m_soundHit.Stop(); + m_soundHit.Play(false); + }} } break; } diff --git a/src/Etterna/Actor/Gameplay/Player.h b/src/Etterna/Actor/Gameplay/Player.h index df2b7886c7..f93c9cf2f7 100644 --- a/src/Etterna/Actor/Gameplay/Player.h +++ b/src/Etterna/Actor/Gameplay/Player.h @@ -285,6 +285,7 @@ class Player : public ActorFrame JudgedRows* m_pJudgedRows; RageSound m_soundMine; + RageSound m_soundHit; std::vector m_vKeysounds; diff --git a/src/Etterna/Screen/Options/ScreenOptionsMasterPrefs.cpp b/src/Etterna/Screen/Options/ScreenOptionsMasterPrefs.cpp index c47192672a..20ed1c9690 100644 --- a/src/Etterna/Screen/Options/ScreenOptionsMasterPrefs.cpp +++ b/src/Etterna/Screen/Options/ScreenOptionsMasterPrefs.cpp @@ -995,6 +995,7 @@ InitializeConfOptions() ADD(c); } ADD(ConfOption("EnableMineHitSound", MovePref, "No", "Yes")); + ADD(ConfOption("HitsoundsEnabled", MovePref, "No", "Yes")); ADD(ConfOption("Invalid", MoveNop, "|Invalid option")); }