OpenBarnyard
 
Loading...
Searching...
No Matches
ABINKMoviePlayer Class Reference

#include <ABINKMoviePlayer.h>

Inheritance diagram for ABINKMoviePlayer:
AMoviePlayer

Public Types

using ThisClass = ABINKMoviePlayer
 
using BaseClass = AMoviePlayer
 
- Public Types inherited from AMoviePlayer
using ThisClass = AMoviePlayer
 
using BaseClass = Toshi::TTask
 

Public Member Functions

virtual Toshi::TClass * GetClass () override
 
 ABINKMoviePlayer ()
 
virtual TBOOL OnCreate () override
 
virtual TBOOL OnUpdate (TFLOAT a_fDeltaTime) override
 
virtual void OnDestroy () override
 
virtual TBOOL PlayMovie (const TCHAR *a_szFileName, TUINT32 a_Unk) override
 
virtual void StopMovie () override
 
virtual void PauseMovie (TBOOL a_bPause) override
 
virtual TBOOL IsMoviePlaying () override
 
virtual TBOOL IsMoviePaused () override
 
virtual void Render (TFLOAT a_fDeltaTime) override
 
virtual void SetMovieFile (const TCHAR *a_szFile)
 
- Public Member Functions inherited from AMoviePlayer
 AMoviePlayer ()
 
virtual void Mute (TBOOL a_bMute=true)
 
virtual TBOOL IsFullScreen ()
 
virtual void SetHideMovie (TBOOL a_bHide=true)
 
virtual void SetFullScreen (TBOOL a_bFullscreen=true)
 
virtual void Unk1 (void *a_Unk)
 
virtual void Unk2 (void *a_Unk)
 

Static Public Member Functions

static Toshi::TObject * CreateTObject ()
 
static Toshi::TObject * CreateTObjectInPlace (void *a_pPtr)
 
static void InitialiseClass ()
 
static void DeinitialiseClass ()
 
static TFORCEINLINE Toshi::TClass * GetClassStatic ()
 
- Static Public Member Functions inherited from AMoviePlayer
static Toshi::TObject * CreateTObject ()
 
static Toshi::TObject * CreateTObjectInPlace (void *a_pPtr)
 
static void InitialiseClass ()
 
static void DeinitialiseClass ()
 
static TFORCEINLINE Toshi::TClass * GetClassStatic ()
 

Static Public Attributes

static constexpr Toshi::TClass * PARENTCLASS = & AMoviePlayer::ms_oClass
 
static Toshi::TClass ms_oClass = Toshi::TClass( "ABINKMoviePlayer", ABINKMoviePlayer::PARENTCLASS, ABINKMoviePlayer::CreateTObject, ABINKMoviePlayer::CreateTObjectInPlace, ABINKMoviePlayer::InitialiseClass, ABINKMoviePlayer::DeinitialiseClass, 0, 1, sizeof( ABINKMoviePlayer ), alignof( ABINKMoviePlayer ) )
 
- Static Public Attributes inherited from AMoviePlayer
static constexpr Toshi::TClass * PARENTCLASS = & Toshi::TTask::ms_oClass
 
static Toshi::TClass ms_oClass = Toshi::TClass( "AMoviePlayer", AMoviePlayer::PARENTCLASS, AMoviePlayer::CreateTObject, AMoviePlayer::CreateTObjectInPlace, AMoviePlayer::InitialiseClass, AMoviePlayer::DeinitialiseClass, 0, 1, sizeof( AMoviePlayer ), alignof( AMoviePlayer ) )
 

Detailed Description

Definition at line 12 of file ABINKMoviePlayer.h.

Member Typedef Documentation

◆ BaseClass

Definition at line 15 of file ABINKMoviePlayer.h.

◆ ThisClass

Constructor & Destructor Documentation

◆ ABINKMoviePlayer()

ABINKMoviePlayer::ABINKMoviePlayer ( )

Definition at line 24 of file ABINKMoviePlayer.cpp.

25{
26 m_Bink = TNULL;
27 m_bPlaying = TFALSE;
28 m_bPaused = TFALSE;
29 m_bVisible = TFALSE;
30 m_pSurface = TNULL;
31 m_iNumRects = 0;
32}
#define TNULL
Definition Typedefs.h:23
#define TFALSE
Definition Typedefs.h:24

Member Function Documentation

◆ CreateTObject()

Toshi::TObject * ABINKMoviePlayer::CreateTObject ( )
static

Definition at line 22 of file ABINKMoviePlayer.cpp.

◆ CreateTObjectInPlace()

Toshi::TObject * ABINKMoviePlayer::CreateTObjectInPlace ( void * a_pPtr)
static

Definition at line 22 of file ABINKMoviePlayer.cpp.

◆ DeinitialiseClass()

void ABINKMoviePlayer::DeinitialiseClass ( )
static

Definition at line 22 of file ABINKMoviePlayer.cpp.

◆ GetClass()

Toshi::TClass * ABINKMoviePlayer::GetClass ( )
overridevirtual

