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/
21 #include "W32Util/PropertySheet.h"
22 #include "W32Util/ShellUtil.h"
27 #include "VideoConfig.h"
29 #include "TextureCache.h"
30 // TODO: remove if/when ini files use unicode
31 #define ComboBox_GetTextA(hwndCtl, lpch, cchMax) GetWindowTextA((hwndCtl), (lpch), (cchMax))
33 const char *aspect_ratio_names
[4] = {
35 "Force 16:9 Widescreen",
40 struct TabDirect3D
: public W32Util::Tab
46 for (int i
= 0; i
< D3D::GetNumAdapters(); i
++)
48 const D3D::Adapter
&adapter
= D3D::GetAdapter(i
);
49 MultiByteToWideChar(CP_ACP
, MB_PRECOMPOSED
, adapter
.ident
.Description
, -1, tempwstr
, 2000);
50 ComboBox_AddString(GetDlgItem(hDlg
, IDC_ADAPTER
),tempwstr
);
53 const D3D::Adapter
&adapter
= D3D::GetAdapter(g_Config
.iAdapter
);
54 ComboBox_SetCurSel(GetDlgItem(hDlg
, IDC_ADAPTER
), g_Config
.iAdapter
);
56 for (int i
= 0; i
< (int)adapter
.aa_levels
.size(); i
++)
58 MultiByteToWideChar(CP_ACP
, MB_PRECOMPOSED
, adapter
.aa_levels
[i
].name
, -1, tempwstr
, 2000);
59 ComboBox_AddString(GetDlgItem(hDlg
, IDC_ANTIALIASMODE
), tempwstr
);
62 ComboBox_SetCurSel(GetDlgItem(hDlg
, IDC_ANTIALIASMODE
), g_Config
.iMultisampleMode
);
63 if (adapter
.aa_levels
.size() == 1)
65 ComboBox_Enable(GetDlgItem(hDlg
, IDC_ANTIALIASMODE
), FALSE
);
68 for (int i
= 0; i
< 4; i
++)
70 MultiByteToWideChar(CP_ACP
, MB_PRECOMPOSED
, aspect_ratio_names
[i
], -1, tempwstr
, 2000);
71 ComboBox_AddString(GetDlgItem(hDlg
, IDC_ASPECTRATIO
), tempwstr
);
73 ComboBox_SetCurSel(GetDlgItem(hDlg
, IDC_ASPECTRATIO
), g_Config
.iAspectRatio
);
75 Button_SetCheck(GetDlgItem(hDlg
, IDC_VSYNC
), g_Config
.bVSync
);
76 Button_SetCheck(GetDlgItem(hDlg
, IDC_WIDESCREEN_HACK
), g_Config
.bWidescreenHack
);
77 Button_SetCheck(GetDlgItem(hDlg
, IDC_SAFE_TEXTURE_CACHE
), g_Config
.bSafeTextureCache
);
79 if(g_Config
.iSafeTextureCache_ColorSamples
== 0)
81 Button_SetCheck(GetDlgItem(hDlg
, IDC_SAFE_TEXTURE_CACHE_SAFE
), true);
85 if(g_Config
.iSafeTextureCache_ColorSamples
> 128)
87 Button_SetCheck(GetDlgItem(hDlg
, IDC_SAFE_TEXTURE_CACHE_NORMAL
), true);
91 Button_SetCheck(GetDlgItem(hDlg
, IDC_SAFE_TEXTURE_CACHE_FAST
), true);
94 Button_Enable(GetDlgItem(hDlg
, IDC_SAFE_TEXTURE_CACHE_SAFE
),g_Config
.bSafeTextureCache
);
95 Button_Enable(GetDlgItem(hDlg
, IDC_SAFE_TEXTURE_CACHE_NORMAL
),g_Config
.bSafeTextureCache
);
96 Button_Enable(GetDlgItem(hDlg
, IDC_SAFE_TEXTURE_CACHE_FAST
),g_Config
.bSafeTextureCache
);
98 Button_SetCheck(GetDlgItem(hDlg
, IDC_EFB_ACCESS_ENABLE
), g_Config
.bEFBAccessEnable
);
101 void Command(HWND hDlg
,WPARAM wParam
)
103 switch (LOWORD(wParam
))
105 case IDC_ASPECTRATIO
:
106 g_Config
.iAspectRatio
= ComboBox_GetCurSel(GetDlgItem(hDlg
, IDC_ASPECTRATIO
));
108 case IDC_WIDESCREEN_HACK
:
109 g_Config
.bWidescreenHack
= Button_GetCheck(GetDlgItem(hDlg
, IDC_WIDESCREEN_HACK
)) ? true : false;
111 case IDC_SAFE_TEXTURE_CACHE
:
112 g_Config
.bSafeTextureCache
= Button_GetCheck(GetDlgItem(hDlg
, IDC_SAFE_TEXTURE_CACHE
)) == 0 ? false : true;
113 Button_Enable(GetDlgItem(hDlg
, IDC_SAFE_TEXTURE_CACHE_SAFE
),g_Config
.bSafeTextureCache
);
114 Button_Enable(GetDlgItem(hDlg
, IDC_SAFE_TEXTURE_CACHE_NORMAL
),g_Config
.bSafeTextureCache
);
115 Button_Enable(GetDlgItem(hDlg
, IDC_SAFE_TEXTURE_CACHE_FAST
),g_Config
.bSafeTextureCache
);
117 case IDC_EFB_ACCESS_ENABLE
:
118 g_Config
.bEFBAccessEnable
= Button_GetCheck(GetDlgItem(hDlg
, IDC_EFB_ACCESS_ENABLE
)) == 0 ? false : true;
125 void Apply(HWND hDlg
)
127 g_Config
.iAdapter
= ComboBox_GetCurSel(GetDlgItem(hDlg
, IDC_ADAPTER
));
128 g_Config
.iMultisampleMode
= ComboBox_GetCurSel(GetDlgItem(hDlg
, IDC_ANTIALIASMODE
));
129 g_Config
.bVSync
= Button_GetCheck(GetDlgItem(hDlg
, IDC_VSYNC
)) ? true : false;
130 if(Button_GetCheck(GetDlgItem(hDlg
, IDC_SAFE_TEXTURE_CACHE_SAFE
)))
132 g_Config
.iSafeTextureCache_ColorSamples
= 0;
136 if(Button_GetCheck(GetDlgItem(hDlg
, IDC_SAFE_TEXTURE_CACHE_NORMAL
)))
138 if(g_Config
.iSafeTextureCache_ColorSamples
< 512)
140 g_Config
.iSafeTextureCache_ColorSamples
= 512;
145 if(g_Config
.iSafeTextureCache_ColorSamples
> 128 || g_Config
.iSafeTextureCache_ColorSamples
== 0)
147 g_Config
.iSafeTextureCache_ColorSamples
= 128;
151 g_Config
.Save((std::string(File::GetUserPath(D_CONFIG_IDX
)) + "gfx_dx9.ini").c_str());
155 struct TabAdvanced
: public W32Util::Tab
159 // HWND opt = GetDlgItem(hDlg,IDC_DLOPTLEVEL);
160 // ComboBox_AddString(opt,"0: Interpret (slowest, most compatible)");
161 // ComboBox_AddString(opt,"1: Compile lists and decode vertex lists");
162 //ComboBox_AddString(opt,"2: Compile+decode to vbufs and use hw xform");
163 //ComboBox_AddString(opt,"Recompile to vbuffers and shaders");
164 // ComboBox_SetCurSel(opt,g_Config.iCompileDLsLevel);
166 Button_SetCheck(GetDlgItem(hDlg
,IDC_OSDHOTKEY
), g_Config
.bOSDHotKey
);
167 Button_SetCheck(GetDlgItem(hDlg
,IDC_OVERLAYFPS
), g_Config
.bShowFPS
);
168 Button_SetCheck(GetDlgItem(hDlg
,IDC_OVERLAYSTATS
), g_Config
.bOverlayStats
);
169 Button_SetCheck(GetDlgItem(hDlg
,IDC_OVERLAYPROJSTATS
), g_Config
.bOverlayProjStats
);
170 Button_SetCheck(GetDlgItem(hDlg
,IDC_WIREFRAME
), g_Config
.bWireFrame
);
171 Button_SetCheck(GetDlgItem(hDlg
,IDC_TEXDUMP
), g_Config
.bDumpTextures
);
172 Button_SetCheck(GetDlgItem(hDlg
,IDC_DUMPFRAMES
), g_Config
.bDumpFrames
);
173 Button_SetCheck(GetDlgItem(hDlg
,IDC_SHOWSHADERERRORS
), g_Config
.bShowShaderErrors
);
174 Button_SetCheck(GetDlgItem(hDlg
,IDC_DISABLEFOG
), g_Config
.bDisableFog
);
175 Button_SetCheck(GetDlgItem(hDlg
,IDC_ENABLEEFBCOPY
), !g_Config
.bEFBCopyDisable
);
176 Button_SetCheck(GetDlgItem(hDlg
,IDC_ENABLEXFB
),g_Config
.bUseXFB
);
177 Button_SetCheck(GetDlgItem(hDlg
,IDC_ENABLEREALXFB
),g_Config
.bUseRealXFB
);
179 if(g_Config
.bCopyEFBToTexture
)
180 Button_SetCheck(GetDlgItem(hDlg
,IDC_EFBTOTEX
), true);
182 Button_SetCheck(GetDlgItem(hDlg
,IDC_EFBTORAM
), true);
185 Button_SetCheck(GetDlgItem(hDlg
,IDC_TEXFMT_OVERLAY
), g_Config
.bTexFmtOverlayEnable
);
186 Button_SetCheck(GetDlgItem(hDlg
,IDC_TEXFMT_CENTER
), g_Config
.bTexFmtOverlayCenter
);
187 Button_GetCheck(GetDlgItem(hDlg
,IDC_TEXFMT_OVERLAY
)) ? Button_Enable(GetDlgItem(hDlg
,IDC_TEXFMT_CENTER
), true) : Button_Enable(GetDlgItem(hDlg
,IDC_TEXFMT_CENTER
), false);
188 Button_GetCheck(GetDlgItem(hDlg
,IDC_ENABLEEFBCOPY
)) ? Button_Enable(GetDlgItem(hDlg
,IDC_EFBTORAM
), true) : Button_Enable(GetDlgItem(hDlg
,IDC_EFBTORAM
), false);
189 Button_GetCheck(GetDlgItem(hDlg
,IDC_ENABLEEFBCOPY
)) ? Button_Enable(GetDlgItem(hDlg
,IDC_EFBTOTEX
), true) : Button_Enable(GetDlgItem(hDlg
,IDC_EFBTOTEX
), false);
191 void Command(HWND hDlg
,WPARAM wParam
)
193 switch (LOWORD(wParam
))
197 g_Config
.bUseXFB
= Button_GetCheck(GetDlgItem(hDlg
, IDC_ENABLEXFB
)) ? true : false;
200 case IDC_ENABLEREALXFB
:
202 g_Config
.bUseXFB
= Button_GetCheck(GetDlgItem(hDlg
, IDC_ENABLEREALXFB
)) ? true : (Button_GetCheck(GetDlgItem(hDlg
, IDC_ENABLEXFB
)) ? true : false);
203 g_Config
.bUseRealXFB
= Button_GetCheck(GetDlgItem(hDlg
, IDC_ENABLEREALXFB
)) ? true : false;
204 Button_GetCheck(GetDlgItem(hDlg
, IDC_ENABLEREALXFB
)) ? Button_Enable(GetDlgItem(hDlg
,IDC_ENABLEXFB
), false) : Button_Enable(GetDlgItem(hDlg
,IDC_ENABLEXFB
), true);
207 case IDC_ENABLEEFBCOPY
:
209 Button_GetCheck(GetDlgItem(hDlg
,IDC_ENABLEEFBCOPY
)) ? Button_Enable(GetDlgItem(hDlg
,IDC_EFBTORAM
), true) : Button_Enable(GetDlgItem(hDlg
,IDC_EFBTORAM
), false);
210 Button_GetCheck(GetDlgItem(hDlg
,IDC_ENABLEEFBCOPY
)) ? Button_Enable(GetDlgItem(hDlg
,IDC_EFBTOTEX
), true) : Button_Enable(GetDlgItem(hDlg
,IDC_EFBTOTEX
), false);
213 case IDC_TEXFMT_OVERLAY
:
215 Button_GetCheck(GetDlgItem(hDlg
, IDC_TEXFMT_OVERLAY
)) ? Button_Enable(GetDlgItem(hDlg
,IDC_TEXFMT_CENTER
), true) : Button_Enable(GetDlgItem(hDlg
,IDC_TEXFMT_CENTER
), false);
222 void Apply(HWND hDlg
)
224 g_Config
.bTexFmtOverlayEnable
= Button_GetCheck(GetDlgItem(hDlg
,IDC_TEXFMT_OVERLAY
)) ? true : false;
225 g_Config
.bTexFmtOverlayCenter
= Button_GetCheck(GetDlgItem(hDlg
,IDC_TEXFMT_CENTER
)) ? true : false;
227 g_Config
.bOSDHotKey
= Button_GetCheck(GetDlgItem(hDlg
,IDC_OSDHOTKEY
)) ? true : false;
228 g_Config
.bShowFPS
= Button_GetCheck(GetDlgItem(hDlg
,IDC_OVERLAYFPS
)) ? true : false;
229 g_Config
.bOverlayStats
= Button_GetCheck(GetDlgItem(hDlg
,IDC_OVERLAYSTATS
)) ? true : false;
230 g_Config
.bOverlayProjStats
= Button_GetCheck(GetDlgItem(hDlg
,IDC_OVERLAYPROJSTATS
)) ? true : false;
231 g_Config
.bWireFrame
= Button_GetCheck(GetDlgItem(hDlg
,IDC_WIREFRAME
)) ? true : false;
232 g_Config
.bDumpTextures
= Button_GetCheck(GetDlgItem(hDlg
,IDC_TEXDUMP
)) ? true : false;
233 g_Config
.bDumpFrames
= Button_GetCheck(GetDlgItem(hDlg
,IDC_DUMPFRAMES
)) ? true : false;
234 g_Config
.bShowShaderErrors
= Button_GetCheck(GetDlgItem(hDlg
,IDC_SHOWSHADERERRORS
)) ? true : false;
235 g_Config
.bDisableFog
= Button_GetCheck(GetDlgItem(hDlg
,IDC_DISABLEFOG
)) ? true : false;
236 g_Config
.bEFBCopyDisable
= Button_GetCheck(GetDlgItem(hDlg
,IDC_ENABLEEFBCOPY
)) ? false : true;
237 g_Config
.bCopyEFBToTexture
= Button_GetCheck(GetDlgItem(hDlg
,IDC_EFBTORAM
)) ? false : true;
238 g_Config
.bUseXFB
= Button_GetCheck(GetDlgItem(hDlg
, IDC_ENABLEXFB
)) ? true : false;
239 g_Config
.bUseRealXFB
= Button_GetCheck(GetDlgItem(hDlg
, IDC_ENABLEREALXFB
)) ? true : false;
240 g_Config
.Save((std::string(File::GetUserPath(D_CONFIG_IDX
)) + "gfx_dx9.ini").c_str());
242 if( D3D::dev
!= NULL
) {
243 D3D::SetRenderState( D3DRS_FILLMODE
, g_Config
.bWireFrame
? D3DFILL_WIREFRAME
: D3DFILL_SOLID
);
248 struct TabEnhancements
: public W32Util::Tab
252 Button_SetCheck(GetDlgItem(hDlg
,IDC_FORCEFILTERING
),g_Config
.bForceFiltering
);
253 Button_SetCheck(GetDlgItem(hDlg
,IDC_FORCEANISOTROPY
),g_Config
.iMaxAnisotropy
> 1);
254 Button_SetCheck(GetDlgItem(hDlg
, IDC_LOADHIRESTEXTURE
), g_Config
.bHiresTextures
);
255 Button_SetCheck(GetDlgItem(hDlg
,IDC_EFBSCALEDCOPY
), g_Config
.bCopyEFBScaled
);
258 Temporarily disabled the old postprocessing code since it wasn't working anyway.
259 New postprocessing code will come sooner or later, sharing shaders and framework with
260 the GL postprocessing.
262 HWND pp = GetDlgItem(hDlg, IDC_POSTPROCESSEFFECT);
263 const char **names = Postprocess::GetPostprocessingNames();
270 MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, names[i], -1, tempwstr, 2000);
271 ComboBox_AddString(pp, tempwstr);
274 ComboBox_SetCurSel(pp, g_Config.iPostprocessEffect);
277 void Command(HWND hDlg
,WPARAM wParam
)
280 switch (LOWORD(wParam))
287 void Apply(HWND hDlg
)
289 g_Config
.iMaxAnisotropy
= Button_GetCheck(GetDlgItem(hDlg
, IDC_FORCEANISOTROPY
)) ? 8 : 1;
290 g_Config
.bForceFiltering
= Button_GetCheck(GetDlgItem(hDlg
, IDC_FORCEFILTERING
)) ? true : false;
291 g_Config
.bHiresTextures
= Button_GetCheck(GetDlgItem(hDlg
, IDC_LOADHIRESTEXTURE
)) ? true : false;
292 g_Config
.bCopyEFBScaled
= Button_GetCheck(GetDlgItem(hDlg
,IDC_EFBSCALEDCOPY
)) ? true : false;
293 g_Config
.Save((std::string(File::GetUserPath(D_CONFIG_IDX
)) + "gfx_dx9.ini").c_str());
298 void DlgSettings_Show(HINSTANCE hInstance
, HWND _hParent
)
300 bool tfoe
= g_Config
.bTexFmtOverlayEnable
;
301 bool tfoc
= g_Config
.bTexFmtOverlayCenter
;
303 g_Config
.Load((std::string(File::GetUserPath(D_CONFIG_IDX
)) + "gfx_dx9.ini").c_str());
304 W32Util::PropSheet sheet
;
305 sheet
.Add(new TabDirect3D
, (LPCTSTR
)IDD_SETTINGS
,_T("Direct3D"));
306 sheet
.Add(new TabEnhancements
, (LPCTSTR
)IDD_ENHANCEMENTS
,_T("Enhancements"));
307 sheet
.Add(new TabAdvanced
, (LPCTSTR
)IDD_ADVANCED
,_T("Advanced"));
310 sheet
.Show(hInstance
,_hParent
,_T("DX9 Graphics Plugin (DEBUGFAST)"));
313 sheet
.Show(hInstance
,_hParent
,_T("DX9 Graphics Plugin"));
315 sheet
.Show(hInstance
,_hParent
,_T("DX9 Graphics Plugin (DEBUG)"));
319 if ((tfoe
!= g_Config
.bTexFmtOverlayEnable
) ||
320 ((g_Config
.bTexFmtOverlayEnable
) && ( tfoc
!= g_Config
.bTexFmtOverlayCenter
)))
322 TextureCache::Invalidate(false);