engine: client: remove AVI_GetState/OpenVideo/CloseVideo

This commit is contained in:
Alibek Omarov 2024-03-14 23:36:39 +03:00
parent f30c1bcf32
commit 6645988e7e
2 changed files with 20 additions and 21 deletions

View File

@ -22,6 +22,7 @@ GNU General Public License for more details.
#include "vid_common.h" #include "vid_common.h"
static void UI_UpdateUserinfo( void ); static void UI_UpdateUserinfo( void );
static movie_state_t *cin_state;
gameui_static_t gameui; gameui_static_t gameui;
@ -67,8 +68,6 @@ void UI_MouseMove( int x, int y )
void UI_SetActiveMenu( qboolean fActive ) void UI_SetActiveMenu( qboolean fActive )
{ {
movie_state_t *cin_state;
if( !gameui.hInstance ) if( !gameui.hInstance )
{ {
if( !fActive ) if( !fActive )
@ -82,8 +81,7 @@ void UI_SetActiveMenu( qboolean fActive )
if( !fActive ) if( !fActive )
{ {
// close logo when menu is shutdown // close logo when menu is shutdown
cin_state = AVI_GetState( CIN_LOGO ); AVI_FreeVideo( &cin_state );
AVI_CloseVideo( cin_state );
} }
} }
@ -300,13 +298,15 @@ static void GAME_EXPORT UI_DrawLogo( const char *filename, float x, float y, flo
qboolean redraw = false; qboolean redraw = false;
if( !gameui.drawLogo ) return; if( !gameui.drawLogo ) return;
cin_state = AVI_GetState( CIN_LOGO );
if( !AVI_IsActive( cin_state )) if( !AVI_IsActive( cin_state ))
{ {
string path; string path;
const char *fullpath; const char *fullpath;
if( cin_state )
AVI_FreeVideo( &cin_state );
// run cinematic if not // run cinematic if not
Q_snprintf( path, sizeof( path ), "media/%s", filename ); Q_snprintf( path, sizeof( path ), "media/%s", filename );
COM_DefaultExtension( path, ".avi", sizeof( path )); COM_DefaultExtension( path, ".avi", sizeof( path ));
@ -319,10 +319,10 @@ static void GAME_EXPORT UI_DrawLogo( const char *filename, float x, float y, flo
return; return;
} }
AVI_OpenVideo( cin_state, fullpath, false, true ); cin_state = AVI_LoadVideo( fullpath, MOVIE_LOAD_QUIET );
if( !( AVI_GetVideoInfo( cin_state, &gameui.logo_xres, &gameui.logo_yres, &gameui.logo_length ))) if( !( AVI_GetVideoInfo( cin_state, &gameui.logo_xres, &gameui.logo_yres, &gameui.logo_length )))
{ {
AVI_CloseVideo( cin_state ); AVI_FreeVideo( &cin_state );
gameui.drawLogo = false; gameui.drawLogo = false;
return; return;
} }
@ -1234,6 +1234,7 @@ void UI_UnloadProgs( void )
Cvar_Unlink( FCVAR_GAMEUIDLL ); Cvar_Unlink( FCVAR_GAMEUIDLL );
Cmd_Unlink( CMD_GAMEUIDLL ); Cmd_Unlink( CMD_GAMEUIDLL );
AVI_FreeVideo( &cin_state );
COM_FreeLibrary( gameui.hInstance ); COM_FreeLibrary( gameui.hInstance );
Mem_FreePool( &gameui.mempool ); Mem_FreePool( &gameui.mempool );

View File

@ -142,7 +142,7 @@ void SCR_RunCinematic( void )
if( UI_IsVisible( )) if( UI_IsVisible( ))
{ {
// these can happens when user set +menu_ option to cmdline // these can happens when user set +menu_ option to cmdline
AVI_CloseVideo( cin_state ); AVI_FreeVideo( &cin_state );
cls.state = ca_disconnected; cls.state = ca_disconnected;
Key_SetKeyDest( key_menu ); Key_SetKeyDest( key_menu );
S_StopStreaming(); S_StopStreaming();
@ -204,6 +204,9 @@ qboolean SCR_PlayCinematic( const char *arg )
{ {
const char *fullpath; const char *fullpath;
if( cin_state )
AVI_FreeVideo( &cin_state );
fullpath = FS_GetDiskPath( arg, false ); fullpath = FS_GetDiskPath( arg, false );
if( FS_FileExists( arg, false ) && !fullpath ) if( FS_FileExists( arg, false ) && !fullpath )
@ -212,16 +215,19 @@ qboolean SCR_PlayCinematic( const char *arg )
return false; return false;
} }
AVI_OpenVideo( cin_state, fullpath, true, false ); cin_state = AVI_LoadVideo( fullpath, MOVIE_LOAD_AUDIO );
if( !AVI_IsActive( cin_state )) if( !AVI_IsActive( cin_state ))
{ {
AVI_CloseVideo( cin_state ); AVI_FreeVideo( &cin_state );
cin_state = NULL;
return false; return false;
} }
if( !( AVI_GetVideoInfo( cin_state, &xres, &yres, &video_duration ))) // couldn't open this at all. if( !( AVI_GetVideoInfo( cin_state, &xres, &yres, &video_duration ))) // couldn't open this at all.
{ {
AVI_CloseVideo( cin_state ); AVI_FreeVideo( &cin_state );
cin_state = NULL;
return false; return false;
} }
@ -268,7 +274,7 @@ void SCR_StopCinematic( void )
if( cls.state != ca_cinematic ) if( cls.state != ca_cinematic )
return; return;
AVI_CloseVideo( cin_state ); AVI_FreeVideo( &cin_state );
S_StopStreaming(); S_StopStreaming();
cin_time = 0.0f; cin_time = 0.0f;
@ -286,7 +292,6 @@ SCR_InitCinematic
void SCR_InitCinematic( void ) void SCR_InitCinematic( void )
{ {
AVI_Initailize (); AVI_Initailize ();
cin_state = AVI_GetState( CIN_MAIN );
} }
/* /*
@ -296,14 +301,7 @@ SCR_FreeCinematic
*/ */
void SCR_FreeCinematic( void ) void SCR_FreeCinematic( void )
{ {
movie_state_t *cin_state;
// release videos // release videos
cin_state = AVI_GetState( CIN_LOGO ); AVI_FreeVideo( &cin_state );
AVI_CloseVideo( cin_state );
cin_state = AVI_GetState( CIN_MAIN );
AVI_CloseVideo( cin_state );
AVI_Shutdown(); AVI_Shutdown();
} }