Initial commit: ROW Client source code
Game client codebase including: - CharacterActionControl: Character and creature management - GlobalScript: Network, items, skills, quests, utilities - RYLClient: Main client application with GUI and event handlers - Engine: 3D rendering engine (RYLGL) - MemoryManager: Custom memory allocation - Library: Third-party dependencies (DirectX, boost, etc.) - Tools: Development utilities 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,115 @@
|
||||
# Microsoft Developer Studio Project File - Name="Cutscene" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Application" 0x0101
|
||||
|
||||
CFG=Cutscene - Win32 Debug
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "Cutscene.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "Cutscene.mak" CFG="Cutscene - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "Cutscene - Win32 Release" (based on "Win32 (x86) Application")
|
||||
!MESSAGE "Cutscene - Win32 Debug" (based on "Win32 (x86) Application")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
MTL=midl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "Cutscene - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release"
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /W3 /GX /O2 /I "..\..\BaseClasses" /I "..\..\..\..\..\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c
|
||||
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG" /d "WIN32"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386
|
||||
# ADD LINK32 strmiids.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 /stack:0x200000,0x200000
|
||||
|
||||
!ELSEIF "$(CFG)" == "Cutscene - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "Debug"
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /W3 /Gm /GX /Zi /Od /I "..\..\BaseClasses" /I "..\..\..\..\..\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG" /d "WIN32"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 strmiids.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept /stack:0x200000,0x200000
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "Cutscene - Win32 Release"
|
||||
# Name "Cutscene - Win32 Debug"
|
||||
# Begin Group "Source Files"
|
||||
|
||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\cutscene.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\main.cpp
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Header Files"
|
||||
|
||||
# PROP Default_Filter "h;hpp;hxx;hm;inl"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\cutscene.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Resource Files"
|
||||
|
||||
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
|
||||
# End Group
|
||||
# End Target
|
||||
# End Project
|
||||
@@ -0,0 +1,29 @@
|
||||
Microsoft Developer Studio Workspace File, Format Version 6.00
|
||||
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "Cutscene"=.\Cutscene.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Global:
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<3>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
@@ -0,0 +1,198 @@
|
||||
# Microsoft Developer Studio Generated NMAKE File, Based on Cutscene.dsp
|
||||
!IF "$(CFG)" == ""
|
||||
CFG=Cutscene - Win32 Debug
|
||||
!MESSAGE No configuration specified. Defaulting to Cutscene - Win32 Debug.
|
||||
!ENDIF
|
||||
|
||||
!IF "$(CFG)" != "Cutscene - Win32 Release" && "$(CFG)" != "Cutscene - Win32 Debug"
|
||||
!MESSAGE Invalid configuration "$(CFG)" specified.
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "Cutscene.mak" CFG="Cutscene - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "Cutscene - Win32 Release" (based on "Win32 (x86) Application")
|
||||
!MESSAGE "Cutscene - Win32 Debug" (based on "Win32 (x86) Application")
|
||||
!MESSAGE
|
||||
!ERROR An invalid configuration is specified.
|
||||
!ENDIF
|
||||
|
||||
!IF "$(OS)" == "Windows_NT"
|
||||
NULL=
|
||||
!ELSE
|
||||
NULL=nul
|
||||
!ENDIF
|
||||
|
||||
!IF "$(CFG)" == "Cutscene - Win32 Release"
|
||||
|
||||
OUTDIR=.\Release
|
||||
INTDIR=.\Release
|
||||
# Begin Custom Macros
|
||||
OutDir=.\Release
|
||||
# End Custom Macros
|
||||
|
||||
ALL : "$(OUTDIR)\Cutscene.exe"
|
||||
|
||||
|
||||
CLEAN :
|
||||
-@erase "$(INTDIR)\cutscene.obj"
|
||||
-@erase "$(INTDIR)\main.obj"
|
||||
-@erase "$(INTDIR)\vc60.idb"
|
||||
-@erase "$(OUTDIR)\Cutscene.exe"
|
||||
|
||||
"$(OUTDIR)" :
|
||||
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
|
||||
|
||||
CPP=cl.exe
|
||||
CPP_PROJ=/nologo /ML /W3 /GX /O2 /I "..\..\BaseClasses" /I "..\..\..\..\..\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /Fp"$(INTDIR)\Cutscene.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c
|
||||
|
||||
.c{$(INTDIR)}.obj::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cpp{$(INTDIR)}.obj::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cxx{$(INTDIR)}.obj::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.c{$(INTDIR)}.sbr::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cpp{$(INTDIR)}.sbr::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cxx{$(INTDIR)}.sbr::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
MTL=midl.exe
|
||||
MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
RSC=rc.exe
|
||||
BSC32=bscmake.exe
|
||||
BSC32_FLAGS=/nologo /o"$(OUTDIR)\Cutscene.bsc"
|
||||
BSC32_SBRS= \
|
||||
|
||||
LINK32=link.exe
|
||||
LINK32_FLAGS=strmiids.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /incremental:no /pdb:"$(OUTDIR)\Cutscene.pdb" /machine:I386 /out:"$(OUTDIR)\Cutscene.exe" /stack:0x200000,0x200000
|
||||
LINK32_OBJS= \
|
||||
"$(INTDIR)\cutscene.obj" \
|
||||
"$(INTDIR)\main.obj"
|
||||
|
||||
"$(OUTDIR)\Cutscene.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
|
||||
$(LINK32) @<<
|
||||
$(LINK32_FLAGS) $(LINK32_OBJS)
|
||||
<<
|
||||
|
||||
!ELSEIF "$(CFG)" == "Cutscene - Win32 Debug"
|
||||
|
||||
OUTDIR=.\Debug
|
||||
INTDIR=.\Debug
|
||||
# Begin Custom Macros
|
||||
OutDir=.\Debug
|
||||
# End Custom Macros
|
||||
|
||||
ALL : "$(OUTDIR)\Cutscene.exe"
|
||||
|
||||
|
||||
CLEAN :
|
||||
-@erase "$(INTDIR)\cutscene.obj"
|
||||
-@erase "$(INTDIR)\main.obj"
|
||||
-@erase "$(INTDIR)\vc60.idb"
|
||||
-@erase "$(INTDIR)\vc60.pdb"
|
||||
-@erase "$(OUTDIR)\Cutscene.exe"
|
||||
-@erase "$(OUTDIR)\Cutscene.ilk"
|
||||
-@erase "$(OUTDIR)\Cutscene.pdb"
|
||||
|
||||
"$(OUTDIR)" :
|
||||
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
|
||||
|
||||
CPP=cl.exe
|
||||
CPP_PROJ=/nologo /MLd /W3 /Gm /GX /Zi /Od /I "..\..\BaseClasses" /I "..\..\..\..\..\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /Fp"$(INTDIR)\Cutscene.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /GZ /c
|
||||
|
||||
.c{$(INTDIR)}.obj::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cpp{$(INTDIR)}.obj::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cxx{$(INTDIR)}.obj::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.c{$(INTDIR)}.sbr::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cpp{$(INTDIR)}.sbr::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cxx{$(INTDIR)}.sbr::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
MTL=midl.exe
|
||||
MTL_PROJ=/nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
RSC=rc.exe
|
||||
BSC32=bscmake.exe
|
||||
BSC32_FLAGS=/nologo /o"$(OUTDIR)\Cutscene.bsc"
|
||||
BSC32_SBRS= \
|
||||
|
||||
LINK32=link.exe
|
||||
LINK32_FLAGS=strmiids.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /incremental:yes /pdb:"$(OUTDIR)\Cutscene.pdb" /debug /machine:I386 /out:"$(OUTDIR)\Cutscene.exe" /pdbtype:sept /stack:0x200000,0x200000
|
||||
LINK32_OBJS= \
|
||||
"$(INTDIR)\cutscene.obj" \
|
||||
"$(INTDIR)\main.obj"
|
||||
|
||||
"$(OUTDIR)\Cutscene.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
|
||||
$(LINK32) @<<
|
||||
$(LINK32_FLAGS) $(LINK32_OBJS)
|
||||
<<
|
||||
|
||||
!ENDIF
|
||||
|
||||
|
||||
!IF "$(NO_EXTERNAL_DEPS)" != "1"
|
||||
!IF EXISTS("Cutscene.dep")
|
||||
!INCLUDE "Cutscene.dep"
|
||||
!ELSE
|
||||
!MESSAGE Warning: cannot find "Cutscene.dep"
|
||||
!ENDIF
|
||||
!ENDIF
|
||||
|
||||
|
||||
!IF "$(CFG)" == "Cutscene - Win32 Release" || "$(CFG)" == "Cutscene - Win32 Debug"
|
||||
SOURCE=.\cutscene.cpp
|
||||
|
||||
"$(INTDIR)\cutscene.obj" : $(SOURCE) "$(INTDIR)"
|
||||
|
||||
|
||||
SOURCE=.\main.cpp
|
||||
|
||||
"$(INTDIR)\main.obj" : $(SOURCE) "$(INTDIR)"
|
||||
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
@@ -0,0 +1,350 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// File: CutScene.cpp
|
||||
//
|
||||
// Desc: DirectShow sample code - simple interactive movie player. Plays
|
||||
// a movie or game cutscene in fullscreen mode. Supports simple user
|
||||
// input to enable ESC, spacebar, or ENTER to quit.
|
||||
//
|
||||
// Copyright (c) 1998-2001 Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
#include <dshow.h>
|
||||
#include <stdio.h>
|
||||
#include <atlbase.h>
|
||||
|
||||
#include "cutscene.h"
|
||||
|
||||
//
|
||||
// Constants
|
||||
//
|
||||
#define KEYBOARD_SAMPLE_FREQ 100 // Sample user input on an interval
|
||||
#define CUTSCENE_NAME TEXT("Cutscene Player Sample")
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
static IGraphBuilder *pGB = NULL;
|
||||
static IMediaControl *pMC = NULL;
|
||||
static IVideoWindow *pVW = NULL;
|
||||
static IMediaEvent *pME = NULL;
|
||||
|
||||
static HWND g_hwndMain=0;
|
||||
static BOOL g_bContinue=TRUE, g_bUserInterruptedPlayback=FALSE;
|
||||
|
||||
|
||||
//
|
||||
// Function prototypes
|
||||
//
|
||||
static HRESULT PlayMedia(LPTSTR lpszMovie, HINSTANCE hInstance);
|
||||
static HRESULT GetInterfaces(void);
|
||||
static HRESULT SetFullscreen(void);
|
||||
static BOOL CreateHiddenWindow( HINSTANCE hInstance, TCHAR *szFile );
|
||||
static LONG WINAPI WindowProc(HWND, UINT, WPARAM, LPARAM);
|
||||
static void CloseApp();
|
||||
static void CleanupInterfaces(void);
|
||||
static void Msg(TCHAR *szFormat, ...);
|
||||
|
||||
|
||||
//
|
||||
// Helper Macros (Jump-If-Failed, Log-If-Failed)
|
||||
//
|
||||
#define RELEASE(i) {if (i) i->Release(); i = NULL;}
|
||||
|
||||
#define JIF(x) if (FAILED(hr=(x))) \
|
||||
{Msg(TEXT("FAILED(hr=0x%x) in ") TEXT(#x) TEXT("\n"), hr); goto CLEANUP;}
|
||||
|
||||
#define LIF(x) if (FAILED(hr=(x))) \
|
||||
{Msg(TEXT("FAILED(hr=0x%x) in ") TEXT(#x) TEXT("\n"), hr); return hr;}
|
||||
|
||||
|
||||
|
||||
HRESULT PlayCutscene(LPTSTR szMovie, HINSTANCE hInstance)
|
||||
{
|
||||
HRESULT hr;
|
||||
|
||||
// Create the main hidden window to field keyboard input
|
||||
if (!CreateHiddenWindow(hInstance, szMovie))
|
||||
return E_FAIL;
|
||||
|
||||
// Initialize COM
|
||||
if (FAILED(hr = CoInitialize(NULL)))
|
||||
return hr;
|
||||
|
||||
// Get DirectShow interfaces
|
||||
if (FAILED(hr = GetInterfaces()))
|
||||
{
|
||||
CoUninitialize();
|
||||
return hr;
|
||||
}
|
||||
|
||||
// Play the movie / cutscene
|
||||
hr = PlayMedia(szMovie, hInstance);
|
||||
|
||||
// If the user interrupted playback and there was no other error,
|
||||
// return S_FALSE.
|
||||
if ((hr == S_OK) && g_bUserInterruptedPlayback)
|
||||
hr = S_FALSE;
|
||||
|
||||
// Release DirectShow interfaces
|
||||
CleanupInterfaces();
|
||||
CoUninitialize();
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
|
||||
BOOL CreateHiddenWindow( HINSTANCE hInstance, TCHAR *szFile )
|
||||
{
|
||||
TCHAR szTitle[MAX_PATH];
|
||||
|
||||
// Set up and register window class
|
||||
WNDCLASS wc = {0};
|
||||
wc.lpfnWndProc = (WNDPROC) WindowProc;
|
||||
wc.hInstance = hInstance;
|
||||
wc.lpszClassName = CUTSCENE_NAME;
|
||||
if (!RegisterClass(&wc))
|
||||
return FALSE;
|
||||
|
||||
wsprintf(szTitle, TEXT("%s: %s"), CUTSCENE_NAME, szFile);
|
||||
|
||||
// Create a window of zero size that will serve as the sink for
|
||||
// keyboard input. If this media file has a video component, then
|
||||
// a second ActiveMovie window will be displayed in which the video
|
||||
// will be rendered. Setting keyboard focus on this application window
|
||||
// will allow the user to move the video window around the screen, make
|
||||
// it full screen, resize, center, etc. independent of the application
|
||||
// window. If the media file has only an audio component, then this will
|
||||
// be the only window created.
|
||||
g_hwndMain = CreateWindowEx(
|
||||
0, CUTSCENE_NAME, szTitle,
|
||||
0, // not visible
|
||||
0, 0, 0, 0,
|
||||
NULL, NULL, hInstance, NULL );
|
||||
|
||||
return (g_hwndMain != NULL);
|
||||
}
|
||||
|
||||
|
||||
LONG WINAPI WindowProc( HWND hWnd, UINT message,
|
||||
WPARAM wParam, LPARAM lParam )
|
||||
{
|
||||
switch( message )
|
||||
{
|
||||
// Monitor keystrokes for manipulating video window
|
||||
// and program options
|
||||
case WM_KEYDOWN:
|
||||
switch( wParam )
|
||||
{
|
||||
case VK_ESCAPE:
|
||||
case VK_SPACE:
|
||||
case VK_RETURN:
|
||||
g_bUserInterruptedPlayback = TRUE;
|
||||
CloseApp();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_DESTROY:
|
||||
PostQuitMessage(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return (LONG) DefWindowProc(hWnd, message, wParam, lParam);
|
||||
}
|
||||
|
||||
|
||||
|
||||
HRESULT GetInterfaces(void)
|
||||
{
|
||||
HRESULT hr = S_OK;
|
||||
|
||||
// Instantiate filter graph interface
|
||||
JIF(CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC,
|
||||
IID_IGraphBuilder, (void **)&pGB));
|
||||
|
||||
// Get interfaces to control playback & screensize
|
||||
JIF(pGB->QueryInterface(IID_IMediaControl, (void **)&pMC));
|
||||
JIF(pGB->QueryInterface(IID_IVideoWindow, (void **)&pVW));
|
||||
|
||||
// Get interface to allow the app to wait for completion of playback
|
||||
JIF(pGB->QueryInterface(IID_IMediaEventEx, (void **)&pME));
|
||||
|
||||
return S_OK;
|
||||
|
||||
// In case of failure, the helper macro jumps here
|
||||
CLEANUP:
|
||||
CleanupInterfaces();
|
||||
return(hr);
|
||||
}
|
||||
|
||||
|
||||
void CleanupInterfaces(void)
|
||||
{
|
||||
// Release the DirectShow interfaces
|
||||
RELEASE(pGB);
|
||||
RELEASE(pMC);
|
||||
RELEASE(pVW);
|
||||
RELEASE(pME);
|
||||
|
||||
DestroyWindow(g_hwndMain);
|
||||
}
|
||||
|
||||
|
||||
void CloseApp()
|
||||
{
|
||||
// Stop playback and exit
|
||||
pMC->Stop();
|
||||
g_bContinue = FALSE;
|
||||
|
||||
PostMessage(g_hwndMain, WM_CLOSE, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
HRESULT PlayMedia(LPTSTR lpszMovie, HINSTANCE hInstance)
|
||||
{
|
||||
USES_CONVERSION;
|
||||
|
||||
HRESULT hr = S_OK;
|
||||
WCHAR wFileName[MAX_PATH];
|
||||
BOOL bSleep=TRUE;
|
||||
|
||||
wcscpy(wFileName, T2W(lpszMovie));
|
||||
|
||||
// Allow DirectShow to create the FilterGraph for this media file
|
||||
hr = pGB->RenderFile(wFileName, NULL);
|
||||
if (FAILED(hr)) {
|
||||
Msg(TEXT("Failed(0x%08lx) in RenderFile(%s)!\r\n"), hr, lpszMovie);
|
||||
return hr;
|
||||
}
|
||||
|
||||
// Set the message drain of the video window to point to our hidden
|
||||
// application window. This allows keyboard input to be transferred
|
||||
// to our main window for processing.
|
||||
//
|
||||
// If this is an audio-only or MIDI file, then put_MessageDrain will fail.
|
||||
//
|
||||
hr = pVW->put_MessageDrain((OAHWND) g_hwndMain);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
Msg(TEXT("Failed(0x%08lx) to set message drain for %s.\r\n\r\n")
|
||||
TEXT("This sample is designed to play videos, but the file selected ")
|
||||
TEXT("has no video component."), hr, lpszMovie);
|
||||
return hr;
|
||||
}
|
||||
|
||||
// Set fullscreen
|
||||
hr = SetFullscreen();
|
||||
if (FAILED(hr)) {
|
||||
Msg(TEXT("Failed(%08lx) to set fullscreen!\r\n"), hr);
|
||||
return hr;
|
||||
}
|
||||
|
||||
// Display first frame of the movie
|
||||
hr = pMC->Pause();
|
||||
if (FAILED(hr)) {
|
||||
Msg(TEXT("Failed(%08lx) in Pause()!\r\n"), hr);
|
||||
return hr;
|
||||
}
|
||||
|
||||
// Start playback
|
||||
hr = pMC->Run();
|
||||
if (FAILED(hr)) {
|
||||
Msg(TEXT("Failed(%08lx) in Run()!\r\n"), hr);
|
||||
return hr;
|
||||
}
|
||||
|
||||
// Update state variables
|
||||
g_bContinue = TRUE;
|
||||
|
||||
// Enter a loop of checking for events and sampling keyboard i6nput
|
||||
while (g_bContinue)
|
||||
{
|
||||
MSG msg;
|
||||
long lEventCode, lParam1, lParam2;
|
||||
|
||||
// Reset sleep flag
|
||||
bSleep = TRUE;
|
||||
|
||||
// Has there been a media event? Look for end of stream condition.
|
||||
if(E_ABORT != pME->GetEvent(&lEventCode, (LONG_PTR *) &lParam1,
|
||||
(LONG_PTR *) &lParam2, 0))
|
||||
{
|
||||
// Free the media event resources.
|
||||
hr = pME->FreeEventParams(lEventCode, lParam1, lParam2);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
Msg(TEXT("Failed(%08lx) to free event params (%s)!\r\n"),
|
||||
hr, lpszMovie);
|
||||
}
|
||||
|
||||
// Is this the end of the movie?
|
||||
if (lEventCode == EC_COMPLETE)
|
||||
{
|
||||
g_bContinue = FALSE;
|
||||
bSleep = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
// Give system threads time to run (and don't sample user input madly)
|
||||
if (bSleep)
|
||||
Sleep(KEYBOARD_SAMPLE_FREQ);
|
||||
|
||||
// Check and process window messages (like our keystrokes)
|
||||
while (PeekMessage (&msg, g_hwndMain, 0, 0, PM_REMOVE))
|
||||
{
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
}
|
||||
}
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
|
||||
HRESULT SetFullscreen(void)
|
||||
{
|
||||
HRESULT hr=S_OK;
|
||||
LONG lMode;
|
||||
static HWND hDrain=0;
|
||||
|
||||
if (!pVW)
|
||||
return S_FALSE;
|
||||
|
||||
// Read current state
|
||||
LIF(pVW->get_FullScreenMode(&lMode));
|
||||
|
||||
if (lMode == 0) /* OAFALSE */
|
||||
{
|
||||
// Save current message drain
|
||||
LIF(pVW->get_MessageDrain((OAHWND *) &hDrain));
|
||||
|
||||
// Set message drain to application main window
|
||||
LIF(pVW->put_MessageDrain((OAHWND) g_hwndMain));
|
||||
|
||||
// Switch to full-screen mode
|
||||
lMode = -1; /* OATRUE */
|
||||
LIF(pVW->put_FullScreenMode(lMode));
|
||||
}
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
|
||||
void Msg(TCHAR *szFormat, ...)
|
||||
{
|
||||
TCHAR szBuffer[512]; // Large buffer for very long filenames (like with HTTP)
|
||||
|
||||
va_list pArgs;
|
||||
va_start(pArgs, szFormat);
|
||||
_vstprintf(szBuffer, szFormat, pArgs);
|
||||
va_end(pArgs);
|
||||
|
||||
// This sample uses a simple message box to convey warning and error
|
||||
// messages. You may want to display a debug string or suppress messages
|
||||
// altogether, depending on your application.
|
||||
MessageBox(NULL, szBuffer, TEXT("PlayCutscene Error"), MB_OK);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// File: CutScene.h
|
||||
//
|
||||
// Desc: DirectShow sample code - declarations for simple movie player.
|
||||
//
|
||||
// Copyright (c) 2000-2001 Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
//
|
||||
// Function prototypes
|
||||
//
|
||||
HRESULT PlayCutscene(LPTSTR lpszMovie, HINSTANCE hInstance);
|
||||
@@ -0,0 +1,107 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// File: Main.cpp
|
||||
//
|
||||
// Desc: DirectShow sample code - simple movie player console application.
|
||||
//
|
||||
// Copyright (c) 2000-2001 Microsoft Corporation. All rights reserved.
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
//
|
||||
// This program uses the PlayCutscene() function provided in cutscene.cpp.
|
||||
// It is only necessary to provide the name of a file and the application's
|
||||
// instance handle.
|
||||
//
|
||||
// If the file was played to the end, PlayCutscene returns S_OK.
|
||||
// If the user interrupted playback, PlayCutscene returns S_FALSE.
|
||||
// Otherwise, PlayCutscene will return an HRESULT error code.
|
||||
//
|
||||
// Usage: cutscene <required file name>
|
||||
//
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#include "cutscene.h"
|
||||
|
||||
#define USAGE \
|
||||
TEXT("Cutscene is a console application that demonstrates\r\n") \
|
||||
TEXT("playing a movie at the beginning of your game.\r\n\r\n") \
|
||||
TEXT("Please provide a valid filename on the command line.\r\n") \
|
||||
TEXT("\r\n Usage: cutscene <filename>\r\n") \
|
||||
|
||||
|
||||
//
|
||||
// Main program code
|
||||
//
|
||||
int APIENTRY
|
||||
WinMain (
|
||||
HINSTANCE hInstance,
|
||||
HINSTANCE hPrevInstance,
|
||||
LPSTR lpszMovie,
|
||||
int nCmdShow
|
||||
)
|
||||
{
|
||||
HRESULT hr;
|
||||
TCHAR szMovieName[MAX_PATH];
|
||||
|
||||
// Prevent C4100: unreferenced formal parameter
|
||||
hPrevInstance = hPrevInstance;
|
||||
nCmdShow = nCmdShow;
|
||||
|
||||
#ifdef UNICODE
|
||||
TCHAR szCommandLine[MAX_PATH], *pstrCommandLine=NULL;
|
||||
UNREFERENCED_PARAMETER(lpszMovie);
|
||||
|
||||
// Get the UNICODE command line. This is necessary for UNICODE apps
|
||||
// because the standard WinMain only passes in an LPSTR for command line.
|
||||
lstrcpy(szCommandLine, GetCommandLine());
|
||||
pstrCommandLine = szCommandLine;
|
||||
|
||||
// Skip the first part of the command line, which is the full path
|
||||
// to the exe. If the path contains spaces, it will be contained in quotes,
|
||||
// so the leading and trailing quotes need to be removed.
|
||||
if (*pstrCommandLine == TEXT('\"'))
|
||||
{
|
||||
// Remove the leading quotes
|
||||
pstrCommandLine++;
|
||||
|
||||
// Skip characters until we reach the trailing quotes
|
||||
while (*pstrCommandLine != TEXT('\0') && *pstrCommandLine != TEXT('\"'))
|
||||
pstrCommandLine++;
|
||||
|
||||
// Strip trailing quotes from executable name
|
||||
if( *pstrCommandLine == TEXT('\"'))
|
||||
pstrCommandLine++;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Executable name isn't encased in quotes, so just search for the
|
||||
// first space, which indicates the end of the executable name.
|
||||
while (*pstrCommandLine != TEXT('\0') && *pstrCommandLine != TEXT(' '))
|
||||
pstrCommandLine++;
|
||||
}
|
||||
|
||||
// Strip all leading spaces on file name
|
||||
while( *pstrCommandLine == TEXT(' '))
|
||||
pstrCommandLine++;
|
||||
|
||||
lstrcpy(szMovieName, pstrCommandLine);
|
||||
|
||||
#else
|
||||
lstrcpy(szMovieName, lpszMovie);
|
||||
#endif
|
||||
|
||||
// If no filename is specified, show an error message and exit
|
||||
if (szMovieName[0] == TEXT('\0'))
|
||||
{
|
||||
MessageBox(NULL, USAGE, TEXT("Cutscene Error"), MB_OK | MB_ICONERROR);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// Play movie
|
||||
hr = PlayCutscene(szMovieName, hInstance);
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
DirectShow Sample -- CutScene
|
||||
-----------------------------
|
||||
|
||||
Usage:
|
||||
|
||||
cutscene <media filename>
|
||||
|
||||
Description:
|
||||
|
||||
Cutscene is a simple fullscreen movie player sample that enables you to
|
||||
add movie playback to your application without needing to learn the
|
||||
specifics of DirectShow programming.
|
||||
|
||||
The application's WinMain() calls PlayCutscene(), a generic function that
|
||||
you can use to add easy playback of movies or cutscenes to the beginning
|
||||
of your game. All of the code needed for movie playback is contained
|
||||
within cutscene.cpp and cutscene.h and can be added to your project.
|
||||
|
||||
Cutscene creates a hidden window to handle keyboard input. A user can
|
||||
press SPACE, ENTER, or ESCAPE keys to cause the playback to end.
|
||||
When playback ends, the window is destroyed.
|
||||
|
||||
Return values:
|
||||
|
||||
If movie playback continues to the end without error,
|
||||
PlayCutscene() returns S_OK.
|
||||
|
||||
If movie playback is interrupted by the user, PlayCutscene returns S_FALSE.
|
||||
(S_FALSE is not an error and will not fail in the FAILED() macro.)
|
||||
|
||||
If there is an error, PlayCutscene returns an HRESULT error code.
|
||||
|
||||
Reference in New Issue
Block a user