mirror of
https://github.com/OpenMW/openmw.git
synced 2025-04-12 09:36:43 +00:00
parent
a6788cfb0e
commit
3b3b53d665
4 changed files with 75 additions and 7 deletions
|
@ -137,6 +137,7 @@ bool OMW::Engine::frameRenderingQueued (const Ogre::FrameEvent& evt)
|
||||||
}
|
}
|
||||||
|
|
||||||
// update GUI
|
// update GUI
|
||||||
|
MWBase::Environment::get().getWindowManager()->onFrame(frametime);
|
||||||
if (MWBase::Environment::get().getStateManager()->getState()!=
|
if (MWBase::Environment::get().getStateManager()->getState()!=
|
||||||
MWBase::StateManager::State_NoGame)
|
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().getWorld()->getTriangleBatchCount(tri, batch);
|
||||||
MWBase::Environment::get().getWindowManager()->wmUpdateFps(window->getLastFPS(), tri, batch);
|
MWBase::Environment::get().getWindowManager()->wmUpdateFps(window->getLastFPS(), tri, batch);
|
||||||
|
|
||||||
MWBase::Environment::get().getWindowManager()->onFrame(frametime);
|
|
||||||
MWBase::Environment::get().getWindowManager()->update();
|
MWBase::Environment::get().getWindowManager()->update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
#include "mainmenu.hpp"
|
#include "mainmenu.hpp"
|
||||||
|
|
||||||
|
#include <OgreResourceGroupManager.h>
|
||||||
|
|
||||||
#include <components/version/version.hpp>
|
#include <components/version/version.hpp>
|
||||||
|
|
||||||
#include "../mwbase/environment.hpp"
|
#include "../mwbase/environment.hpp"
|
||||||
|
@ -16,6 +18,7 @@
|
||||||
#include "confirmationdialog.hpp"
|
#include "confirmationdialog.hpp"
|
||||||
#include "imagebutton.hpp"
|
#include "imagebutton.hpp"
|
||||||
#include "backgroundimage.hpp"
|
#include "backgroundimage.hpp"
|
||||||
|
#include "videowidget.hpp"
|
||||||
|
|
||||||
namespace MWGui
|
namespace MWGui
|
||||||
{
|
{
|
||||||
|
@ -25,6 +28,7 @@ namespace MWGui
|
||||||
, mButtonBox(0), mWidth (w), mHeight (h)
|
, mButtonBox(0), mWidth (w), mHeight (h)
|
||||||
, mSaveGameDialog(NULL)
|
, mSaveGameDialog(NULL)
|
||||||
, mBackground(NULL)
|
, mBackground(NULL)
|
||||||
|
, mVideo(NULL)
|
||||||
{
|
{
|
||||||
getWidget(mVersionText, "VersionText");
|
getWidget(mVersionText, "VersionText");
|
||||||
std::stringstream sstream;
|
std::stringstream sstream;
|
||||||
|
@ -42,6 +46,8 @@ namespace MWGui
|
||||||
std::string output = sstream.str();
|
std::string output = sstream.str();
|
||||||
mVersionText->setCaption(output);
|
mVersionText->setCaption(output);
|
||||||
|
|
||||||
|
mHasAnimatedMenu = (Ogre::ResourceGroupManager::getSingleton().resourceExistsInAnyGroup("video\\menu_background.bik"));
|
||||||
|
|
||||||
updateMenu();
|
updateMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,14 +140,66 @@ namespace MWGui
|
||||||
|
|
||||||
void MainMenu::showBackground(bool show)
|
void MainMenu::showBackground(bool show)
|
||||||
{
|
{
|
||||||
if (show && !mBackground)
|
if (mVideo && !show)
|
||||||
|
{
|
||||||
|
MyGUI::Gui::getInstance().destroyWidget(mVideo);
|
||||||
|
mVideo = NULL;
|
||||||
|
}
|
||||||
|
if (mBackground && !show)
|
||||||
|
{
|
||||||
|
MyGUI::Gui::getInstance().destroyWidget(mBackground);
|
||||||
|
mBackground = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
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,
|
mBackground = MyGUI::Gui::getInstance().createWidgetReal<BackgroundImage>("ImageBox", 0,0,1,1,
|
||||||
MyGUI::Align::Stretch, "Menu");
|
MyGUI::Align::Stretch, "Menu");
|
||||||
mBackground->setBackgroundImage("textures\\menu_morrowind.dds");
|
mBackground->setBackgroundImage("textures\\menu_morrowind.dds");
|
||||||
}
|
}
|
||||||
if (mBackground)
|
mBackground->setVisible(true);
|
||||||
mBackground->setVisible(show);
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainMenu::update(float dt)
|
||||||
|
{
|
||||||
|
if (mVideo)
|
||||||
|
mVideo->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainMenu::updateMenu()
|
void MainMenu::updateMenu()
|
||||||
|
|
|
@ -9,12 +9,15 @@ namespace MWGui
|
||||||
class ImageButton;
|
class ImageButton;
|
||||||
class BackgroundImage;
|
class BackgroundImage;
|
||||||
class SaveGameDialog;
|
class SaveGameDialog;
|
||||||
|
class VideoWidget;
|
||||||
|
|
||||||
class MainMenu : public OEngine::GUI::Layout
|
class MainMenu : public OEngine::GUI::Layout
|
||||||
{
|
{
|
||||||
int mWidth;
|
int mWidth;
|
||||||
int mHeight;
|
int mHeight;
|
||||||
|
|
||||||
|
bool mHasAnimatedMenu;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
MainMenu(int w, int h);
|
MainMenu(int w, int h);
|
||||||
|
@ -24,6 +27,8 @@ namespace MWGui
|
||||||
|
|
||||||
virtual void setVisible (bool visible);
|
virtual void setVisible (bool visible);
|
||||||
|
|
||||||
|
void update(float dt);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
MyGUI::Widget* mButtonBox;
|
MyGUI::Widget* mButtonBox;
|
||||||
|
@ -31,6 +36,9 @@ namespace MWGui
|
||||||
|
|
||||||
BackgroundImage* mBackground;
|
BackgroundImage* mBackground;
|
||||||
|
|
||||||
|
MyGUI::ImageBox* mVideoBackground;
|
||||||
|
VideoWidget* mVideo; // For animated main menus
|
||||||
|
|
||||||
std::map<std::string, MWGui::ImageButton*> mButtons;
|
std::map<std::string, MWGui::ImageButton*> mButtons;
|
||||||
|
|
||||||
void onButtonClicked (MyGUI::Widget* sender);
|
void onButtonClicked (MyGUI::Widget* sender);
|
||||||
|
|
|
@ -713,6 +713,8 @@ namespace MWGui
|
||||||
|
|
||||||
mToolTips->onFrame(frameDuration);
|
mToolTips->onFrame(frameDuration);
|
||||||
|
|
||||||
|
mMenu->update(frameDuration);
|
||||||
|
|
||||||
if (MWBase::Environment::get().getStateManager()->getState()==
|
if (MWBase::Environment::get().getStateManager()->getState()==
|
||||||
MWBase::StateManager::State_NoGame)
|
MWBase::StateManager::State_NoGame)
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in a new issue