mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-03 12:15:41 +00:00
Move video skip detection to WindowManager
Fixes a bug where skipping using Esc would not work if a mouse button had been pressed previously
This commit is contained in:
parent
7721e54191
commit
e0d6670ac4
6 changed files with 39 additions and 30 deletions
|
@ -30,9 +30,9 @@ namespace MWGui
|
|||
|
||||
void ConfirmationDialog::exit()
|
||||
{
|
||||
eventCancelClicked();
|
||||
|
||||
setVisible(false);
|
||||
|
||||
eventCancelClicked();
|
||||
}
|
||||
|
||||
void ConfirmationDialog::onCancelButtonClicked(MyGUI::Widget* _sender)
|
||||
|
@ -42,8 +42,8 @@ namespace MWGui
|
|||
|
||||
void ConfirmationDialog::onOkButtonClicked(MyGUI::Widget* _sender)
|
||||
{
|
||||
eventOkClicked();
|
||||
|
||||
setVisible(false);
|
||||
|
||||
eventOkClicked();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -167,7 +167,7 @@ namespace MWGui
|
|||
mVideo = mVideoBackground->createWidget<VideoWidget>("ImageBox", 0,0,1,1,
|
||||
MyGUI::Align::Stretch, "Menu");
|
||||
|
||||
mVideo->playVideo("video\\menu_background.bik", false);
|
||||
mVideo->playVideo("video\\menu_background.bik");
|
||||
}
|
||||
|
||||
MyGUI::IntSize viewSize = MyGUI::RenderManager::getInstance().getViewSize();
|
||||
|
@ -204,7 +204,7 @@ namespace MWGui
|
|||
if (!mVideo->update())
|
||||
{
|
||||
// If finished playing, start again
|
||||
mVideo->playVideo("video\\menu_background.bik", 0);
|
||||
mVideo->playVideo("video\\menu_background.bik");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,17 +4,12 @@ namespace MWGui
|
|||
{
|
||||
|
||||
VideoWidget::VideoWidget()
|
||||
: mAllowSkipping(true)
|
||||
{
|
||||
eventKeyButtonPressed += MyGUI::newDelegate(this, &VideoWidget::onKeyPressed);
|
||||
|
||||
setNeedKeyFocus(true);
|
||||
}
|
||||
|
||||
void VideoWidget::playVideo(const std::string &video, bool allowSkipping)
|
||||
void VideoWidget::playVideo(const std::string &video)
|
||||
{
|
||||
mAllowSkipping = allowSkipping;
|
||||
|
||||
mPlayer.playVideo(video);
|
||||
|
||||
setImageTexture(mPlayer.getTextureName());
|
||||
|
@ -30,19 +25,13 @@ int VideoWidget::getVideoHeight()
|
|||
return mPlayer.getVideoHeight();
|
||||
}
|
||||
|
||||
void VideoWidget::onKeyPressed(MyGUI::Widget *_sender, MyGUI::KeyCode _key, MyGUI::Char _char)
|
||||
{
|
||||
if (_key == MyGUI::KeyCode::Escape && mAllowSkipping)
|
||||
mPlayer.stopVideo();
|
||||
}
|
||||
|
||||
bool VideoWidget::update()
|
||||
{
|
||||
mPlayer.update();
|
||||
return mPlayer.isPlaying();
|
||||
}
|
||||
|
||||
void VideoWidget::cleanup()
|
||||
void VideoWidget::stop()
|
||||
{
|
||||
mPlayer.close();
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ namespace MWGui
|
|||
{
|
||||
|
||||
/**
|
||||
* Widget that plays a video. Can be skipped by pressing Esc.
|
||||
* Widget that plays a video.
|
||||
*/
|
||||
class VideoWidget : public MyGUI::ImageBox
|
||||
{
|
||||
|
@ -18,7 +18,7 @@ namespace MWGui
|
|||
|
||||
VideoWidget();
|
||||
|
||||
void playVideo (const std::string& video, bool allowSkipping);
|
||||
void playVideo (const std::string& video);
|
||||
|
||||
int getVideoWidth();
|
||||
int getVideoHeight();
|
||||
|
@ -26,15 +26,11 @@ namespace MWGui
|
|||
/// @return Is the video still playing?
|
||||
bool update();
|
||||
|
||||
/// Free video player resources (done automatically on destruction)
|
||||
void cleanup();
|
||||
/// Stop video and free resources (done automatically on destruction)
|
||||
void stop();
|
||||
|
||||
private:
|
||||
bool mAllowSkipping;
|
||||
|
||||
MWRender::VideoPlayer mPlayer;
|
||||
|
||||
void onKeyPressed(MyGUI::Widget *_sender, MyGUI::KeyCode _key, MyGUI::Char _char);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -202,8 +202,12 @@ namespace MWGui
|
|||
MyGUI::Align::Default, "Overlay");
|
||||
mVideoBackground->setImageTexture("black.png");
|
||||
mVideoBackground->setVisible(false);
|
||||
mVideoBackground->setNeedMouseFocus(true);
|
||||
mVideoBackground->setNeedKeyFocus(true);
|
||||
|
||||
mVideoWidget = mVideoBackground->createWidgetReal<VideoWidget>("ImageBox", 0,0,1,1, MyGUI::Align::Default);
|
||||
mVideoWidget->setNeedMouseFocus(true);
|
||||
mVideoWidget->setNeedKeyFocus(true);
|
||||
}
|
||||
|
||||
void WindowManager::initUI()
|
||||
|
@ -263,7 +267,7 @@ namespace MWGui
|
|||
mCompanionWindow = new CompanionWindow(mDragAndDrop, mMessageBoxManager);
|
||||
trackWindow(mCompanionWindow, "companion");
|
||||
|
||||
mInputBlocker = mGui->createWidget<MyGUI::Widget>("",0,0,w,h,MyGUI::Align::Default,"Windows","");
|
||||
mInputBlocker = mGui->createWidget<MyGUI::Widget>("",0,0,w,h,MyGUI::Align::Default,"Windows");
|
||||
|
||||
mHud->setVisible(mHudEnabled);
|
||||
|
||||
|
@ -1559,7 +1563,15 @@ namespace MWGui
|
|||
|
||||
void WindowManager::playVideo(const std::string &name, bool allowSkipping)
|
||||
{
|
||||
mVideoWidget->playVideo("video\\" + name, allowSkipping);
|
||||
mVideoWidget->playVideo("video\\" + name);
|
||||
|
||||
mVideoWidget->eventKeyButtonPressed.clear();
|
||||
mVideoBackground->eventKeyButtonPressed.clear();
|
||||
if (allowSkipping)
|
||||
{
|
||||
mVideoWidget->eventKeyButtonPressed += MyGUI::newDelegate(this, &WindowManager::onVideoKeyPressed);
|
||||
mVideoBackground->eventKeyButtonPressed += MyGUI::newDelegate(this, &WindowManager::onVideoKeyPressed);
|
||||
}
|
||||
|
||||
// Turn off all rendering except for the GUI
|
||||
mRendering->getScene()->clearSpecialCaseRenderQueues();
|
||||
|
@ -1587,7 +1599,7 @@ namespace MWGui
|
|||
|
||||
mRendering->getWindow()->update();
|
||||
}
|
||||
mVideoWidget->cleanup();
|
||||
mVideoWidget->stop();
|
||||
|
||||
setCursorVisible(cursorWasVisible);
|
||||
|
||||
|
@ -1628,4 +1640,10 @@ namespace MWGui
|
|||
if(input == mCurrentModals.top())
|
||||
mCurrentModals.pop();
|
||||
}
|
||||
|
||||
void WindowManager::onVideoKeyPressed(MyGUI::Widget *_sender, MyGUI::KeyCode _key, MyGUI::Char _char)
|
||||
{
|
||||
if (_key == MyGUI::KeyCode::Escape)
|
||||
mVideoWidget->stop();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,6 +12,9 @@
|
|||
|
||||
#include "../mwbase/windowmanager.hpp"
|
||||
|
||||
#include <MyGUI_KeyCode.h>
|
||||
#include <MyGUI_Types.h>
|
||||
|
||||
namespace MyGUI
|
||||
{
|
||||
class Gui;
|
||||
|
@ -424,6 +427,9 @@ namespace MWGui
|
|||
void onCursorChange(const std::string& name);
|
||||
void onKeyFocusChanged(MyGUI::Widget* widget);
|
||||
|
||||
// Key pressed while playing a video
|
||||
void onVideoKeyPressed(MyGUI::Widget *_sender, MyGUI::KeyCode _key, MyGUI::Char _char);
|
||||
|
||||
void sizeVideo(int screenWidth, int screenHeight);
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue