@@ -24,20 +24,13 @@ Track::Track()
24
24
25
25
Track::~Track ()
26
26
{
27
- if (loader)
28
- delete loader;
27
+ delete loader;
29
28
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;
41
34
}
42
35
43
36
bool Track::AsyncLoad ()
@@ -49,35 +42,6 @@ bool Track::AsyncLoad()
49
42
laserHues[0 ] = g_gameConfig.GetFloat (GameConfigKeys::Laser0Color);
50
43
laserHues[1 ] = g_gameConfig.GetFloat (GameConfigKeys::Laser1Color);
51
44
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
- }
81
45
82
46
for (uint32 i = 0 ; i < 2 ; i++)
83
47
laserColors[i] = Color::FromHSV (laserHues[i],1.0 ,1.0 );
@@ -131,6 +95,7 @@ bool Track::AsyncLoad()
131
95
132
96
return loader->Load ();
133
97
}
98
+
134
99
bool Track::AsyncFinalize ()
135
100
{
136
101
// Finalizer loading textures/material/etc.
@@ -173,18 +138,18 @@ bool Track::AsyncFinalize()
173
138
174
139
holdButtonMaterial->opaque = false ;
175
140
176
- for (uint32 i = 0 ; i < 2 ; i++ )
141
+ for (auto &laserTexture : laserTextures )
177
142
{
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);
181
146
}
182
147
183
- for (uint32 i = 0 ; i < 4 ; i++ )
148
+ for ( auto &laserTailTexture : laserTailTextures )
184
149
{
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);
188
153
}
189
154
190
155
// Track and sprite material (all transparent)
@@ -255,11 +220,42 @@ bool Track::AsyncFinalize()
255
220
whiteTexture = TextureRes::Create (g_gl);
256
221
whiteTexture->SetData ({ 1 ,1 }, (void *)whiteData);
257
222
258
-
259
223
timedHitEffect = new TimedHitEffect (false );
260
224
timedHitEffect->time = 0 ;
261
225
timedHitEffect->track = this ;
262
226
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
+
263
259
return success;
264
260
}
265
261
void Track::Tick (class BeatmapPlayback & playback, float deltaTime)
0 commit comments