Implement FR #1559561: "GUI: output sample rate widgets"

svn-id: r26056
This commit is contained in:
Eugene Sandulenko 2007-03-10 13:39:38 +00:00
parent 669c34d8c2
commit 5577379ac3
4 changed files with 69 additions and 0 deletions

View File

@ -63,6 +63,8 @@ enum {
static const char *savePeriodLabels[] = { "Never", "every 5 mins", "every 10 mins", "every 15 mins", "every 30 mins", 0 };
static const int savePeriodValues[] = { 0, 5 * 60, 10 * 60, 15 * 60, 30 * 60, -1 };
static const char *outputRateLabels[] = { "Default", "22 kHz", "8 kHz", "11kHz", "44 kHz", "48 kHz", 0 };
static const int outputRateValues[] = { 0, 22050, 8000, 11025, 44100, 48000, -1 };
@ -90,6 +92,7 @@ void OptionsDialog::init() {
_aspectCheckbox = 0;
_enableAudioSettings = false;
_midiPopUp = 0;
_outputRatePopUp = 0;
_enableMIDISettings = false;
_multiMidiCheckbox = 0;
_mt32Checkbox = 0;
@ -173,6 +176,15 @@ void OptionsDialog::open() {
_midiPopUp->setSelected(md->name ? i : 0);
}
if (_outputRatePopUp) {
_outputRatePopUp->setSelected(1);
int value = ConfMan.getInt("output_rate", _domain);
for (int i = 0; outputRateLabels[i]; i++) {
if (value == outputRateValues[i])
_outputRatePopUp->setSelected(i);
}
}
if (_multiMidiCheckbox) {
// Multi midi setting
@ -298,6 +310,17 @@ void OptionsDialog::close() {
}
}
if (_outputRatePopUp) {
if (_enableAudioSettings) {
if (_outputRatePopUp->getSelectedTag() != 0)
ConfMan.setInt("output_rate", _outputRatePopUp->getSelectedTag(), _domain);
else
ConfMan.removeKey("output_rate", _domain);
} else {
ConfMan.removeKey("output_rate", _domain);
}
}
// MIDI options
if (_multiMidiCheckbox) {
if (_enableMIDISettings) {
@ -424,6 +447,7 @@ void OptionsDialog::setAudioSettingsState(bool enabled) {
_enableAudioSettings = enabled;
_midiPopUp->setEnabled(enabled);
_outputRatePopUp->setEnabled(enabled);
}
void OptionsDialog::setMIDISettingsState(bool enabled) {
@ -521,6 +545,13 @@ void OptionsDialog::addAudioControls(GuiObject *boss, const String &prefix) {
md++;
}
// Sample rate settings
_outputRatePopUp = new PopUpWidget(boss, prefix + "auSampleRatePopup", "Output rate: ", labelWidth);
for (int i = 0; outputRateLabels[i]; i++) {
_outputRatePopUp->appendEntry(outputRateLabels[i], outputRateValues[i]);
}
_enableAudioSettings = true;
}
@ -612,6 +643,8 @@ void OptionsDialog::reflowLayout() {
if (_midiPopUp)
_midiPopUp->changeLabelWidth(labelWidth);
if (_outputRatePopUp)
_outputRatePopUp->changeLabelWidth(labelWidth);
if (_gfxPopUp)
_gfxPopUp->changeLabelWidth(labelWidth);
if (_renderModePopUp)
@ -764,10 +797,14 @@ void GlobalOptionsDialog::close() {
String themePath(_themePath->getLabel());
if (!themePath.empty() && (themePath != "None"))
ConfMan.set("themepath", themePath, _domain);
else
ConfMan.removeKey("themepath", _domain);
String extraPath(_extraPath->getLabel());
if (!extraPath.empty() && (extraPath != "None"))
ConfMan.set("extrapath", extraPath, _domain);
else
ConfMan.removeKey("extrapath", _domain);
ConfMan.setInt("autosave_period", _autosavePeriodPopUp->getSelectedTag(), _domain);
}

View File

@ -93,6 +93,7 @@ private:
//
bool _enableAudioSettings;
PopUpWidget *_midiPopUp;
PopUpWidget *_outputRatePopUp;
//
// MIDI controls

View File

@ -55,6 +55,32 @@ const char *Theme::_defaultConfigINI =
"def_vcAudioTabSpacing=2\n"
"use=XxY\n"
"\n"
"# Override audio tab\n"
"set_parent=gameoptions\n"
"vBorder=5\n"
"\n"
"# audio tab\n"
"opYoffset=vBorder\n"
"useWithPrefix=audioControls globaloptions_\n"
"useWithPrefix=subtitleControls globaloptions_\n"
"\n"
"# volume tab\n"
"opYoffset=vBorder\n"
"useWithPrefix=volumeControls globaloptions_\n"
"\n"
"# audio tab\n"
"opYoffset=vBorder\n"
"gameoptions_audioCheckbox=gox opYoffset (kFontHeight + 10 + 180) buttonHeight\n"
"opYoffset=(opYoffset + buttonHeight + 6)\n"
"useWithPrefix=audioControls gameoptions_\n"
"useWithPrefix=subtitleControls gameoptions_\n"
"\n"
"# volume tab\n"
"opYoffset=vBorder\n"
"gameoptions_volumeCheckbox=gox opYoffset (kFontHeight + 10 + 190) buttonHeight\n"
"opYoffset=(opYoffset + buttonHeight + 6)\n"
"useWithPrefix=volumeControls gameoptions_\n"
"\n"
"TabWidget.tabWidth=0\n"
"TabWidget.tabHeight=16\n"
"TabWidget.titleVPad=2\n"
@ -348,6 +374,8 @@ const char *Theme::_defaultConfigINI =
"auw=(parent.w - 2 * 10)\n"
"auMidiPopup=(aux - 5) (opYoffset - 1) (auw + 5) (kLineHeight + 2)\n"
"opYoffset=(opYoffset + buttonHeight + 4)\n"
"auSampleRatePopup=(aux - 5) (opYoffset - 1) (auw + 5) (kLineHeight + 2)\n"
"opYoffset=(opYoffset + buttonHeight + 4)\n"
"\n"
"[volumeControls]\n"
"vctextw=(95 + vcAudioTabIndent)\n"

View File

@ -466,6 +466,8 @@ aux=(opXoffset + 10)
auw=(parent.w - aux - 30)
auMidiPopup=(aux) (opYoffset - 1) (auw + 5) kPopUpHeight
opYoffset=(opYoffset + buttonHeight + 4)
auSampleRatePopup=(aux) (opYoffset - 1) (auw + 5) kPopUpHeight
opYoffset=(opYoffset + buttonHeight + 4)
[volumeControls]
vctextw=110
@ -553,6 +555,7 @@ use=extra
pix_checkbox_empty="checkbox_empty320.bmp"
pix_checkbox_checked="checkbox_checked320.bmp"
pix_cursor_image="cursor320.bmp"
def_volumeControlsInAudio=false
# NES resoltuion
[256x240]