/[pcsx2_0.9.7]/trunk/plugins/GSdx/GSSettingsDlg.cpp
ViewVC logotype

Contents of /trunk/plugins/GSdx/GSSettingsDlg.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 280 - (show annotations) (download)
Thu Dec 23 12:02:12 2010 UTC (9 years, 2 months ago) by william
File size: 10427 byte(s)
re-commit (had local access denied errors when committing)
1 /*
2 * Copyright (C) 2007-2009 Gabest
3 * http://www.gabest.org
4 *
5 * This Program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
8 * any later version.
9 *
10 * This Program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with GNU Make; see the file COPYING. If not, write to
17 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
18 * http://www.gnu.org/copyleft/gpl.html
19 *
20 */
21
22 #include "stdafx.h"
23 #include "GSdx.h"
24 #include "GSSettingsDlg.h"
25 #include "GSUtil.h"
26 #include "resource.h"
27
28 GSSetting GSSettingsDlg::g_renderers[] =
29 {
30 {0, "Direct3D9 (Hardware)", ""},
31 {1, "Direct3D9 (Software)", ""},
32 {2, "Direct3D9 (Null)", ""},
33 {3, "Direct3D%d ", "Hardware"},
34 {4, "Direct3D%d ", "Software"},
35 {5, "Direct3D%d ", "Null"},
36 {12, "Null (Software)", ""},
37 {13, "Null (Null)", ""},
38 };
39
40 GSSetting GSSettingsDlg::g_interlace[] =
41 {
42 {0, "None", ""},
43 {1, "Weave tff", "saw-tooth"},
44 {2, "Weave bff", "saw-tooth"},
45 {3, "Bob tff", "use blend if shaking"},
46 {4, "Bob bff", "use blend if shaking"},
47 {5, "Blend tff", "slight blur, 1/2 fps"},
48 {6, "Blend bff", "slight blur, 1/2 fps"},
49 };
50
51 GSSetting GSSettingsDlg::g_aspectratio[] =
52 {
53 {0, "Stretch", ""},
54 {1, "4:3", ""},
55 {2, "16:9", ""},
56 };
57
58 GSSetting GSSettingsDlg::g_upscale_multiplier[] =
59 {
60 {1, "1x", "Use D3D internal Res"},
61 {2, "2x", ""},
62 {3, "3x", ""},
63 {4, "4x", ""},
64 {5, "5x", ""},
65 {6, "6x", ""},
66 };
67
68 GSSettingsDlg::GSSettingsDlg( bool isOpen2 )
69 : GSDialog(isOpen2 ? IDD_CONFIG2 : IDD_CONFIG)
70 , m_IsOpen2(isOpen2)
71 {
72 }
73 bool allowHacks = false;
74 void GSSettingsDlg::OnInit()
75 {
76 __super::OnInit();
77
78 m_modes.clear();
79
80 if(!m_IsOpen2)
81 {
82 D3DDISPLAYMODE mode;
83 memset(&mode, 0, sizeof(mode));
84 m_modes.push_back(mode);
85
86 ComboBoxAppend(IDC_RESOLUTION, "Please select...", (LPARAM)&m_modes.back(), true);
87
88 CComPtr<IDirect3D9> d3d;
89 d3d.Attach(Direct3DCreate9(D3D_SDK_VERSION));
90 if(d3d)
91 {
92 uint32 w = theApp.GetConfig("ModeWidth", 0);
93 uint32 h = theApp.GetConfig("ModeHeight", 0);
94 uint32 hz = theApp.GetConfig("ModeRefreshRate", 0);
95
96 uint32 n = d3d->GetAdapterModeCount(D3DADAPTER_DEFAULT, D3DFMT_R5G6B5);
97
98 for(uint32 i = 0; i < n; i++)
99 {
100 if(S_OK == d3d->EnumAdapterModes(D3DADAPTER_DEFAULT, D3DFMT_R5G6B5, i, &mode))
101 {
102 m_modes.push_back(mode);
103
104 string str = format("%dx%d %dHz", mode.Width, mode.Height, mode.RefreshRate);
105
106 ComboBoxAppend(IDC_RESOLUTION, str.c_str(), (LPARAM)&m_modes.back(), w == mode.Width && h == mode.Height && hz == mode.RefreshRate);
107 }
108 }
109 }
110 }
111
112 bool isdx11avail_config = GSUtil::IsDirect3D11Available();
113
114 vector<GSSetting> renderers;
115
116 for(size_t i = 0; i < countof(g_renderers); i++)
117 {
118 if(i >= 3 && i <= 5)
119 {
120 if(!isdx11avail_config) continue;
121 g_renderers[i].name = std::string("Direct3D") + (GSUtil::HasD3D11Features() ? "11" : "10");
122 }
123
124 renderers.push_back(g_renderers[i]);
125 }
126
127 ComboBoxInit(IDC_RENDERER, &renderers[0], renderers.size(), theApp.GetConfig("Renderer", 0));
128 ComboBoxInit(IDC_INTERLACE, g_interlace, countof(g_interlace), theApp.GetConfig("Interlace", 0));
129 ComboBoxInit(IDC_ASPECTRATIO, g_aspectratio, countof(g_aspectratio), theApp.GetConfig("AspectRatio", 1));
130 ComboBoxInit(IDC_UPSCALE_MULTIPLIER, g_upscale_multiplier, countof(g_upscale_multiplier), theApp.GetConfig("upscale_multiplier", 1));
131
132 CheckDlgButton(m_hWnd, IDC_WINDOWED, theApp.GetConfig("windowed", 1));
133 CheckDlgButton(m_hWnd, IDC_FILTER, theApp.GetConfig("filter", 2));
134 CheckDlgButton(m_hWnd, IDC_PALTEX, theApp.GetConfig("paltex", 0));
135 CheckDlgButton(m_hWnd, IDC_VSYNC, theApp.GetConfig("vsync", 0));
136 CheckDlgButton(m_hWnd, IDC_LOGZ, theApp.GetConfig("logz", 1));
137 CheckDlgButton(m_hWnd, IDC_FBA, theApp.GetConfig("fba", 1));
138 CheckDlgButton(m_hWnd, IDC_AA1, theApp.GetConfig("aa1", 0));
139 CheckDlgButton(m_hWnd, IDC_NATIVERES, theApp.GetConfig("nativeres", 0));
140 // Hacks
141 CheckDlgButton(m_hWnd, IDC_ALPHAHACK, theApp.GetConfig("UserHacks_AlphaHack", 0));
142 CheckDlgButton(m_hWnd, IDC_OFFSETHACK, theApp.GetConfig("UserHacks_HalfPixelOffset", 0));
143 SendMessage(GetDlgItem(m_hWnd, IDC_SKIPDRAWHACK), UDM_SETRANGE, 0, MAKELPARAM(1000, 0));
144 SendMessage(GetDlgItem(m_hWnd, IDC_SKIPDRAWHACK), UDM_SETPOS, 0, MAKELPARAM(theApp.GetConfig("UserHacks_SkipDraw", 0), 0));
145
146 SendMessage(GetDlgItem(m_hWnd, IDC_RESX), UDM_SETRANGE, 0, MAKELPARAM(8192, 256));
147 SendMessage(GetDlgItem(m_hWnd, IDC_RESX), UDM_SETPOS, 0, MAKELPARAM(theApp.GetConfig("resx", 1024), 0));
148
149 SendMessage(GetDlgItem(m_hWnd, IDC_RESY), UDM_SETRANGE, 0, MAKELPARAM(8192, 256));
150 SendMessage(GetDlgItem(m_hWnd, IDC_RESY), UDM_SETPOS, 0, MAKELPARAM(theApp.GetConfig("resy", 1024), 0));
151
152 SendMessage(GetDlgItem(m_hWnd, IDC_MSAA), UDM_SETRANGE, 0, MAKELPARAM(16, 0));
153 SendMessage(GetDlgItem(m_hWnd, IDC_MSAA), UDM_SETPOS, 0, MAKELPARAM(theApp.GetConfig("msaa", 0), 0));
154
155 SendMessage(GetDlgItem(m_hWnd, IDC_SWTHREADS), UDM_SETRANGE, 0, MAKELPARAM(16, 1));
156 SendMessage(GetDlgItem(m_hWnd, IDC_SWTHREADS), UDM_SETPOS, 0, MAKELPARAM(theApp.GetConfig("swthreads", 1), 0));
157
158 UpdateControls();
159 }
160
161 bool GSSettingsDlg::OnCommand(HWND hWnd, UINT id, UINT code)
162 {
163 if(id == IDC_RENDERER && code == CBN_SELCHANGE)
164 {
165 UpdateControls();
166 }
167 else if(id == IDC_NATIVERES && code == BN_CLICKED)
168 {
169 UpdateControls();
170 }
171 else if(id == IDOK)
172 {
173 INT_PTR data;
174
175 if(!m_IsOpen2 && ComboBoxGetSelData(IDC_RESOLUTION, data))
176 {
177 const D3DDISPLAYMODE* mode = (D3DDISPLAYMODE*)data;
178
179 theApp.SetConfig("ModeWidth", (int)mode->Width);
180 theApp.SetConfig("ModeHeight", (int)mode->Height);
181 theApp.SetConfig("ModeRefreshRate", (int)mode->RefreshRate);
182 }
183
184 if(ComboBoxGetSelData(IDC_RENDERER, data))
185 {
186 theApp.SetConfig("Renderer", (int)data);
187 }
188
189 if(ComboBoxGetSelData(IDC_INTERLACE, data))
190 {
191 theApp.SetConfig("Interlace", (int)data);
192 }
193
194 if(ComboBoxGetSelData(IDC_ASPECTRATIO, data))
195 {
196 theApp.SetConfig("AspectRatio", (int)data);
197 }
198
199 if(ComboBoxGetSelData(IDC_UPSCALE_MULTIPLIER, data))
200 {
201 theApp.SetConfig("upscale_multiplier", (int)data);
202 }
203 else
204 {
205 theApp.SetConfig("upscale_multiplier", 1);
206 }
207
208 theApp.SetConfig("windowed", (int)IsDlgButtonChecked(m_hWnd, IDC_WINDOWED));
209 theApp.SetConfig("filter", (int)IsDlgButtonChecked(m_hWnd, IDC_FILTER));
210 theApp.SetConfig("paltex", (int)IsDlgButtonChecked(m_hWnd, IDC_PALTEX));
211 theApp.SetConfig("vsync", (int)IsDlgButtonChecked(m_hWnd, IDC_VSYNC));
212 theApp.SetConfig("logz", (int)IsDlgButtonChecked(m_hWnd, IDC_LOGZ));
213 theApp.SetConfig("fba", (int)IsDlgButtonChecked(m_hWnd, IDC_FBA));
214 theApp.SetConfig("aa1", (int)IsDlgButtonChecked(m_hWnd, IDC_AA1));
215 theApp.SetConfig("nativeres", (int)IsDlgButtonChecked(m_hWnd, IDC_NATIVERES));
216 theApp.SetConfig("resx", (int)SendMessage(GetDlgItem(m_hWnd, IDC_RESX), UDM_GETPOS, 0, 0));
217 theApp.SetConfig("resy", (int)SendMessage(GetDlgItem(m_hWnd, IDC_RESY), UDM_GETPOS, 0, 0));
218 theApp.SetConfig("swthreads", (int)SendMessage(GetDlgItem(m_hWnd, IDC_SWTHREADS), UDM_GETPOS, 0, 0));
219 theApp.SetConfig("msaa", (int)SendMessage(GetDlgItem(m_hWnd, IDC_MSAA), UDM_GETPOS, 0, 0));
220 // Hacks
221 theApp.SetConfig("UserHacks_AlphaHack", (int)IsDlgButtonChecked(m_hWnd, IDC_ALPHAHACK));
222 theApp.SetConfig("UserHacks_HalfPixelOffset", (int)IsDlgButtonChecked(m_hWnd, IDC_OFFSETHACK));
223 theApp.SetConfig("UserHacks_SkipDraw", (int)SendMessage(GetDlgItem(m_hWnd, IDC_SKIPDRAWHACK), UDM_GETPOS, 0, 0));
224
225 bool allowHacks = !!theApp.GetConfig("allowHacks", 0);
226 theApp.SetConfig("allowHacks", allowHacks);
227 }
228
229 return __super::OnCommand(hWnd, id, code);
230 }
231
232 void GSSettingsDlg::UpdateControls()
233 {
234 INT_PTR i;
235
236 bool allowHacks = !!theApp.GetConfig("allowHacks", 0);
237
238 if(ComboBoxGetSelData(IDC_RENDERER, i))
239 {
240 bool dx9 = i >= 0 && i <= 2;
241 bool dx10 = i >= 3 && i <= 5;
242 bool dx11 = i >= 6 && i <= 8;
243 bool ogl = i >= 9 && i <= 12;
244 bool hw = i == 0 || i == 3 || i == 6 || i == 9;
245 bool sw = i == 1 || i == 4 || i == 7 || i == 10;
246 bool native = !!IsDlgButtonChecked(m_hWnd, IDC_NATIVERES);
247
248 ShowWindow(GetDlgItem(m_hWnd, IDC_LOGO9), dx9 ? SW_SHOW : SW_HIDE);
249 ShowWindow(GetDlgItem(m_hWnd, IDC_LOGO10), dx10 ? SW_SHOW : SW_HIDE);
250 // TODO: ShowWindow(GetDlgItem(m_hWnd, IDC_LOGO11), dx11 ? SW_SHOW : SW_HIDE);
251 // TODO: ShowWindow(GetDlgItem(m_hWnd, IDC_LOGO_OGL), ogl ? SW_SHOW : SW_HIDE);
252
253 EnableWindow(GetDlgItem(m_hWnd, IDC_WINDOWED), dx9);
254 EnableWindow(GetDlgItem(m_hWnd, IDC_RESX), hw && !native);
255 EnableWindow(GetDlgItem(m_hWnd, IDC_RESX_EDIT), hw && !native);
256 EnableWindow(GetDlgItem(m_hWnd, IDC_RESY), hw && !native);
257 EnableWindow(GetDlgItem(m_hWnd, IDC_RESY_EDIT), hw && !native);
258 EnableWindow(GetDlgItem(m_hWnd, IDC_UPSCALE_MULTIPLIER), hw && !native);
259 EnableWindow(GetDlgItem(m_hWnd, IDC_NATIVERES), hw);
260 EnableWindow(GetDlgItem(m_hWnd, IDC_FILTER), hw && !native);
261 EnableWindow(GetDlgItem(m_hWnd, IDC_PALTEX), hw);
262 EnableWindow(GetDlgItem(m_hWnd, IDC_LOGZ), dx9 && hw);
263 EnableWindow(GetDlgItem(m_hWnd, IDC_FBA), dx9 && hw);
264 EnableWindow(GetDlgItem(m_hWnd, IDC_AA1), sw);
265 EnableWindow(GetDlgItem(m_hWnd, IDC_SWTHREADS_EDIT), sw);
266 EnableWindow(GetDlgItem(m_hWnd, IDC_SWTHREADS), sw);
267 EnableWindow(GetDlgItem(m_hWnd, IDC_MSAAEDIT), hw);
268 EnableWindow(GetDlgItem(m_hWnd, IDC_MSAA), hw);
269
270 //ShowWindow(GetDlgItem(m_hWnd, IDC_USERHACKS), allowHacks && hw)?SW_SHOW:SW_HIDE; //Don't disable the "Hacks" frame
271 ShowWindow(GetDlgItem(m_hWnd, IDC_MSAAEDIT), allowHacks && hw)?SW_SHOW:SW_HIDE;
272 ShowWindow(GetDlgItem(m_hWnd, IDC_MSAA), allowHacks && hw)?SW_SHOW:SW_HIDE;
273 ShowWindow(GetDlgItem(m_hWnd, IDC_STATIC_TEXT_HWAA), allowHacks && hw)?SW_SHOW:SW_HIDE;
274
275 ShowWindow(GetDlgItem(m_hWnd, IDC_ALPHAHACK), allowHacks && hw)?SW_SHOW:SW_HIDE;
276 ShowWindow(GetDlgItem(m_hWnd, IDC_OFFSETHACK), allowHacks && hw)?SW_SHOW:SW_HIDE;
277
278 ShowWindow(GetDlgItem(m_hWnd, IDC_SKIPDRAWHACKEDIT), allowHacks && hw)?SW_SHOW:SW_HIDE;
279 ShowWindow(GetDlgItem(m_hWnd, IDC_SKIPDRAWHACK), allowHacks && hw)?SW_SHOW:SW_HIDE;
280 ShowWindow(GetDlgItem(m_hWnd, IDC_STATIC_TEXT_SKIPDRAW), allowHacks && hw)?SW_SHOW:SW_HIDE;
281 }
282 }

  ViewVC Help
Powered by ViewVC 1.1.22