Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions Core/GameEngine/Include/GameClient/LoadScreen.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,6 @@ class SinglePlayerLoadScreen : public LoadScreen

UnicodeString m_unicodeObjectiveLines[MAX_OBJECTIVE_LINES];

VideoBuffer *m_videoBuffer;
VideoStreamInterface *m_videoStream;

void moveWindows( Int frame );

AudioEventRTS m_ambientLoop;
Expand Down
130 changes: 33 additions & 97 deletions Core/GameEngine/Source/GameClient/GUI/LoadScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,6 @@ SinglePlayerLoadScreen::SinglePlayerLoadScreen( void )
m_currentObjectiveWidthOffset = 0;
m_progressBar = nullptr;
m_percent = nullptr;
m_videoStream = nullptr;
m_videoBuffer = nullptr;
m_objectiveWin = nullptr;
for(Int i = 0; i < MAX_OBJECTIVE_LINES; ++i)
m_objectiveLines[i] = nullptr;
Expand All @@ -189,13 +187,6 @@ SinglePlayerLoadScreen::SinglePlayerLoadScreen( void )

SinglePlayerLoadScreen::~SinglePlayerLoadScreen( void )
{
delete m_videoBuffer;

if ( m_videoStream )
{
m_videoStream->close();
}

TheAudio->removeAudioEvent( m_ambientLoopHandle );
}

Expand Down Expand Up @@ -463,32 +454,6 @@ void SinglePlayerLoadScreen::init( GameInfo *game )

*/
m_ambientLoop.setEventName("LoadScreenAmbient");
// create the new stream
m_videoStream = TheVideoPlayer->open( TheCampaignManager->getCurrentMission()->m_movieLabel );
if ( m_videoStream == nullptr )
{
m_percent->winHide(TRUE);
return;
}

// Create the new buffer
m_videoBuffer = TheDisplay->createVideoBuffer();
if ( m_videoBuffer == nullptr ||
!m_videoBuffer->allocate( m_videoStream->width(),
m_videoStream->height())
)
{
delete m_videoBuffer;
m_videoBuffer = nullptr;

if ( m_videoStream )
{
m_videoStream->close();
m_videoStream = nullptr;
}

return;
}

// format the progress bar: USA to blue, GLA to green, China to red
// and set the background image
Expand Down Expand Up @@ -535,9 +500,18 @@ void SinglePlayerLoadScreen::init( GameInfo *game )
// TheSuperHackers @bugfix Originally this movie render loop stopped rendering when the game window was inactive.
// This either skipped the movie or caused decompression artifacts. Now the video just keeps playing until it done.

Int progressUpdateCount = m_videoStream->frameCount() / FRAME_FUDGE_ADD;
Int shiftedPercent = -FRAME_FUDGE_ADD + 1;
while (m_videoStream->frameIndex() < m_videoStream->frameCount() - 1 )
#if !RTS_GENERALS
// Hide the background window while the movie is playing
backgroundWin->winEnable(false);
#endif

// Show video progress bar
m_progressBar->winEnable(true);

// TheSuperHackers @info We now make use of movie playback within the display object
TheDisplay->playMovie(TheCampaignManager->getCurrentMission()->m_movieLabel);

while(TheDisplay->isMoviePlaying())
{
// TheSuperHackers @feature User can now skip video by pressing ESC
if (TheKeyboard)
Expand All @@ -553,76 +527,34 @@ void SinglePlayerLoadScreen::init( GameInfo *game )

TheGameEngine->serviceWindowsOS();

if(!m_videoStream->isFrameReady())
{
Sleep(1);
continue;
}

m_videoStream->frameDecompress();
m_videoStream->frameRender(m_videoBuffer);

#if RTS_GENERALS
moveWindows( m_videoStream->frameIndex());
#endif

m_videoStream->frameNext();

if(m_videoBuffer)
m_loadScreen->winGetInstanceData()->setVideoBuffer(m_videoBuffer);
if(m_videoStream->frameIndex() % progressUpdateCount == 0)
{
shiftedPercent++;
if(shiftedPercent >0)
shiftedPercent = 0;
Int percent = (shiftedPercent + FRAME_FUDGE_ADD)/1.3;
UnicodeString per;
per.format(L"%d%%",percent);
TheMouse->setCursorTooltip(UnicodeString::TheEmptyString);
GadgetProgressBarSetProgress(m_progressBar, percent);
GadgetStaticTextSetText(m_percent, per);

}
TheWindowManager->update();
// Update the video progress in the progress bar
Int percentValue = TheDisplay->getMovieProgress() * 100.0f;
UnicodeString percentText;
percentText.format(L"%d%%", percentValue);
TheMouse->setCursorTooltip(UnicodeString::TheEmptyString);
GadgetProgressBarSetProgress(m_progressBar, percentValue);
GadgetStaticTextSetText(m_percent, percentText);

// redraw all views, update the GUI
TheWindowManager->update();
TheDisplay->update();
TheDisplay->draw();
}

