1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: VGUI panel which can play back video, in-engine
//
//=============================================================================
#include "cbase.h"
#include <vgui/IVGui.h>
#include <vgui/ISurface.h>
#include <KeyValues.h>
#include "vgui_video.h"
#include "tf_vgui_video.h"
#include "engine/IEngineSound.h"
// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"
DECLARE_BUILD_FACTORY( CTFVideoPanel );
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
CTFVideoPanel::CTFVideoPanel( vgui::Panel *parent, const char *panelName ) : VideoPanel( 0, 0, 50, 50 )
{
SetParent( parent );
SetProportional( true );
SetKeyBoardInputEnabled( false );
SetBlackBackground( false );
m_flStartAnimDelay = 0.0f;
m_flEndAnimDelay = 0.0f;
}
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
CTFVideoPanel::~CTFVideoPanel()
{
ReleaseVideo();
}
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
void CTFVideoPanel::ReleaseVideo()
{
enginesound->NotifyEndMoviePlayback();
// Destroy any previously allocated video
if ( g_pVideo && m_VideoMaterial != NULL )
{
g_pVideo->DestroyVideoMaterial( m_VideoMaterial );
m_VideoMaterial = NULL;
}
}
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
void CTFVideoPanel::ApplySettings( KeyValues *inResourceData )
{
BaseClass::ApplySettings( inResourceData );
SetExitCommand( inResourceData->GetString( "command", "" ) );
m_flStartAnimDelay = inResourceData->GetFloat( "start_delay", 0.0 );
m_flEndAnimDelay = inResourceData->GetFloat( "end_delay", 0.0 );
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CTFVideoPanel::GetPanelPos( int &xpos, int &ypos )
{
vgui::ipanel()->GetAbsPos( GetVPanel(), xpos, ypos );
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CTFVideoPanel::OnVideoOver()
{
BaseClass::OnVideoOver();
PostMessage( GetParent(), new KeyValues( "IntroFinished" ) );
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CTFVideoPanel::OnClose()
{
// Fire an exit command if we're asked to do so
if ( m_szExitCommand[0] )
{
engine->ClientCmd( m_szExitCommand );
}
// intentionally skipping VideoPanel::OnClose()
EditablePanel::OnClose();
SetVisible( false );
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CTFVideoPanel::Shutdown()
{
OnClose();
ReleaseVideo();
}
|