forked from teamnwah/openmw-tes3coop
Add proper main menu (background image, logo animation, title music)
This commit is contained in:
parent
27956f3624
commit
2e4ef93b28
5 changed files with 91 additions and 9 deletions
|
@ -33,7 +33,7 @@ add_openmw_dir (mwgui
|
||||||
merchantrepair repair soulgemdialog companionwindow bookpage journalviewmodel journalbooks
|
merchantrepair repair soulgemdialog companionwindow bookpage journalviewmodel journalbooks
|
||||||
keywordsearch itemmodel containeritemmodel inventoryitemmodel sortfilteritemmodel itemview
|
keywordsearch itemmodel containeritemmodel inventoryitemmodel sortfilteritemmodel itemview
|
||||||
tradeitemmodel companionitemmodel pickpocketitemmodel fontloader controllers savegamedialog
|
tradeitemmodel companionitemmodel pickpocketitemmodel fontloader controllers savegamedialog
|
||||||
recharge
|
recharge mode
|
||||||
)
|
)
|
||||||
|
|
||||||
add_openmw_dir (mwdialogue
|
add_openmw_dir (mwdialogue
|
||||||
|
|
|
@ -339,6 +339,9 @@ void OMW::Engine::prepareEngine (Settings::Manager & settings)
|
||||||
std::string aa = settings.getString("antialiasing", "Video");
|
std::string aa = settings.getString("antialiasing", "Video");
|
||||||
windowSettings.fsaa = (aa.substr(0, 4) == "MSAA") ? aa.substr(5, aa.size()-5) : "0";
|
windowSettings.fsaa = (aa.substr(0, 4) == "MSAA") ? aa.substr(5, aa.size()-5) : "0";
|
||||||
|
|
||||||
|
SDL_SetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS,
|
||||||
|
settings.getBool("minimize on focus loss", "Video") ? "1" : "0");
|
||||||
|
|
||||||
mOgre->createWindow("OpenMW", windowSettings);
|
mOgre->createWindow("OpenMW", windowSettings);
|
||||||
|
|
||||||
Bsa::registerResources (mFileCollections, mArchives, true, mFSStrict);
|
Bsa::registerResources (mFileCollections, mArchives, true, mFSStrict);
|
||||||
|
@ -356,6 +359,18 @@ void OMW::Engine::prepareEngine (Settings::Manager & settings)
|
||||||
mCfgMgr.getCachePath ().string(), mScriptConsoleMode, mTranslationDataStorage, mEncoding);
|
mCfgMgr.getCachePath ().string(), mScriptConsoleMode, mTranslationDataStorage, mEncoding);
|
||||||
mEnvironment.setWindowManager (window);
|
mEnvironment.setWindowManager (window);
|
||||||
|
|
||||||
|
// Create sound system
|
||||||
|
mEnvironment.setSoundManager (new MWSound::SoundManager(mUseSound));
|
||||||
|
|
||||||
|
// TODO: play pre-load intro videos. Need to find a way to have them receive input.
|
||||||
|
// Make videoplayer a MyGUI widget?
|
||||||
|
/*
|
||||||
|
{
|
||||||
|
MWRender::VideoPlayer player(mOgre->getScene(), mOgre->getWindow());
|
||||||
|
player.playVideo("mw_logo.bik", 1);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
// Create the world
|
// Create the world
|
||||||
mEnvironment.setWorld( new MWWorld::World (*mOgre, mFileCollections, mContentFiles,
|
mEnvironment.setWorld( new MWWorld::World (*mOgre, mFileCollections, mContentFiles,
|
||||||
mResDir, mCfgMgr.getCachePath(), mEncoder, mFallbackMap,
|
mResDir, mCfgMgr.getCachePath(), mEncoder, mFallbackMap,
|
||||||
|
@ -373,9 +388,6 @@ void OMW::Engine::prepareEngine (Settings::Manager & settings)
|
||||||
|
|
||||||
Compiler::registerExtensions (mExtensions);
|
Compiler::registerExtensions (mExtensions);
|
||||||
|
|
||||||
// Create sound system
|
|
||||||
mEnvironment.setSoundManager (new MWSound::SoundManager(mUseSound));
|
|
||||||
|
|
||||||
// Create script system
|
// Create script system
|
||||||
mScriptContext = new MWScript::CompilerContext (MWScript::CompilerContext::Type_Full);
|
mScriptContext = new MWScript::CompilerContext (MWScript::CompilerContext::Type_Full);
|
||||||
mScriptContext->setExtensions (&mExtensions);
|
mScriptContext->setExtensions (&mExtensions);
|
||||||
|
@ -434,7 +446,20 @@ void OMW::Engine::go()
|
||||||
|
|
||||||
// start in main menu
|
// start in main menu
|
||||||
if (!mSkipMenu)
|
if (!mSkipMenu)
|
||||||
|
{
|
||||||
MWBase::Environment::get().getWindowManager()->pushGuiMode (MWGui::GM_MainMenu);
|
MWBase::Environment::get().getWindowManager()->pushGuiMode (MWGui::GM_MainMenu);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// Is there an ini setting for this filename or something?
|
||||||
|
MWBase::Environment::get().getSoundManager()->streamMusic("Special/morrowind title.mp3");
|
||||||
|
|
||||||
|
// TODO: there are other intro videos, too. They need to be imported from Morrowind.ini.
|
||||||
|
// Unfortunately those must play BEFORE any loading is done, which will currently not work.
|
||||||
|
// The videoplayer is created by World, so all content files must be loaded first...
|
||||||
|
MWBase::Environment::get().getWorld()->playVideo("mw_logo.bik", true);
|
||||||
|
}
|
||||||
|
catch (...) {}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
MWBase::Environment::get().getStateManager()->newGame (true);
|
MWBase::Environment::get().getStateManager()->newGame (true);
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@ namespace MWGui
|
||||||
: OEngine::GUI::Layout("openmw_mainmenu.layout")
|
: OEngine::GUI::Layout("openmw_mainmenu.layout")
|
||||||
, mButtonBox(0), mWidth (w), mHeight (h)
|
, mButtonBox(0), mWidth (w), mHeight (h)
|
||||||
, mSaveGameDialog(NULL)
|
, mSaveGameDialog(NULL)
|
||||||
|
, mBackground(NULL)
|
||||||
{
|
{
|
||||||
getWidget(mVersionText, "VersionText");
|
getWidget(mVersionText, "VersionText");
|
||||||
std::stringstream sstream;
|
std::stringstream sstream;
|
||||||
|
@ -59,6 +60,10 @@ namespace MWGui
|
||||||
{
|
{
|
||||||
if (visible)
|
if (visible)
|
||||||
updateMenu();
|
updateMenu();
|
||||||
|
else
|
||||||
|
showBackground(
|
||||||
|
MWBase::Environment::get().getWindowManager()->containsMode(MWGui::GM_MainMenu) &&
|
||||||
|
MWBase::Environment::get().getStateManager()->getState() == MWBase::StateManager::State_NoGame);
|
||||||
|
|
||||||
OEngine::GUI::Layout::setVisible (visible);
|
OEngine::GUI::Layout::setVisible (visible);
|
||||||
}
|
}
|
||||||
|
@ -125,11 +130,42 @@ namespace MWGui
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainMenu::showBackground(bool show)
|
||||||
|
{
|
||||||
|
if (mBackground)
|
||||||
|
{
|
||||||
|
MyGUI::Gui::getInstance().destroyWidget(mBackground);
|
||||||
|
mBackground = NULL;
|
||||||
|
}
|
||||||
|
if (show)
|
||||||
|
{
|
||||||
|
if (!mBackground)
|
||||||
|
{
|
||||||
|
mBackground = MyGUI::Gui::getInstance().createWidgetReal<MyGUI::ImageBox>("ImageBox", 0,0,1,1,
|
||||||
|
MyGUI::Align::Stretch, "Menu");
|
||||||
|
mBackground->setImageTexture("black.png");
|
||||||
|
|
||||||
|
// Use black bars to correct aspect ratio. The video player also does it, so we need to do it
|
||||||
|
// for mw_logo.bik to align correctly with menu_morrowind.dds.
|
||||||
|
MyGUI::IntSize screenSize = MyGUI::RenderManager::getInstance().getViewSize();
|
||||||
|
|
||||||
|
// No way to un-hardcode this right now, menu_morrowind.dds is 1024x512 but was designed for 4:3
|
||||||
|
double imageaspect = 4.0/3.0;
|
||||||
|
|
||||||
|
int leftPadding = std::max(0.0, (screenSize.width - screenSize.height * imageaspect) / 2);
|
||||||
|
int topPadding = std::max(0.0, (screenSize.height - screenSize.width / imageaspect) / 2);
|
||||||
|
|
||||||
|
MyGUI::ImageBox* image = mBackground->createWidget<MyGUI::ImageBox>("ImageBox",
|
||||||
|
leftPadding, topPadding, screenSize.width - leftPadding*2, screenSize.height - topPadding*2, MyGUI::Align::Default);
|
||||||
|
image->setImageTexture("textures\\menu_morrowind.dds");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void MainMenu::updateMenu()
|
void MainMenu::updateMenu()
|
||||||
{
|
{
|
||||||
setCoord(0,0, mWidth, mHeight);
|
setCoord(0,0, mWidth, mHeight);
|
||||||
|
|
||||||
|
|
||||||
if (!mButtonBox)
|
if (!mButtonBox)
|
||||||
mButtonBox = mMainWidget->createWidget<MyGUI::Widget>("", MyGUI::IntCoord(0, 0, 0, 0), MyGUI::Align::Default);
|
mButtonBox = mMainWidget->createWidget<MyGUI::Widget>("", MyGUI::IntCoord(0, 0, 0, 0), MyGUI::Align::Default);
|
||||||
|
|
||||||
|
@ -137,6 +173,8 @@ namespace MWGui
|
||||||
|
|
||||||
MWBase::StateManager::State state = MWBase::Environment::get().getStateManager()->getState();
|
MWBase::StateManager::State state = MWBase::Environment::get().getStateManager()->getState();
|
||||||
|
|
||||||
|
showBackground(state == MWBase::StateManager::State_NoGame);
|
||||||
|
|
||||||
std::vector<std::string> buttons;
|
std::vector<std::string> buttons;
|
||||||
|
|
||||||
if (state==MWBase::StateManager::State_Running)
|
if (state==MWBase::StateManager::State_Running)
|
||||||
|
@ -191,12 +229,27 @@ namespace MWGui
|
||||||
assert(mButtons.find(*it) != mButtons.end());
|
assert(mButtons.find(*it) != mButtons.end());
|
||||||
MWGui::ImageButton* button = mButtons[*it];
|
MWGui::ImageButton* button = mButtons[*it];
|
||||||
button->setVisible(true);
|
button->setVisible(true);
|
||||||
|
|
||||||
MyGUI::IntSize requested = button->getRequestedSize();
|
MyGUI::IntSize requested = button->getRequestedSize();
|
||||||
button->setCoord((maxwidth-requested.width) / 2, curH, requested.width, requested.height);
|
|
||||||
curH += requested.height;
|
// Trim off some of the excessive padding
|
||||||
|
// TODO: perhaps do this within ImageButton?
|
||||||
|
int trim = 8;
|
||||||
|
button->setImageCoord(MyGUI::IntCoord(0, trim, requested.width, requested.height-trim));
|
||||||
|
int height = requested.height-trim*2;
|
||||||
|
button->setImageTile(MyGUI::IntSize(requested.width, height));
|
||||||
|
button->setCoord((maxwidth-requested.width) / 2, curH, requested.width, height);
|
||||||
|
curH += height;
|
||||||
}
|
}
|
||||||
|
|
||||||
mButtonBox->setCoord (mWidth/2 - maxwidth/2, mHeight/2 - curH/2, maxwidth, curH);
|
if (state == MWBase::StateManager::State_NoGame)
|
||||||
|
{
|
||||||
|
// Align with the background image
|
||||||
|
int bottomPadding=48;
|
||||||
|
mButtonBox->setCoord (mWidth/2 - maxwidth/2, mHeight - curH - bottomPadding, maxwidth, curH);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
mButtonBox->setCoord (mWidth/2 - maxwidth/2, mHeight/2 - curH/2, maxwidth, curH);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,12 +29,16 @@ namespace MWGui
|
||||||
MyGUI::Widget* mButtonBox;
|
MyGUI::Widget* mButtonBox;
|
||||||
MyGUI::TextBox* mVersionText;
|
MyGUI::TextBox* mVersionText;
|
||||||
|
|
||||||
|
MyGUI::ImageBox* mBackground;
|
||||||
|
|
||||||
std::map<std::string, MWGui::ImageButton*> mButtons;
|
std::map<std::string, MWGui::ImageButton*> mButtons;
|
||||||
|
|
||||||
void onButtonClicked (MyGUI::Widget* sender);
|
void onButtonClicked (MyGUI::Widget* sender);
|
||||||
void onNewGameConfirmed();
|
void onNewGameConfirmed();
|
||||||
void onExitConfirmed();
|
void onExitConfirmed();
|
||||||
|
|
||||||
|
void showBackground(bool show);
|
||||||
|
|
||||||
void updateMenu();
|
void updateMenu();
|
||||||
|
|
||||||
SaveGameDialog* mSaveGameDialog;
|
SaveGameDialog* mSaveGameDialog;
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
<MyGUI type="Layer">
|
<MyGUI type="Layer">
|
||||||
<Layer name="Scene" overlapped="false" peek="true"/>
|
|
||||||
<Layer name="HUD" overlapped="false" peek="true"/>
|
<Layer name="HUD" overlapped="false" peek="true"/>
|
||||||
|
<Layer name="Menu" overlapped="false" peek="false"/>
|
||||||
<Layer name="Windows" overlapped="true" peek="true"/>
|
<Layer name="Windows" overlapped="true" peek="true"/>
|
||||||
<Layer name="Console" overlapped="false" peek="true"/>
|
<Layer name="Console" overlapped="false" peek="true"/>
|
||||||
<Layer name="Notification" overlapped="false" peek="false"/>
|
<Layer name="Notification" overlapped="false" peek="false"/>
|
||||||
|
|
Loading…
Reference in a new issue