#if !RTS_GENERALS

// let the background image show through
m_videoStream->close();
m_videoStream = nullptr;
m_loadScreen->winGetInstanceData()->setVideoBuffer( nullptr );
TheDisplay->draw();
TheDisplay->stopMovie();
#if !RTS_GENERALS
backgroundWin->winEnable(true);
#endif
TheDisplay->draw();
}
else
{
#if RTS_GENERALS
// if we're min speced
m_videoStream->frameGoto(m_videoStream->frameCount()); // zero based
while(!m_videoStream->isFrameReady())
Sleep(1);
m_videoStream->frameDecompress();
m_videoStream->frameRender(m_videoBuffer);
if(m_videoBuffer)
m_loadScreen->winGetInstanceData()->setVideoBuffer(m_videoBuffer);

m_objectiveWin->winHide(FALSE);
for(i = 0; i < MAX_DISPLAYED_UNITS; ++i)
m_unitDesc[i]->winHide(FALSE);
m_location->winHide(FALSE);

// Audio was choppy so, I chopped it out!
TheAudio->friend_forcePlayAudioEventRTS(&TheCampaignManager->getCurrentMission()->m_briefingVoice);

for(Int i = 0; i < MAX_OBJECTIVE_LINES; ++i)
{
GadgetStaticTextSetText(m_objectiveLines[i], m_unicodeObjectiveLines[i]);
}
#else
// if we're min spec'ed don't play a movie

#if !RTS_GENERALS
backgroundWin->winEnable(true);
#endif

Int delay = mission->m_voiceLength * 1000;
Expand All @@ -645,6 +577,10 @@ void SinglePlayerLoadScreen::init( GameInfo *game )
TheDisplay->draw();

}

GadgetProgressBarSetProgress(m_progressBar, 0);
GadgetStaticTextSetText(m_percent, UnicodeString::TheEmptyString);

setFPMode();
m_percent->winHide(TRUE);
m_ambientLoopHandle = TheAudio->addAudioEvent(&m_ambientLoop);
Expand Down
6 changes: 4 additions & 2 deletions Generals/Code/GameEngine/Include/GameClient/Display.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,15 @@ class Display : public SubsystemInterface

/// draw a video buffer fit within the screen coordinates
virtual void drawScaledVideoBuffer( VideoBuffer *buffer, VideoStreamInterface *stream ) = 0;
virtual void drawVideoBuffer( VideoBuffer *buffer, Int startX, Int startY,
Int endX, Int endY ) = 0;
virtual void drawScaledVideoBuffer() = 0;
virtual void drawVideoBuffer( VideoBuffer *buffer, Int startX, Int startY, Int endX, Int endY ) = 0;
virtual void drawVideoBuffer(Int startX, Int startY, Int endX, Int endY) = 0;

/// FullScreen video playback
virtual void playLogoMovie( AsciiString movieName, Int minMovieLength, Int minCopyrightLength );
virtual void playMovie( AsciiString movieName );
virtual void stopMovie( void );
virtual Real getMovieProgress(); ///< returns the playback progress in the range 0.0 to 1.0
virtual Bool isMoviePlaying(void);

/// Register debug display callback
Expand Down
10 changes: 10 additions & 0 deletions Generals/Code/GameEngine/Source/GameClient/Display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,16 @@ void Display::reset()
v->reset();
}

