diff --git a/Main/include/Track.hpp b/Main/include/Track.hpp index e835a93c7..d168630f3 100644 --- a/Main/include/Track.hpp +++ b/Main/include/Track.hpp @@ -34,10 +34,10 @@ struct ButtonHitEffect : TimedEffect uint32 buttonCode; // Only used for Draw Color color; - float delayFadeDuration; + float delayFadeDuration = 0; bool held = false; float hitEffectDuration; - float alphaScale; + float alphaScale = 1; }; // Button hit rating effect @@ -203,8 +203,8 @@ class Track : Unique, public IAsyncLoadable // Track Origin position Transform trackOrigin; - bool hitEffectAutoplay; - float scrollSpeed; + bool hitEffectAutoplay = false; + float scrollSpeed = 0; private: // Laser track generators diff --git a/Main/src/Game.cpp b/Main/src/Game.cpp index 022504040..04aa55657 100755 --- a/Main/src/Game.cpp +++ b/Main/src/Game.cpp @@ -479,14 +479,13 @@ class Game_Impl : public Game m_track->distantButtonScale = g_gameConfig.GetFloat(GameConfigKeys::DistantButtonScale); m_showCover = g_gameConfig.GetBool(GameConfigKeys::ShowCover); - - g_input.OnButtonReleased.Add(m_track, &Track::OnButtonReleased); - if (m_delayedHitEffects) - { - m_scoring.OnHoldEnter.Add(m_track, &Track::OnHoldEnter); - if (m_scoring.autoplayInfo.IsAutoplayButtons()) - m_scoring.OnHoldLeave.Add(m_track, &Track::OnButtonReleased); - } + + if (m_delayedHitEffects) + { + m_scoring.OnHoldEnter.Add(m_track, &Track::OnHoldEnter); + if (m_scoring.autoplayInfo.IsAutoplayButtons()) + m_scoring.OnHoldLeave.Add(m_track, &Track::OnButtonReleased); + } #ifdef EMBEDDED basicParticleTexture = Ref(); diff --git a/Main/src/Track.cpp b/Main/src/Track.cpp index e6a35d11c..06720b2ab 100644 --- a/Main/src/Track.cpp +++ b/Main/src/Track.cpp @@ -24,20 +24,13 @@ Track::Track() Track::~Track() { - if(loader) - delete loader; + delete loader; - for(uint32 i = 0; i < 2; i++) - { - if(m_laserTrackBuilder[i]) - delete m_laserTrackBuilder[i]; - } - for(auto it = m_hitEffects.begin(); it != m_hitEffects.end(); it++) - { - delete *it; - } - if(timedHitEffect) - delete timedHitEffect; + for (auto & i : m_laserTrackBuilder) + delete i; + for (auto & m_hitEffect : m_hitEffects) + delete m_hitEffect; + delete timedHitEffect; } bool Track::AsyncLoad() @@ -49,35 +42,6 @@ bool Track::AsyncLoad() laserHues[0] = g_gameConfig.GetFloat(GameConfigKeys::Laser0Color); laserHues[1] = g_gameConfig.GetFloat(GameConfigKeys::Laser1Color); m_btOverFxScale = Math::Clamp(g_gameConfig.GetFloat(GameConfigKeys::BTOverFXScale), 0.01f, 1.0f); - bool delayedHitEffects = g_gameConfig.GetBool(GameConfigKeys::DelayedHitEffects); - - for (int i = 0; i < 6; ++i) - { - ButtonHitEffect& bfx = m_buttonHitEffects[i]; - if (delayedHitEffects) - { - if (i < 4) - { - bfx.delayFadeDuration = BT_DELAY_FADE_DURATION; - bfx.hitEffectDuration = BT_HIT_EFFECT_DURATION; - bfx.alphaScale = 0.6f; // Ranges from 0.6 to 0.85 depending on hispeed - } - else - { - bfx.delayFadeDuration = FX_DELAY_FADE_DURATION; - bfx.hitEffectDuration = FX_HIT_EFFECT_DURATION; - bfx.alphaScale = 0.45f; - } - } - else - { - bfx.delayFadeDuration = 0; - bfx.hitEffectDuration = 7 / 60.f; - bfx.alphaScale = 1; - } - bfx.buttonCode = i; - bfx.track = this; - } for (uint32 i = 0; i < 2; i++) laserColors[i] = Color::FromHSV(laserHues[i],1.0,1.0); @@ -131,6 +95,7 @@ bool Track::AsyncLoad() return loader->Load(); } + bool Track::AsyncFinalize() { // Finalizer loading textures/material/etc. @@ -173,18 +138,18 @@ bool Track::AsyncFinalize() holdButtonMaterial->opaque = false; - for (uint32 i = 0; i < 2; i++) + for (auto &laserTexture : laserTextures) { - laserTextures[i]->SetMipmaps(true); - laserTextures[i]->SetFilter(true, true, 16.0f); - laserTextures[i]->SetWrap(TextureWrap::Clamp, TextureWrap::Repeat); + laserTexture->SetMipmaps(true); + laserTexture->SetFilter(true, true, 16.0f); + laserTexture->SetWrap(TextureWrap::Clamp, TextureWrap::Repeat); } - for(uint32 i = 0; i < 4; i++) + for (auto &laserTailTexture : laserTailTextures) { - laserTailTextures[i]->SetMipmaps(true); - laserTailTextures[i]->SetFilter(true, true, 16.0f); - laserTailTextures[i]->SetWrap(TextureWrap::Clamp, TextureWrap::Clamp); + laserTailTexture->SetMipmaps(true); + laserTailTexture->SetFilter(true, true, 16.0f); + laserTailTexture->SetWrap(TextureWrap::Clamp, TextureWrap::Clamp); } // Track and sprite material (all transparent) @@ -255,11 +220,42 @@ bool Track::AsyncFinalize() whiteTexture = TextureRes::Create(g_gl); whiteTexture->SetData({ 1,1 }, (void*)whiteData); - timedHitEffect = new TimedHitEffect(false); timedHitEffect->time = 0; timedHitEffect->track = this; + g_input.OnButtonReleased.Add(this, &Track::OnButtonReleased); + + bool delayedHitEffects = g_gameConfig.GetBool(GameConfigKeys::DelayedHitEffects); + + for (int i = 0; i < 6; ++i) + { + ButtonHitEffect& bfx = m_buttonHitEffects[i]; + if (delayedHitEffects) + { + if (i < 4) + { + bfx.delayFadeDuration = BT_DELAY_FADE_DURATION; + bfx.hitEffectDuration = BT_HIT_EFFECT_DURATION; + bfx.alphaScale = 0.6f; // Ranges from 0.6 to 0.85 depending on hispeed + } + else + { + bfx.delayFadeDuration = FX_DELAY_FADE_DURATION; + bfx.hitEffectDuration = FX_HIT_EFFECT_DURATION; + bfx.alphaScale = 0.45f; + } + } + else + { + bfx.delayFadeDuration = 0; + bfx.hitEffectDuration = 7 / 60.f; + bfx.alphaScale = 1; + } + bfx.buttonCode = i; + bfx.track = this; + } + return success; } void Track::Tick(class BeatmapPlayback& playback, float deltaTime)