#include "mainmenu.hpp" #include #include "../mwbase/environment.hpp" #include "../mwbase/world.hpp" #include "../mwbase/windowmanager.hpp" namespace MWGui { MainMenu::MainMenu(int w, int h) : OEngine::GUI::Layout("openmw_mainmenu.layout") , mButtonBox(0) { onResChange(w,h); } void MainMenu::onResChange(int w, int h) { setCoord(0,0,w,h); int height = 64 * 3; if (mButtonBox) MyGUI::Gui::getInstance ().destroyWidget(mButtonBox); mButtonBox = mMainWidget->createWidget("", MyGUI::IntCoord(w/2 - 64, h/2 - height/2, 128, height), MyGUI::Align::Default); int curH = 0; mReturn = mButtonBox->createWidget ("ButtonImage", MyGUI::IntCoord(0, curH, 128, 64), MyGUI::Align::Default); mReturn->setImageResource ("Menu_Return"); mReturn->eventMouseButtonClick += MyGUI::newDelegate(this, &MainMenu::returnToGame); curH += 64; /* mNewGame = mButtonBox->createWidget ("ButtonImage", MyGUI::IntCoord(0, curH, 128, 64), MyGUI::Align::Default); mNewGame->setImageResource ("Menu_NewGame"); curH += 64; mLoadGame = mButtonBox->createWidget ("ButtonImage", MyGUI::IntCoord(0, curH, 128, 64), MyGUI::Align::Default); mLoadGame->setImageResource ("Menu_LoadGame"); curH += 64; mSaveGame = mButtonBox->createWidget ("ButtonImage", MyGUI::IntCoord(0, curH, 128, 64), MyGUI::Align::Default); mSaveGame->setImageResource ("Menu_SaveGame"); curH += 64; */ mOptions = mButtonBox->createWidget ("ButtonImage", MyGUI::IntCoord(0, curH, 128, 64), MyGUI::Align::Default); mOptions->setImageResource ("Menu_Options"); mOptions->eventMouseButtonClick += MyGUI::newDelegate(this, &MainMenu::showOptions); curH += 64; /* mCredits = mButtonBox->createWidget ("ButtonImage", MyGUI::IntCoord(0, curH, 128, 64), MyGUI::Align::Default); mCredits->setImageResource ("Menu_Credits"); curH += 64; */ mExitGame = mButtonBox->createWidget ("ButtonImage", MyGUI::IntCoord(0, curH, 128, 64), MyGUI::Align::Default); mExitGame->setImageResource ("Menu_ExitGame"); mExitGame->eventMouseButtonClick += MyGUI::newDelegate(this, &MainMenu::exitGame); curH += 64; } void MainMenu::returnToGame(MyGUI::Widget* sender) { MWBase::Environment::get().getWindowManager ()->removeGuiMode (GM_MainMenu); } void MainMenu::showOptions(MyGUI::Widget* sender) { MWBase::Environment::get().getWindowManager ()->pushGuiMode (GM_Settings); } void MainMenu::exitGame(MyGUI::Widget* sender) { Ogre::Root::getSingleton ().queueEndRendering (); } }