//============================================================================
// Display::getMovieProgress
//============================================================================

Real Display::getMovieProgress()
{
return m_videoStream && m_videoStream->frameCount() > 0 ?
(Real)m_videoStream->frameIndex() / (Real)m_videoStream->frameCount() : 0.0f;
}

//============================================================================
// Display::isMoviePlaying
//============================================================================
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,9 @@ class W3DDisplay : public Display

/// draw a video buffer fit within the screen coordinates
virtual void drawScaledVideoBuffer( VideoBuffer *buffer, VideoStreamInterface *stream );
virtual void drawVideoBuffer( VideoBuffer *buffer, Int startX, Int startY,
Int endX, Int endY );
virtual void drawScaledVideoBuffer();
virtual void drawVideoBuffer( VideoBuffer *buffer, Int startX, Int startY, Int endX, Int endY );
virtual void drawVideoBuffer( Int startX, Int startY, Int endX, Int endY );

virtual VideoBuffer* createVideoBuffer( void ) ; ///< Create a video buffer that can be used for this display

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,7 @@ void W3DGameWinDefaultDraw( GameWindow *window, WinInstanceData *instData )
}

// if we have a video buffer, draw the video buffer
// else if the display has a movie playing then we need to draw the displays video buffer
if ( instData->m_videoBuffer )
{
ICoord2D pos, size;
Expand All @@ -387,6 +388,14 @@ void W3DGameWinDefaultDraw( GameWindow *window, WinInstanceData *instData )

TheDisplay->drawVideoBuffer( instData->m_videoBuffer, pos.x, pos.y, pos.x + size.x, pos.y + size.y );
}
else if (TheDisplay->isMoviePlaying())
{
ICoord2D pos, size;
window->winGetScreenPosition(&pos.x, &pos.y);
window->winGetSize(&size.x, &size.y);

TheDisplay->drawVideoBuffer(pos.x, pos.y, pos.x + size.x, pos.y + size.y);
}

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2735,6 +2735,11 @@ void W3DDisplay::drawScaledVideoBuffer( VideoBuffer *buffer, VideoStreamInterfac
drawVideoBuffer( buffer, startX, startY, endX, endY );
}

void W3DDisplay::drawScaledVideoBuffer()
{
drawScaledVideoBuffer(m_videoBuffer, m_videoStream);
}

//============================================================================
// W3DDisplay::drawVideoBuffer
//============================================================================
Expand All @@ -2752,6 +2757,11 @@ void W3DDisplay::drawVideoBuffer( VideoBuffer *buffer, Int startX, Int startY, I

}

void W3DDisplay::drawVideoBuffer( Int startX, Int startY, Int endX, Int endY )
{
drawVideoBuffer(m_videoBuffer, startX, startY, endX, endY);
}

// W3DDisplay::setClipRegion ============================================
/** Set the clipping region for images.
@todo: Make this work for all primitives, not just drawImage. */
Expand Down
8 changes: 5 additions & 3 deletions Generals/Code/Tools/GUIEdit/Include/GUIEditDisplay.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,11 @@ class GUIEditDisplay : public Display
virtual VideoBuffer* createVideoBuffer( void ) { return nullptr; }

/// draw a video buffer fit within the screen coordinates
virtual void drawScaledVideoBuffer( VideoBuffer *buffer, VideoStreamInterface *stream ) { }
virtual void drawVideoBuffer( VideoBuffer *buffer, Int startX, Int startY,
Int endX, Int endY ) { }
virtual void drawScaledVideoBuffer(VideoBuffer* buffer, VideoStreamInterface* stream) { }
virtual void drawScaledVideoBuffer() { }
virtual void drawVideoBuffer(VideoBuffer* buffer, Int startX, Int startY, Int endX, Int endY) { }
virtual void drawVideoBuffer(Int startX, Int startY, Int endX, Int endY) { }

virtual void takeScreenShot(void){ }
virtual void toggleMovieCapture(void) {}

Expand Down
6 changes: 4 additions & 2 deletions GeneralsMD/Code/GameEngine/Include/GameClient/Display.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,15 @@ class Display : public SubsystemInterface

