Mercurial > mm7
comparison OSWindow.cpp @ 2064:74f06d8a8017
Merge
author | Ritor1 |
---|---|
date | Mon, 02 Dec 2013 20:43:28 +0600 |
parents | b2a434d65344 |
children | 259df09dfb50 |
comparison
equal
deleted
inserted
replaced
2063:7890930801a8 | 2064:74f06d8a8017 |
---|---|
267 return *result = 0, true; | 267 return *result = 0, true; |
268 | 268 |
269 case WM_ACTIVATEAPP: | 269 case WM_ACTIVATEAPP: |
270 if ( wparam && (GetForegroundWindow() == api_handle || GetForegroundWindow() == hInsertCDWindow) ) | 270 if ( wparam && (GetForegroundWindow() == api_handle || GetForegroundWindow() == hInsertCDWindow) ) |
271 { | 271 { |
272 if ( BYTE1(dword_6BE364_game_settings_1) & 1 ) | 272 if (dword_6BE364_game_settings_1 & GAME_SETTINGS_APP_INACTIVE) |
273 { | 273 { |
274 dword_4E98BC_bApplicationActive = 1; | 274 dword_4E98BC_bApplicationActive = 1; |
275 if ( pRenderer->bWindowMode ) | 275 if ( pRenderer->bWindowMode ) |
276 { | 276 { |
277 HDC hDC = GetDC(api_handle); | 277 HDC hDC = GetDC(api_handle); |
279 int planes = GetDeviceCaps(hDC, PLANES); | 279 int planes = GetDeviceCaps(hDC, PLANES); |
280 ReleaseDC(api_handle, hDC); | 280 ReleaseDC(api_handle, hDC); |
281 if (bitsPerPixel != 16 || planes != 1) | 281 if (bitsPerPixel != 16 || planes != 1) |
282 Error(pGlobalTXT_LocalizationStrings[62]); | 282 Error(pGlobalTXT_LocalizationStrings[62]); |
283 } | 283 } |
284 BYTE1(dword_6BE364_game_settings_1) &= 0xFEu; | 284 dword_6BE364_game_settings_1 &= ~GAME_SETTINGS_APP_INACTIVE; |
285 | 285 |
286 if ( pArcomageGame->bGameInProgress ) | 286 if ( pArcomageGame->bGameInProgress ) |
287 { | 287 { |
288 pArcomageGame->field_F9 = 1; | 288 pArcomageGame->field_F9 = 1; |
289 } | 289 } |
290 else | 290 else |
291 { | 291 { |
292 if ( BYTE1(dword_6BE364_game_settings_1) & 2 ) | 292 if (dword_6BE364_game_settings_1 & GAME_SETTINGS_0200_EVENT_TIMER) |
293 BYTE1(dword_6BE364_game_settings_1) &= 0xFDu; | 293 dword_6BE364_game_settings_1 &= ~GAME_SETTINGS_0200_EVENT_TIMER; |
294 else | 294 else |
295 pEventTimer->Resume(); | 295 pEventTimer->Resume(); |
296 if ( BYTE1(dword_6BE364_game_settings_1) & 4 ) | 296 if (dword_6BE364_game_settings_1 & GAME_SETTINGS_0400_MISC_TIMER) |
297 BYTE1(dword_6BE364_game_settings_1) &= 0xFBu; | 297 dword_6BE364_game_settings_1 &= ~GAME_SETTINGS_0400_MISC_TIMER; |
298 else | 298 else |
299 pMiscTimer->Resume(); | 299 pMiscTimer->Resume(); |
300 | 300 |
301 viewparams->bRedrawGameUI = true; | 301 viewparams->bRedrawGameUI = true; |
302 if ( pVideoPlayer->pSmackerMovie ) | 302 if ( pVideoPlayer->pSmackerMovie ) |
310 AIL_redbook_resume(pAudioPlayer->hAILRedbook); | 310 AIL_redbook_resume(pAudioPlayer->hAILRedbook); |
311 } | 311 } |
312 } | 312 } |
313 else | 313 else |
314 { | 314 { |
315 if (!(dword_6BE364_game_settings_1 & 0x100)) | 315 if (!(dword_6BE364_game_settings_1 & GAME_SETTINGS_APP_INACTIVE)) |
316 { | 316 { |
317 dword_4E98BC_bApplicationActive = 0; | 317 dword_4E98BC_bApplicationActive = 0; |
318 if ( (pVideoPlayer->pSmackerMovie || pVideoPlayer->pBinkMovie) && pVideoPlayer->bPlayingMovie ) | 318 if ( (pVideoPlayer->pSmackerMovie || pVideoPlayer->pBinkMovie) && pVideoPlayer->bPlayingMovie ) |
319 pVideoPlayer->bStopBeforeSchedule = 1; | 319 pVideoPlayer->bStopBeforeSchedule = 1; |
320 | 320 |
321 if (/*pRenderer->bUserDirect3D && */pRenderer->uAcquiredDirect3DDevice == 1) | 321 if (/*pRenderer->bUserDirect3D && */pRenderer->uAcquiredDirect3DDevice == 1) |
322 SetWindowPos(api_handle, (HWND)0xFFFFFFFE, 0, 0, 0, 0, 0x18u); | 322 SetWindowPos(api_handle, (HWND)0xFFFFFFFE, 0, 0, 0, 0, 0x18u); |
323 ClipCursor(0); | 323 ClipCursor(0); |
324 dword_6BE364_game_settings_1 |= 0x100u; | 324 dword_6BE364_game_settings_1 |= GAME_SETTINGS_APP_INACTIVE; |
325 if ( pEventTimer->bPaused ) | 325 if ( pEventTimer->bPaused ) |
326 BYTE1(dword_6BE364_game_settings_1) |= 2u; | 326 dword_6BE364_game_settings_1 |= GAME_SETTINGS_0200_EVENT_TIMER; |
327 else | 327 else |
328 pEventTimer->Pause(); | 328 pEventTimer->Pause(); |
329 if ( pMiscTimer->bPaused ) | 329 if ( pMiscTimer->bPaused ) |
330 BYTE1(dword_6BE364_game_settings_1) |= 4u; | 330 dword_6BE364_game_settings_1 |= GAME_SETTINGS_0400_MISC_TIMER; |
331 else | 331 else |
332 pMiscTimer->Pause(); | 332 pMiscTimer->Pause(); |
333 | 333 |
334 pAudioPlayer->StopChannels(-1, -1); | 334 pAudioPlayer->StopChannels(-1, -1); |
335 if ( pAudioPlayer->hAILRedbook ) | 335 if ( pAudioPlayer->hAILRedbook ) |
399 wcxw.lpszMenuName = nullptr; | 399 wcxw.lpszMenuName = nullptr; |
400 wcxw.style = CS_OWNDC | CS_HREDRAW | CS_VREDRAW; | 400 wcxw.style = CS_OWNDC | CS_HREDRAW | CS_VREDRAW; |
401 if (!RegisterClassExW(&wcxw)) | 401 if (!RegisterClassExW(&wcxw)) |
402 return false; | 402 return false; |
403 | 403 |
404 api_handle = CreateWindowExW(0, wcxw.lpszClassName, title, | 404 api_handle = CreateWindowExW(0, wcxw.lpszClassName, title, 0, |
405 0, | |
406 0, 0, window_width, window_height, nullptr, | 405 0, 0, window_width, window_height, nullptr, |
407 nullptr, wcxw.hInstance, this); | 406 nullptr, wcxw.hInstance, this); |
408 if (!api_handle) | 407 if (!api_handle) |
409 { | 408 { |
410 UnregisterClassW(wcxw.lpszClassName, wcxw.hInstance); | 409 UnregisterClassW(wcxw.lpszClassName, wcxw.hInstance); |
411 return false; | 410 return false; |
412 } | |
413 | |
414 HDC hDC = GetDC(NULL); | |
415 int bitsPerPixel = GetDeviceCaps(hDC, BITSPIXEL); | |
416 int planes = GetDeviceCaps(hDC, PLANES); | |
417 ReleaseDC(NULL, hDC); | |
418 if (bitsPerPixel != 16 || planes != 1) | |
419 { | |
420 SetColorDepth(16); | |
421 } | 411 } |
422 | 412 |
423 SetWindowedMode(window_width, window_height); | 413 SetWindowedMode(window_width, window_height); |
424 Show(); | 414 Show(); |
425 | 415 |
438 | 428 |
439 | 429 |
440 | 430 |
441 OSWindow *OSWindow::Create(const wchar_t *title, int window_width, int window_height) | 431 OSWindow *OSWindow::Create(const wchar_t *title, int window_width, int window_height) |
442 { | 432 { |
443 OSWindow* window = new OSWindow; | 433 auto window = new OSWindow; |
444 if (window) | 434 if (window) |
445 if (!window->Initialize(title, window_width, window_height)) | 435 if (!window->Initialize(title, window_width, window_height)) |
446 { | 436 { |
447 delete window; | 437 delete window; |
448 window = nullptr; | 438 window = nullptr; |
798 break; | 788 break; |
799 } | 789 } |
800 | 790 |
801 return true; | 791 return true; |
802 } | 792 } |
803 | |
804 bool OSWindow::SetColorDepth(int bit) | |
805 { | |
806 DEVMODE dm; | |
807 if (!EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &dm)) | |
808 { | |
809 Log::Warning(L"EnumDisplaySettings failed: %d\n", GetLastError()); | |
810 return false; | |
811 } | |
812 | |
813 dm.dmSize = sizeof(DEVMODE); | |
814 dm.dmBitsPerPel = bit; | |
815 dm.dmFields = DM_BITSPERPEL; | |
816 if (ChangeDisplaySettings(&dm, CDS_TEST) != DISP_CHANGE_SUCCESSFUL) | |
817 { | |
818 Log::Warning(L"Illegal graphics mode: %d\n", GetLastError()); | |
819 return false; | |
820 } | |
821 if (ChangeDisplaySettings(&dm, 0) == DISP_CHANGE_SUCCESSFUL) | |
822 { | |
823 ChangedColorDepth = true; | |
824 } | |
825 } | |
826 | |
827 void OSWindow::Delete() | |
828 { | |
829 Deinitialize(); | |
830 } | |
831 | |
832 void OSWindow::Deinitialize() | |
833 { | |
834 if( ChangedColorDepth ) | |
835 { | |
836 SetColorDepth(32); | |
837 } | |
838 } |