|
|
|
@ -4,6 +4,7 @@
|
|
|
|
|
#include <MyGUI_RenderManager.h>
|
|
|
|
|
#include <MyGUI_TextBox.h>
|
|
|
|
|
|
|
|
|
|
#include <components/misc/frameratelimiter.hpp>
|
|
|
|
|
#include <components/settings/values.hpp>
|
|
|
|
|
#include <components/vfs/manager.hpp>
|
|
|
|
|
#include <components/vfs/pathutil.hpp>
|
|
|
|
@ -24,6 +25,56 @@
|
|
|
|
|
|
|
|
|
|
namespace MWGui
|
|
|
|
|
{
|
|
|
|
|
void MenuVideo::run()
|
|
|
|
|
{
|
|
|
|
|
Misc::FrameRateLimiter frameRateLimiter
|
|
|
|
|
= Misc::makeFrameRateLimiter(MWBase::Environment::get().getFrameRateLimit());
|
|
|
|
|
while (mRunning)
|
|
|
|
|
{
|
|
|
|
|
// If finished playing, start again
|
|
|
|
|
if (!mVideo->update())
|
|
|
|
|
mVideo->playVideo("video\\menu_background.bik");
|
|
|
|
|
frameRateLimiter.limit();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MenuVideo::MenuVideo(const VFS::Manager* vfs)
|
|
|
|
|
: mRunning(true)
|
|
|
|
|
{
|
|
|
|
|
// Use black background to correct aspect ratio
|
|
|
|
|
mVideoBackground = MyGUI::Gui::getInstance().createWidgetReal<MyGUI::ImageBox>(
|
|
|
|
|
"ImageBox", 0, 0, 1, 1, MyGUI::Align::Default, "MainMenuBackground");
|
|
|
|
|
mVideoBackground->setImageTexture("black");
|
|
|
|
|
|
|
|
|
|
mVideo = mVideoBackground->createWidget<VideoWidget>(
|
|
|
|
|
"ImageBox", 0, 0, 1, 1, MyGUI::Align::Stretch, "MainMenuBackground");
|
|
|
|
|
mVideo->setVFS(vfs);
|
|
|
|
|
|
|
|
|
|
mVideo->playVideo("video\\menu_background.bik");
|
|
|
|
|
mThread = std::thread([this] { run(); });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MenuVideo::resize(int screenWidth, int screenHeight)
|
|
|
|
|
{
|
|
|
|
|
const bool stretch = Settings::gui().mStretchMenuBackground;
|
|
|
|
|
mVideoBackground->setSize(screenWidth, screenHeight);
|
|
|
|
|
mVideo->autoResize(stretch);
|
|
|
|
|
mVideo->setVisible(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MenuVideo::~MenuVideo()
|
|
|
|
|
{
|
|
|
|
|
mRunning = false;
|
|
|
|
|
mThread.join();
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
MyGUI::Gui::getInstance().destroyWidget(mVideoBackground);
|
|
|
|
|
}
|
|
|
|
|
catch (const MyGUI::Exception& e)
|
|
|
|
|
{
|
|
|
|
|
Log(Debug::Error) << "Error in the destructor: " << e.what();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MainMenu::MainMenu(int w, int h, const VFS::Manager* vfs, const std::string& versionDescription)
|
|
|
|
|
: WindowBase("openmw_mainmenu.layout")
|
|
|
|
@ -32,8 +83,6 @@ namespace MWGui
|
|
|
|
|
, mVFS(vfs)
|
|
|
|
|
, mButtonBox(nullptr)
|
|
|
|
|
, mBackground(nullptr)
|
|
|
|
|
, mVideoBackground(nullptr)
|
|
|
|
|
, mVideo(nullptr)
|
|
|
|
|
{
|
|
|
|
|
getWidget(mVersionText, "VersionText");
|
|
|
|
|
mVersionText->setCaption(versionDescription);
|
|
|
|
@ -51,6 +100,8 @@ namespace MWGui
|
|
|
|
|
mHeight = h;
|
|
|
|
|
|
|
|
|
|
updateMenu();
|
|
|
|
|
if (mVideo)
|
|
|
|
|
mVideo->resize(w, h);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainMenu::setVisible(bool visible)
|
|
|
|
@ -146,9 +197,7 @@ namespace MWGui
|
|
|
|
|
{
|
|
|
|
|
if (mVideo && !show)
|
|
|
|
|
{
|
|
|
|
|
MyGUI::Gui::getInstance().destroyWidget(mVideoBackground);
|
|
|
|
|
mVideoBackground = nullptr;
|
|
|
|
|
mVideo = nullptr;
|
|
|
|
|
mVideo.reset();
|
|
|
|
|
}
|
|
|
|
|
if (mBackground && !show)
|
|
|
|
|
{
|
|
|
|
@ -164,27 +213,12 @@ namespace MWGui
|
|
|
|
|
if (mHasAnimatedMenu)
|
|
|
|
|
{
|
|
|
|
|
if (!mVideo)
|
|
|
|
|
{
|
|
|
|
|
// Use black background to correct aspect ratio
|
|
|
|
|
mVideoBackground = MyGUI::Gui::getInstance().createWidgetReal<MyGUI::ImageBox>(
|
|
|
|
|
"ImageBox", 0, 0, 1, 1, MyGUI::Align::Default, "MainMenuBackground");
|
|
|
|
|
mVideoBackground->setImageTexture("black");
|
|
|
|
|
|
|
|
|
|
mVideo = mVideoBackground->createWidget<VideoWidget>(
|
|
|
|
|
"ImageBox", 0, 0, 1, 1, MyGUI::Align::Stretch, "MainMenuBackground");
|
|
|
|
|
mVideo->setVFS(mVFS);
|
|
|
|
|
mVideo.emplace(mVFS);
|
|
|
|
|
|
|
|
|
|
mVideo->playVideo("video\\menu_background.bik");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MyGUI::IntSize viewSize = MyGUI::RenderManager::getInstance().getViewSize();
|
|
|
|
|
const auto& viewSize = MyGUI::RenderManager::getInstance().getViewSize();
|
|
|
|
|
int screenWidth = viewSize.width;
|
|
|
|
|
int screenHeight = viewSize.height;
|
|
|
|
|
mVideoBackground->setSize(screenWidth, screenHeight);
|
|
|
|
|
|
|
|
|
|
mVideo->autoResize(stretch);
|
|
|
|
|
|
|
|
|
|
mVideo->setVisible(true);
|
|
|
|
|
mVideo->resize(screenWidth, screenHeight);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
@ -198,18 +232,6 @@ namespace MWGui
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainMenu::onFrame(float dt)
|
|
|
|
|
{
|
|
|
|
|
if (mVideo)
|
|
|
|
|
{
|
|
|
|
|
if (!mVideo->update())
|
|
|
|
|
{
|
|
|
|
|
// If finished playing, start again
|
|
|
|
|
mVideo->playVideo("video\\menu_background.bik");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool MainMenu::exit()
|
|
|
|
|
{
|
|
|
|
|
if (MWBase::Environment::get().getWindowManager()->isSettingsWindowVisible())
|
|
|
|
|