1
0
mirror of synced 2024-12-05 04:18:06 +01:00
OpenTaiko/TJAPlayer3/Common/ConfigIniToSoundGroupLevelControllerBinder.cs

68 lines
3.2 KiB
C#
Raw Normal View History

2021-09-21 00:16:38 +02:00
using System;
using FDK;
namespace TJAPlayer3
{
/// <summary>
/// The ConfigIniToSoundGroupLevelControllerBinder allows for updated sound
/// group level values, and keyboard sound level adjustment increment
/// values, to flow between CConfigIni and the SoundGroupLevelController
/// without either of those two classes being aware of one another.
/// See those classes properties, methods, and events for more details.
/// </summary>
internal static class ConfigIniToSoundGroupLevelControllerBinder
{
internal static void Bind(CConfigIni configIni, SoundGroupLevelController soundGroupLevelController)
{
soundGroupLevelController.SetLevel(ESoundGroup.SoundEffect, configIni.SoundEffectLevel);
soundGroupLevelController.SetLevel(ESoundGroup.Voice, configIni.VoiceLevel);
soundGroupLevelController.SetLevel(ESoundGroup.SongPreview, configIni.SongPreviewLevel);
2021-09-21 00:16:38 +02:00
soundGroupLevelController.SetLevel(ESoundGroup.SongPlayback, configIni.SongPlaybackLevel);
soundGroupLevelController.SetKeyboardSoundLevelIncrement(configIni.KeyboardSoundLevelIncrement);
configIni.PropertyChanged += (sender, args) =>
{
switch (args.PropertyName)
{
case nameof(CConfigIni.SoundEffectLevel):
soundGroupLevelController.SetLevel(ESoundGroup.SoundEffect, configIni.SoundEffectLevel);
break;
case nameof(CConfigIni.VoiceLevel):
soundGroupLevelController.SetLevel(ESoundGroup.Voice, configIni.VoiceLevel);
break;
case nameof(CConfigIni.SongPreviewLevel):
soundGroupLevelController.SetLevel(ESoundGroup.SongPreview, configIni.SongPreviewLevel);
2021-09-21 00:16:38 +02:00
break;
case nameof(CConfigIni.SongPlaybackLevel):
soundGroupLevelController.SetLevel(ESoundGroup.SongPlayback, configIni.SongPlaybackLevel);
break;
case nameof(CConfigIni.KeyboardSoundLevelIncrement):
soundGroupLevelController.SetKeyboardSoundLevelIncrement(configIni.KeyboardSoundLevelIncrement);
break;
}
};
soundGroupLevelController.LevelChanged += (sender, args) =>
{
switch (args.SoundGroup)
{
case ESoundGroup.SoundEffect:
configIni.SoundEffectLevel = args.Level;
break;
case ESoundGroup.Voice:
configIni.VoiceLevel = args.Level;
break;
case ESoundGroup.SongPreview:
configIni.SongPreviewLevel = args.Level;
2021-09-21 00:16:38 +02:00
break;
case ESoundGroup.SongPlayback:
configIni.SongPlaybackLevel = args.Level;
break;
default:
throw new ArgumentOutOfRangeException();
}
};
}
}
}