/** * @brief Opens the audio settings menu. */ void opt_menuAudio (void) { unsigned int wid; /* Create the window. */ wid = window_create( "Audio", -1, -1, AUDIO_WIDTH, AUDIO_HEIGHT ); /* Sound fader. */ if (!sound_disabled) { window_addFader( wid, 20, -40, 160, 20, "fadSound", 0., 1., sound_getVolume(), opt_setSFXLevel ); window_addText( wid, 200, -40, AUDIO_WIDTH-220, 20, 1, "txtSound", NULL, NULL, "Sound Volume" ); } else window_addText( wid, 200, -40, AUDIO_WIDTH-220, 20, 1, "txtSound", NULL, NULL, "Sound Disabled" ); /* Music fader. */ if (!music_disabled) { window_addFader( wid, 20, -80, 160, 20, "fadMusic", 0., 1., music_getVolume(), opt_setMusicLevel ); window_addText( wid, 200, -80, AUDIO_WIDTH-220, 20, 1, "txtMusic", NULL, NULL, "Music Volume" ); } else window_addText( wid, 200, -80, AUDIO_WIDTH-220, 20, 1, "txtMusic", NULL, NULL, "Music Disabled" ); /* Close button */ window_addButton( wid, -20, 20, BUTTON_WIDTH, BUTTON_HEIGHT, "btnClose", "Close", window_close ); }
/** * @brief Callback to set the music level. * * @param wid Window calling the callback. * @param str Name of the widget calling the callback. */ static void opt_setMusicLevel( unsigned int wid, char *str ) { char buf[32]; double vol; /* Update fader. */ vol = window_getFaderValue(wid, str); music_volume(vol); /* Update message. */ snprintf( buf, sizeof(buf), "Music Volume: %.2f", music_getVolume() ); window_modifyText( wid, "txtMusic", buf ); }
/** * @brief Updates the audio widgets. */ static void opt_audioUpdate( unsigned int wid, char *str ) { (void) str; /* Faders. */ window_faderValue( wid, "fadSound", sound_getVolume() ); window_faderValue( wid, "fadMusic", music_getVolume() ); /* Checkboxkes. */ window_checkboxSet( wid, "chkNosound", conf.nosound ); window_checkboxSet( wid, "chkEFX", conf.al_efx ); /* List. */ toolkit_setList( wid, "lstSound", (conf.sound_backend==NULL) ? "none" : conf.sound_backend ); }
/** * @brief Opens the audio settings menu. */ static void opt_audio( unsigned int wid ) { (void) wid; int i, j; int cw; int w, h, y, x, l; char buf[32], **s; const char *str; /* Get size. */ window_dimWindow( wid, &w, &h ); /* Close button */ window_addButton( wid, -20, 20, BUTTON_WIDTH, BUTTON_HEIGHT, "btnClose", "Close", opt_close ); window_addButton( wid, -20 - 1*(BUTTON_WIDTH+20), 20, BUTTON_WIDTH, BUTTON_HEIGHT, "btnApply", "Apply", opt_audioSave ); window_addButton( wid, -20 - 2*(BUTTON_WIDTH+20), 20, BUTTON_WIDTH, BUTTON_HEIGHT, "btnDefaults", "Defaults", opt_audioDefaults ); /* General options. */ cw = (w-60)/2; x = 20; y = -60; window_addText( wid, x+20, y, cw, 20, 0, "txtSGeneral", NULL, &cDConsole, "General" ); y -= 30; window_addCheckbox( wid, x, y, cw, 20, "chkNosound", "Disable all sound/music", NULL, conf.nosound ); y -= 30; str = "Backends"; l = gl_printWidthRaw( NULL, str ); window_addText( wid, x, y, l, 40, 0, "txtSBackends", NULL, NULL, str ); l += 10; i = 0; j = 0; s = malloc(sizeof(char*)*2); #if USE_OPENAL if (strcmp(conf.sound_backend,"openal")==0) j = i; s[i++] = strdup("openal"); #endif /* USE_OPENAL */ #if USE_SDLMIX if (strcmp(conf.sound_backend,"sdlmix")==0) j = i; s[i++] = strdup("sdlmix"); #endif /* USE_SDLMIX */ if (i==0) s[i++] = strdup("none"); window_addList( wid, x+l, y, cw-(x+l), 40, "lstSound", s, i, j, NULL ); y -= 50; /* OpenAL options. */ window_addText( wid, x+20, y, cw, 20, 0, "txtSOpenal", NULL, &cDConsole, "OpenAL" ); y -= 30; window_addCheckbox( wid, x, y, cw, 20, "chkEFX", "EFX (More CPU)", NULL, conf.al_efx ); y -= 20; /* Sound levels. */ x = 20 + cw + 20; y = -60; window_addText( wid, x+20, y, 100, 20, 0, "txtSVolume", NULL, &cDConsole, "Volume Levels" ); y -= 30; /* Sound fader. */ opt_audioLevelStr( buf, sizeof(buf), 0, sound_getVolume() ); window_addText( wid, x, y, cw, 20, 1, "txtSound", NULL, NULL, buf ); y -= 20; window_addFader( wid, x, y, cw, 20, "fadSound", 0., 1., sound_getVolume(), opt_setAudioLevel ); window_faderScrollDone( wid, "fadSound", opt_beep ); y -= 40; /* Music fader. */ opt_audioLevelStr( buf, sizeof(buf), 1, music_getVolume() ); window_addText( wid, x, y, cw, 20, 1, "txtMusic", NULL, NULL, buf ); y -= 20; window_addFader( wid, x, y, cw, 20, "fadMusic", 0., 1., music_getVolume(), opt_setAudioLevel ); y -= 20; /* Restart text. */ window_addText( wid, 20, 10, 3*(BUTTON_WIDTH + 20), 30, 0, "txtRestart", &gl_smallFont, &cBlack, NULL ); }