Reimplemented from AMoviePlayer.

Definition at line 22 of file ABINKMoviePlayer.cpp.

◆ GetClassStatic()

static TFORCEINLINE Toshi::TClass * ABINKMoviePlayer::GetClassStatic ( )
inlinestatic

Definition at line 15 of file ABINKMoviePlayer.h.

◆ InitialiseClass()

void ABINKMoviePlayer::InitialiseClass ( )
static

Definition at line 22 of file ABINKMoviePlayer.cpp.

◆ IsMoviePaused()

TBOOL ABINKMoviePlayer::IsMoviePaused ( )
overridevirtual

Implements AMoviePlayer.

Definition at line 254 of file ABINKMoviePlayer.cpp.

255{
256 return m_bPaused;
257}

◆ IsMoviePlaying()

TBOOL ABINKMoviePlayer::IsMoviePlaying ( )
overridevirtual

Implements AMoviePlayer.

Definition at line 249 of file ABINKMoviePlayer.cpp.

250{
251 return m_bPlaying;
252}

◆ OnCreate()

TBOOL ABINKMoviePlayer::OnCreate ( )
overridevirtual

Reimplemented from AMoviePlayer.

Definition at line 34 of file ABINKMoviePlayer.cpp.

35{
36 BinkSetMemory(
37 []( unsigned int size ) {
38 return TMalloc( size );
39 },
40 []( void* ptr ) {
41 TFree( ptr );
42 }
43 );
44
45 int iOutput = FSOUND_GetOutput();
46
47 if ( iOutput == FSOUND_OUTPUT_WINMM )
48 {
49 BinkSetSoundSystem( BinkOpenWaveOut, 0 );
50 }
51 else if ( iOutput == FSOUND_OUTPUT_DSOUND )
52 {
53 auto outHandle = FSOUND_GetOutputHandle();
54
55 if ( outHandle )
56 {
57 BinkSetSoundSystem( BinkOpenDirectSound, TREINTERPRETCAST( int, outHandle ) );
58 }
59 }
60
61 return TTRUE;
62}
void * TMalloc(TSIZE a_uiSize, Toshi::TMemory::MemBlock *a_pMemBlock, const TCHAR *a_szFileName, TINT a_iLineNum)
Allocates memory from a specific memory block.
Definition TMemory.cpp:973
void TFree(void *a_pMem)
Frees previously allocated memory.
Definition TMemory.cpp:1054
#define TREINTERPRETCAST(TYPE, VALUE)
Definition Defines.h:68
#define TTRUE
Definition Typedefs.h:25

◆ OnDestroy()

void ABINKMoviePlayer::OnDestroy ( )
overridevirtual

Reimplemented from AMoviePlayer.

Definition at line 143 of file ABINKMoviePlayer.cpp.

144{
145}

◆ OnUpdate()

TBOOL ABINKMoviePlayer::OnUpdate ( TFLOAT a_fDeltaTime)
overridevirtual

Definition at line 64 of file ABINKMoviePlayer.cpp.

65{
66 if ( !IsMoviePlaying() )
67 {
68 return TTRUE;
69 }
70
71 if ( m_Bink->LastFrameNum == m_Bink->Frames )
72 {
73 StopMovie();
74 return TTRUE;
75 }
76
78 {
79 if ( !m_bPaused )
80 {
81 BinkPause( m_Bink, 1 );
82 BinkSetSoundOnOff( m_Bink, 0 );
83 m_bPaused = TTRUE;
84 }
85 }
86 else
87 {
88 if ( m_bPaused )
89 {
90 BinkPause( m_Bink, 0 );
91 BinkSetSoundOnOff( m_Bink, 1 );
92 m_bPaused = TFALSE;
93 }
94 }
95
96 auto iWaitRes = BinkWait( m_Bink );
97
98 if ( iWaitRes == 0 )
99 {
100 if ( BinkDoFrame( m_Bink ) == 0 )
101 {
102 if ( !m_bVideoFitsBackBuffer || !m_pSurface )
103 {
104 if ( !m_pRects )
105 {
106 if ( !CreateSurfaces() )
107 {
108 return TTRUE;
109 }
110
111 m_eFormat |= 0x80000000;
112 }
113 }
114
115 auto ppRenderSurface = &m_pSurface;
116
117 if ( m_bVideoFitsBackBuffer ||
118 TSTATICCAST( TTextureResourceHAL, m_pRects[ 0 ].pTexture )->GetD3DTexture()->GetSurfaceLevel( 0, ppRenderSurface ) == S_OK )
119 {
120 D3DLOCKED_RECT rect;
121 if ( S_OK == ( *ppRenderSurface )->LockRect( &rect, TNULL, 0 ) )
122 {
123 BinkCopyToBuffer( m_Bink, rect.pBits, rect.Pitch, m_Bink->Height, 0, 0, m_eFormat );
124 m_eFormat &= 0x7fffffff;
125 ( *ppRenderSurface )->UnlockRect();
126
127 if ( !m_bVideoFitsBackBuffer )
128 {
129 ( *ppRenderSurface )->Release();
130 ( *ppRenderSurface ) = TNULL;
131 }
132 }
133 }
134 }
135
136 BinkNextFrame( m_Bink );
137 }
138
139 m_bVisible = TTRUE;
140 return TTRUE;
141}
#define TSTATICCAST(POINTERTYPE, VALUE)
Definition Defines.h:69
TSystemManager g_oSystemManager
Definition TSystem.cpp:15
TBOOL IsPaused() const
Definition TSystem.h:160
virtual TBOOL IsMoviePlaying() override
virtual void StopMovie() override

