From 6d5e88563a594c444ea574ffd9b3a04ddb4c0dce Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Mon, 26 Nov 2001 08:28:48 +0000 Subject: [PATCH] added directx and divx checkers and divx auto installer --- stepmania/src/RageMovieTexture.cpp | 40 ++++++++++++++++++++++ stepmania/src/RageUtil.cpp | 53 ++++++++++++++++++++++++++++++ stepmania/src/RageUtil.h | 2 ++ stepmania/src/StepMania.cpp | 31 ++++++++++++++++- stepmania/src/StepMania.dsp | 8 +++++ 5 files changed, 133 insertions(+), 1 deletion(-) diff --git a/stepmania/src/RageMovieTexture.cpp b/stepmania/src/RageMovieTexture.cpp index b4dcc714bc..ff43141a81 100644 --- a/stepmania/src/RageMovieTexture.cpp +++ b/stepmania/src/RageMovieTexture.cpp @@ -326,7 +326,47 @@ HRESULT RageMovieTexture::InitDShowTextureRenderer() // Add the source filter if( FAILED( hr = m_pGB->AddSourceFilter( wFileName, L"SOURCE", &pFSrc ) ) ) + { + int iRetVal = MessageBox( NULL, "Could not locate the DivX video codec. \n\ +DivX is required to play the animations in this game and must \n\ +be installed before running the application.\n\n\ +If you'd like, we can install the DivX codec version 3.11 \n\ +automatically for you. Would you like to do this?", "Error - DivX missing", MB_YESNO|MB_ICONSTOP ); + if( iRetVal == IDYES ) + { + STARTUPINFO si; + ZeroMemory( &si, sizeof(si) ); + si.cb = sizeof(si); + PROCESS_INFORMATION pi; + + + CreateProcess( + NULL, + "divx/Register_DivX.exe", // pointer to command line string + NULL, // process security attributes + NULL, // thread security attributes + FALSE, // handle inheritance flag + 0, // creation flags + NULL, // pointer to new environment block + "divx", // pointer to current directory name + &si, // pointer to STARTUPINFO + &pi // pointer to PROCESS_INFORMATION + ); + + } + else + { + int iRetVal = MessageBox( NULL, "We're sorry, but you must install DivX before using this application.\n\ +Would you like to visit www.divx.com for more information on DivX codec?", "Sorry", MB_YESNO|MB_ICONSTOP ); + if( iRetVal == IDYES ) + { + GotoURL("http://www.divx.com"); + } + } + exit(1); + // if this fails, it's probably because the user doesn't have DivX installed RageErrorHr( "Could not create source filter to graph!", hr ); + } // Find the source's output and the renderer's input if( FAILED( hr = pFTR->FindPin( L"In", &pFTRPinIn ) ) ) diff --git a/stepmania/src/RageUtil.cpp b/stepmania/src/RageUtil.cpp index 4b48d5e4d3..2fa21fab45 100644 --- a/stepmania/src/RageUtil.cpp +++ b/stepmania/src/RageUtil.cpp @@ -297,3 +297,56 @@ VOID DisplayErrorAndDie( CString sError ) ); exit(1); } + + +LONG GetRegKey(HKEY key, LPCTSTR subkey, LPTSTR retdata) +{ + HKEY hkey; + LONG retval = RegOpenKeyEx(key, subkey, 0, KEY_QUERY_VALUE, &hkey); + + if (retval == ERROR_SUCCESS) { + long datasize = MAX_PATH; + TCHAR data[MAX_PATH]; + RegQueryValue(hkey, NULL, data, &datasize); + lstrcpy(retdata,data); + RegCloseKey(hkey); + } + + return retval; +} + +HINSTANCE GotoURL(LPCTSTR url) +{ + TCHAR key[MAX_PATH + MAX_PATH]; + + // First try ShellExecute() + HINSTANCE result = ShellExecute(NULL, _T("open"), url, NULL,NULL, SW_SHOWDEFAULT); + + // If it failed, get the .htm regkey and lookup the program + if ((UINT)result <= HINSTANCE_ERROR) { + + if (GetRegKey(HKEY_CLASSES_ROOT, _T(".htm"), key) == ERROR_SUCCESS) { + lstrcat(key, _T("\\shell\\open\\command")); + + if (GetRegKey(HKEY_CLASSES_ROOT,key,key) == ERROR_SUCCESS) { + TCHAR *pos; + pos = _tcsstr(key, _T("\"%1\"")); + if (pos == NULL) { // No quotes found + pos = strstr(key, _T("%1")); // Check for %1, without quotes + if (pos == NULL) // No parameter at all... + pos = key+lstrlen(key)-1; + else + *pos = '\0'; // Remove the parameter + } + else + *pos = '\0'; // Remove the parameter + + lstrcat(pos, _T(" ")); + lstrcat(pos, url); + result = (HINSTANCE) WinExec(key,SW_SHOWDEFAULT); + } + } + } + + return result; +} diff --git a/stepmania/src/RageUtil.h b/stepmania/src/RageUtil.h index 86088b7a04..4287352242 100644 --- a/stepmania/src/RageUtil.h +++ b/stepmania/src/RageUtil.h @@ -111,6 +111,8 @@ VOID DisplayErrorAndDie( CString sError ); //#endif +LONG GetRegKey(HKEY key, LPCTSTR subkey, LPTSTR retdata); +HINSTANCE GotoURL(LPCTSTR url); #endif diff --git a/stepmania/src/StepMania.cpp b/stepmania/src/StepMania.cpp index 0734245467..47a86a651b 100644 --- a/stepmania/src/StepMania.cpp +++ b/stepmania/src/StepMania.cpp @@ -67,7 +67,7 @@ void Update(); // Update the game logic void Render(); // Render a frame void ShowFrame(); // Display the contents of the back buffer to the screen void SetFullscreen( BOOL bFullscreen ); // Switch between fullscreen and windowed modes. - +void TestForDirectX(); // check for DirectX 8 // Functions that work with game objects HRESULT CreateObjects( HWND hWnd ); // allocate and initialize game objects @@ -123,6 +123,9 @@ int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE, LPSTR, int nCmdShow ) if( NULL == g_hWndMain ) exit(1); + + TestForDirectX(); + // Load keyboard accelerators HACCEL hAccel = LoadAccelerators( NULL, MAKEINTRESOURCE(IDR_MAIN_ACCEL) ); @@ -478,3 +481,29 @@ void SetFullscreen( BOOL bFullscreen ) SCREEN_HEIGHT ); RestoreObjects(); } + + +//----------------------------------------------------------------------------- +// Name: TestForDirectX() +// Desc: check for DirectX 8 +//----------------------------------------------------------------------------- +#include "getdxver.h" + +void TestForDirectX() +{ + if( GetDXVersion() < 0x0800 ) + { + int iRetVal = MessageBox( NULL, "We're sorry, but you have an old version of the Microsoft DirectX drivers.\n\ +This application requires DirectX version 8.1 or higher.\n\n\ +Would you like to visit the Microsoft DirectX site to download the latest version?", "Sorry", MB_YESNO|MB_ICONSTOP ); + if( iRetVal == IDYES ) + { + GotoURL("http://www.microsoft.com/directx/homeuser/downloads/default.asp"); + } + + exit(1); + } + +} + + diff --git a/stepmania/src/StepMania.dsp b/stepmania/src/StepMania.dsp index 923bbf20bb..b868c02c9c 100644 --- a/stepmania/src/StepMania.dsp +++ b/stepmania/src/StepMania.dsp @@ -404,6 +404,14 @@ SOURCE=.\dxutil.cpp # End Source File # Begin Source File +SOURCE=.\getdxver.cpp +# End Source File +# Begin Source File + +SOURCE=.\getdxver.h +# End Source File +# Begin Source File + SOURCE=.\resource.h # End Source File # Begin Source File