From 6f48ec63305db47b5d7dbf6249f37543a06cdd9f Mon Sep 17 00:00:00 2001 From: Mark Vejvoda Date: Mon, 4 Jun 2012 00:11:29 +0000 Subject: [PATCH] - play no videos when running special commands like validations --- source/glest_game/main/main.cpp | 20 +++++++++++++++++- .../include/graphics/video_player.h | 4 ++++ .../sources/graphics/video_player.cpp | 21 +++++++++++++++++++ 3 files changed, 44 insertions(+), 1 deletion(-) diff --git a/source/glest_game/main/main.cpp b/source/glest_game/main/main.cpp index 6a244a85..17065bc2 100644 --- a/source/glest_game/main/main.cpp +++ b/source/glest_game/main/main.cpp @@ -2989,6 +2989,25 @@ int glestMain(int argc, char** argv) { #endif } + if( hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_OPENGL_INFO]) == true || + hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_SDL_INFO]) == true || + hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_LUA_INFO]) == true || + hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_CURL_INFO]) == true || + hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_XERCES_INFO]) == true || + hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_VERSION]) == true || + hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_SHOW_INI_SETTINGS]) == true || + hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_VALIDATE_TECHTREES]) == true || + hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_VALIDATE_FACTIONS]) == true || + hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_VALIDATE_SCENARIO]) == true || + hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_VALIDATE_TILESET]) == true || + hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_LIST_MAPS]) == true || + hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_LIST_TECHTRESS]) == true || + hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_LIST_SCENARIOS]) == true || + hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_LIST_TILESETS]) == true || + hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_LIST_TUTORIALS]) == true) { + VideoPlayer::setDisabled(true); + } + //throw megaglest_runtime_error("Test!"); if(hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_SDL_INFO]) == true) { @@ -4396,7 +4415,6 @@ int glestMain(int argc, char** argv) { if( hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_VALIDATE_TECHTREES]) == true || hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_VALIDATE_FACTIONS]) == true || hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_VALIDATE_SCENARIO]) == true) { - runTechValidationReport(argc, argv); delete mainWindow; diff --git a/source/shared_lib/include/graphics/video_player.h b/source/shared_lib/include/graphics/video_player.h index 3758a9ef..c491f604 100644 --- a/source/shared_lib/include/graphics/video_player.h +++ b/source/shared_lib/include/graphics/video_player.h @@ -48,6 +48,7 @@ protected: VideoLoadingCallbackInterface *loadingCB; ctx *ctxPtr; + static bool disabled; void init(); void cleanupPlayer(); @@ -62,6 +63,9 @@ public: string pluginsPath,bool verboseEnabled=false); virtual ~VideoPlayer(); + static void setDisabled(bool value) { disabled = value; } + static bool getDisabled() { return disabled; } + void PlayVideo(); void StopVideo() { stop = true; } diff --git a/source/shared_lib/sources/graphics/video_player.cpp b/source/shared_lib/sources/graphics/video_player.cpp index 9ad87dc0..70abf63c 100644 --- a/source/shared_lib/sources/graphics/video_player.cpp +++ b/source/shared_lib/sources/graphics/video_player.cpp @@ -38,6 +38,7 @@ typedef unsigned __int64 uint64_t; #include #endif + #if defined(WIN32) /** * @param location The location of the registry key. For example "Software\\Bethesda Softworks\\Morrowind" @@ -136,6 +137,8 @@ public: namespace Shared{ namespace Graphics{ +bool VideoPlayer::disabled = false; + // Load a texture static void loadTexture(class ctx *ctx) { if(ctx->verboseEnabled) printf("In [%s] Line: %d\n",__FUNCTION__,__LINE__); @@ -430,6 +433,9 @@ VideoPlayer::VideoPlayer(VideoLoadingCallbackInterface *loadingCB, } void VideoPlayer::init() { + if(VideoPlayer::disabled == true) { + return; + } ctxPtr = new ctx(); ctxPtr->loadingCB = loadingCB; ctxPtr->x = x; @@ -464,6 +470,10 @@ void VideoPlayer::cleanupPlayer() { } bool VideoPlayer::initPlayer(string mediaURL) { + if(VideoPlayer::disabled == true) { + return true; + } + #ifdef HAS_LIBVLC ctxPtr->libvlc = NULL; ctxPtr->m = NULL; @@ -915,6 +925,9 @@ bool VideoPlayer::initPlayer(string mediaURL) { } bool VideoPlayer::initPlayer() { + if(VideoPlayer::disabled == true) { + return true; + } #ifdef HAS_LIBVLC @@ -1010,6 +1023,10 @@ void VideoPlayer::closePlayer() { } void VideoPlayer::PlayVideo() { + if(VideoPlayer::disabled == true) { + return; + } + /* #ifdef HAS_LIBVLC libvlc_instance_t *libvlc = NULL; @@ -1273,6 +1290,10 @@ bool VideoPlayer::isPlaying() const { } bool VideoPlayer::playFrame(bool swapBuffers) { + if(VideoPlayer::disabled == true) { + return false; + } + //bool needToQuit = false; int action = 0, pause = 0, n = 0; if(successLoadingLib == true &&