Refactor audio module to use built-in music and sound effect identifiers
- Introduced BuiltInMusicModule and BuiltInSfxModule to replace RetailMusicModule and RetailSfxModule. - Updated RetailAssetRegistry and SharewareAssetRegistry to utilize the new built-in modules. - Removed deprecated MusicKey and SfxKey classes, replacing them with Music and SoundEffect enums for better clarity and maintainability. - Adjusted music and sound effect resolution methods to align with the new structure. - Updated audio playback methods in WolfAudio and FlutterAudioAdapter to accept the new Music and SoundEffect types. - Refactored tests to accommodate changes in audio event handling and ensure compatibility with the new identifiers. Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
This commit is contained in:
@@ -25,7 +25,7 @@ void main() {
|
||||
);
|
||||
engine.tick(const Duration(milliseconds: 16));
|
||||
|
||||
expect(audio.sfxIds, contains(WolfSound.getAmmo));
|
||||
expect(audio.sfxIds, contains(SoundEffect.getAmmo));
|
||||
});
|
||||
|
||||
test('plays guard alert when guard notices player', () {
|
||||
@@ -47,7 +47,7 @@ void main() {
|
||||
engine.tick(const Duration(milliseconds: 16));
|
||||
}
|
||||
|
||||
expect(audio.sfxIds, contains(WolfSound.guardHalt));
|
||||
expect(audio.sfxIds, contains(SoundEffect.guardHalt));
|
||||
});
|
||||
|
||||
test('plays dog death sound when dog dies', () {
|
||||
@@ -69,7 +69,7 @@ void main() {
|
||||
|
||||
engine.tick(const Duration(milliseconds: 16));
|
||||
|
||||
expect(audio.sfxIds, contains(WolfSound.dogDeath));
|
||||
expect(audio.sfxIds, contains(SoundEffect.dogDeath));
|
||||
});
|
||||
|
||||
test('plays pushwall sound when triggering a secret wall', () {
|
||||
@@ -90,7 +90,7 @@ void main() {
|
||||
engine.init();
|
||||
engine.tick(const Duration(milliseconds: 16));
|
||||
|
||||
expect(audio.sfxIds, contains(WolfSound.pushWall));
|
||||
expect(audio.sfxIds, contains(SoundEffect.pushWall));
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -134,7 +134,7 @@ WolfEngine _buildEngine({
|
||||
wallGrid: wallGrid,
|
||||
areaGrid: List.generate(64, (_) => List.filled(64, -1)),
|
||||
objectGrid: objectGrid,
|
||||
musicIndex: 0,
|
||||
music: Music.level01,
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -159,7 +159,7 @@ class _CapturingAudio implements EngineAudio {
|
||||
@override
|
||||
WolfensteinData? activeGame;
|
||||
|
||||
final List<int> sfxIds = [];
|
||||
final List<SoundEffect> sfxIds = [];
|
||||
|
||||
@override
|
||||
Future<void> debugSoundTest() async {}
|
||||
@@ -168,14 +168,24 @@ class _CapturingAudio implements EngineAudio {
|
||||
Future<void> init() async {}
|
||||
|
||||
@override
|
||||
void playLevelMusic(WolfLevel level) {}
|
||||
void playLevelMusic(Music music) {}
|
||||
|
||||
@override
|
||||
void playMenuMusic() {}
|
||||
|
||||
@override
|
||||
void playSoundEffect(int sfxId) {
|
||||
sfxIds.add(sfxId);
|
||||
void playSoundEffect(SoundEffect effect) {
|
||||
sfxIds.add(effect);
|
||||
}
|
||||
|
||||
@override
|
||||
void playSoundEffectId(int sfxId) {
|
||||
final effect = SoundEffect.values
|
||||
.where((entry) => entry.retailId == sfxId)
|
||||
.firstOrNull;
|
||||
if (effect != null) {
|
||||
sfxIds.add(effect);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@@ -88,7 +88,7 @@ WolfEngine _buildEngine() {
|
||||
wallGrid: wallGrid,
|
||||
areaGrid: List.generate(64, (_) => List.filled(64, -1)),
|
||||
objectGrid: objectGrid,
|
||||
musicIndex: 0,
|
||||
music: Music.level01,
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -119,13 +119,16 @@ class _SilentAudio implements EngineAudio {
|
||||
Future<void> init() async {}
|
||||
|
||||
@override
|
||||
void playLevelMusic(WolfLevel level) {}
|
||||
void playLevelMusic(Music music) {}
|
||||
|
||||
@override
|
||||
void playMenuMusic() {}
|
||||
|
||||
@override
|
||||
void playSoundEffect(int sfxId) {}
|
||||
void playSoundEffect(SoundEffect effect) {}
|
||||
|
||||
@override
|
||||
void playSoundEffectId(int sfxId) {}
|
||||
|
||||
@override
|
||||
void stopMusic() {}
|
||||
|
||||
@@ -365,14 +365,14 @@ WolfensteinData _buildTestData({required GameVersion gameVersion}) {
|
||||
wallGrid: levelOneWalls,
|
||||
areaGrid: List.generate(64, (_) => List.filled(64, -1)),
|
||||
objectGrid: levelOneObjects,
|
||||
musicIndex: 0,
|
||||
music: Music.level01,
|
||||
),
|
||||
WolfLevel(
|
||||
name: 'Level 2',
|
||||
wallGrid: levelTwoWalls,
|
||||
areaGrid: List.generate(64, (_) => List.filled(64, -1)),
|
||||
objectGrid: levelTwoObjects,
|
||||
musicIndex: 1,
|
||||
music: Music.level02,
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -396,13 +396,16 @@ class _SilentAudio implements EngineAudio {
|
||||
Future<void> init() async {}
|
||||
|
||||
@override
|
||||
void playLevelMusic(WolfLevel level) {}
|
||||
void playLevelMusic(Music music) {}
|
||||
|
||||
@override
|
||||
void playMenuMusic() {}
|
||||
|
||||
@override
|
||||
void playSoundEffect(int sfxId) {}
|
||||
void playSoundEffect(SoundEffect effect) {}
|
||||
|
||||
@override
|
||||
void playSoundEffectId(int sfxId) {}
|
||||
|
||||
@override
|
||||
void stopMusic() {}
|
||||
|
||||
@@ -45,7 +45,7 @@ void main() {
|
||||
wallGrid: wallGrid,
|
||||
areaGrid: List.generate(64, (_) => List.filled(64, -1)),
|
||||
objectGrid: objectGrid,
|
||||
musicIndex: 0,
|
||||
music: Music.level01,
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -45,7 +45,7 @@ void main() {
|
||||
wallGrid: wallGrid,
|
||||
areaGrid: List.generate(64, (_) => List.filled(64, -1)),
|
||||
objectGrid: objectGrid,
|
||||
musicIndex: 0,
|
||||
music: Music.level01,
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user