forked from teamnwah/openmw-tes3coop
Add option to stretch menu backgrounds/cutscenes to the whole screen
This commit is contained in:
parent
6c08e05fc3
commit
9bcc84ceec
8 changed files with 43 additions and 27 deletions
|
@ -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");
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<double>(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<BackgroundImage>("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);
|
||||
}
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
#include <extern/ogre-ffmpeg-videoplayer/videoplayer.hpp>
|
||||
|
||||
#include <MyGUI_RenderManager.h>
|
||||
|
||||
#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<double>(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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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<Video::VideoPlayer> mPlayer;
|
||||
};
|
||||
|
|
|
@ -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<double>(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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue