mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-16 15:29:55 +00:00
Port VideoWidget
This commit is contained in:
parent
223e3a53f5
commit
b0804734e5
6 changed files with 65 additions and 40 deletions
|
@ -468,7 +468,7 @@ void OMW::Engine::go()
|
|||
|
||||
mViewer->realize();
|
||||
osg::Timer frameTimer;
|
||||
while (!mViewer->done())
|
||||
while (!mViewer->done() && !MWBase::Environment::get().getStateManager()->hasQuitRequest())
|
||||
{
|
||||
double dt = frameTimer.time_s();
|
||||
frameTimer.setStartTick();
|
||||
|
|
|
@ -1,51 +1,70 @@
|
|||
#include "videowidget.hpp"
|
||||
|
||||
//#include <extern/osg-ffmpeg-videoplayer/videoplayer.hpp>
|
||||
#include <extern/osg-ffmpeg-videoplayer/videoplayer.hpp>
|
||||
|
||||
#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
|
||||
{
|
||||
|
||||
VideoWidget::VideoWidget()
|
||||
: mVFS(NULL)
|
||||
{
|
||||
//mPlayer.reset(new Video::VideoPlayer());
|
||||
mPlayer.reset(new Video::VideoPlayer());
|
||||
setNeedKeyFocus(true);
|
||||
}
|
||||
|
||||
void VideoWidget::setVFS(const VFS::Manager *vfs)
|
||||
{
|
||||
mVFS = vfs;
|
||||
}
|
||||
|
||||
void VideoWidget::playVideo(const std::string &video)
|
||||
{
|
||||
//mPlayer->setAudioFactory(new MWSound::MovieAudioFactory());
|
||||
//mPlayer->playVideo(video);
|
||||
mPlayer->setAudioFactory(new MWSound::MovieAudioFactory());
|
||||
|
||||
//setImageTexture(mPlayer->getTextureName());
|
||||
mPlayer->playVideo(mVFS->get(video));
|
||||
|
||||
osg::ref_ptr<osg::Texture2D> texture = mPlayer->getVideoTexture();
|
||||
if (!texture)
|
||||
return;
|
||||
|
||||
mTexture.reset(new osgMyGUI::OSGTexture(texture));
|
||||
|
||||
setRenderItemTexture(mTexture.get());
|
||||
getSubWidgetMain()->_setUVSet(MyGUI::FloatRect(0.f, 0.f, 1.f, 1.f));
|
||||
}
|
||||
|
||||
int VideoWidget::getVideoWidth()
|
||||
{
|
||||
return 0;//mPlayer->getVideoWidth();
|
||||
return mPlayer->getVideoWidth();
|
||||
}
|
||||
|
||||
int VideoWidget::getVideoHeight()
|
||||
{
|
||||
return 0;//mPlayer->getVideoHeight();
|
||||
return mPlayer->getVideoHeight();
|
||||
}
|
||||
|
||||
bool VideoWidget::update()
|
||||
{
|
||||
return 0;//mPlayer->update();
|
||||
return mPlayer->update();
|
||||
}
|
||||
|
||||
void VideoWidget::stop()
|
||||
{
|
||||
//mPlayer->close();
|
||||
mPlayer->close();
|
||||
}
|
||||
|
||||
bool VideoWidget::hasAudioStream()
|
||||
{
|
||||
return 0;//mPlayer->hasAudioStream();
|
||||
return mPlayer->hasAudioStream();
|
||||
}
|
||||
|
||||
void VideoWidget::autoResize(bool stretch)
|
||||
|
|
|
@ -1,26 +1,34 @@
|
|||
#ifndef OPENMW_MWGUI_VIDEOWIDGET_H
|
||||
#define OPENMW_MWGUI_VIDEOWIDGET_H
|
||||
|
||||
#include <MyGUI_ImageBox.h>
|
||||
#include <MyGUI_Widget.h>
|
||||
|
||||
namespace Video
|
||||
{
|
||||
class VideoPlayer;
|
||||
}
|
||||
|
||||
namespace VFS
|
||||
{
|
||||
class Manager;
|
||||
}
|
||||
|
||||
namespace MWGui
|
||||
{
|
||||
|
||||
/**
|
||||
* Widget that plays a video.
|
||||
*/
|
||||
class VideoWidget : public MyGUI::ImageBox
|
||||
class VideoWidget : public MyGUI::Widget
|
||||
{
|
||||
public:
|
||||
MYGUI_RTTI_DERIVED(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);
|
||||
|
||||
int getVideoWidth();
|
||||
|
@ -42,7 +50,9 @@ namespace MWGui
|
|||
void autoResize (bool stretch);
|
||||
|
||||
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 <iterator>
|
||||
|
||||
#include <OgreTextureManager.h>
|
||||
#include <OgreRenderWindow.h>
|
||||
#include <OgreSceneManager.h>
|
||||
#include <osgViewer/Viewer>
|
||||
|
||||
#include <MyGUI_UString.h>
|
||||
#include <MyGUI_IPointer.h>
|
||||
|
@ -38,6 +36,8 @@
|
|||
#include "../mwbase/inputmanager.hpp"
|
||||
#include "../mwbase/statemanager.hpp"
|
||||
|
||||
#include "../mwrender/vismask.hpp"
|
||||
|
||||
#include "../mwworld/class.hpp"
|
||||
#include "../mwworld/player.hpp"
|
||||
#include "../mwworld/cellstore.hpp"
|
||||
|
@ -102,7 +102,8 @@ namespace MWGui
|
|||
osgViewer::Viewer* viewer, osg::Group* guiRoot, Resource::ResourceSystem* resourceSystem
|
||||
, 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)
|
||||
: mConsoleOnlyScripts(consoleOnlyScripts)
|
||||
: mViewer(viewer)
|
||||
, mConsoleOnlyScripts(consoleOnlyScripts)
|
||||
, mHud(NULL)
|
||||
, mMap(NULL)
|
||||
, mMenu(NULL)
|
||||
|
@ -236,6 +237,7 @@ namespace MWGui
|
|||
mVideoWidget = mVideoBackground->createWidgetReal<VideoWidget>("ImageBox", 0,0,1,1, MyGUI::Align::Default);
|
||||
mVideoWidget->setNeedMouseFocus(true);
|
||||
mVideoWidget->setNeedKeyFocus(true);
|
||||
mVideoWidget->setVFS(resourceSystem->getVFS());
|
||||
|
||||
// Removes default MyGUI system clipboard implementation, which supports windows only
|
||||
MyGUI::ClipboardManager::getInstance().eventClipboardChanged.clear();
|
||||
|
@ -1127,8 +1129,8 @@ namespace MWGui
|
|||
|
||||
mGuiModes.push_back(mode);
|
||||
|
||||
bool gameMode = !isGuiMode();
|
||||
MWBase::Environment::get().getInputManager()->changeInputMode(!gameMode);
|
||||
//bool gameMode = !isGuiMode();
|
||||
//MWBase::Environment::get().getInputManager()->changeInputMode(!gameMode);
|
||||
|
||||
updateVisible();
|
||||
}
|
||||
|
@ -1683,7 +1685,6 @@ namespace MWGui
|
|||
|
||||
void WindowManager::playVideo(const std::string &name, bool allowSkipping)
|
||||
{
|
||||
return;
|
||||
mVideoWidget->playVideo("video\\" + name);
|
||||
|
||||
mVideoWidget->eventKeyButtonPressed.clear();
|
||||
|
@ -1695,16 +1696,10 @@ namespace MWGui
|
|||
}
|
||||
|
||||
// Turn off all rendering except for the GUI
|
||||
/*
|
||||
mRendering->getScene()->clearSpecialCaseRenderQueues();
|
||||
// SCRQM_INCLUDE with RENDER_QUEUE_OVERLAY does not work?
|
||||
for(int i = 0;i < Ogre::RENDER_QUEUE_MAX;++i)
|
||||
{
|
||||
if(i > 0 && i < 96)
|
||||
mRendering->getScene()->addSpecialCaseRenderQueue(i);
|
||||
}
|
||||
mRendering->getScene()->setSpecialCaseRenderQueueMode(Ogre::SceneManager::SCRQM_EXCLUDE);
|
||||
*/
|
||||
int oldUpdateMask = mViewer->getUpdateVisitor()->getTraversalMask();
|
||||
int oldCullMask = mViewer->getCamera()->getCullMask();
|
||||
mViewer->getUpdateVisitor()->setTraversalMask(MWRender::Mask_GUI);
|
||||
mViewer->getCamera()->setCullMask(MWRender::Mask_GUI);
|
||||
|
||||
MyGUI::IntSize screenSize = MyGUI::RenderManager::getInstance().getViewSize();
|
||||
sizeVideo(screenSize.width, screenSize.height);
|
||||
|
@ -1722,9 +1717,9 @@ namespace MWGui
|
|||
|
||||
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();
|
||||
|
||||
|
@ -1733,8 +1728,8 @@ namespace MWGui
|
|||
setCursorVisible(cursorWasVisible);
|
||||
|
||||
// Restore normal rendering
|
||||
//mRendering->getScene()->clearSpecialCaseRenderQueues();
|
||||
//mRendering->getScene()->setSpecialCaseRenderQueueMode(Ogre::SceneManager::SCRQM_EXCLUDE);
|
||||
mViewer->getUpdateVisitor()->setTraversalMask(oldUpdateMask);
|
||||
mViewer->getCamera()->setCullMask(oldCullMask);
|
||||
|
||||
mVideoBackground->setVisible(false);
|
||||
}
|
||||
|
|
|
@ -360,6 +360,7 @@ namespace MWGui
|
|||
|
||||
private:
|
||||
osgMyGUI::Platform* mGuiPlatform;
|
||||
osgViewer::Viewer* mViewer;
|
||||
|
||||
std::auto_ptr<Gui::FontLoader> mFontLoader;
|
||||
|
||||
|
|
|
@ -65,16 +65,16 @@ osg::ref_ptr<osg::Texture2D> VideoPlayer::getVideoTexture()
|
|||
int VideoPlayer::getVideoWidth()
|
||||
{
|
||||
int width=0;
|
||||
if (mState && mState->mTexture.get())
|
||||
width = mState->mTexture->getTextureWidth();
|
||||
if (mState && mState->mTexture.get() && mState->mTexture->getImage())
|
||||
width = mState->mTexture->getImage()->s();
|
||||
return width;
|
||||
}
|
||||
|
||||
int VideoPlayer::getVideoHeight()
|
||||
{
|
||||
int height=0;
|
||||
if (mState && mState->mTexture.get())
|
||||
height = mState->mTexture->getTextureHeight();
|
||||
if (mState && mState->mTexture.get() && mState->mTexture->getImage())
|
||||
height = mState->mTexture->getImage()->t();
|
||||
return height;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue