1 // Copyright (C) 2003 Dolphin Project.
3 // This program is free software: you can redistribute it and/or modify
4 // it under the terms of the GNU General Public License as published by
5 // the Free Software Foundation, version 2.0.
7 // This program is distributed in the hope that it will be useful,
8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 // GNU General Public License 2.0 for more details.
12 // A copy of the GPL 2.0 should have been included with the program.
13 // If not, see http://www.gnu.org/licenses/
15 // Official SVN repository and contact information can be found at
16 // http://code.google.com/p/dolphin-emu/
20 #include "DSPConfigDlgLLE.h"
22 BEGIN_EVENT_TABLE(DSPConfigDialogLLE
, wxDialog
)
23 EVT_BUTTON(wxID_OK
, DSPConfigDialogLLE::SettingsChanged
)
24 EVT_CHECKBOX(ID_ENABLE_DTK_MUSIC
, DSPConfigDialogLLE::SettingsChanged
)
25 EVT_CHECKBOX(ID_ENABLE_THROTTLE
, DSPConfigDialogLLE::SettingsChanged
)
26 EVT_CHECKBOX(ID_ENABLE_JIT
, DSPConfigDialogLLE::SettingsChanged
)
27 EVT_CHOICE(ID_BACKEND
, DSPConfigDialogLLE::BackendChanged
)
28 EVT_COMMAND_SCROLL(ID_VOLUME
, DSPConfigDialogLLE::VolumeChanged
)
31 DSPConfigDialogLLE::DSPConfigDialogLLE(wxWindow
*parent
, wxWindowID id
, const wxString
&title
, const wxPoint
&position
, const wxSize
& size
, long style
)
32 : wxDialog(parent
, id
, title
, position
, size
, style
)
34 // Load config settings
37 m_OK
= new wxButton(this, wxID_OK
, wxT("OK"), wxDefaultPosition
, wxDefaultSize
, 0, wxDefaultValidator
);
39 wxStaticBoxSizer
*sbSettings
= new wxStaticBoxSizer(wxVERTICAL
, this, wxT("Sound Settings"));
40 wxStaticBoxSizer
*sbSettingsV
= new wxStaticBoxSizer(wxVERTICAL
, this, wxT("Volume"));
43 m_buttonEnableDTKMusic
= new wxCheckBox(this, ID_ENABLE_DTK_MUSIC
, wxT("Enable DTK Music"), wxDefaultPosition
, wxDefaultSize
, 0, wxDefaultValidator
);
44 m_buttonEnableThrottle
= new wxCheckBox(this, ID_ENABLE_THROTTLE
, wxT("Enable Audio Throttle"), wxDefaultPosition
, wxDefaultSize
, 0, wxDefaultValidator
);
45 m_buttonEnableJIT
= new wxCheckBox(this, ID_ENABLE_JIT
, wxT("Enable JIT Dynarec"), wxDefaultPosition
, wxDefaultSize
, 0, wxDefaultValidator
);
46 wxStaticText
*BackendText
= new wxStaticText(this, wxID_ANY
, wxT("Audio Backend"), wxDefaultPosition
, wxDefaultSize
, 0);
47 m_BackendSelection
= new wxChoice(this, ID_BACKEND
, wxDefaultPosition
, wxSize(110, 20), wxArrayBackends
, 0, wxDefaultValidator
, wxEmptyString
);
49 m_volumeSlider
= new wxSlider(this, ID_VOLUME
, ac_Config
.m_Volume
, 1, 100, wxDefaultPosition
, wxDefaultSize
, wxSL_VERTICAL
|wxSL_INVERSE
);
50 m_volumeSlider
->Enable(SupportsVolumeChanges(ac_Config
.sBackend
));
51 m_volumeText
= new wxStaticText(this, wxID_ANY
, wxString::Format(wxT("%d %%"), ac_Config
.m_Volume
), wxDefaultPosition
, wxDefaultSize
, 0);
54 m_buttonEnableDTKMusic
->SetValue(ac_Config
.m_EnableDTKMusic
? true : false);
55 m_buttonEnableThrottle
->SetValue(ac_Config
.m_EnableThrottle
? true : false);
56 m_buttonEnableJIT
->SetValue(ac_Config
.m_EnableJIT
? true : false);
59 m_buttonEnableDTKMusic
->SetToolTip(wxT("This is used to play music tracks, like BGM."));
60 m_buttonEnableThrottle
->SetToolTip(wxT("This is used to control game speed by sound throttle.\n")
61 wxT("Disabling this could cause abnormal game speed, such as too fast.\n")
62 wxT("But sometimes enabling this could cause constant noise.\n")
63 wxT("\nKeyboard Shortcut <TAB>: Hold down to instantly disable Throttle."));
64 m_buttonEnableJIT
->SetToolTip(wxT("Enables dynamic recompilation of DSP code.\n")
65 wxT("Changing this will have no effect while the emulator is running!"));
66 m_BackendSelection
->SetToolTip(wxT("Changing this will have no effect while the emulator is running!"));
67 m_volumeSlider
->SetToolTip(wxT("This setting only affects DSound, OpenAL, and PulseAudio."));
69 // Create sizer and add items to dialog
70 wxBoxSizer
*sMain
= new wxBoxSizer(wxVERTICAL
);
71 wxBoxSizer
*sSettings
= new wxBoxSizer(wxHORIZONTAL
);
72 wxBoxSizer
*sBackend
= new wxBoxSizer(wxHORIZONTAL
);
73 wxBoxSizer
*sButtons
= new wxBoxSizer(wxHORIZONTAL
);
75 sbSettings
->Add(m_buttonEnableDTKMusic
, 0, wxALL
, 5);
76 sbSettings
->Add(m_buttonEnableThrottle
, 0, wxALL
, 5);
77 sbSettings
->Add(m_buttonEnableJIT
, 0, wxALL
, 5);
79 sBackend
->Add(BackendText
, 0, wxALIGN_CENTER
|wxALL
, 5);
80 sBackend
->Add(m_BackendSelection
, 0, wxALL
, 1);
81 sbSettings
->Add(sBackend
, 0, wxALL
, 2);
83 sbSettingsV
->Add(m_volumeSlider
, 1, wxLEFT
|wxRIGHT
|wxALIGN_CENTER
, 6);
84 sbSettingsV
->Add(m_volumeText
, 0, wxALL
|wxALIGN_LEFT
, 4);
86 sSettings
->Add(sbSettings
, 0, wxALL
|wxEXPAND
, 4);
87 sSettings
->Add(sbSettingsV
, 0, wxALL
|wxEXPAND
, 4);
88 sMain
->Add(sSettings
, 0, wxALL
|wxEXPAND
, 4);
90 sButtons
->AddStretchSpacer();
91 sButtons
->Add(m_OK
, 0, wxALL
, 1);
92 sMain
->Add(sButtons
, 0, wxALL
|wxEXPAND
, 4);
93 SetSizerAndFit(sMain
);
99 // Add audio output options
100 void DSPConfigDialogLLE::AddBackend(const char* backend
)
103 m_BackendSelection
->Append(wxString::FromAscii(backend
));
106 int num
= m_BackendSelection
->FindString(wxString::FromAscii(ac_Config
.sBackend
));
108 int num
= m_BackendSelection
->FindString(wxString::FromAscii(ac_Config
.sBackend
.c_str()));
110 m_BackendSelection
->SetSelection(num
);
113 void DSPConfigDialogLLE::ClearBackends()
115 m_BackendSelection
->Clear();
118 DSPConfigDialogLLE::~DSPConfigDialogLLE()
122 void DSPConfigDialogLLE::VolumeChanged(wxScrollEvent
& WXUNUSED(event
))
124 ac_Config
.m_Volume
= m_volumeSlider
->GetValue();
127 m_volumeText
->SetLabel(wxString::Format(wxT("%d %%"), m_volumeSlider
->GetValue()));
130 void DSPConfigDialogLLE::SettingsChanged(wxCommandEvent
& event
)
132 ac_Config
.m_EnableDTKMusic
= m_buttonEnableDTKMusic
->GetValue();
133 ac_Config
.m_EnableThrottle
= m_buttonEnableThrottle
->GetValue();
134 ac_Config
.m_EnableJIT
= m_buttonEnableJIT
->GetValue();
137 strncpy(ac_Config
.sBackend
, m_BackendSelection
->GetStringSelection().mb_str(), 128);
139 ac_Config
.sBackend
= m_BackendSelection
->GetStringSelection().mb_str();
144 if (event
.GetId() == wxID_OK
)
148 bool DSPConfigDialogLLE::SupportsVolumeChanges(std::string backend
)
150 //FIXME: this one should ask the backend whether it supports it.
151 // but getting the backend from string etc. is probably
152 // too much just to enable/disable a stupid slider...
153 return (backend
== BACKEND_DIRECTSOUND
||
154 backend
== BACKEND_OPENAL
||
155 backend
== BACKEND_PULSEAUDIO
);
158 void DSPConfigDialogLLE::BackendChanged(wxCommandEvent
& event
)
160 m_volumeSlider
->Enable(SupportsVolumeChanges(std::string(m_BackendSelection
->GetStringSelection().mb_str())));