mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-12 09:06:55 -04:00
Fix music/sounds not defaulting to 100 volume in misc options (Thanks lavacraft)
This commit is contained in:
parent
2969efcc7e
commit
483d489d99
16
src/Audio.c
16
src/Audio.c
@ -19,6 +19,11 @@
|
|||||||
int Audio_SoundsVolume, Audio_MusicVolume;
|
int Audio_SoundsVolume, Audio_MusicVolume;
|
||||||
static const cc_string audio_dir = String_FromConst("audio");
|
static const cc_string audio_dir = String_FromConst("audio");
|
||||||
|
|
||||||
|
struct Sound {
|
||||||
|
int channels, sampleRate;
|
||||||
|
void* data; cc_uint32 size;
|
||||||
|
};
|
||||||
|
|
||||||
static void ApplyVolume(cc_int16* samples, int count, int volume) {
|
static void ApplyVolume(cc_int16* samples, int count, int volume) {
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -1135,12 +1140,7 @@ static void Sounds_Stop(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void Sounds_Init(void) {
|
static void Sounds_Init(void) {
|
||||||
#ifdef CC_BUILD_WEBAUDIO
|
int volume = Options_GetInt(OPT_SOUND_VOLUME, 0, 100, DEFAULT_SOUNDS_VOLUME);
|
||||||
int volume = Options_GetInt(OPT_SOUND_VOLUME, 0, 100, 0);
|
|
||||||
#else
|
|
||||||
int volume = Options_GetInt(OPT_SOUND_VOLUME, 0, 100, 100);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
Audio_SetSounds(volume);
|
Audio_SetSounds(volume);
|
||||||
Event_Register_(&UserEvents.BlockChanged, NULL, Audio_PlayBlockSound);
|
Event_Register_(&UserEvents.BlockChanged, NULL, Audio_PlayBlockSound);
|
||||||
}
|
}
|
||||||
@ -1355,9 +1355,9 @@ static void Music_Init(void) {
|
|||||||
/* music is delayed between 2 - 7 minutes by default */
|
/* music is delayed between 2 - 7 minutes by default */
|
||||||
music_minDelay = Options_GetInt(OPT_MIN_MUSIC_DELAY, 0, 3600, 120) * MILLIS_PER_SEC;
|
music_minDelay = Options_GetInt(OPT_MIN_MUSIC_DELAY, 0, 3600, 120) * MILLIS_PER_SEC;
|
||||||
music_maxDelay = Options_GetInt(OPT_MAX_MUSIC_DELAY, 0, 3600, 420) * MILLIS_PER_SEC;
|
music_maxDelay = Options_GetInt(OPT_MAX_MUSIC_DELAY, 0, 3600, 420) * MILLIS_PER_SEC;
|
||||||
|
|
||||||
music_waitable = Waitable_Create();
|
music_waitable = Waitable_Create();
|
||||||
volume = Options_GetInt(OPT_MUSIC_VOLUME, 0, 100, 100);
|
|
||||||
|
volume = Options_GetInt(OPT_MUSIC_VOLUME, 0, 100, DEFAULT_MUSIC_VOLUME);
|
||||||
Audio_SetMusic(volume);
|
Audio_SetMusic(volume);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
16
src/Audio.h
16
src/Audio.h
@ -8,10 +8,18 @@ struct IGameComponent;
|
|||||||
extern struct IGameComponent Audio_Component;
|
extern struct IGameComponent Audio_Component;
|
||||||
struct AudioContext;
|
struct AudioContext;
|
||||||
|
|
||||||
struct Sound {
|
#ifdef CC_BUILD_WEBAUDIO
|
||||||
int channels, sampleRate;
|
#define DEFAULT_SOUNDS_VOLUME 0
|
||||||
void* data; cc_uint32 size;
|
#else
|
||||||
};
|
#define DEFAULT_SOUNDS_VOLUME 100
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CC_BUILD_NOMUSIC
|
||||||
|
#define DEFAULT_MUSIC_VOLUME 0
|
||||||
|
#else
|
||||||
|
#define DEFAULT_MUSIC_VOLUME 100
|
||||||
|
#endif
|
||||||
|
|
||||||
struct AudioData {
|
struct AudioData {
|
||||||
void* data; cc_uint32 size; /* the raw 16 bit integer samples */
|
void* data; cc_uint32 size; /* the raw 16 bit integer samples */
|
||||||
int channels;
|
int channels;
|
||||||
|
@ -3134,8 +3134,8 @@ static void MiscSettingsScreen_InitWidgets(struct MenuOptionsScreen* s) {
|
|||||||
void MiscOptionsScreen_Show(void) {
|
void MiscOptionsScreen_Show(void) {
|
||||||
static struct MenuInputDesc descs[9];
|
static struct MenuInputDesc descs[9];
|
||||||
MenuInput_Float(descs[0], 1, 1024, 5);
|
MenuInput_Float(descs[0], 1, 1024, 5);
|
||||||
MenuInput_Int(descs[1], 0, 100, 0);
|
MenuInput_Int(descs[1], 0, 100, DEFAULT_MUSIC_VOLUME);
|
||||||
MenuInput_Int(descs[2], 0, 100, 0);
|
MenuInput_Int(descs[2], 0, 100, DEFAULT_SOUNDS_VOLUME);
|
||||||
#ifdef CC_BUILD_WIN
|
#ifdef CC_BUILD_WIN
|
||||||
MenuInput_Int(descs[7], 1, 200, 40);
|
MenuInput_Int(descs[7], 1, 200, 40);
|
||||||
#else
|
#else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user