diff --git a/source/glest_game/menu/menu_state_connected_game.cpp b/source/glest_game/menu/menu_state_connected_game.cpp index 73d63675..3137f530 100644 --- a/source/glest_game/menu/menu_state_connected_game.cpp +++ b/source/glest_game/menu/menu_state_connected_game.cpp @@ -62,6 +62,7 @@ MenuStateConnectedGame::MenuStateConnectedGame(Program *program, MainMenu *mainM broadcastServerSettingsDelayTimer=0; lastGameSettingsReceivedCount=0; + this->factionVideo = NULL; currentTechName_factionPreview=""; currentFactionName_factionPreview=""; @@ -648,6 +649,12 @@ MenuStateConnectedGame::~MenuStateConnectedGame() { } cleanupMapPreviewTexture(); + + if(factionVideo != NULL) { + factionVideo->closePlayer(); + delete factionVideo; + factionVideo = NULL; + } } void MenuStateConnectedGame::mouseClick(int x, int y, MouseButton mouseButton){ @@ -1674,6 +1681,12 @@ void MenuStateConnectedGame::render() { //renderer.renderTextureQuad(60+575+80,365,200,225,factionTexture,1); renderer.renderTextureQuad(800,600,200,150,factionTexture,1); } + if(factionVideo != NULL) { + if(factionVideo->isPlaying() == true) { + factionVideo->playFrame(false); + } + } + if(mapPreviewTexture != NULL) { renderer.renderTextureQuad(5,185,150,150,mapPreviewTexture,1.0f); //printf("=================> Rendering map preview texture\n"); @@ -3610,13 +3623,51 @@ void MenuStateConnectedGame::setupUIFromGameSettings(GameSettings *gameSettings, currentTechName_factionPreview=gameSettings->getTech(); currentFactionName_factionPreview=gameSettings->getFactionTypeName(gameSettings->getThisFactionIndex()); - string factionLogo = Game::findFactionLogoFile(gameSettings, NULL,"preview_screen.*"); - if(factionLogo == "") { - factionLogo = Game::findFactionLogoFile(gameSettings, NULL); + string factionVideoUrl = Game::findFactionLogoFile(gameSettings, NULL,"preview_video.*"); + if(factionVideoUrl != "") { + if(currentFactionLogo != factionVideoUrl) { + currentFactionLogo = factionVideoUrl; + if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == false && + Shared::Graphics::VideoPlayer::hasBackEndVideoPlayer() == true) { + + if(factionVideo != NULL) { + factionVideo->closePlayer(); + delete factionVideo; + factionVideo = NULL; + } + string introVideoFile = factionVideoUrl; + string introVideoFileFallback = ""; + + Context *c= GraphicsInterface::getInstance().getCurrentContext(); + SDL_Surface *screen = static_cast(c)->getPlatformContextGlPtr()->getScreen(); + + string vlcPluginsPath = Config::getInstance().getString("VideoPlayerPluginsPath",""); + //printf("screen->w = %d screen->h = %d screen->format->BitsPerPixel = %d\n",screen->w,screen->h,screen->format->BitsPerPixel); + factionVideo = new VideoPlayer( + &Renderer::getInstance(), + introVideoFile, + introVideoFileFallback, + screen, + 0,0, + screen->w, + screen->h, + screen->format->BitsPerPixel, + vlcPluginsPath, + SystemFlags::VERBOSE_MODE_ENABLED); + factionVideo->initPlayer(); + } + } } - if(currentFactionLogo != factionLogo) { - currentFactionLogo = factionLogo; - loadFactionTexture(currentFactionLogo); + + if(factionVideo == NULL) { + string factionLogo = Game::findFactionLogoFile(gameSettings, NULL,"preview_screen.*"); + if(factionLogo == "") { + factionLogo = Game::findFactionLogoFile(gameSettings, NULL); + } + if(currentFactionLogo != factionLogo) { + currentFactionLogo = factionLogo; + loadFactionTexture(currentFactionLogo); + } } } } diff --git a/source/glest_game/menu/menu_state_connected_game.h b/source/glest_game/menu/menu_state_connected_game.h index a37c37d0..c8c09668 100644 --- a/source/glest_game/menu/menu_state_connected_game.h +++ b/source/glest_game/menu/menu_state_connected_game.h @@ -23,6 +23,10 @@ #include "miniftpclient.h" #include "leak_dumper.h" +namespace Shared { namespace Graphics { + class VideoPlayer; +}} + namespace Glest { namespace Game { enum JoinMenu { @@ -125,6 +129,7 @@ private: string currentFactionName_factionPreview; string currentFactionLogo; Texture2D *factionTexture; + Shared::Graphics::VideoPlayer *factionVideo; MapPreview mapPreview; diff --git a/source/glest_game/menu/menu_state_custom_game.cpp b/source/glest_game/menu/menu_state_custom_game.cpp index 2346bf99..f478e9eb 100644 --- a/source/glest_game/menu/menu_state_custom_game.cpp +++ b/source/glest_game/menu/menu_state_custom_game.cpp @@ -68,6 +68,7 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, this->lastMasterServerSettingsUpdateCount = 0; this->masterserverModeMinimalResources = true; this->parentMenuState=parentMenuState; + this->factionVideo = NULL; //printf("this->masterserverMode = %d [%d]\n",this->masterserverMode,masterserverMode); @@ -925,6 +926,12 @@ void MenuStateCustomGame::cleanup() { cleanupMapPreviewTexture(); + if(factionVideo != NULL) { + factionVideo->closePlayer(); + delete factionVideo; + factionVideo = NULL; + } + if(forceWaitForShutdown == true) { NetworkManager::getInstance().end(); } @@ -1736,6 +1743,11 @@ void MenuStateCustomGame::render() { if(factionTexture != NULL) { renderer.renderTextureQuad(800,600,200,150,factionTexture,0.7f); } + if(factionVideo != NULL) { + if(factionVideo->isPlaying() == true) { + factionVideo->playFrame(false); + } + } if(mapPreviewTexture != NULL) { renderer.renderTextureQuad(5,185,150,150,mapPreviewTexture,1.0f); //printf("=================> Rendering map preview texture\n"); @@ -2507,13 +2519,51 @@ void MenuStateCustomGame::update() { currentTechName_factionPreview=gameSettings.getTech(); currentFactionName_factionPreview=gameSettings.getFactionTypeName(gameSettings.getThisFactionIndex()); - string factionLogo = Game::findFactionLogoFile(&gameSettings, NULL,"preview_screen.*"); - if(factionLogo == "") { - factionLogo = Game::findFactionLogoFile(&gameSettings, NULL); + string factionVideoUrl = Game::findFactionLogoFile(&gameSettings, NULL,"preview_video.*"); + if(factionVideoUrl != "") { + if(currentFactionLogo != factionVideoUrl) { + currentFactionLogo = factionVideoUrl; + if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == false && + Shared::Graphics::VideoPlayer::hasBackEndVideoPlayer() == true) { + + if(factionVideo != NULL) { + factionVideo->closePlayer(); + delete factionVideo; + factionVideo = NULL; + } + string introVideoFile = factionVideoUrl; + string introVideoFileFallback = ""; + + Context *c= GraphicsInterface::getInstance().getCurrentContext(); + SDL_Surface *screen = static_cast(c)->getPlatformContextGlPtr()->getScreen(); + + string vlcPluginsPath = Config::getInstance().getString("VideoPlayerPluginsPath",""); + //printf("screen->w = %d screen->h = %d screen->format->BitsPerPixel = %d\n",screen->w,screen->h,screen->format->BitsPerPixel); + factionVideo = new VideoPlayer( + &Renderer::getInstance(), + introVideoFile, + introVideoFileFallback, + screen, + 0,0, + screen->w, + screen->h, + screen->format->BitsPerPixel, + vlcPluginsPath, + SystemFlags::VERBOSE_MODE_ENABLED); + factionVideo->initPlayer(); + } + } } - if(currentFactionLogo != factionLogo) { - currentFactionLogo = factionLogo; - loadFactionTexture(currentFactionLogo); + + if(factionVideo == NULL) { + string factionLogo = Game::findFactionLogoFile(&gameSettings, NULL,"preview_screen.*"); + if(factionLogo == "") { + factionLogo = Game::findFactionLogoFile(&gameSettings, NULL); + } + if(currentFactionLogo != factionLogo) { + currentFactionLogo = factionLogo; + loadFactionTexture(currentFactionLogo); + } } } } diff --git a/source/glest_game/menu/menu_state_custom_game.h b/source/glest_game/menu/menu_state_custom_game.h index 21e9f8eb..729713d5 100644 --- a/source/glest_game/menu/menu_state_custom_game.h +++ b/source/glest_game/menu/menu_state_custom_game.h @@ -20,6 +20,10 @@ using namespace Shared::Map; +namespace Shared { namespace Graphics { + class VideoPlayer; +}} + namespace Glest { namespace Game { class SwitchSetupRequest; @@ -168,6 +172,7 @@ private: string currentFactionName_factionPreview; string currentFactionLogo; Texture2D *factionTexture; + Shared::Graphics::VideoPlayer *factionVideo; MapPreview mapPreview; Texture2D *mapPreviewTexture;