diff --git a/apps/openmw/mwgui/backgroundimage.cpp b/apps/openmw/mwgui/backgroundimage.cpp index 1e87c0ff1..9c07c5780 100644 --- a/apps/openmw/mwgui/backgroundimage.cpp +++ b/apps/openmw/mwgui/backgroundimage.cpp @@ -5,14 +5,14 @@ namespace MWGui { -void BackgroundImage::setBackgroundImage (const std::string& image, bool fixedRatio, bool correct) +void BackgroundImage::setBackgroundImage (const std::string& image, bool fixedRatio, bool stretch) { if (mChild) { MyGUI::Gui::getInstance().destroyWidget(mChild); mChild = NULL; } - if (correct) + if (!stretch) { setImageTexture("black.png"); diff --git a/apps/openmw/mwgui/backgroundimage.hpp b/apps/openmw/mwgui/backgroundimage.hpp index 3d1a61eaf..8c963b762 100644 --- a/apps/openmw/mwgui/backgroundimage.hpp +++ b/apps/openmw/mwgui/backgroundimage.hpp @@ -18,9 +18,9 @@ namespace MWGui /** * @param fixedRatio Use a fixed ratio of 4:3, regardless of the image dimensions - * @param correct Add black bars? + * @param stretch Stretch to fill the whole screen, or add black bars? */ - void setBackgroundImage (const std::string& image, bool fixedRatio=true, bool correct=true); + void setBackgroundImage (const std::string& image, bool fixedRatio=true, bool stretch=true); virtual void setSize (const MyGUI::IntSize &_value); virtual void setCoord (const MyGUI::IntCoord &_value); diff --git a/apps/openmw/mwgui/loadingscreen.cpp b/apps/openmw/mwgui/loadingscreen.cpp index d10a295c1..270066c97 100644 --- a/apps/openmw/mwgui/loadingscreen.cpp +++ b/apps/openmw/mwgui/loadingscreen.cpp @@ -149,7 +149,9 @@ namespace MWGui Ogre::TextureManager::getSingleton ().load (randomSplash, Ogre::ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME); // TODO: add option (filename pattern?) to use image aspect ratio instead of 4:3 - mBackgroundImage->setBackgroundImage(randomSplash, true, true); + // we can't do this by default, because the Morrowind splash screens are 1024x1024, but should be displayed as 4:3 + bool stretch = Settings::Manager::getBool("stretch menu background", "GUI"); + mBackgroundImage->setBackgroundImage(randomSplash, true, stretch); } else std::cerr << "No loading screens found!" << std::endl; diff --git a/apps/openmw/mwgui/mainmenu.cpp b/apps/openmw/mwgui/mainmenu.cpp index c7855b367..f1c4c4088 100644 --- a/apps/openmw/mwgui/mainmenu.cpp +++ b/apps/openmw/mwgui/mainmenu.cpp @@ -160,6 +160,8 @@ namespace MWGui if (!show) return; + bool stretch = Settings::Manager::getBool("stretch menu background", "GUI"); + if (mHasAnimatedMenu) { if (!mVideo) @@ -180,16 +182,7 @@ namespace MWGui int screenHeight = viewSize.height; mVideoBackground->setSize(screenWidth, screenHeight); - if (mVideo->getVideoHeight() > 0) - { - double imageaspect = static_cast(mVideo->getVideoWidth())/mVideo->getVideoHeight(); - - int leftPadding = std::max(0.0, (screenWidth - screenHeight * imageaspect) / 2); - int topPadding = std::max(0.0, (screenHeight - screenWidth / imageaspect) / 2); - - mVideo->setCoord(leftPadding, topPadding, - screenWidth - leftPadding*2, screenHeight - topPadding*2); - } + mVideo->autoResize(stretch); mVideo->setVisible(true); } @@ -199,7 +192,7 @@ namespace MWGui { mBackground = MyGUI::Gui::getInstance().createWidgetReal("ImageBox", 0,0,1,1, MyGUI::Align::Stretch, "Menu"); - mBackground->setBackgroundImage("textures\\menu_morrowind.dds"); + mBackground->setBackgroundImage("textures\\menu_morrowind.dds", true, stretch); } mBackground->setVisible(true); } diff --git a/apps/openmw/mwgui/videowidget.cpp b/apps/openmw/mwgui/videowidget.cpp index 2ade0f4c5..046070841 100644 --- a/apps/openmw/mwgui/videowidget.cpp +++ b/apps/openmw/mwgui/videowidget.cpp @@ -2,6 +2,8 @@ #include +#include + #include "../mwsound/movieaudiofactory.hpp" namespace MWGui @@ -46,4 +48,24 @@ bool VideoWidget::hasAudioStream() return mPlayer->hasAudioStream(); } +void VideoWidget::autoResize(bool stretch) +{ + MyGUI::IntSize screenSize = MyGUI::RenderManager::getInstance().getViewSize(); + if (getParent()) + screenSize = getParent()->getSize(); + + if (getVideoHeight() > 0 && !stretch) + { + double imageaspect = static_cast(getVideoWidth())/getVideoHeight(); + + int leftPadding = std::max(0.0, (screenSize.width - screenSize.height * imageaspect) / 2); + int topPadding = std::max(0.0, (screenSize.height - screenSize.width / imageaspect) / 2); + + setCoord(leftPadding, topPadding, + screenSize.width - leftPadding*2, screenSize.height - topPadding*2); + } + else + setCoord(0,0,screenSize.width,screenSize.height); +} + } diff --git a/apps/openmw/mwgui/videowidget.hpp b/apps/openmw/mwgui/videowidget.hpp index e350573c4..ee44328eb 100644 --- a/apps/openmw/mwgui/videowidget.hpp +++ b/apps/openmw/mwgui/videowidget.hpp @@ -35,6 +35,12 @@ namespace MWGui /// Stop video and free resources (done automatically on destruction) void stop(); + /// Adjust the coordinates of this video widget relative to its parent, + /// based on the dimensions of the playing video. + /// @param stretch Stretch the video to fill the whole screen? If false, + /// black bars may be added to fix the aspect ratio. + void autoResize (bool stretch); + private: std::auto_ptr mPlayer; }; diff --git a/apps/openmw/mwgui/windowmanagerimp.cpp b/apps/openmw/mwgui/windowmanagerimp.cpp index e976b984f..cf4679287 100644 --- a/apps/openmw/mwgui/windowmanagerimp.cpp +++ b/apps/openmw/mwgui/windowmanagerimp.cpp @@ -1712,18 +1712,9 @@ namespace MWGui void WindowManager::sizeVideo(int screenWidth, int screenHeight) { // Use black bars to correct aspect ratio + bool stretch = Settings::Manager::getBool("stretch menu background", "GUI"); mVideoBackground->setSize(screenWidth, screenHeight); - - if (mVideoWidget->getVideoHeight() > 0) - { - double imageaspect = static_cast(mVideoWidget->getVideoWidth())/mVideoWidget->getVideoHeight(); - - int leftPadding = std::max(0.0, (screenWidth - screenHeight * imageaspect) / 2); - int topPadding = std::max(0.0, (screenHeight - screenWidth / imageaspect) / 2); - - mVideoWidget->setCoord(leftPadding, topPadding, - screenWidth - leftPadding*2, screenHeight - topPadding*2); - } + mVideoWidget->autoResize(stretch); } WindowModal* WindowManager::getCurrentModal() const diff --git a/files/settings-default.cfg b/files/settings-default.cfg index f91299a1f..064c34d9c 100644 --- a/files/settings-default.cfg +++ b/files/settings-default.cfg @@ -45,6 +45,8 @@ subtitles = false hit fader = true werewolf overlay = true +stretch menu background = false + [General] # Camera field of view field of view = 55