src/video/win32_v.cpp
branchNewGRF_ports
changeset 10994 cd9968b6f96b
parent 10991 d8811e327d12
equal deleted inserted replaced
10991:d8811e327d12 10994:cd9968b6f96b
    34 
    34 
    35 bool _force_full_redraw;
    35 bool _force_full_redraw;
    36 bool _window_maximize;
    36 bool _window_maximize;
    37 uint _display_hz;
    37 uint _display_hz;
    38 uint _fullscreen_bpp;
    38 uint _fullscreen_bpp;
    39 static uint16 _bck_resolution[2];
    39 static Dimension _bck_resolution;
    40 #if !defined(UNICODE)
    40 #if !defined(UNICODE)
    41 uint _codepage;
    41 uint _codepage;
    42 #endif
    42 #endif
    43 
    43 
    44 static void MakePalette()
    44 static void MakePalette()
   369 		case WM_CLOSE:
   369 		case WM_CLOSE:
   370 			HandleExitGameRequest();
   370 			HandleExitGameRequest();
   371 			return 0;
   371 			return 0;
   372 
   372 
   373 		case WM_DESTROY:
   373 		case WM_DESTROY:
   374 			if (_window_maximize) {
   374 			if (_window_maximize) _cur_resolution = _bck_resolution;
   375 				_cur_resolution[0] = _bck_resolution[0];
       
   376 				_cur_resolution[1] = _bck_resolution[1];
       
   377 			}
       
   378 			return 0;
   375 			return 0;
   379 
   376 
   380 		case WM_LBUTTONDOWN:
   377 		case WM_LBUTTONDOWN:
   381 			SetCapture(hwnd);
   378 			SetCapture(hwnd);
   382 			_left_button_down = true;
   379 			_left_button_down = true;
   528 		case WM_SIZE:
   525 		case WM_SIZE:
   529 			if (wParam != SIZE_MINIMIZED) {
   526 			if (wParam != SIZE_MINIMIZED) {
   530 				/* Set maximized flag when we maximize (obviously), but also when we
   527 				/* Set maximized flag when we maximize (obviously), but also when we
   531 				 * switched to fullscreen from a maximized state */
   528 				 * switched to fullscreen from a maximized state */
   532 				_window_maximize = (wParam == SIZE_MAXIMIZED || (_window_maximize && _fullscreen));
   529 				_window_maximize = (wParam == SIZE_MAXIMIZED || (_window_maximize && _fullscreen));
   533 				if (_window_maximize) {
   530 				if (_window_maximize) _bck_resolution = _cur_resolution;
   534 					_bck_resolution[0] = _cur_resolution[0];
       
   535 					_bck_resolution[1] = _cur_resolution[1];
       
   536 				}
       
   537 				ClientSizeChanged(LOWORD(lParam), HIWORD(lParam));
   531 				ClientSizeChanged(LOWORD(lParam), HIWORD(lParam));
   538 			}
   532 			}
   539 			return 0;
   533 			return 0;
   540 
   534 
   541 #if !defined(WINCE)
   535 #if !defined(WINCE)
   711 	ReleaseDC(0, dc);
   705 	ReleaseDC(0, dc);
   712 
   706 
   713 	return true;
   707 	return true;
   714 }
   708 }
   715 
   709 
   716 static const uint16 default_resolutions[][2] = {
   710 static const Dimension default_resolutions[] = {
   717 	{  640,  480 },
   711 	{  640,  480 },
   718 	{  800,  600 },
   712 	{  800,  600 },
   719 	{ 1024,  768 },
   713 	{ 1024,  768 },
   720 	{ 1152,  864 },
   714 	{ 1152,  864 },
   721 	{ 1280,  800 },
   715 	{ 1280,  800 },
   744 		if (dm.dmBitsPerPel == BlitterFactoryBase::GetCurrentBlitter()->GetScreenDepth() &&
   738 		if (dm.dmBitsPerPel == BlitterFactoryBase::GetCurrentBlitter()->GetScreenDepth() &&
   745 				dm.dmPelsWidth >= 640 && dm.dmPelsHeight >= 480) {
   739 				dm.dmPelsWidth >= 640 && dm.dmPelsHeight >= 480) {
   746 			uint j;
   740 			uint j;
   747 
   741 
   748 			for (j = 0; j < n; j++) {
   742 			for (j = 0; j < n; j++) {
   749 				if (_resolutions[j][0] == dm.dmPelsWidth && _resolutions[j][1] == dm.dmPelsHeight) break;
   743 				if (_resolutions[j].width == (int)dm.dmPelsWidth && _resolutions[j].height == (int)dm.dmPelsHeight) break;
   750 			}
   744 			}
   751 
   745 
   752 			/* In the previous loop we have checked already existing/added resolutions if
   746 			/* In the previous loop we have checked already existing/added resolutions if
   753 			 * they are the same as the new ones. If this is not the case (j == n); we have
   747 			 * they are the same as the new ones. If this is not the case (j == n); we have
   754 			 * looped all and found none, add the new one to the list. If we have reached the
   748 			 * looped all and found none, add the new one to the list. If we have reached the
   755 			 * maximum amount of resolutions, then quit querying the display */
   749 			 * maximum amount of resolutions, then quit querying the display */
   756 			if (j == n) {
   750 			if (j == n) {
   757 				_resolutions[j][0] = dm.dmPelsWidth;
   751 				_resolutions[j].width  = dm.dmPelsWidth;
   758 				_resolutions[j][1] = dm.dmPelsHeight;
   752 				_resolutions[j].height = dm.dmPelsHeight;
   759 				if (++n == lengthof(_resolutions)) break;
   753 				if (++n == lengthof(_resolutions)) break;
   760 			}
   754 			}
   761 		}
   755 		}
   762 	}
   756 	}
   763 #endif
   757 #endif
   782 
   776 
   783 	MakePalette();
   777 	MakePalette();
   784 
   778 
   785 	FindResolutions();
   779 	FindResolutions();
   786 
   780 
   787 	DEBUG(driver, 2, "Resolution for display: %dx%d", _cur_resolution[0], _cur_resolution[1]);
   781 	DEBUG(driver, 2, "Resolution for display: %dx%d", _cur_resolution.width, _cur_resolution.height);
   788 
   782 
   789 	// fullscreen uses those
   783 	// fullscreen uses those
   790 	_wnd.width_org = _cur_resolution[0];
   784 	_wnd.width_org  = _cur_resolution.width;
   791 	_wnd.height_org = _cur_resolution[1];
   785 	_wnd.height_org = _cur_resolution.height;
   792 
   786 
   793 	AllocateDibSection(_cur_resolution[0], _cur_resolution[1]);
   787 	AllocateDibSection(_cur_resolution.width, _cur_resolution.height);
   794 	MakeWindow(_fullscreen);
   788 	MakeWindow(_fullscreen);
   795 
   789 
   796 	MarkWholeScreenDirty();
   790 	MarkWholeScreenDirty();
   797 
   791 
   798 	return NULL;
   792 	return NULL;