| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512 |
- /*
- ** Command & Conquer Generals Zero Hour(tm)
- ** Copyright 2025 Electronic Arts Inc.
- **
- ** This program is free software: you can redistribute it and/or modify
- ** it under the terms of the GNU General Public License as published by
- ** the Free Software Foundation, either version 3 of the License, or
- ** (at your option) any later version.
- **
- ** This program is distributed in the hope that it will be useful,
- ** but WITHOUT ANY WARRANTY; without even the implied warranty of
- ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- ** GNU General Public License for more details.
- **
- ** You should have received a copy of the GNU General Public License
- ** along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
- ////////////////////////////////////////////////////////////////////////////////
- // //
- // (c) 2001-2003 Electronic Arts Inc. //
- // //
- ////////////////////////////////////////////////////////////////////////////////
- //----------------------------------------------------------------------------
- //
- // Westwood Studios Pacific.
- //
- // Confidential Information
- // Copyright (C) 2001 - All Rights Reserved
- //
- //----------------------------------------------------------------------------
- //
- // Project: Generals
- //
- // Module: GameClient
- //
- // File name: VideoPlayer.cpp
- //
- // Created: 10/22/01 TR
- //
- //----------------------------------------------------------------------------
- //----------------------------------------------------------------------------
- // Includes
- //----------------------------------------------------------------------------
- #include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine
- #include "Lib/BaseType.h"
- #include "GameClient/VideoPlayer.h"
- //----------------------------------------------------------------------------
- // Externals
- //----------------------------------------------------------------------------
- //----------------------------------------------------------------------------
- // Defines
- //----------------------------------------------------------------------------
- //----------------------------------------------------------------------------
- // Private Types
- //----------------------------------------------------------------------------
- //----------------------------------------------------------------------------
- // Private Data
- //----------------------------------------------------------------------------
- //----------------------------------------------------------------------------
- // Public Data
- //----------------------------------------------------------------------------
- VideoPlayerInterface *TheVideoPlayer = NULL;
- //----------------------------------------------------------------------------
- // Private Prototypes
- //----------------------------------------------------------------------------
- //----------------------------------------------------------------------------
- // Private Functions
- //----------------------------------------------------------------------------
- //----------------------------------------------------------------------------
- // Public Functions
- //----------------------------------------------------------------------------
- //============================================================================
- // VideoBuffer::VideoBuffer
- //============================================================================
- VideoBuffer::VideoBuffer( Type format)
- : m_width(0),
- m_height(0),
- m_textureWidth(0),
- m_textureHeight(0),
- m_format(format),
- m_pitch(0),
- m_xPos(0),
- m_yPos(0)
- {
- if ( m_format >= NUM_TYPES || m_format < 0 )
- {
- m_format = TYPE_UNKNOWN;
- }
- }
- //============================================================================
- // VideoBuffer::Rect
- //============================================================================
- RectClass VideoBuffer::Rect( Real x1, Real y1, Real x2, Real y2 )
- {
- RectClass rect(0,0,0,0);
- if ( valid() )
- {
- rect.Set(
- ((Real)m_width/(Real)m_textureWidth)*x1, ((Real)m_height/(Real)m_textureHeight)*y1,
- ((Real)m_width/(Real)m_textureWidth)*x2, ((Real)m_height/(Real)m_textureHeight)*y2
- );
- }
- return rect;
- }
- //============================================================================
- // VideoBuffer::free
- //============================================================================
- void VideoBuffer::free( void )
- {
- m_width = 0;
- m_height = 0;
- m_textureWidth = 0;
- m_textureHeight = 0;
- }
- //============================================================================
- // VideoPlayer::VideoPlayer
- //============================================================================
- VideoPlayer::VideoPlayer()
- : m_firstStream(NULL)
- {
- }
- //============================================================================
- // VideoPlayer::~VideoPlayer
- //============================================================================
- VideoPlayer::~VideoPlayer()
- {
- deinit();
- // Set the video player to null if its us. (WB requires this.)
- if (this == TheVideoPlayer) {
- TheVideoPlayer = NULL;
- }
- }
- //============================================================================
- // VideoPlayer::init
- //============================================================================
- void VideoPlayer::init( void )
- {
- // Load this here so that WB doesn't have to link to BinkLib, costing us (potentially)
- // an extra license.
- INI ini;
- ini.load( AsciiString( "Data\\INI\\Default\\Video.ini" ), INI_LOAD_OVERWRITE, NULL );
- ini.load( AsciiString( "Data\\INI\\Video.ini" ), INI_LOAD_OVERWRITE, NULL );
- }
- //============================================================================
- // VideoPlayer::deinit
- //============================================================================
- void VideoPlayer::deinit( void )
- {
- }
- //============================================================================
- // VideoPlayer::reset
- //============================================================================
- void VideoPlayer::reset( void )
- {
- closeAllStreams();
- }
- //============================================================================
- // VideoPlayer::update
- //============================================================================
- void VideoPlayer::update( void )
- {
- VideoStreamInterface *stream = firstStream();
- while ( stream )
- {
- stream->update();
- stream = stream->next();
- }
- }
- //============================================================================
- // VideoPlayer::loseFocus
- //============================================================================
- void VideoPlayer::loseFocus( void )
- {
- }
- //============================================================================
- // VideoPlayer::regainFocus
- //============================================================================
- void VideoPlayer::regainFocus( void )
- {
- }
- //============================================================================
- // VideoPlayer::open
- //============================================================================
- VideoStreamInterface* VideoPlayer::open( AsciiString movieTitle )
- {
- return NULL;
- }
- //============================================================================
- // VideoPlayer::load
- //============================================================================
- VideoStreamInterface* VideoPlayer::load( AsciiString movieTitle )
- {
- return NULL;
- }
- //============================================================================
- // VideoPlayer::firstStream
- //============================================================================
- VideoStreamInterface* VideoPlayer::firstStream( void )
- {
- return m_firstStream;
- }
- //============================================================================
- // VideoPlayer::closeAllStreams
- //============================================================================
- void VideoPlayer::closeAllStreams( void )
- {
- VideoStreamInterface *stream ;
- while ( (stream = firstStream()) != 0 )
- {
- stream->close();
- }
- }
- //============================================================================
- // VideoPlayer::remove
- //============================================================================
- void VideoPlayer::remove( VideoStream *stream_to_remove )
- {
- VideoStream *last = NULL;
- VideoStream *stream = (VideoStream*) firstStream();
- while ( stream != NULL && stream != stream_to_remove )
- {
- last = stream;
- stream = (VideoStream*) stream->next();
- }
- if ( stream )
- {
- if ( last )
- {
- last->m_next = stream->m_next;
- }
- else
- {
- m_firstStream = stream->m_next;
- }
- }
- }
- //============================================================================
- // VideoPlayer::addVideo
- //============================================================================
- void VideoPlayer::addVideo( Video* videoToAdd )
- {
- for (VecVideoIt it = mVideosAvailableForPlay.begin(); it != mVideosAvailableForPlay.end(); ++it) {
- if (it->m_internalName == videoToAdd->m_internalName) {
- (*it) = (*videoToAdd);
- return;
- }
- }
- // That internal name hasn't been used, so push a new entry on the back
- mVideosAvailableForPlay.push_back(*videoToAdd);
- }
- //============================================================================
- // VideoPlayer::removeVideo
- //============================================================================
- void VideoPlayer::removeVideo( Video* videoToRemove )
- {
- for (VecVideoIt it = mVideosAvailableForPlay.begin(); it != mVideosAvailableForPlay.end(); ++it) {
- if (it->m_internalName == videoToRemove->m_internalName) {
- mVideosAvailableForPlay.erase(it);
- return;
- }
- }
- }
- //============================================================================
- // VideoPlayer::getNumVideos
- //============================================================================
- Int VideoPlayer::getNumVideos( void )
- {
- return mVideosAvailableForPlay.size();
- }
- //============================================================================
- // VideoPlayer::removeVideo
- //============================================================================
- const Video* VideoPlayer::getVideo( AsciiString movieTitle )
- {
- for (VecVideoIt it = mVideosAvailableForPlay.begin(); it != mVideosAvailableForPlay.end(); ++it) {
- if (it->m_internalName == movieTitle) {
- return &(*it);
- }
- }
- return NULL;
- }
- //============================================================================
- // VideoPlayer::getVideo
- //============================================================================
- const Video* VideoPlayer::getVideo( Int index )
- {
- if (index < 0 || index >= mVideosAvailableForPlay.size()) {
- return NULL;
- }
- return &mVideosAvailableForPlay[index];
- }
- //============================================================================
- // VideoStream::VideoStream
- //============================================================================
- VideoStream::VideoStream()
- : m_next(NULL),
- m_player(NULL)
- {
- }
- //============================================================================
- // VideoStream::~VideoStream
- //============================================================================
- VideoStream::~VideoStream()
- {
- if ( m_player )
- {
- m_player->remove( this );
- m_player = NULL;
- }
- }
- //============================================================================
- // VideoStream::next
- //============================================================================
- VideoStreamInterface* VideoStream::next( void )
- {
- return m_next;
- }
- //============================================================================
- // VideoStream::update
- //============================================================================
- void VideoStream::update( void )
- {
- }
- //============================================================================
- // VideoStream::close
- //============================================================================
- void VideoStream::close( void )
- {
- delete this;
- }
- //============================================================================
- // VideoStream::isFrameReady
- //============================================================================
- Bool VideoStream::isFrameReady( void )
- {
- return TRUE;
- }
- //============================================================================
- // VideoStream::frameDecompress
- //============================================================================
- void VideoStream::frameDecompress( void )
- {
- }
- //============================================================================
- // VideoStream::frameRender
- //============================================================================
- void VideoStream::frameRender( VideoBuffer *buffer )
- {
- }
- //============================================================================
- // VideoStream::frameNext
- //============================================================================
- void VideoStream::frameNext( void )
- {
- }
- //============================================================================
- // VideoStream::frameIndex
- //============================================================================
- Int VideoStream::frameIndex( void )
- {
- return 0;
- }
- //============================================================================
- // VideoStream::totalFrames
- //============================================================================
- Int VideoStream::frameCount( void )
- {
- return 0;
- }
- //============================================================================
- // VideoStream::frameGoto
- //============================================================================
- void VideoStream::frameGoto( Int index )
- {
- }
- //============================================================================
- // VideoStream::height
- //============================================================================
- Int VideoStream::height( void )
- {
- return 0;
- }
- //============================================================================
- // VideoStream::width
- //============================================================================
- Int VideoStream::width( void )
- {
- return 0;
- }
- const FieldParse VideoPlayer::m_videoFieldParseTable[] =
- {
- { "Filename", INI::parseAsciiString, NULL, offsetof( Video, m_filename) },
- { "Comment", INI::parseAsciiString, NULL, offsetof( Video, m_commentForWB) },
- { NULL, NULL, NULL, 0 },
- };
|