1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
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.
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 // preset_dlg.cpp : implementation file
23 #include "client_config.h"
24 #include "preset_dlg.h"
26 #include "display_dlg.h"
31 using namespace NLMISC
;
33 /////////////////////////////////////////////////////////////////////////////
37 CPresetDlg::CPresetDlg(CWnd
* pParent
/*=NULL*/)
38 : CDialog(CPresetDlg::IDD
, pParent
)
40 //{{AFX_DATA_INIT(CPresetDlg)
41 CPUFrequency
= _T("");
42 SystemMemory
= _T("");
45 HardwareSoundBuffer
= _T("");
50 void CPresetDlg::DoDataExchange(CDataExchange
* pDX
)
52 CDialog::DoDataExchange(pDX
);
53 //{{AFX_DATA_MAP(CPresetDlg)
54 DDX_Control(pDX
, IDOK
, OkCtrl
);
55 DDX_Control(pDX
, IDCANCEL
, CancelCtrl
);
56 DDX_Control(pDX
, IDC_VIDEO_CARD
, VideoCardCtrl
);
57 DDX_Text(pDX
, IDC_CPU_FREQUENCY
, CPUFrequency
);
58 DDX_Text(pDX
, IDC_SYSTEM_MEMORY
, SystemMemory
);
59 DDX_CBIndex(pDX
, IDC_VIDEO_CARD
, VideoCard
);
60 DDX_Text(pDX
, IDC_VIDEO_MEMORY
, VideoMemory
);
61 DDX_Text(pDX
, IDC_HARDWARE_SOUND_BUFFER
, HardwareSoundBuffer
);
66 BEGIN_MESSAGE_MAP(CPresetDlg
, CDialog
)
67 //{{AFX_MSG_MAP(CPresetDlg)
68 ON_BN_CLICKED(IDC_RESET
, OnReset
)
72 /////////////////////////////////////////////////////////////////////////////
73 // CPresetDlg message handlers
75 void CPresetDlg::OnReset()
77 // TODO: Add your control notification handler code here
81 BOOL
CPresetDlg::OnInitDialog()
83 CDialog::OnInitDialog();
85 // Set the video card list
87 for (i
=0; i
<CVideoCard::CardCount
; i
++)
88 VideoCardCtrl
.AddString (GetString (VideoCards
[i
].DisplayString
));
90 // Select the good video card
91 for (VideoCard
=0; VideoCard
<CVideoCard::CardCount
; VideoCard
++)
96 for (j
=0; j
<CVideoCard::TokenCount
; j
++)
98 // Check it is not an empty keyword
99 if (strcmp (VideoCards
[VideoCard
].MatchingTokens
[j
], "") != 0)
101 // Look for the keyword in the tokens
103 strcpy (str
, GLRenderer
.c_str ());
104 const char *token
= strtok( str
, " ");
105 while( token
!= NULL
)
107 if (stricmp (token
, VideoCards
[VideoCard
].MatchingTokens
[j
]) == 0)
114 token
= strtok( NULL
, " ");
124 if (found
&& (j
== CVideoCard::TokenCount
))
129 if (VideoCard
== CVideoCard::CardCount
)
134 return TRUE
; // return TRUE unless you set the focus to a control
135 // EXCEPTION: OCX Property Pages should return FALSE
138 void CPresetDlg::OnOK()
141 // Choose a video card
144 MessageBoxW (GetString (IDS_CHOOSE_A_CARD
), CI18N::get ("uiConfigTitle"), MB_OK
|MB_ICONEXCLAMATION
);
152 GetFromConfigFile ();
154 // Merge the config files
155 MergeConfigFile (ConfigFilePreset
[((::SystemMemory
/ (1024*1024)) < 500)?RAM256
:RAM512
]);
156 MergeConfigFile (ConfigFilePreset
[(::CPUFrequency
< 1500)?CPU1
:(::CPUFrequency
< 2000)?CPU2
:(::CPUFrequency
< 2500)?CPU3
:CPU4
]);
157 MergeConfigFile (ConfigFilePreset
[VideoCards
[VideoCard
].Preset
]);
158 int vram
= ::VideoMemory
/ (1024*1024);
159 MergeConfigFile (ConfigFilePreset
[(vram
< 50)?VRAM32
:(vram
< 100)?VRAM64
:VRAM128
]);
160 CConfigFile::CVar
*var
= ConfigFilePreset
[SoundBuffer
].getVarPtr ("MaxTrack");
161 if (var
&& var
->Type
)
163 var
->setAsInt (::HardwareSoundBuffer
);
164 MergeConfigFile (ConfigFilePreset
[SoundBuffer
]);
171 void CPresetDlg::OnCancel()