Skip to content

Commit e233790

Browse files
committed
Fix hit effects not decaying in the calibration screen
1 parent 8f0fe93 commit e233790

File tree

3 files changed

+58
-63
lines changed

3 files changed

+58
-63
lines changed

Main/include/Track.hpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ struct ButtonHitEffect : TimedEffect
3434

3535
uint32 buttonCode; // Only used for Draw
3636
Color color;
37-
float delayFadeDuration;
37+
float delayFadeDuration = 0;
3838
bool held = false;
3939
float hitEffectDuration;
40-
float alphaScale;
40+
float alphaScale = 1;
4141
};
4242

4343
// Button hit rating effect
@@ -203,8 +203,8 @@ class Track : Unique, public IAsyncLoadable
203203
// Track Origin position
204204
Transform trackOrigin;
205205

206-
bool hitEffectAutoplay;
207-
float scrollSpeed;
206+
bool hitEffectAutoplay = false;
207+
float scrollSpeed = 0;
208208

209209
private:
210210
// Laser track generators

Main/src/Game.cpp

+7-8
Original file line numberDiff line numberDiff line change
@@ -479,14 +479,13 @@ class Game_Impl : public Game
479479

480480
m_track->distantButtonScale = g_gameConfig.GetFloat(GameConfigKeys::DistantButtonScale);
481481
m_showCover = g_gameConfig.GetBool(GameConfigKeys::ShowCover);
482-
483-
g_input.OnButtonReleased.Add(m_track, &Track::OnButtonReleased);
484-
if (m_delayedHitEffects)
485-
{
486-
m_scoring.OnHoldEnter.Add(m_track, &Track::OnHoldEnter);
487-
if (m_scoring.autoplayInfo.IsAutoplayButtons())
488-
m_scoring.OnHoldLeave.Add(m_track, &Track::OnButtonReleased);
489-
}
482+
483+
if (m_delayedHitEffects)
484+
{
485+
m_scoring.OnHoldEnter.Add(m_track, &Track::OnHoldEnter);
486+
if (m_scoring.autoplayInfo.IsAutoplayButtons())
487+
m_scoring.OnHoldLeave.Add(m_track, &Track::OnButtonReleased);
488+
}
490489

491490
#ifdef EMBEDDED
492491
basicParticleTexture = Ref<TextureRes>();

Main/src/Track.cpp

+47-51
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,13 @@ Track::Track()
2424

2525
Track::~Track()
2626
{
27-
if(loader)
28-
delete loader;
27+
delete loader;
2928

30-
for(uint32 i = 0; i < 2; i++)
31-
{
32-
if(m_laserTrackBuilder[i])
33-
delete m_laserTrackBuilder[i];
34-
}
35-
for(auto it = m_hitEffects.begin(); it != m_hitEffects.end(); it++)
36-
{
37-
delete *it;
38-
}
39-
if(timedHitEffect)
40-
delete timedHitEffect;
29+
for (auto & i : m_laserTrackBuilder)
30+
delete i;
31+
for (auto & m_hitEffect : m_hitEffects)
32+
delete m_hitEffect;
33+
delete timedHitEffect;
4134
}
4235

4336
bool Track::AsyncLoad()
@@ -49,35 +42,6 @@ bool Track::AsyncLoad()
4942
laserHues[0] = g_gameConfig.GetFloat(GameConfigKeys::Laser0Color);
5043
laserHues[1] = g_gameConfig.GetFloat(GameConfigKeys::Laser1Color);
5144
m_btOverFxScale = Math::Clamp(g_gameConfig.GetFloat(GameConfigKeys::BTOverFXScale), 0.01f, 1.0f);
52-
bool delayedHitEffects = g_gameConfig.GetBool(GameConfigKeys::DelayedHitEffects);
53-
54-
for (int i = 0; i < 6; ++i)
55-
{
56-
ButtonHitEffect& bfx = m_buttonHitEffects[i];
57-
if (delayedHitEffects)
58-
{
59-
if (i < 4)
60-
{
61-
bfx.delayFadeDuration = BT_DELAY_FADE_DURATION;
62-
bfx.hitEffectDuration = BT_HIT_EFFECT_DURATION;
63-
bfx.alphaScale = 0.6f; // Ranges from 0.6 to 0.85 depending on hispeed
64-
}
65-
else
66-
{
67-
bfx.delayFadeDuration = FX_DELAY_FADE_DURATION;
68-
bfx.hitEffectDuration = FX_HIT_EFFECT_DURATION;
69-
bfx.alphaScale = 0.45f;
70-
}
71-
}
72-
else
73-
{
74-
bfx.delayFadeDuration = 0;
75-
bfx.hitEffectDuration = 7 / 60.f;
76-
bfx.alphaScale = 1;
77-
}
78-
bfx.buttonCode = i;
79-
bfx.track = this;
80-
}
8145

