Support animated main menus (menu_background.bik)

Closes #1362
deque
scrawl 11 years ago
parent a6788cfb0e
commit 3b3b53d665

@ -137,6 +137,7 @@ bool OMW::Engine::frameRenderingQueued (const Ogre::FrameEvent& evt)
}
// update GUI
MWBase::Environment::get().getWindowManager()->onFrame(frametime);
if (MWBase::Environment::get().getStateManager()->getState()!=
MWBase::StateManager::State_NoGame)
{
@ -145,7 +146,6 @@ bool OMW::Engine::frameRenderingQueued (const Ogre::FrameEvent& evt)
MWBase::Environment::get().getWorld()->getTriangleBatchCount(tri, batch);
MWBase::Environment::get().getWindowManager()->wmUpdateFps(window->getLastFPS(), tri, batch);
MWBase::Environment::get().getWindowManager()->onFrame(frametime);
MWBase::Environment::get().getWindowManager()->update();
}
}

@ -1,5 +1,7 @@
#include "mainmenu.hpp"
#include <OgreResourceGroupManager.h>
#include <components/version/version.hpp>
#include "../mwbase/environment.hpp"
@ -16,6 +18,7 @@
#include "confirmationdialog.hpp"
#include "imagebutton.hpp"
#include "backgroundimage.hpp"
#include "videowidget.hpp"
namespace MWGui
{
@ -25,6 +28,7 @@ namespace MWGui
, mButtonBox(0), mWidth (w), mHeight (h)
, mSaveGameDialog(NULL)
, mBackground(NULL)
, mVideo(NULL)
{
getWidget(mVersionText, "VersionText");
std::stringstream sstream;
@ -42,6 +46,8 @@ namespace MWGui
std::string output = sstream.str();
mVersionText->setCaption(output);
mHasAnimatedMenu = (Ogre::ResourceGroupManager::getSingleton().resourceExistsInAnyGroup("video\\menu_background.bik"));
updateMenu();
}
@ -134,14 +140,66 @@ namespace MWGui
void MainMenu::showBackground(bool show)
{
if (show && !mBackground)
if (mVideo && !show)
{
MyGUI::Gui::getInstance().destroyWidget(mVideo);
mVideo = NULL;
}
if (mBackground && !show)
{
mBackground = MyGUI::Gui::getInstance().createWidgetReal<BackgroundImage>("ImageBox", 0,0,1,1,
MyGUI::Align::Stretch, "Menu");
mBackground->setBackgroundImage("textures\\menu_morrowind.dds");
MyGUI::Gui::getInstance().destroyWidget(mBackground);
mBackground = NULL;
}
if (mBackground)
mBackground->setVisible(show);
if (!show)
return;
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, "Menu");
mVideoBackground->setImageTexture("black.png");
mVideo = mVideoBackground->createWidget<VideoWidget>("ImageBox", 0,0,1,1,
MyGUI::Align::Stretch, "Menu");
mVideo->playVideo("video\\menu_background.bik", false);
}
MyGUI::IntSize viewSize = MyGUI::RenderManager::getInstance().getViewSize();
int screenWidth = viewSize.width;
int screenHeight = viewSize.height;
mVideoBackground->setSize(screenWidth, screenHeight);
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->setVisible(true);
}
else
{
if (!mBackground)
{
mBackground = MyGUI::Gui::getInstance().createWidgetReal<BackgroundImage>("ImageBox", 0,0,1,1,
MyGUI::Align::Stretch, "Menu");
mBackground->setBackgroundImage("textures\\menu_morrowind.dds");
}
mBackground->setVisible(true);
}
}
void MainMenu::update(float dt)
{
if (mVideo)
mVideo->update();
}
void MainMenu::updateMenu()

@ -9,12 +9,15 @@ namespace MWGui
class ImageButton;
class BackgroundImage;
class SaveGameDialog;
class VideoWidget;
class MainMenu : public OEngine::GUI::Layout
{
int mWidth;
int mHeight;
bool mHasAnimatedMenu;
public:
MainMenu(int w, int h);
@ -24,6 +27,8 @@ namespace MWGui
virtual void setVisible (bool visible);
void update(float dt);
private:
MyGUI::Widget* mButtonBox;
@ -31,6 +36,9 @@ namespace MWGui
BackgroundImage* mBackground;
MyGUI::ImageBox* mVideoBackground;
VideoWidget* mVideo; // For animated main menus
std::map<std::string, MWGui::ImageButton*> mButtons;
void onButtonClicked (MyGUI::Widget* sender);

@ -713,6 +713,8 @@ namespace MWGui
mToolTips->onFrame(frameDuration);
mMenu->update(frameDuration);
if (MWBase::Environment::get().getStateManager()->getState()==
MWBase::StateManager::State_NoGame)
return;

Loading…
Cancel
Save