added directx and divx checkers and divx auto installer
This commit is contained in:
@@ -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 ) ) )
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -111,6 +111,8 @@ VOID DisplayErrorAndDie( CString sError );
|
||||
//#endif
|
||||
|
||||
|
||||
LONG GetRegKey(HKEY key, LPCTSTR subkey, LPTSTR retdata);
|
||||
HINSTANCE GotoURL(LPCTSTR url);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user