◆ PauseMovie()

void ABINKMoviePlayer::PauseMovie ( TBOOL a_bPause)
overridevirtual

Implements AMoviePlayer.

Definition at line 244 of file ABINKMoviePlayer.cpp.

245{
246 m_bPaused = a_bPause;
247}

◆ PlayMovie()

TBOOL ABINKMoviePlayer::PlayMovie ( const TCHAR * a_szFileName,
TUINT32 a_Unk )
overridevirtual

Implements AMoviePlayer.

Definition at line 147 of file ABINKMoviePlayer.cpp.

148{
149 TVALIDPTR( a_szFileName );
150
151 SetMovieFile( a_szFileName );
152 m_Bink = BinkOpen( m_szMoviePath, 0 );
153
154 if ( m_Bink != TNULL )
155 {
156 if ( !CreateSurfaces() )
157 {
158 BinkClose( m_Bink );
159 m_Bink = TNULL;
160 return TFALSE;
161 }
162
163 m_bPlaying = TTRUE;
164 m_bVisible = TFALSE;
165 m_bPaused = TFALSE;
166 OnUpdate( 0.0f );
167 }
168
169 return m_Bink != TNULL;
170}
#define TVALIDPTR(PTR)
Definition Defines.h:139
virtual void SetMovieFile(const TCHAR *a_szFile)
virtual TBOOL OnUpdate(TFLOAT a_fDeltaTime) override

◆ Render()

void ABINKMoviePlayer::Render ( TFLOAT a_fDeltaTime)
overridevirtual

Implements AMoviePlayer.

Definition at line 259 of file ABINKMoviePlayer.cpp.

260{
261 if ( IsMoviePlaying() && m_bVisible )
262 {
264
265 if ( m_bVideoFitsBackBuffer )
266 {
267 IDirect3DSurface8* pSurface;
268 auto hRes = pDevice->GetBackBuffer( 0, D3DBACKBUFFER_TYPE_MONO, &pSurface );
269
270 if ( hRes == S_OK )
271 {
272 pDevice->CopyRects( m_pSurface, TNULL, 0, pSurface, TNULL );
273 pSurface->Release();
274 }
275 }
276 else
277 {
278 auto pRender = AGUI2::GetRenderer();
279
280 pRender->BeginScene();
281
282 for ( TINT i = 0; i < m_iNumRects; i++ )
283 {
284 pRender->SetMaterial( m_pRects[ i ].pMaterial );
285 pRender->RenderRectangle( m_pRects[ i ].Pos1, m_pRects[ i ].Pos2, m_pRects[ i ].UV1, m_pRects[ i ].UV2 );
286 }
287
288 pRender->EndScene();
289 }
290 }
291}
int TINT
Definition Typedefs.h:7
TFORCEINLINE IDirect3DDevice8 * GetDirect3DDevice() const
Gets the Direct3D device.
static TFORCEINLINE TRenderD3DInterface * Interface()
Gets the render interface singleton.
static AGUI2Renderer * GetRenderer()
Definition AGUI2.cpp:239

◆ SetMovieFile()

void ABINKMoviePlayer::SetMovieFile ( const TCHAR * a_szFile)
virtual

Definition at line 293 of file ABINKMoviePlayer.cpp.

294{
295 TStringManager::String8Format( m_szMoviePath, sizeof( m_szMoviePath ), "Data/Movies/%s.bik", a_szFile );
296}
static void String8Format(TCHAR *str, TINT size, const TCHAR *format,...)

◆ StopMovie()

void ABINKMoviePlayer::StopMovie ( )
overridevirtual

Implements AMoviePlayer.

Definition at line 230 of file ABINKMoviePlayer.cpp.

231{
232 if ( m_Bink )
233 {
234 BinkClose( m_Bink );
235 m_Bink = TNULL;
236 DestroySurfaces();
237 }
238
239 m_bPlaying = TFALSE;
240 m_bVisible = TFALSE;
241 m_bPaused = TFALSE;
242}

Member Data Documentation

◆ ms_oClass

Definition at line 15 of file ABINKMoviePlayer.h.

◆ PARENTCLASS

Toshi::TClass* ABINKMoviePlayer::PARENTCLASS = & AMoviePlayer::ms_oClass
staticconstexpr

Definition at line 15 of file ABINKMoviePlayer.h.


The documentation for this class was generated from the following files: