Revert parts of r5021, OpenAL also uses the Volume slider.

This now enables/disables the slider, depending on chosen Backend. Linux and OSX can now also use the slider to change the Volume of OpenAL. Other Backends do not support Volume changes.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5026 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
j4ck.fr0st 2010-02-07 14:51:12 +00:00
parent 7be712808a
commit fdcfade27a
4 changed files with 43 additions and 37 deletions

View File

@ -25,9 +25,8 @@ BEGIN_EVENT_TABLE(DSPConfigDialogHLE, wxDialog)
EVT_CHECKBOX(ID_ENABLE_DTK_MUSIC, DSPConfigDialogHLE::SettingsChanged)
EVT_CHECKBOX(ID_ENABLE_THROTTLE, DSPConfigDialogHLE::SettingsChanged)
EVT_CHECKBOX(ID_ENABLE_RE0_FIX, DSPConfigDialogHLE::SettingsChanged)
#ifdef _WIN32
EVT_COMBOBOX(wxID_ANY, DSPConfigDialogHLE::BackendChanged)
EVT_COMMAND_SCROLL(ID_VOLUME, DSPConfigDialogHLE::VolumeChanged)
#endif
END_EVENT_TABLE()
DSPConfigDialogHLE::DSPConfigDialogHLE(wxWindow *parent, wxWindowID id, const wxString &title, const wxPoint &position, const wxSize& size, long style)
@ -39,13 +38,7 @@ DSPConfigDialogHLE::DSPConfigDialogHLE(wxWindow *parent, wxWindowID id, const wx
m_OK = new wxButton(this, wxID_OK, wxT("OK"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
wxStaticBoxSizer *sbSettings = new wxStaticBoxSizer(wxVERTICAL, this, wxT("Sound Settings"));
// Unfortunately, DSound is the only API having a volume setting...
// Its better to remove the Volume setting on non-WIN32, since the user might
// be confused about why he cannot change the volume
// (or the dev fixing it might be confused about why it still doesn't work :P)
#ifdef _WIN32
wxStaticBoxSizer *sbSettingsV = new wxStaticBoxSizer(wxVERTICAL, this, wxT("Volume"));
#endif
// Create items
m_buttonEnableHLEAudio = new wxCheckBox(this, ID_ENABLE_HLE_AUDIO, wxT("Enable HLE Audio"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
@ -55,10 +48,9 @@ DSPConfigDialogHLE::DSPConfigDialogHLE(wxWindow *parent, wxWindowID id, const wx
wxStaticText *BackendText = new wxStaticText(this, wxID_ANY, wxT("Audio Backend"), wxDefaultPosition, wxDefaultSize, 0);
m_BackendSelection = new wxComboBox(this, ID_BACKEND, wxEmptyString, wxDefaultPosition, wxSize(90, 20), wxArrayBackends, wxCB_READONLY, wxDefaultValidator);
#ifdef _WIN32
m_volumeText = new wxStaticText(this, wxID_ANY, wxString::Format(wxT("%d %%"), ac_Config.m_Volume), wxDefaultPosition, wxDefaultSize, 0);
m_volumeSlider = new wxSlider(this, ID_VOLUME, ac_Config.m_Volume, 1, 100, wxDefaultPosition, wxDefaultSize, wxSL_VERTICAL|wxSL_INVERSE);
#endif
m_volumeSlider->Enable(SupportsVolumeChanges(ac_Config.sBackend));
m_volumeText = new wxStaticText(this, wxID_ANY, wxString::Format(wxT("%d %%"), ac_Config.m_Volume), wxDefaultPosition, wxDefaultSize, 0);
// Update values
m_buttonEnableHLEAudio->SetValue(g_Config.m_EnableHLEAudio ? true : false);
@ -75,6 +67,7 @@ DSPConfigDialogHLE::DSPConfigDialogHLE(wxWindow *parent, wxWindowID id, const wx
wxT("\nKeyboard Shortcut <TAB>: Hold down to instantly disable Throttle."));
m_buttonEnableRE0Fix->SetToolTip(wxT("This fixes audio in Resident Evil Zero and maybe some other games."));
m_BackendSelection->SetToolTip(wxT("Changing this will have no effect while the emulator is running!"));
m_volumeSlider->SetToolTip(wxT("This setting only affects DSound and OpenAL."));
// Create sizer and add items to dialog
wxBoxSizer *sMain = new wxBoxSizer(wxVERTICAL);
@ -90,12 +83,11 @@ DSPConfigDialogHLE::DSPConfigDialogHLE(wxWindow *parent, wxWindowID id, const wx
sBackend->Add(m_BackendSelection, 0, wxALL, 1);
sbSettings->Add(sBackend, 0, wxALL, 2);
sSettings->Add(sbSettings, 0, wxALL|wxEXPAND, 4);
#ifdef _WIN32
sbSettingsV->Add(m_volumeSlider, 0, wxLEFT|wxRIGHT|wxALIGN_CENTER, 6);
sbSettingsV->Add(m_volumeText, 0, wxALL|wxALIGN_LEFT, 4);
sSettings->Add(sbSettings, 0, wxALL|wxEXPAND, 4);
sSettings->Add(sbSettingsV, 0, wxALL|wxEXPAND, 4);
#endif
sMain->Add(sSettings, 0, wxALL|wxEXPAND, 4);
sButtons->AddStretchSpacer();
@ -125,7 +117,6 @@ DSPConfigDialogHLE::~DSPConfigDialogHLE()
{
}
#ifdef _WIN32
void DSPConfigDialogHLE::VolumeChanged(wxScrollEvent& WXUNUSED(event))
{
ac_Config.m_Volume = m_volumeSlider->GetValue();
@ -133,7 +124,6 @@ void DSPConfigDialogHLE::VolumeChanged(wxScrollEvent& WXUNUSED(event))
m_volumeText->SetLabel(wxString::Format(wxT("%d %%"), m_volumeSlider->GetValue()));
}
#endif
void DSPConfigDialogHLE::SettingsChanged(wxCommandEvent& event)
{
@ -153,3 +143,17 @@ void DSPConfigDialogHLE::SettingsChanged(wxCommandEvent& event)
if (event.GetId() == wxID_OK)
EndModal(wxID_OK);
}
bool DSPConfigDialogHLE::SupportsVolumeChanges(std::string backend)
{
//FIXME: this one should ask the backend whether it supports it.
// but getting the backend from string etc. is probably
// too much just to enable/disable a stupid slider...
return (backend == BACKEND_DIRECTSOUND ||
backend == BACKEND_OPENAL);
}
void DSPConfigDialogHLE::BackendChanged(wxCommandEvent& event)
{
m_volumeSlider->Enable(SupportsVolumeChanges(std::string(m_BackendSelection->GetValue().mb_str())));
}

View File

@ -40,10 +40,8 @@ public:
private:
DECLARE_EVENT_TABLE();
#ifdef _WIN32
wxSlider *m_volumeSlider;
wxStaticText *m_volumeText;
#endif
wxButton *m_OK;
wxCheckBox *m_buttonEnableHLEAudio;
wxCheckBox *m_buttonEnableDTKMusic;
@ -65,9 +63,9 @@ private:
void OnOK(wxCommandEvent& event);
void SettingsChanged(wxCommandEvent& event);
#ifdef _WIN32
void VolumeChanged(wxScrollEvent& event);
#endif
bool SupportsVolumeChanges(std::string backend);
void BackendChanged(wxCommandEvent& event);
};
#endif //__DSP_HLE_CONFIGDIALOG_h__

View File

@ -23,9 +23,8 @@ BEGIN_EVENT_TABLE(DSPConfigDialogLLE, wxDialog)
EVT_BUTTON(wxID_OK, DSPConfigDialogLLE::SettingsChanged)
EVT_CHECKBOX(ID_ENABLE_DTK_MUSIC, DSPConfigDialogLLE::SettingsChanged)
EVT_CHECKBOX(ID_ENABLE_THROTTLE, DSPConfigDialogLLE::SettingsChanged)
#ifdef _WIN32
EVT_COMBOBOX(wxID_ANY, DSPConfigDialogLLE::BackendChanged)
EVT_COMMAND_SCROLL(ID_VOLUME, DSPConfigDialogLLE::VolumeChanged)
#endif
END_EVENT_TABLE()
DSPConfigDialogLLE::DSPConfigDialogLLE(wxWindow *parent, wxWindowID id, const wxString &title, const wxPoint &position, const wxSize& size, long style)
@ -40,10 +39,7 @@ DSPConfigDialogLLE::DSPConfigDialogLLE(wxWindow *parent, wxWindowID id, const wx
m_OK = new wxButton(this, wxID_OK, wxT("OK"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
wxStaticBoxSizer *sbSettings = new wxStaticBoxSizer(wxVERTICAL, this, wxT("Sound Settings"));
// Same as for HLE. Maybe this dialog could be moved into AudioCommon or the likes?
#ifdef _WIN32
wxStaticBoxSizer *sbSettingsV = new wxStaticBoxSizer(wxVERTICAL, this, wxT("Volume"));
#endif
// Create items
m_buttonEnableDTKMusic = new wxCheckBox(this, ID_ENABLE_DTK_MUSIC, wxT("Enable DTK Music"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
@ -51,10 +47,9 @@ DSPConfigDialogLLE::DSPConfigDialogLLE(wxWindow *parent, wxWindowID id, const wx
wxStaticText *BackendText = new wxStaticText(this, wxID_ANY, wxT("Audio Backend"), wxDefaultPosition, wxDefaultSize, 0);
m_BackendSelection = new wxComboBox(this, ID_BACKEND, wxEmptyString, wxDefaultPosition, wxSize(90, 20), wxArrayBackends, wxCB_READONLY, wxDefaultValidator);
#ifdef _WIN32
m_volumeSlider = new wxSlider(this, ID_VOLUME, ac_Config.m_Volume, 1, 100, wxDefaultPosition, wxDefaultSize, wxSL_VERTICAL|wxSL_INVERSE);
m_volumeSlider->Enable(SupportsVolumeChanges(ac_Config.sBackend));
m_volumeText = new wxStaticText(this, wxID_ANY, wxString::Format(wxT("%d %%"), ac_Config.m_Volume), wxDefaultPosition, wxDefaultSize, 0);
#endif
// Update values
m_buttonEnableDTKMusic->SetValue(ac_Config.m_EnableDTKMusic ? true : false);
@ -67,6 +62,7 @@ DSPConfigDialogLLE::DSPConfigDialogLLE(wxWindow *parent, wxWindowID id, const wx
wxT("But sometimes enabling this could cause constant noise.\n")
wxT("\nKeyboard Shortcut <TAB>: Hold down to instantly disable Throttle."));
m_BackendSelection->SetToolTip(wxT("Changing this will have no effect while the emulator is running!"));
m_volumeSlider->SetToolTip(wxT("This setting only affects DSound and OpenAL."));
// Create sizer and add items to dialog
wxBoxSizer *sMain = new wxBoxSizer(wxVERTICAL);
@ -81,13 +77,11 @@ DSPConfigDialogLLE::DSPConfigDialogLLE(wxWindow *parent, wxWindowID id, const wx
sBackend->Add(m_BackendSelection, 0, wxALL, 1);
sbSettings->Add(sBackend, 0, wxALL, 2);
sSettings->Add(sbSettings, 0, wxALL|wxEXPAND, 4);
#ifdef _WIN32
sbSettingsV->Add(m_volumeSlider, 0, wxLEFT|wxRIGHT|wxALIGN_CENTER, 6);
sbSettingsV->Add(m_volumeText, 0, wxALL|wxALIGN_LEFT, 4);
sSettings->Add(sbSettings, 0, wxALL|wxEXPAND, 4);
sSettings->Add(sbSettingsV, 0, wxALL|wxEXPAND, 4);
#endif
sMain->Add(sSettings, 0, wxALL|wxEXPAND, 4);
sButtons->AddStretchSpacer();
@ -119,7 +113,6 @@ DSPConfigDialogLLE::~DSPConfigDialogLLE()
{
}
#ifdef _WIN32
void DSPConfigDialogLLE::VolumeChanged(wxScrollEvent& WXUNUSED(event))
{
ac_Config.m_Volume = m_volumeSlider->GetValue();
@ -127,7 +120,6 @@ void DSPConfigDialogLLE::VolumeChanged(wxScrollEvent& WXUNUSED(event))
m_volumeText->SetLabel(wxString::Format(wxT("%d %%"), m_volumeSlider->GetValue()));
}
#endif
void DSPConfigDialogLLE::SettingsChanged(wxCommandEvent& event)
{
@ -145,3 +137,17 @@ void DSPConfigDialogLLE::SettingsChanged(wxCommandEvent& event)
if (event.GetId() == wxID_OK)
EndModal(wxID_OK);
}
bool DSPConfigDialogLLE::SupportsVolumeChanges(std::string backend)
{
//FIXME: this one should ask the backend whether it supports it.
// but getting the backend from string etc. is probably
// too much just to enable/disable a stupid slider...
return (backend == BACKEND_DIRECTSOUND ||
backend == BACKEND_OPENAL);
}
void DSPConfigDialogLLE::BackendChanged(wxCommandEvent& event)
{
m_volumeSlider->Enable(SupportsVolumeChanges(std::string(m_BackendSelection->GetValue().mb_str())));
}

View File

@ -40,10 +40,8 @@ public:
private:
DECLARE_EVENT_TABLE();
#ifdef _WIN32
wxSlider *m_volumeSlider;
wxStaticText *m_volumeText;
#endif
wxButton *m_OK;
wxCheckBox *m_buttonEnableDTKMusic;
wxCheckBox *m_buttonEnableThrottle;
@ -61,9 +59,9 @@ private:
void OnOK(wxCommandEvent& event);
void SettingsChanged(wxCommandEvent& event);
#ifdef _WIN32
void VolumeChanged(wxScrollEvent& event);
#endif
bool SupportsVolumeChanges(std::string backend);
void BackendChanged(wxCommandEvent& event);
};
#endif //__DSP_LLE_CONFIGDIALOG_h__