From ca7a5b36dc1e3fc8332ea26d06a0a69e20a32a85 Mon Sep 17 00:00:00 2001 From: LPFaint99 Date: Tue, 15 Sep 2009 08:13:45 +0000 Subject: [PATCH] only load gameini settings if they exist change D3D to use char[] for resolution settings in ini warning fixes for FrameAui.cpp git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4273 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/DolphinWX/Src/FrameAui.cpp | 18 ++++----- Source/Core/VideoCommon/Src/VideoConfig.cpp | 37 +++++++++++-------- Source/Core/VideoCommon/Src/VideoConfig.h | 4 -- .../Plugins/Plugin_VideoDX9/Src/D3DBase.cpp | 16 ++++---- .../Plugin_VideoDX9/Src/DlgSettings.cpp | 20 ++++++---- Source/Plugins/Plugin_VideoDX9/Src/Render.cpp | 19 ++++++++-- 6 files changed, 66 insertions(+), 48 deletions(-) diff --git a/Source/Core/DolphinWX/Src/FrameAui.cpp b/Source/Core/DolphinWX/Src/FrameAui.cpp index b8bdc6febb..a2ba9af60a 100644 --- a/Source/Core/DolphinWX/Src/FrameAui.cpp +++ b/Source/Core/DolphinWX/Src/FrameAui.cpp @@ -292,33 +292,33 @@ void CFrame::OnTab(wxAuiNotebookEvent& event) MenuPopup.Append(new wxMenuItem(&MenuPopup)); Item = new wxMenuItem(&MenuPopup, IDM_FLOAT_LOGWINDOW, WindowNameFromId(IDM_LOGWINDOW), wxT(""), wxITEM_CHECK); MenuPopup.Append(Item); - Item->Check(FindWindowById(IDM_LOGWINDOW_PARENT)); + Item->Check(!!FindWindowById(IDM_LOGWINDOW_PARENT)); Item = new wxMenuItem(&MenuPopup, IDM_FLOAT_CONSOLEWINDOW, WindowNameFromId(IDM_CONSOLEWINDOW), wxT(""), wxITEM_CHECK); MenuPopup.Append(Item); - Item->Check(FindWindowById(IDM_CONSOLEWINDOW_PARENT)); + Item->Check(!!FindWindowById(IDM_CONSOLEWINDOW_PARENT)); MenuPopup.Append(new wxMenuItem(&MenuPopup)); Item = new wxMenuItem(&MenuPopup, IDM_FLOAT_CODEWINDOW, WindowNameFromId(IDM_CODEWINDOW), wxT(""), wxITEM_CHECK); MenuPopup.Append(Item); - Item->Check(FindWindowById(IDM_CODEWINDOW_PARENT)); + Item->Check(!!FindWindowById(IDM_CODEWINDOW_PARENT)); Item = new wxMenuItem(&MenuPopup, IDM_FLOAT_REGISTERWINDOW, WindowNameFromId(IDM_REGISTERWINDOW), wxT(""), wxITEM_CHECK); MenuPopup.Append(Item); - Item->Check(FindWindowById(IDM_REGISTERWINDOW_PARENT)); + Item->Check(!!FindWindowById(IDM_REGISTERWINDOW_PARENT)); Item = new wxMenuItem(&MenuPopup, IDM_FLOAT_BREAKPOINTWINDOW, WindowNameFromId(IDM_BREAKPOINTWINDOW), wxT(""), wxITEM_CHECK); MenuPopup.Append(Item); - Item->Check(FindWindowById(IDM_BREAKPOINTWINDOW_PARENT)); + Item->Check(!!FindWindowById(IDM_BREAKPOINTWINDOW_PARENT)); Item = new wxMenuItem(&MenuPopup, IDM_FLOAT_MEMORYWINDOW, WindowNameFromId(IDM_MEMORYWINDOW), wxT(""), wxITEM_CHECK); MenuPopup.Append(Item); - Item->Check(FindWindowById(IDM_MEMORYWINDOW_PARENT)); + Item->Check(!!FindWindowById(IDM_MEMORYWINDOW_PARENT)); Item = new wxMenuItem(&MenuPopup, IDM_FLOAT_JITWINDOW, WindowNameFromId(IDM_JITWINDOW), wxT(""), wxITEM_CHECK); MenuPopup.Append(Item); - Item->Check(FindWindowById(IDM_JITWINDOW_PARENT)); + Item->Check(!!FindWindowById(IDM_JITWINDOW_PARENT)); Item = new wxMenuItem(&MenuPopup, IDM_FLOAT_SOUNDWINDOW, WindowNameFromId(IDM_SOUNDWINDOW), wxT(""), wxITEM_CHECK); MenuPopup.Append(Item); - Item->Check(FindWindowById(IDM_SOUNDWINDOW_PARENT)); + Item->Check(!!FindWindowById(IDM_SOUNDWINDOW_PARENT)); Item->Enable(false); Item = new wxMenuItem(&MenuPopup, IDM_FLOAT_VIDEOWINDOW, WindowNameFromId(IDM_VIDEOWINDOW), wxT(""), wxITEM_CHECK); MenuPopup.Append(Item); - Item->Check(FindWindowById(IDM_VIDEOWINDOW_PARENT)); + Item->Check(!!FindWindowById(IDM_VIDEOWINDOW_PARENT)); Item->Enable(false); // Line up our menu with the cursor diff --git a/Source/Core/VideoCommon/Src/VideoConfig.cpp b/Source/Core/VideoCommon/Src/VideoConfig.cpp index df54fa146a..239c527134 100644 --- a/Source/Core/VideoCommon/Src/VideoConfig.cpp +++ b/Source/Core/VideoCommon/Src/VideoConfig.cpp @@ -95,9 +95,6 @@ void VideoConfig::Load(const char *ini_file) iniFile.Get("Hardware", "Adapter", &iAdapter, 0); if (iAdapter == -1) iAdapter = 0; - // iniFile.Get("Hardware", "WindowedRes", &iWindowedRes, 0); - iniFile.Get("Hardware", "VSync", &bVsync, 0); - // iniFile.Get("Hardware", "FullscreenRes", &iFSResolution, 0); iniFile.Get("Hardware", "SimpleFB", &bSimpleFB, false); // Load common settings @@ -111,16 +108,27 @@ void VideoConfig::GameIniLoad(const char *ini_file) { IniFile iniFile; iniFile.Load(ini_file); - iniFile.Get("Video", "ForceFiltering", &bForceFiltering, 0); - iniFile.Get("Video", "MaxAnisotropy", &iMaxAnisotropy, 3); // NOTE - this is x in (1 << x) - iniFile.Get("Video", "EFBCopyDisable", &bEFBCopyDisable, 0); - iniFile.Get("Video", "EFBCopyDisableHotKey", &bEFBCopyDisableHotKey, 0); - iniFile.Get("Video", "EFBToRAMEnable", &bCopyEFBToRAM, 0); - iniFile.Get("Video", "SafeTextureCache", &bSafeTextureCache, false); - iniFile.Get("Video", "MSAA", &iMultisampleMode, 0); - iniFile.Get("Video", "DstAlphaPass", &bDstAlphaPass, false); - iniFile.Get("Video", "UseXFB", &bUseXFB, 0); - iniFile.Get("Video", "ProjectionHack", &iPhackvalue, 0); + + if (iniFile.Exists("Video", "ForceFiltering")) + iniFile.Get("Video", "ForceFiltering", &bForceFiltering, 0); + if (iniFile.Exists("Video", "MaxAnisotropy")) + iniFile.Get("Video", "MaxAnisotropy", &iMaxAnisotropy, 3); // NOTE - this is x in (1 << x) + if (iniFile.Exists("Video", "EFBCopyDisable")) + iniFile.Get("Video", "EFBCopyDisable", &bEFBCopyDisable, 0); + if (iniFile.Exists("Video", "EFBCopyDisableHotKey")) + iniFile.Get("Video", "EFBCopyDisableHotKey", &bEFBCopyDisableHotKey, 0); + if (iniFile.Exists("Video", "EFBToRAMEnable")) + iniFile.Get("Video", "EFBToRAMEnable", &bCopyEFBToRAM, 0); + if (iniFile.Exists("Video", "SafeTextureCache")) + iniFile.Get("Video", "SafeTextureCache", &bSafeTextureCache, false); + if (iniFile.Exists("Video", "MSAA")) + iniFile.Get("Video", "MSAA", &iMultisampleMode, 0); + if (iniFile.Exists("Video", "DstAlphaPass")) + iniFile.Get("Video", "DstAlphaPass", &bDstAlphaPass, false); + if (iniFile.Exists("Video", "UseXFB")) + iniFile.Get("Video", "UseXFB", &bUseXFB, 0); + if (iniFile.Exists("Video", "ProjectionHack")) + iniFile.Get("Video", "ProjectionHack", &iPhackvalue, 0); } void VideoConfig::Save(const char *ini_file) @@ -174,9 +182,6 @@ void VideoConfig::Save(const char *ini_file) iniFile.Set("Hacks", "ProjectionHack", iPhackvalue); iniFile.Set("Hardware", "Adapter", iAdapter); - // iniFile.Set("Hardware", "WindowedRes", iWindowedRes); - iniFile.Set("Hardware", "VSync", bVsync); - // iniFile.Set("Hardware", "FullscreenRes", iFSResolution); iniFile.Set("Hardware", "SimpleFB", bSimpleFB); iniFile.Save(ini_file); diff --git a/Source/Core/VideoCommon/Src/VideoConfig.h b/Source/Core/VideoCommon/Src/VideoConfig.h index 47b28e43a7..3b4224bb86 100644 --- a/Source/Core/VideoCommon/Src/VideoConfig.h +++ b/Source/Core/VideoCommon/Src/VideoConfig.h @@ -123,10 +123,6 @@ struct VideoConfig // D3D only config, mostly to be merged into the above int iAdapter; - int iWindowedRes; - int iFSResolution; - - bool bVsync; // With this enabled, the plugin renders directly to the backbuffer. Many features are // disabled but it might be faster on really old GPUs. diff --git a/Source/Plugins/Plugin_VideoDX9/Src/D3DBase.cpp b/Source/Plugins/Plugin_VideoDX9/Src/D3DBase.cpp index e8cd0fcf44..1ece923ce7 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/D3DBase.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/D3DBase.cpp @@ -232,11 +232,11 @@ void EnableAlphaToCoverage() D3DCREATE_HARDWARE_VERTEXPROCESSING, &d3dpp, &dev))) { - MessageBoxA(wnd, - "Sorry, but it looks like your 3D accelerator is too old,\n" - "or doesn't support features that Dolphin requires.\n" - "Falling back to software vertex processing.\n", - "Dolphin Direct3D plugin", MB_OK | MB_ICONERROR); + MessageBox(wnd, + _T("Sorry, but it looks like your 3D accelerator is too old,\n") + _T("or doesn't support features that Dolphin requires.\n") + _T("Falling back to software vertex processing.\n"), + _T("Dolphin Direct3D plugin"), MB_OK | MB_ICONERROR); if (FAILED(D3D->CreateDevice( adapter, D3DDEVTYPE_HAL, @@ -246,9 +246,9 @@ void EnableAlphaToCoverage() //D3DCREATE_SOFTWARE_VERTEXPROCESSING , &d3dpp, &dev))) { - MessageBoxA(wnd, - "Software VP failed too. Upgrade your graphics card.", - "Dolphin Direct3D plugin", MB_OK | MB_ICONERROR); + MessageBox(wnd, + _T("Software VP failed too. Upgrade your graphics card."), + _T("Dolphin Direct3D plugin"), MB_OK | MB_ICONERROR); return E_FAIL; } } diff --git a/Source/Plugins/Plugin_VideoDX9/Src/DlgSettings.cpp b/Source/Plugins/Plugin_VideoDX9/Src/DlgSettings.cpp index f59b73ca65..29c75fc108 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/DlgSettings.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/DlgSettings.cpp @@ -26,7 +26,8 @@ #include "VideoConfig.h" #include "TextureCache.h" - +// TODO: remove if/when ini files use unicode +#define ComboBox_GetTextA(hwndCtl, lpch, cchMax) GetWindowTextA((hwndCtl), (lpch), (cchMax)) #define NUMWNDRES 6 int g_Res[NUMWNDRES][2] = { @@ -72,8 +73,9 @@ struct TabDirect3D : public W32Util::Tab MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, r.name, -1, tempwstr, 2000); ComboBox_AddString(GetDlgItem(hDlg,IDC_RESOLUTION), tempwstr); } - ComboBox_SetCurSel(GetDlgItem(hDlg,IDC_RESOLUTION), g_Config.iFSResolution); - + + for (int i = 0; i <16; i++) tempwstr[i] = g_Config.cFSResolution[i]; + ComboBox_SelectString(GetDlgItem(hDlg,IDC_RESOLUTION), -1, tempwstr); for (int i = 0; i < NUMWNDRES; i++) { char temp[256]; @@ -81,10 +83,11 @@ struct TabDirect3D : public W32Util::Tab MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, temp, -1, tempwstr, 2000); ComboBox_AddString(GetDlgItem(hDlg,IDC_RESOLUTIONWINDOWED),tempwstr); } - ComboBox_SetCurSel(GetDlgItem(hDlg,IDC_RESOLUTIONWINDOWED),g_Config.iWindowedRes); + for (int i = 0; i < 16; i++) tempwstr[i] = g_Config.cInternalRes[i]; + ComboBox_SelectString(GetDlgItem(hDlg,IDC_RESOLUTIONWINDOWED), -1, tempwstr); CheckDlgButton(hDlg, IDC_FULLSCREENENABLE, g_Config.bFullscreen ? TRUE : FALSE); - CheckDlgButton(hDlg, IDC_VSYNC, g_Config.bVsync ? TRUE : FALSE); + CheckDlgButton(hDlg, IDC_VSYNC, g_Config.bVSync ? TRUE : FALSE); CheckDlgButton(hDlg, IDC_RENDER_TO_MAINWINDOW, g_Config.RenderToMainframe ? TRUE : FALSE); CheckDlgButton(hDlg, IDC_ASPECT_16_9, g_Config.bKeepAR169 ? TRUE : FALSE); CheckDlgButton(hDlg, IDC_ASPECT_4_3, g_Config.bKeepAR43 ? TRUE : FALSE); @@ -118,12 +121,13 @@ struct TabDirect3D : public W32Util::Tab void Apply(HWND hDlg) { + ComboBox_GetTextA(GetDlgItem(hDlg, IDC_RESOLUTIONWINDOWED), g_Config.cInternalRes, 16); + ComboBox_GetTextA(GetDlgItem(hDlg, IDC_RESOLUTION), g_Config.cFSResolution, 16); + g_Config.iAdapter = ComboBox_GetCurSel(GetDlgItem(hDlg, IDC_ADAPTER)); - g_Config.iWindowedRes = ComboBox_GetCurSel(GetDlgItem(hDlg, IDC_RESOLUTIONWINDOWED)); g_Config.iMultisampleMode = ComboBox_GetCurSel(GetDlgItem(hDlg, IDC_ANTIALIASMODE)); - g_Config.iFSResolution = ComboBox_GetCurSel(GetDlgItem(hDlg,IDC_RESOLUTION)); g_Config.bFullscreen = Button_GetCheck(GetDlgItem(hDlg, IDC_FULLSCREENENABLE)) ? true : false; - g_Config.bVsync = Button_GetCheck(GetDlgItem(hDlg, IDC_VSYNC)) ? true : false; + g_Config.bVSync = Button_GetCheck(GetDlgItem(hDlg, IDC_VSYNC)) ? true : false; g_Config.RenderToMainframe = Button_GetCheck(GetDlgItem(hDlg, IDC_RENDER_TO_MAINWINDOW)) ? true : false; g_Config.Save(FULL_CONFIG_DIR "gfx_dx9.ini"); } diff --git a/Source/Plugins/Plugin_VideoDX9/Src/Render.cpp b/Source/Plugins/Plugin_VideoDX9/Src/Render.cpp index 385b841780..ac887f2593 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/Render.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/Render.cpp @@ -88,11 +88,24 @@ void TeardownDeviceObjects() bool Renderer::Init() { UpdateActiveConfig(); - EmuWindow::SetSize(g_Res[g_ActiveConfig.iWindowedRes][0], g_Res[g_ActiveConfig.iWindowedRes][1]); + int fullScreenRes, + w_temp, + h_temp; + sscanf(g_Config.cInternalRes, "%dx%d", &w_temp, &h_temp); + EmuWindow::SetSize(w_temp, h_temp); int backbuffer_ms_mode = 0; // g_ActiveConfig.iMultisampleMode; - D3D::Create(g_ActiveConfig.iAdapter, EmuWindow::GetWnd(), g_ActiveConfig.bFullscreen, - g_ActiveConfig.iFSResolution, backbuffer_ms_mode); + + sscanf(g_Config.cFSResolution, "%dx%d", &w_temp, &h_temp); + + for (fullScreenRes = 0; fullScreenRes < D3D::GetNumAdapters(); fullScreenRes++) + { + if ((D3D::GetAdapter(fullScreenRes).resolutions[fullScreenRes].xres == w_temp) && + (D3D::GetAdapter(fullScreenRes).resolutions[fullScreenRes].yres == h_temp)) + break; + } + D3D::Create(g_ActiveConfig.iAdapter, EmuWindow::GetWnd(), g_ActiveConfig.bFullscreen, + fullScreenRes, backbuffer_ms_mode); s_backbuffer_width = D3D::GetBackBufferWidth(); s_backbuffer_height = D3D::GetBackBufferHeight();