Port VideoWidget

pull/638/head
scrawl 10 years ago
parent 223e3a53f5
commit b0804734e5

@ -468,7 +468,7 @@ void OMW::Engine::go()
mViewer->realize(); mViewer->realize();
osg::Timer frameTimer; osg::Timer frameTimer;
while (!mViewer->done()) while (!mViewer->done() && !MWBase::Environment::get().getStateManager()->hasQuitRequest())
{ {
double dt = frameTimer.time_s(); double dt = frameTimer.time_s();
frameTimer.setStartTick(); frameTimer.setStartTick();

@ -1,51 +1,70 @@
#include "videowidget.hpp" #include "videowidget.hpp"
//#include <extern/osg-ffmpeg-videoplayer/videoplayer.hpp> #include <extern/osg-ffmpeg-videoplayer/videoplayer.hpp>
#include <MyGUI_RenderManager.h> #include <MyGUI_RenderManager.h>
//#include "../mwsound/movieaudiofactory.hpp" #include <osg/Texture2D>
#include <components/vfs/manager.hpp>
#include <components/myguiplatform/myguitexture.hpp>
#include "../mwsound/movieaudiofactory.hpp"
namespace MWGui namespace MWGui
{ {
VideoWidget::VideoWidget() VideoWidget::VideoWidget()
: mVFS(NULL)
{ {
//mPlayer.reset(new Video::VideoPlayer()); mPlayer.reset(new Video::VideoPlayer());
setNeedKeyFocus(true); setNeedKeyFocus(true);
} }
void VideoWidget::setVFS(const VFS::Manager *vfs)
{
mVFS = vfs;
}
void VideoWidget::playVideo(const std::string &video) void VideoWidget::playVideo(const std::string &video)
{ {
//mPlayer->setAudioFactory(new MWSound::MovieAudioFactory()); mPlayer->setAudioFactory(new MWSound::MovieAudioFactory());
//mPlayer->playVideo(video);
mPlayer->playVideo(mVFS->get(video));
osg::ref_ptr<osg::Texture2D> texture = mPlayer->getVideoTexture();
if (!texture)
return;
mTexture.reset(new osgMyGUI::OSGTexture(texture));
//setImageTexture(mPlayer->getTextureName()); setRenderItemTexture(mTexture.get());
getSubWidgetMain()->_setUVSet(MyGUI::FloatRect(0.f, 0.f, 1.f, 1.f));
} }
int VideoWidget::getVideoWidth() int VideoWidget::getVideoWidth()
{ {
return 0;//mPlayer->getVideoWidth(); return mPlayer->getVideoWidth();
} }
int VideoWidget::getVideoHeight() int VideoWidget::getVideoHeight()
{ {
return 0;//mPlayer->getVideoHeight(); return mPlayer->getVideoHeight();
} }
bool VideoWidget::update() bool VideoWidget::update()
{ {
return 0;//mPlayer->update(); return mPlayer->update();
} }
void VideoWidget::stop() void VideoWidget::stop()
{ {
//mPlayer->close(); mPlayer->close();
} }
bool VideoWidget::hasAudioStream() bool VideoWidget::hasAudioStream()
{ {
return 0;//mPlayer->hasAudioStream(); return mPlayer->hasAudioStream();
} }
void VideoWidget::autoResize(bool stretch) void VideoWidget::autoResize(bool stretch)

@ -1,26 +1,34 @@
#ifndef OPENMW_MWGUI_VIDEOWIDGET_H #ifndef OPENMW_MWGUI_VIDEOWIDGET_H
#define OPENMW_MWGUI_VIDEOWIDGET_H #define OPENMW_MWGUI_VIDEOWIDGET_H
#include <MyGUI_ImageBox.h> #include <MyGUI_Widget.h>
namespace Video namespace Video
{ {
class VideoPlayer; class VideoPlayer;
} }
namespace VFS
{
class Manager;
}
namespace MWGui namespace MWGui
{ {
/** /**
* Widget that plays a video. * Widget that plays a video.
*/ */
class VideoWidget : public MyGUI::ImageBox class VideoWidget : public MyGUI::Widget
{ {
public: public:
MYGUI_RTTI_DERIVED(VideoWidget) MYGUI_RTTI_DERIVED(VideoWidget)
VideoWidget(); VideoWidget();
/// Set the VFS (virtual file system) to find the videos on.
void setVFS(const VFS::Manager* vfs);
void playVideo (const std::string& video); void playVideo (const std::string& video);
int getVideoWidth(); int getVideoWidth();
@ -42,7 +50,9 @@ namespace MWGui
void autoResize (bool stretch); void autoResize (bool stretch);
private: private:
//std::auto_ptr<Video::VideoPlayer> mPlayer; const VFS::Manager* mVFS;
std::auto_ptr<MyGUI::ITexture> mTexture;
std::auto_ptr<Video::VideoPlayer> mPlayer;
}; };
} }

@ -3,9 +3,7 @@
#include <cassert> #include <cassert>
#include <iterator> #include <iterator>
#include <OgreTextureManager.h> #include <osgViewer/Viewer>
#include <OgreRenderWindow.h>
#include <OgreSceneManager.h>
#include <MyGUI_UString.h> #include <MyGUI_UString.h>
#include <MyGUI_IPointer.h> #include <MyGUI_IPointer.h>
@ -38,6 +36,8 @@
#include "../mwbase/inputmanager.hpp" #include "../mwbase/inputmanager.hpp"
#include "../mwbase/statemanager.hpp" #include "../mwbase/statemanager.hpp"
#include "../mwrender/vismask.hpp"
#include "../mwworld/class.hpp" #include "../mwworld/class.hpp"
#include "../mwworld/player.hpp" #include "../mwworld/player.hpp"
#include "../mwworld/cellstore.hpp" #include "../mwworld/cellstore.hpp"
@ -102,7 +102,8 @@ namespace MWGui
osgViewer::Viewer* viewer, osg::Group* guiRoot, Resource::ResourceSystem* resourceSystem osgViewer::Viewer* viewer, osg::Group* guiRoot, Resource::ResourceSystem* resourceSystem
, const std::string& logpath, const std::string& resourcePath, bool consoleOnlyScripts, , const std::string& logpath, const std::string& resourcePath, bool consoleOnlyScripts,
Translation::Storage& translationDataStorage, ToUTF8::FromType encoding, bool exportFonts, const std::map<std::string, std::string>& fallbackMap) Translation::Storage& translationDataStorage, ToUTF8::FromType encoding, bool exportFonts, const std::map<std::string, std::string>& fallbackMap)
: mConsoleOnlyScripts(consoleOnlyScripts) : mViewer(viewer)
, mConsoleOnlyScripts(consoleOnlyScripts)
, mHud(NULL) , mHud(NULL)
, mMap(NULL) , mMap(NULL)
, mMenu(NULL) , mMenu(NULL)
@ -236,6 +237,7 @@ namespace MWGui
mVideoWidget = mVideoBackground->createWidgetReal<VideoWidget>("ImageBox", 0,0,1,1, MyGUI::Align::Default); mVideoWidget = mVideoBackground->createWidgetReal<VideoWidget>("ImageBox", 0,0,1,1, MyGUI::Align::Default);
mVideoWidget->setNeedMouseFocus(true); mVideoWidget->setNeedMouseFocus(true);
mVideoWidget->setNeedKeyFocus(true); mVideoWidget->setNeedKeyFocus(true);
mVideoWidget->setVFS(resourceSystem->getVFS());
// Removes default MyGUI system clipboard implementation, which supports windows only // Removes default MyGUI system clipboard implementation, which supports windows only
MyGUI::ClipboardManager::getInstance().eventClipboardChanged.clear(); MyGUI::ClipboardManager::getInstance().eventClipboardChanged.clear();
@ -1127,8 +1129,8 @@ namespace MWGui
mGuiModes.push_back(mode); mGuiModes.push_back(mode);
bool gameMode = !isGuiMode(); //bool gameMode = !isGuiMode();
MWBase::Environment::get().getInputManager()->changeInputMode(!gameMode); //MWBase::Environment::get().getInputManager()->changeInputMode(!gameMode);
updateVisible(); updateVisible();
} }
@ -1683,7 +1685,6 @@ namespace MWGui
void WindowManager::playVideo(const std::string &name, bool allowSkipping) void WindowManager::playVideo(const std::string &name, bool allowSkipping)
{ {
return;
mVideoWidget->playVideo("video\\" + name); mVideoWidget->playVideo("video\\" + name);
mVideoWidget->eventKeyButtonPressed.clear(); mVideoWidget->eventKeyButtonPressed.clear();
@ -1695,16 +1696,10 @@ namespace MWGui
} }
// Turn off all rendering except for the GUI // Turn off all rendering except for the GUI
/* int oldUpdateMask = mViewer->getUpdateVisitor()->getTraversalMask();
mRendering->getScene()->clearSpecialCaseRenderQueues(); int oldCullMask = mViewer->getCamera()->getCullMask();
// SCRQM_INCLUDE with RENDER_QUEUE_OVERLAY does not work? mViewer->getUpdateVisitor()->setTraversalMask(MWRender::Mask_GUI);
for(int i = 0;i < Ogre::RENDER_QUEUE_MAX;++i) mViewer->getCamera()->setCullMask(MWRender::Mask_GUI);
{
if(i > 0 && i < 96)
mRendering->getScene()->addSpecialCaseRenderQueue(i);
}
mRendering->getScene()->setSpecialCaseRenderQueueMode(Ogre::SceneManager::SCRQM_EXCLUDE);
*/
MyGUI::IntSize screenSize = MyGUI::RenderManager::getInstance().getViewSize(); MyGUI::IntSize screenSize = MyGUI::RenderManager::getInstance().getViewSize();
sizeVideo(screenSize.width, screenSize.height); sizeVideo(screenSize.width, screenSize.height);
@ -1722,9 +1717,9 @@ namespace MWGui
while (mVideoWidget->update() && !MWBase::Environment::get().getStateManager()->hasQuitRequest()) while (mVideoWidget->update() && !MWBase::Environment::get().getStateManager()->hasQuitRequest())
{ {
MWBase::Environment::get().getInputManager()->update(0, true, false); //MWBase::Environment::get().getInputManager()->update(0, true, false);
//mRendering->getWindow()->update(); mViewer->frame();
} }
mVideoWidget->stop(); mVideoWidget->stop();
@ -1733,8 +1728,8 @@ namespace MWGui
setCursorVisible(cursorWasVisible); setCursorVisible(cursorWasVisible);
// Restore normal rendering // Restore normal rendering
//mRendering->getScene()->clearSpecialCaseRenderQueues(); mViewer->getUpdateVisitor()->setTraversalMask(oldUpdateMask);
//mRendering->getScene()->setSpecialCaseRenderQueueMode(Ogre::SceneManager::SCRQM_EXCLUDE); mViewer->getCamera()->setCullMask(oldCullMask);
mVideoBackground->setVisible(false); mVideoBackground->setVisible(false);
} }

@ -360,6 +360,7 @@ namespace MWGui
private: private:
osgMyGUI::Platform* mGuiPlatform; osgMyGUI::Platform* mGuiPlatform;
osgViewer::Viewer* mViewer;
std::auto_ptr<Gui::FontLoader> mFontLoader; std::auto_ptr<Gui::FontLoader> mFontLoader;

@ -65,16 +65,16 @@ osg::ref_ptr<osg::Texture2D> VideoPlayer::getVideoTexture()
int VideoPlayer::getVideoWidth() int VideoPlayer::getVideoWidth()
{ {
int width=0; int width=0;
if (mState && mState->mTexture.get()) if (mState && mState->mTexture.get() && mState->mTexture->getImage())
width = mState->mTexture->getTextureWidth(); width = mState->mTexture->getImage()->s();
return width; return width;
} }
int VideoPlayer::getVideoHeight() int VideoPlayer::getVideoHeight()
{ {
int height=0; int height=0;
if (mState && mState->mTexture.get()) if (mState && mState->mTexture.get() && mState->mTexture->getImage())
height = mState->mTexture->getTextureHeight(); height = mState->mTexture->getImage()->t();
return height; return height;
} }

Loading…
Cancel
Save