bool CWinSystemWin32DX::SetFullScreen(bool fullScreen, RESOLUTION_INFO& res, bool blankOtherDisplays) { // When going DX fullscreen -> windowed, we must switch DXGI device to windowed mode first to // get it out of fullscreen mode because it restores a former resolution. // We then change to the mode we want. // In other cases, set the window/mode then swith DXGI mode. bool FS2Windowed = !m_useWindowedDX && UseWindowedDX(fullScreen); const MONITOR_DETAILS* monitor = GetMonitor(res.iScreen); if (!monitor) return false; SetMonitor(monitor->hMonitor); CRenderSystemDX::m_interlaced = ((res.dwFlags & D3DPRESENTFLAG_INTERLACED) != 0); CRenderSystemDX::m_useWindowedDX = UseWindowedDX(fullScreen); // this needed to prevent resize/move events from DXGI during changing mode CWinSystemWin32::m_IsAlteringWindow = true; if (FS2Windowed) CRenderSystemDX::SetFullScreenInternal(); if (!m_useWindowedDX) SetForegroundWindowInternal(m_hWnd); // most 3D content has 23.976fps, so switch for this mode if (g_graphicsContext.GetStereoMode() == RENDER_STEREO_MODE_HARDWAREBASED) res = CDisplaySettings::GetInstance().GetResolutionInfo(CResolutionUtils::ChooseBestResolution(24.f / 1.001f, res.iWidth, true)); // so this flags delays call SetFullScreen _after_ resetting render system bool delaySetFS = CRenderSystemDX::m_bHWStereoEnabled; if (!delaySetFS) CWinSystemWin32::SetFullScreen(fullScreen, res, blankOtherDisplays); // this needed to prevent resize/move events from DXGI during changing mode CWinSystemWin32::m_IsAlteringWindow = true; CRenderSystemDX::ResetRenderSystem(res.iWidth, res.iHeight, fullScreen, res.fRefreshRate); if (delaySetFS) { // now resize window and force changing resolution if stereo mode disabled if (UseWindowedDX(fullScreen)) CWinSystemWin32::SetFullScreenEx(fullScreen, res, blankOtherDisplays, !CRenderSystemDX::m_bHWStereoEnabled); else { CRenderSystemDX::SetFullScreenInternal(); CRenderSystemDX::CreateWindowSizeDependentResources(); } } CWinSystemWin32::m_IsAlteringWindow = false; return true; }
DWORD WINAPI PopupThread(LPVOID pData) { PopupData * pD = (PopupData *)pData; animationDone = false; showCreditBox = false; kidList.pRecords = NULL; kidList.nRecords = 0; pClassList = new ClassList(pD->sname); srand((unsigned)time(NULL)); if (pClassList->err()) { MessageBox(NULL, pClassList->errStr(), L"Error", MB_OK); goto cleanup; } kidList = pClassList->getRecordSet(); nameListPos = 0.0f; if (!isPopupWndRegistered) { if (!PopupRegisterClass(pD->instance)) goto cleanup; isPopupWndRegistered = true; } UINT sX = GetSystemMetrics(SM_CXSCREEN); UINT sY = GetSystemMetrics(SM_CYSCREEN); HWND hWnd = CreateWindowExW(WS_EX_LEFT, L"NowUGo Banner", L"Banner!", WS_POPUP | WS_VISIBLE | WS_SYSMENU, 0, (UINT)(sY * GFX::YPos), sX, (UINT)(sY * GFX::YSize) , nullptr, nullptr, pD->instance, nullptr); if (!hWnd) goto cleanup; ShowWindow(hWnd, SW_SHOWNORMAL); UpdateWindow(hWnd); if (!SetForegroundWindow(hWnd)) if (!SetForegroundWindowInternal2(hWnd)) { SetForegroundWindowInternal(hWnd); } // Start animation timer timerID = SetTimer(hWnd, timerID, 50, NULL); // Popup thread message loop: MSG msg; while (GetMessage(&msg, nullptr, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } cleanup: // Thread Cleanup HWND pHwnd = pD->parent; delete pD->sname; delete pD; delete pClassList; if (kidList.pRecords) delete[] kidList.pRecords; kidList.nRecords = 0; SendMessage(pHwnd, WM_USER_HKLISTEN, 0, 0); return 0; }
// TODO cleanup messy code BOOL _CreateMap(VOID) { STARTUPINFOW si = { 0 }; PROCESS_INFORMATION pi = { 0 }; BOOL bRet = FALSE; WCHAR cwd[MAX_PATH] = { 0 }; WCHAR rmgtmp[MAX_PATH] = { 0 }; char rmg_dll[MAX_PATH] = { 0 }; WCHAR h3maped_dir[MAX_PATH] = { 0 }; WCHAR h3maped_exe[MAX_PATH] = { 0 }; WCHAR gzip_utils_dest[MAX_PATH] = { 0 }; HKEY key = NULL; char value[MAX_PATH] = { 0 }; DWORD value_length = sizeof(value)-1; DWORD type = REG_SZ; GetCurrentDirectoryW(sizeof(cwd)-1, cwd); _snwprintf(rmgtmp, sizeof(rmgtmp) / sizeof(WCHAR)-1, L"%s\\data\\maps\\rmgtmp", cwd); DeleteFileW(rmgtmp); if (RegOpenKeyA(HKEY_CURRENT_USER, "Software\\h3minternals\\", &key) != ERROR_SUCCESS) { return FALSE; } value_length = sizeof(value); memset(value, 0, sizeof(value)); if (ERROR_SUCCESS != RegQueryValueExA(key, "orig_maped_path", NULL, &type, (LPBYTE)value, &value_length)) { char fail[64]; sprintf(fail, "fail %d", GetLastError()); OutputDebugStringA(fail); } _snwprintf(h3maped_dir, sizeof(h3maped_dir) / sizeof(WCHAR) - 1, L"%S", value); _snwprintf(h3maped_exe, sizeof(h3maped_exe) / sizeof(WCHAR)-1, L"%s\\h3maped.exe", h3maped_dir); _snwprintf(gzip_utils_dest, sizeof(gzip_utils_dest) / sizeof(WCHAR)-1, L"%s\\gzip_utils.dll", h3maped_dir); if (FALSE == CopyFileW(L"gzip_utils.dll", gzip_utils_dest, FALSE)) { MessageBoxA(0, "Failed to copy gzip_utils.dll to map editor path. Please copy this file manually.", "Error", MB_ICONERROR); } OutputDebugStringW(L"anymap: orig_maped_path"); OutputDebugStringW(h3maped_exe); value_length = sizeof(rmg_dll); memset(rmg_dll, 0, sizeof(rmg_dll)); if (ERROR_SUCCESS != RegQueryValueExA(key, "maped_rmg_path", NULL, &type, (LPBYTE)rmg_dll, &value_length)) { char fail[64]; sprintf(fail, "fail %d", GetLastError()); OutputDebugStringA(fail); } OutputDebugStringA("anymap: maped_rmg_path"); OutputDebugStringA(rmg_dll); RegCloseKey(key); si.cb = sizeof(si); si.lpReserved = cwd; if (FALSE == (bRet = CreateProcessW(NULL, h3maped_exe, NULL, NULL, FALSE, CREATE_SUSPENDED, NULL, NULL, &si, &pi ))) { CloseHandle(pi.hThread); CloseHandle(pi.hProcess); return FALSE; } inject_dll(pi.hProcess, rmg_dll, 0); ResumeThread(pi.hThread); { for (;;) { MSG msg; if (0 != PeekMessageA(&msg, NULL, 0, 0, PM_REMOVE)) { TranslateMessage(&msg); DispatchMessage(&msg); } if (WAIT_OBJECT_0 == WaitForSingleObject(pi.hThread, 50)) { break; } } } SetForegroundWindowInternal(FindWindowA("SDL_app", TITLE)); CloseHandle(pi.hThread); CloseHandle(pi.hProcess); return TRUE; }