Skip to content

Commit

Permalink
Fix hit effects not decaying in the calibration screen
Browse files Browse the repository at this point in the history
  • Loading branch information
ASleepyCat committed Apr 17, 2021
1 parent 8f0fe93 commit e233790
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 63 deletions.
8 changes: 4 additions & 4 deletions Main/include/Track.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
15 changes: 7 additions & 8 deletions Main/src/Game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<TextureRes>();
Expand Down
98 changes: 47 additions & 51 deletions Main/src/Track.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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);
Expand Down Expand Up @@ -131,6 +95,7 @@ bool Track::AsyncLoad()

return loader->Load();
}

bool Track::AsyncFinalize()
{
// Finalizer loading textures/material/etc.
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit e233790

Please sign in to comment.