From 282601d6e9d2ccdbf82ab793218ac210bc270489 Mon Sep 17 00:00:00 2001 From: scrawl Date: Mon, 7 Jan 2013 13:19:52 +0100 Subject: [PATCH] support the allowSkipping extra parameter for playBink command. --- apps/openmw/mwbase/world.hpp | 2 +- apps/openmw/mwrender/renderingmanager.cpp | 6 +++--- apps/openmw/mwrender/renderingmanager.hpp | 2 +- apps/openmw/mwrender/videoplayer.cpp | 11 ++++++++++- apps/openmw/mwrender/videoplayer.hpp | 5 ++++- apps/openmw/mwscript/miscextensions.cpp | 7 +++++-- apps/openmw/mwworld/worldimp.cpp | 4 ++-- apps/openmw/mwworld/worldimp.hpp | 2 +- 8 files changed, 27 insertions(+), 12 deletions(-) diff --git a/apps/openmw/mwbase/world.hpp b/apps/openmw/mwbase/world.hpp index 198a20d454..7ec25f1ead 100644 --- a/apps/openmw/mwbase/world.hpp +++ b/apps/openmw/mwbase/world.hpp @@ -305,7 +305,7 @@ namespace MWBase /// \todo this does not belong here - virtual void playVideo(const std::string& name) = 0; + virtual void playVideo(const std::string& name, bool allowSkipping) = 0; virtual void stopVideo() = 0; }; } diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index 3abf88cca3..ae7d6612bd 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -929,14 +929,14 @@ void RenderingManager::setupExternalRendering (MWRender::ExternalRendering& rend rendering.setup (mRendering.getScene()); } -void RenderingManager::playVideo(const std::string& name) +void RenderingManager::playVideo(const std::string& name, bool allowSkipping) { - mVideoPlayer->playVideo ("video/" + name); + mVideoPlayer->playVideo ("video/" + name, allowSkipping); } void RenderingManager::stopVideo() { - mVideoPlayer->close (); + mVideoPlayer->stopVideo (); } } // namespace diff --git a/apps/openmw/mwrender/renderingmanager.hpp b/apps/openmw/mwrender/renderingmanager.hpp index 02b4bcef61..68f2d79c37 100644 --- a/apps/openmw/mwrender/renderingmanager.hpp +++ b/apps/openmw/mwrender/renderingmanager.hpp @@ -196,7 +196,7 @@ class RenderingManager: private RenderingInterface, public Ogre::WindowEventList void setupExternalRendering (MWRender::ExternalRendering& rendering); - void playVideo(const std::string& name); + void playVideo(const std::string& name, bool allowSkipping); void stopVideo(); protected: diff --git a/apps/openmw/mwrender/videoplayer.cpp b/apps/openmw/mwrender/videoplayer.cpp index 8e05a4f82b..618331c12e 100644 --- a/apps/openmw/mwrender/videoplayer.cpp +++ b/apps/openmw/mwrender/videoplayer.cpp @@ -1010,6 +1010,7 @@ VideoPlayer::VideoPlayer(Ogre::SceneManager* sceneMgr) , mVideoMaterial(NULL) , mRectangle(NULL) , mNode(NULL) + , mAllowSkipping(false) { mVideoMaterial = Ogre::MaterialManager::getSingleton().getByName("VideoMaterial", "General"); if (mVideoMaterial.isNull ()) @@ -1071,8 +1072,10 @@ VideoPlayer::~VideoPlayer() delete mBackgroundRectangle; } -void VideoPlayer::playVideo(const std::string &resourceName) +void VideoPlayer::playVideo(const std::string &resourceName, bool allowSkipping) { + mAllowSkipping = allowSkipping; + if(mState) close(); @@ -1113,6 +1116,12 @@ void VideoPlayer::update () } } +void VideoPlayer::stopVideo () +{ + if (mAllowSkipping) + close(); +} + void VideoPlayer::close() { if(mState) diff --git a/apps/openmw/mwrender/videoplayer.hpp b/apps/openmw/mwrender/videoplayer.hpp index d8c1902aa4..5e9d18ba41 100644 --- a/apps/openmw/mwrender/videoplayer.hpp +++ b/apps/openmw/mwrender/videoplayer.hpp @@ -20,11 +20,12 @@ namespace MWRender VideoPlayer(Ogre::SceneManager* sceneMgr); ~VideoPlayer(); - void playVideo (const std::string& resourceName); + void playVideo (const std::string& resourceName, bool allowSkipping); void update(); void close(); + void stopVideo(); bool isPlaying(); @@ -34,6 +35,8 @@ namespace MWRender private: VideoState* mState; + bool mAllowSkipping; + Ogre::SceneManager* mSceneMgr; Ogre::MaterialPtr mVideoMaterial; Ogre::Rectangle2D* mRectangle; diff --git a/apps/openmw/mwscript/miscextensions.cpp b/apps/openmw/mwscript/miscextensions.cpp index ef9976a0b3..80725b1f29 100644 --- a/apps/openmw/mwscript/miscextensions.cpp +++ b/apps/openmw/mwscript/miscextensions.cpp @@ -34,7 +34,10 @@ namespace MWScript std::string name = runtime.getStringLiteral (runtime[0].mInteger); runtime.pop(); - MWBase::Environment::get().getWorld ()->playVideo (name); + bool allowSkipping = runtime[0].mInteger; + runtime.pop(); + + MWBase::Environment::get().getWorld ()->playVideo (name, allowSkipping); } }; @@ -465,7 +468,7 @@ namespace MWScript extensions.registerInstruction ("tvm", "", opcodeToggleVanityMode); extensions.registerFunction ("getpcsleep", 'l', "", opcodeGetPcSleep); extensions.registerInstruction ("wakeuppc", "", opcodeWakeUpPc); - extensions.registerInstruction ("playbink", "S", opcodePlayBink); + extensions.registerInstruction ("playbink", "Sl", opcodePlayBink); extensions.registerFunction ("getlocked", 'l', "", opcodeGetLocked, opcodeGetLockedExplicit); extensions.registerFunction ("geteffect", 'l', "l", opcodeGetEffect, opcodeGetEffectExplicit); extensions.registerFunction ("getattacked", 'l', "", opcodeGetAttacked, opcodeGetAttackedExplicit); diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index 8eb121d374..6b06c60f51 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -1287,9 +1287,9 @@ namespace MWWorld } - void World::playVideo (const std::string &name) + void World::playVideo (const std::string &name, bool allowSkipping) { - mRendering->playVideo(name); + mRendering->playVideo(name, allowSkipping); } void World::stopVideo () diff --git a/apps/openmw/mwworld/worldimp.hpp b/apps/openmw/mwworld/worldimp.hpp index 1c13529136..ce0bbb1c46 100644 --- a/apps/openmw/mwworld/worldimp.hpp +++ b/apps/openmw/mwworld/worldimp.hpp @@ -334,7 +334,7 @@ namespace MWWorld /// 3 - enemies are nearby (not implemented) /// \todo this does not belong here - virtual void playVideo(const std::string& name); + virtual void playVideo(const std::string& name, bool allowSkipping); virtual void stopVideo(); }; }