From 1c09cba69a5dea2df14184b97af9e2fe447c8055 Mon Sep 17 00:00:00 2001 From: ayuanx Date: Tue, 19 Jan 2010 20:18:41 +0000 Subject: [PATCH] Create wxWindow in heap rather than stack Center DX9 window Bring Wiimote reconnect confirm dialog to topmost, now only works with OpenGL. (It seems DX9 in full screen doesn't like other windows overlapped upon it.) git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4895 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/DolphinWX/Src/Frame.cpp | 17 ++++++-- Source/Core/DolphinWX/Src/FrameTools.cpp | 12 +++--- .../Plugins/Plugin_VideoDX9/Src/EmuWindow.cpp | 40 ++++++++++++++++++- 3 files changed, 58 insertions(+), 11 deletions(-) diff --git a/Source/Core/DolphinWX/Src/Frame.cpp b/Source/Core/DolphinWX/Src/Frame.cpp index 2fcbbbd06e..31d5327c37 100644 --- a/Source/Core/DolphinWX/Src/Frame.cpp +++ b/Source/Core/DolphinWX/Src/Frame.cpp @@ -166,11 +166,20 @@ CPanel::CPanel( else { // The Wiimote has been disconnect, we offer reconnect here - if(AskYesNo("Wiimote %i has been disconnected by system.\n" - "Maybe this game doesn't support multi-wiimote,\n" - "or maybe it is due to idle time out or other reason.\n\n" - "Do you want to reconnect immediately?", lParam + 1, "Confirm", wxYES_NO)) + wxMessageDialog *dlg = new wxMessageDialog( + this, + wxString::Format(wxT("Wiimote %i has been disconnected by system.\n") + wxT("Maybe this game doesn't support multi-wiimote,\n") + wxT("or maybe it is due to idle time out or other reason.\n\n") + wxT("Do you want to reconnect immediately?"), lParam + 1), + wxT("Reconnect Wiimote Confirm"), + wxYES_NO | wxSTAY_ON_TOP | wxICON_INFORMATION, //wxICON_QUESTION, + wxDefaultPosition); + + if (dlg->ShowModal() == wxID_YES) GetUsbPointer()->AccessWiiMote(lParam | 0x100)->Activate(true); + + delete dlg; } return 0; } diff --git a/Source/Core/DolphinWX/Src/FrameTools.cpp b/Source/Core/DolphinWX/Src/FrameTools.cpp index 906127dbdf..f6d7b8b31d 100644 --- a/Source/Core/DolphinWX/Src/FrameTools.cpp +++ b/Source/Core/DolphinWX/Src/FrameTools.cpp @@ -698,14 +698,16 @@ void CFrame::DoStop() // Ask for confirmation in case the user accidentally clicked Stop / Escape if (SConfig::GetInstance().m_LocalCoreStartupParameter.bConfirmStop) { - wxMessageDialog dlg( + wxMessageDialog *dlg = new wxMessageDialog( this, - wxString::FromAscii("Do want to stop the current emulation?"), - wxString::FromAscii("Please confirm..."), - wxYES_NO | wxSTAY_ON_TOP | wxCENTRE, + wxT("Do you want to stop the current emulation?"), + wxT("Please confirm..."), + wxYES_NO | wxSTAY_ON_TOP | wxICON_EXCLAMATION, wxDefaultPosition); - if (dlg.ShowModal() == wxID_NO) + int Ret = dlg->ShowModal(); + delete dlg; + if (Ret == wxID_NO) return; } diff --git a/Source/Plugins/Plugin_VideoDX9/Src/EmuWindow.cpp b/Source/Plugins/Plugin_VideoDX9/Src/EmuWindow.cpp index 5e0eafa483..403fba2ebf 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/EmuWindow.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/EmuWindow.cpp @@ -234,9 +234,45 @@ void Show() HWND Create(HWND hParent, HINSTANCE hInstance, const TCHAR *title) { + // TODO: + // 1. Remove redundant window manipulation, + // 2. Make DX9 in fullscreen can be overlapped by other dialogs + HWND Ret; int width=640, height=480; sscanf( g_Config.bFullscreen ? g_Config.cFSResolution : g_Config.cInternalRes, "%dx%d", &width, &height ); - return OpenWindow(hParent, hInstance, width, height, title); +// SetSize(width, height); + Ret = OpenWindow(hParent, hInstance, width, height, title); + + if (Ret) + { + DWORD dwStyle = 0; // Window Style + DWORD dwExStyle = 0; // Window Extended Style + RECT rc = {0, 0, width, height}; + RECT rcdesktop; + GetWindowRect(GetDesktopWindow(), &rcdesktop); + int X = (rcdesktop.right-rcdesktop.left)/2 - (rc.right-rc.left)/2; + int Y = (rcdesktop.bottom-rcdesktop.top)/2 - (rc.bottom-rc.top)/2; + + if (g_Config.bFullscreen && !g_Config.RenderToMainframe) + { + // Hide the cursor + ShowCursor(FALSE); + } + else + { + dwExStyle = WS_EX_APPWINDOW | WS_EX_WINDOWEDGE; + dwStyle = WS_OVERLAPPEDWINDOW; + } + +// AdjustWindowRectEx(&rc, dwStyle, FALSE, dwExStyle); + + if (g_Config.bFullscreen) + // We put the window at the upper left corner of the screen, so x = y = 0 + SetWindowPos(EmuWindow::GetWnd(), NULL, 0, 0, rc.right-rc.left, rc.bottom-rc.top, SWP_NOREPOSITION | SWP_NOZORDER); + else if (!g_Config.RenderToMainframe) + SetWindowPos(EmuWindow::GetWnd(), NULL, X, Y, rc.right-rc.left, rc.bottom-rc.top, SWP_NOREPOSITION | SWP_NOZORDER); + } + return Ret; } void Close() @@ -261,7 +297,7 @@ void SetSize(int width, int height) rc.right = rc.left + w; rc.top = (1024 - h)/2; rc.bottom = rc.top + h; - ::MoveWindow(m_hWnd, rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top, TRUE); + MoveWindow(m_hWnd, rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top, TRUE); } void ToggleFullscreen(HWND hParent)