/// draw a video buffer fit within the screen coordinates
virtual void drawScaledVideoBuffer( VideoBuffer *buffer, VideoStreamInterface *stream ) = 0;
virtual void drawVideoBuffer( VideoBuffer *buffer, Int startX, Int startY,
Int endX, Int endY ) = 0;
virtual void drawScaledVideoBuffer() = 0;
virtual void drawVideoBuffer( VideoBuffer *buffer, Int startX, Int startY, Int endX, Int endY ) = 0;
virtual void drawVideoBuffer(Int startX, Int startY, Int endX, Int endY) = 0;

/// FullScreen video playback
virtual void playLogoMovie( AsciiString movieName, Int minMovieLength, Int minCopyrightLength );
virtual void playMovie( AsciiString movieName );
virtual void stopMovie( void );
virtual Real getMovieProgress(); ///< returns the playback progress in the range 0.0 to 1.0
virtual Bool isMoviePlaying(void);

/// Register debug display callback
Expand Down
10 changes: 10 additions & 0 deletions GeneralsMD/Code/GameEngine/Source/GameClient/Display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,16 @@ void Display::reset()
v->reset();
}

//============================================================================
// Display::getMovieProgress
//============================================================================

Real Display::getMovieProgress()
{
return m_videoStream && m_videoStream->frameCount() > 0 ?
(Real)m_videoStream->frameIndex() / (Real)m_videoStream->frameCount() : 0.0f;
}

//============================================================================
// Display::isMoviePlaying
//============================================================================
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,9 @@ class W3DDisplay : public Display

/// draw a video buffer fit within the screen coordinates
virtual void drawScaledVideoBuffer( VideoBuffer *buffer, VideoStreamInterface *stream );
virtual void drawVideoBuffer( VideoBuffer *buffer, Int startX, Int startY,
Int endX, Int endY );
virtual void drawScaledVideoBuffer();
virtual void drawVideoBuffer( VideoBuffer *buffer, Int startX, Int startY, Int endX, Int endY );
virtual void drawVideoBuffer( Int startX, Int startY, Int endX, Int endY );

virtual VideoBuffer* createVideoBuffer( void ) ; ///< Create a video buffer that can be used for this display

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,7 @@ void W3DGameWinDefaultDraw( GameWindow *window, WinInstanceData *instData )
}

// if we have a video buffer, draw the video buffer
// else if the display has a movie playing then we need to draw the displays video buffer
if ( instData->m_videoBuffer )
{
ICoord2D pos, size;
Expand All @@ -387,6 +388,14 @@ void W3DGameWinDefaultDraw( GameWindow *window, WinInstanceData *instData )

TheDisplay->drawVideoBuffer( instData->m_videoBuffer, pos.x, pos.y, pos.x + size.x, pos.y + size.y );
}
else if (TheDisplay->isMoviePlaying())
{
ICoord2D pos, size;
window->winGetScreenPosition(&pos.x, &pos.y);
window->winGetSize(&size.x, &size.y);

TheDisplay->drawVideoBuffer(pos.x, pos.y, pos.x + size.x, pos.y + size.y);
}

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2844,6 +2844,11 @@ void W3DDisplay::drawScaledVideoBuffer( VideoBuffer *buffer, VideoStreamInterfac
drawVideoBuffer( buffer, startX, startY, endX, endY );
}

void W3DDisplay::drawScaledVideoBuffer()
{
drawScaledVideoBuffer(m_videoBuffer, m_videoStream);
}

//============================================================================
// W3DDisplay::drawVideoBuffer
//============================================================================
Expand All @@ -2861,6 +2866,11 @@ void W3DDisplay::drawVideoBuffer( VideoBuffer *buffer, Int startX, Int startY, I

}

void W3DDisplay::drawVideoBuffer( Int startX, Int startY, Int endX, Int endY )
{
drawVideoBuffer(m_videoBuffer, startX, startY, endX, endY);
}

// W3DDisplay::setClipRegion ============================================
/** Set the clipping region for images.
@todo: Make this work for all primitives, not just drawImage. */
Expand Down
Loading
Loading