Use configured resolution for login/outgame/ingame
[ryzomcore.git] / ryzom / tools / client / client_config / sound_dlg.cpp
blob6d85503988259bd86f64c41170b8f7fde5ff3d4d
1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
17 // sound_dlg.cpp : implementation file
20 #include "stdafx.h"
21 #include "base_dialog.h"
22 #include "client_config.h"
23 #include "sound_dlg.h"
24 #include "cfg_file.h"
26 // ***************************************************************************
27 #define SOUND_BUFFER_STEP 8
28 #define SOUND_BUFFER_NUM_STEP (32/SOUND_BUFFER_STEP)
30 // ***************************************************************************
31 // CSoundDlg dialog
32 // ***************************************************************************
34 CSoundDlg::CSoundDlg(CWnd* pParent /*=NULL*/)
35 : CBaseDialog(CSoundDlg::IDD, pParent)
37 //{{AFX_DATA_INIT(CSoundDlg)
38 SoundOn = FALSE;
39 EAX = FALSE;
40 FMod = FALSE;
41 ForceSoundSoft = FALSE;
42 SoundQualityInt = 1;
43 //}}AFX_DATA_INIT
46 // ***************************************************************************
48 void CSoundDlg::DoDataExchange(CDataExchange* pDX)
50 CDialog::DoDataExchange(pDX);
51 //{{AFX_DATA_MAP(CSoundDlg)
52 DDX_Control(pDX, IDC_SOUND_TEXT_SB, TextSB);
53 DDX_Control(pDX, IDC_SOUND_TEXT_EAX, TextEAX);
54 DDX_Control(pDX, IDC_SOUND_TEXT_FMOD, TextFMod);
55 DDX_Control(pDX, IDC_SOUND_TEXT_FORCESOFT, TextForceSoundSoft);
56 DDX_Control(pDX, IDC_EAX, EAXCtrl);
57 DDX_Control(pDX, IDC_FMOD, FModCtrl);
58 DDX_Control(pDX, IDC_FORCESOUNDSOFT, ForceSoundSoftCtrl);
59 DDX_Check(pDX, IDC_SOUND_ON, SoundOn);
60 DDX_Check(pDX, IDC_EAX, EAX);
61 DDX_Check(pDX, IDC_FMOD, FMod);
62 DDX_Check(pDX, IDC_FORCESOUNDSOFT, ForceSoundSoft);
63 DDX_Control(pDX, IDC_SOUND_QUALITY, SoundQuality);
64 DDX_Control(pDX, IDC_SOUND_QUALITY_VALUE, SoundQualityValue);
65 DDX_Slider(pDX, IDC_SOUND_QUALITY, SoundQualityInt);
66 //}}AFX_DATA_MAP
69 // ***************************************************************************
71 BEGIN_MESSAGE_MAP(CSoundDlg, CDialog)
72 //{{AFX_MSG_MAP(CSoundDlg)
73 ON_WM_HSCROLL()
74 ON_BN_CLICKED(IDC_SOUND_ON, OnSoundOn)
75 ON_BN_CLICKED(IDC_EAX, OnEax)
76 ON_BN_CLICKED(IDC_FMOD, OnFMod)
77 ON_BN_CLICKED(IDC_FORCESOUNDSOFT, OnForceSoundSoft)
78 //}}AFX_MSG_MAP
79 END_MESSAGE_MAP()
81 // ***************************************************************************
82 // CSoundDlg message handlers
83 // ***************************************************************************
85 void CSoundDlg::OnSoundOn()
87 UpdateData (TRUE);
88 updateState ();
89 UpdateData (FALSE);
90 InvalidateConfig ();
93 // ***************************************************************************
95 void CSoundDlg::updateState ()
97 FModCtrl.EnableWindow (SoundOn);
98 ForceSoundSoftCtrl.EnableWindow (SoundOn);
99 EAXCtrl.EnableWindow (SoundOn);
100 SoundQuality.EnableWindow (SoundOn);
101 TextSB.EnableWindow (SoundOn);
102 TextEAX.EnableWindow (SoundOn);
103 TextFMod.EnableWindow (SoundOn);
104 TextForceSoundSoft.EnableWindow (SoundOn);
105 SoundQualityValue.EnableWindow (SoundOn);
107 // Yoyo: temporary avoid FMod ctrl, since always FMod....
108 TextFMod.ShowWindow(SW_HIDE);
109 FModCtrl.ShowWindow(SW_HIDE);
111 ucstring str = NLMISC::toString (getAsNumSoundBuffer()) + " " + NLMISC::CI18N::get ("uiConfigTracks");
112 setWindowText(SoundQualityValue, (WCHAR*)str.c_str());
115 // ***************************************************************************
117 BOOL CSoundDlg::OnInitDialog()
119 CDialog::OnInitDialog();
121 SoundQuality.SetRange(1, SOUND_BUFFER_NUM_STEP);
123 updateState ();
125 return TRUE; // return TRUE unless you set the focus to a control
126 // EXCEPTION: OCX Property Pages should return FALSE
129 // ***************************************************************************
131 void CSoundDlg::OnEax()
133 InvalidateConfig ();
136 // ***************************************************************************
138 void CSoundDlg::OnFMod()
140 InvalidateConfig ();
143 // ***************************************************************************
145 void CSoundDlg::OnForceSoundSoft()
147 InvalidateConfig ();
150 // ***************************************************************************
151 void CSoundDlg::setAsNumSoundBuffer(uint sb)
153 SoundQualityInt= sb/SOUND_BUFFER_STEP;
154 NLMISC::clamp(SoundQualityInt, 1, SOUND_BUFFER_NUM_STEP);
157 // ***************************************************************************
158 uint CSoundDlg::getAsNumSoundBuffer() const
160 return SoundQualityInt * SOUND_BUFFER_STEP;
163 // ***************************************************************************
165 void CSoundDlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
167 UpdateData ();
168 updateState ();
169 UpdateData (FALSE);
170 InvalidateConfig ();
172 CDialog::OnHScroll(nSBCode, nPos, pScrollBar);