diff options
Diffstat (limited to 'src/skel/win/win.cpp')
-rw-r--r-- | src/skel/win/win.cpp | 106 |
1 files changed, 85 insertions, 21 deletions
diff --git a/src/skel/win/win.cpp b/src/skel/win/win.cpp index 5c5c7ece..3e0a7934 100644 --- a/src/skel/win/win.cpp +++ b/src/skel/win/win.cpp @@ -229,7 +229,11 @@ psCameraBeginUpdate(RwCamera *camera) void psCameraShowRaster(RwCamera *camera) { - if (CMenuManager::m_PrefsVsync) +#ifdef LEGACY_MENU_OPTIONS + if (FrontEndMenuManager.m_PrefsVsync || FrontEndMenuManager.m_bMenuActive) +#else + if (FrontEndMenuManager.m_PrefsFrameLimiter || FrontEndMenuManager.m_bMenuActive) +#endif RwCameraShowRaster(camera, PSGLOBAL(window), rwRASTERFLIPWAITVSYNC); else RwCameraShowRaster(camera, PSGLOBAL(window), rwRASTERFLIPDONTWAIT); @@ -1255,6 +1259,16 @@ MainWndProc(HWND window, UINT message, WPARAM wParam, LPARAM lParam) break; } +#ifdef FIX_BUGS // game turns on menu when focus is re-gained rather than lost + case WM_KILLFOCUS: +#else + case WM_SETFOCUS: +#endif + { + CGame::InitAfterFocusLoss(); + break; + } + } /* @@ -1263,6 +1277,33 @@ MainWndProc(HWND window, UINT message, WPARAM wParam, LPARAM lParam) return DefWindowProc(window, message, wParam, lParam); } +/* + ***************************************************************************** + */ +static BOOL +InitApplication(HANDLE instance) +{ + /* + * Perform any necessary MS Windows application initialization. Basically, + * this means registering the window class for this application. + */ + + WNDCLASS windowClass; + + windowClass.style = CS_BYTEALIGNWINDOW; + windowClass.lpfnWndProc = (WNDPROC)MainWndProc; + windowClass.cbClsExtra = 0; + windowClass.cbWndExtra = 0; + windowClass.hInstance = (HINSTANCE)instance; + windowClass.hIcon = nil; + windowClass.hCursor = LoadCursor(nil, IDC_ARROW); + windowClass.hbrBackground = nil; + windowClass.lpszMenuName = NULL; + windowClass.lpszClassName = AppClassName; + + return RegisterClass(&windowClass); +} + /* ***************************************************************************** @@ -1616,7 +1657,6 @@ RwBool _psSetVideoMode(RwInt32 subSystem, RwInt32 videoMode) return TRUE; } - /* ***************************************************************************** */ @@ -1727,7 +1767,7 @@ void InitialiseLanguage() || primLayout == LANG_GERMAN ) { CGame::nastyGame = false; - CMenuManager::m_PrefsAllowNastyGame = false; + FrontEndMenuManager.m_PrefsAllowNastyGame = false; CGame::germanGame = true; } @@ -1736,7 +1776,7 @@ void InitialiseLanguage() || primLayout == LANG_FRENCH ) { CGame::nastyGame = false; - CMenuManager::m_PrefsAllowNastyGame = false; + FrontEndMenuManager.m_PrefsAllowNastyGame = false; CGame::frenchGame = true; } @@ -1747,7 +1787,7 @@ void InitialiseLanguage() #ifdef NASTY_GAME CGame::nastyGame = true; - CMenuManager::m_PrefsAllowNastyGame = true; + FrontEndMenuManager.m_PrefsAllowNastyGame = true; CGame::noProstitutes = false; #endif @@ -1782,33 +1822,33 @@ void InitialiseLanguage() } } - CMenuManager::OS_Language = primUserLCID; + FrontEndMenuManager.OS_Language = primUserLCID; switch ( lang ) { case LANG_GERMAN: { - CMenuManager::m_PrefsLanguage = CMenuManager::LANGUAGE_GERMAN; + FrontEndMenuManager.m_PrefsLanguage = CMenuManager::LANGUAGE_GERMAN; break; } case LANG_SPANISH: { - CMenuManager::m_PrefsLanguage = CMenuManager::LANGUAGE_SPANISH; + FrontEndMenuManager.m_PrefsLanguage = CMenuManager::LANGUAGE_SPANISH; break; } case LANG_FRENCH: { - CMenuManager::m_PrefsLanguage = CMenuManager::LANGUAGE_FRENCH; + FrontEndMenuManager.m_PrefsLanguage = CMenuManager::LANGUAGE_FRENCH; break; } case LANG_ITALIAN: { - CMenuManager::m_PrefsLanguage = CMenuManager::LANGUAGE_ITALIAN; + FrontEndMenuManager.m_PrefsLanguage = CMenuManager::LANGUAGE_ITALIAN; break; } default: { - CMenuManager::m_PrefsLanguage = CMenuManager::LANGUAGE_AMERICAN; + FrontEndMenuManager.m_PrefsLanguage = CMenuManager::LANGUAGE_AMERICAN; break; } } @@ -1956,13 +1996,11 @@ WinMain(HINSTANCE instance, RwChar **argv; SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT, 0, nil, SPIF_SENDCHANGE); -#if 0 // TODO: make this an option somewhere AllocConsole(); freopen("CONIN$", "r", stdin); freopen("CONOUT$", "w", stdout); freopen("CONOUT$", "w", stderr); -#endif /* * Initialize the platform independent data. @@ -2018,7 +2056,7 @@ WinMain(HINSTANCE instance, if ( _InputInitialise() == S_OK ) { - _InputInitialiseMouse(); + _InputInitialiseMouse(false); _InputInitialiseJoys(); } @@ -2092,7 +2130,7 @@ WinMain(HINSTANCE instance, { CFileMgr::SetDirMyDocuments(); - int32 gta3set = CFileMgr::OpenFile("gta3.set", "r"); + int32 gta3set = CFileMgr::OpenFile("gta_vc.set", "r"); if ( gta3set ) { @@ -2227,7 +2265,7 @@ WinMain(HINSTANCE instance, CoUninitialize(); - if ( CMenuManager::OS_Language == LANG_FRENCH || CMenuManager::OS_Language == LANG_GERMAN ) + if ( FrontEndMenuManager.OS_Language == LANG_FRENCH || FrontEndMenuManager.OS_Language == LANG_GERMAN ) PlayMovieInWindow(cmdShow, "movies\\GTAtitlesGER.mpg"); else PlayMovieInWindow(cmdShow, "movies\\GTAtitles.mpg"); @@ -2297,7 +2335,7 @@ WinMain(HINSTANCE instance, FrontEndMenuManager.m_bGameNotLoaded = true; - CMenuManager::m_bStartUpFrontEndRequested = true; + FrontEndMenuManager.m_bStartUpFrontEndRequested = true; if ( defaultFullscreenRes ) { @@ -2382,7 +2420,7 @@ WinMain(HINSTANCE instance, float ms = (float)CTimer::GetCurrentTimeInCycles() / (float)CTimer::GetCyclesPerMillisecond(); if ( RwInitialised ) { - if (!CMenuManager::m_PrefsFrameLimiter || (1000.0f / (float)RsGlobal.maxFPS) < ms) + if (!FrontEndMenuManager.m_PrefsFrameLimiter || (1000.0f / (float)RsGlobal.maxFPS) < ms) RsEventHandler(rsIDLE, (void *)TRUE); } break; @@ -2393,7 +2431,7 @@ WinMain(HINSTANCE instance, float ms = (float)CTimer::GetCurrentTimeInCycles() / (float)CTimer::GetCyclesPerMillisecond(); if (RwInitialised) { - if (!CMenuManager::m_PrefsFrameLimiter || (1000.0f / (float)RsGlobal.maxFPS) < ms) + if (!FrontEndMenuManager.m_PrefsFrameLimiter || (1000.0f / (float)RsGlobal.maxFPS) < ms) RsEventHandler(rsANIMVIEWER, (void*)TRUE); } break; @@ -2557,7 +2595,7 @@ HRESULT _InputInitialise() return S_OK; } -HRESULT _InputInitialiseMouse() +HRESULT _InputInitialiseMouse(bool exclusive) { HRESULT hr; @@ -2575,7 +2613,7 @@ HRESULT _InputInitialiseMouse() if( FAILED( hr = PSGLOBAL(mouse)->SetDataFormat( &c_dfDIMouse2 ) ) ) return hr; - if( FAILED( hr = PSGLOBAL(mouse)->SetCooperativeLevel( PSGLOBAL(window), DISCL_NONEXCLUSIVE | DISCL_FOREGROUND ) ) ) + if( FAILED( hr = PSGLOBAL(mouse)->SetCooperativeLevel( PSGLOBAL(window), (exclusive ? DISCL_EXCLUSIVE : DISCL_NONEXCLUSIVE) | DISCL_FOREGROUND ) ) ) return hr; // Acquire the newly created device @@ -2863,6 +2901,28 @@ void _InputShutdown() SAFE_RELEASE(PSGLOBAL(dinterface)); } +void _InputShutdownMouse() +{ + if (PSGLOBAL(mouse) == nil) + return; + + PSGLOBAL(mouse)->Unacquire(); + SAFE_RELEASE(PSGLOBAL(mouse)); +} + +bool _InputMouseNeedsExclusive(void) +{ + // FIX: I don't know why R* needed that, but it causes infamous mouse bug on modern systems. + // Probably DirectInput bug, since Acquire() and GetDeviceState() reports everything A-OK. +#ifdef FIX_BUGS + return false; +#endif + RwVideoMode vm; + RwEngineGetVideoModeInfo(&vm, GcurSelVM); + + return vm.flags & rwVIDEOMODEEXCLUSIVE; +} + BOOL CALLBACK _InputEnumDevicesCallback( const DIDEVICEINSTANCE* pdidInstance, VOID* pContext ) { HRESULT hr; @@ -3332,5 +3392,9 @@ int strcasecmp(const char *str1, const char *str2) { return _strcmpi(str1, str2); } +int strncasecmp(const char *str1, const char *str2, size_t len) +{ + return _strnicmp(str1, str2, len); +} #endif #endif
\ No newline at end of file |