8246
for (uint32 i = 0; i < 2; i++)
8347
laserColors[i] = Color::FromHSV(laserHues[i],1.0,1.0);
@@ -131,6 +95,7 @@ bool Track::AsyncLoad()
13195

13296
return loader->Load();
13397
}
98+
13499
bool Track::AsyncFinalize()
135100
{
136101
// Finalizer loading textures/material/etc.
@@ -173,18 +138,18 @@ bool Track::AsyncFinalize()
173138

174139
holdButtonMaterial->opaque = false;
175140

176-
for (uint32 i = 0; i < 2; i++)
141+
for (auto &laserTexture : laserTextures)
177142
{
178-
laserTextures[i]->SetMipmaps(true);
179-
laserTextures[i]->SetFilter(true, true, 16.0f);
180-
laserTextures[i]->SetWrap(TextureWrap::Clamp, TextureWrap::Repeat);
143+
laserTexture->SetMipmaps(true);
144+
laserTexture->SetFilter(true, true, 16.0f);
145+
laserTexture->SetWrap(TextureWrap::Clamp, TextureWrap::Repeat);
181146
}
182147

183-
for(uint32 i = 0; i < 4; i++)
148+
for (auto &laserTailTexture : laserTailTextures)
184149
{
185-
laserTailTextures[i]->SetMipmaps(true);
186-
laserTailTextures[i]->SetFilter(true, true, 16.0f);
187-
laserTailTextures[i]->SetWrap(TextureWrap::Clamp, TextureWrap::Clamp);
150+
laserTailTexture->SetMipmaps(true);
151+
laserTailTexture->SetFilter(true, true, 16.0f);
152+
laserTailTexture->SetWrap(TextureWrap::Clamp, TextureWrap::Clamp);
188153
}
189154

190155
// Track and sprite material (all transparent)
@@ -255,11 +220,42 @@ bool Track::AsyncFinalize()
255220
whiteTexture = TextureRes::Create(g_gl);
256221
whiteTexture->SetData({ 1,1 }, (void*)whiteData);
257222

258-
259223
timedHitEffect = new TimedHitEffect(false);
260224
timedHitEffect->time = 0;
261225
timedHitEffect->track = this;
262226

227+
g_input.OnButtonReleased.Add(this, &Track::OnButtonReleased);
228+
229+
bool delayedHitEffects = g_gameConfig.GetBool(GameConfigKeys::DelayedHitEffects);
230+
231+
for (int i = 0; i < 6; ++i)
232+
{
233+
ButtonHitEffect& bfx = m_buttonHitEffects[i];
234+
if (delayedHitEffects)
235+
{
236+
if (i < 4)
237+
{
238+
bfx.delayFadeDuration = BT_DELAY_FADE_DURATION;
239+
bfx.hitEffectDuration = BT_HIT_EFFECT_DURATION;
240+
bfx.alphaScale = 0.6f; // Ranges from 0.6 to 0.85 depending on hispeed
241+
}
242+
else
243+
{
244+
bfx.delayFadeDuration = FX_DELAY_FADE_DURATION;
245+
bfx.hitEffectDuration = FX_HIT_EFFECT_DURATION;
246+
bfx.alphaScale = 0.45f;
247+
}
248+
}
249+
else
250+
{
251+
bfx.delayFadeDuration = 0;
252+
bfx.hitEffectDuration = 7 / 60.f;
253+
bfx.alphaScale = 1;
254+
}
255+
bfx.buttonCode = i;
256+
bfx.track = this;
257+
}
258+
263259
return success;
264260
}
265261
void Track::Tick(class BeatmapPlayback& playback, float deltaTime)

0 commit comments

Comments
 (0)