diff --git a/apps/openmw/mwgui/settingswindow.cpp b/apps/openmw/mwgui/settingswindow.cpp index 8dcea6d89..4fa941681 100644 --- a/apps/openmw/mwgui/settingswindow.cpp +++ b/apps/openmw/mwgui/settingswindow.cpp @@ -6,6 +6,7 @@ #include #include +#include #include @@ -51,6 +52,24 @@ namespace x = boost::lexical_cast (split[0]); y = boost::lexical_cast (split[1]); } + + bool sortResolutions (std::pair left, std::pair right) + { + if (left.first == right.first) + return left.second > right.second; + return left.first > right.first; + } + + std::string getAspect (int x, int y) + { + int gcd = boost::math::gcd (x, y); + int xaspect = x / gcd; + int yaspect = y / gcd; + // special case: 8 : 5 is usually referred to as 16:10 + if (xaspect == 8 && yaspect == 5) + return "16 : 10"; + return boost::lexical_cast(xaspect) + " : " + boost::lexical_cast(yaspect); + } } namespace MWGui @@ -111,13 +130,22 @@ namespace MWGui // fill resolution list Ogre::RenderSystem* rs = Ogre::Root::getSingleton().getRenderSystem(); - const Ogre::StringVector& videoModes = rs->getConfigOptions()["Video Mode"].possibleValues; + Ogre::StringVector videoModes = rs->getConfigOptions()["Video Mode"].possibleValues; + std::vector < std::pair > resolutions; for (Ogre::StringVector::const_iterator it=videoModes.begin(); it!=videoModes.end(); ++it) { + int resX, resY; parseResolution (resX, resY, *it); - std::string str = boost::lexical_cast(resX) + " x " + boost::lexical_cast(resY); + resolutions.push_back(std::make_pair(resX, resY)); + } + std::sort(resolutions.begin(), resolutions.end(), sortResolutions); + for (std::vector < std::pair >::const_iterator it=resolutions.begin(); + it!=resolutions.end(); ++it) + { + std::string str = boost::lexical_cast(it->first) + " x " + boost::lexical_cast(it->second) + + " (" + getAspect(it->first,it->second) + ")"; if (mResolutionList->findItemIndexWith(str) == MyGUI::ITEM_NONE) mResolutionList->addItem(str); @@ -185,7 +213,6 @@ namespace MWGui dialog->eventOkClicked.clear(); dialog->eventOkClicked += MyGUI::newDelegate(this, &SettingsWindow::onResolutionAccept); dialog->eventCancelClicked.clear(); - dialog->eventCancelClicked += MyGUI::newDelegate(this, &SettingsWindow::onResolutionAccept); } void SettingsWindow::onResolutionAccept()