|
|
|
@ -6,6 +6,7 @@
|
|
|
|
|
|
|
|
|
|
#include <boost/lexical_cast.hpp>
|
|
|
|
|
#include <boost/algorithm/string.hpp>
|
|
|
|
|
#include <boost/math/common_factor_rt.hpp>
|
|
|
|
|
|
|
|
|
|
#include <components/settings/settings.hpp>
|
|
|
|
|
|
|
|
|
@ -51,6 +52,24 @@ namespace
|
|
|
|
|
x = boost::lexical_cast<int> (split[0]);
|
|
|
|
|
y = boost::lexical_cast<int> (split[1]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool sortResolutions (std::pair<int, int> left, std::pair<int, int> 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<std::string>(xaspect) + " : " + boost::lexical_cast<std::string>(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<int, int> > 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<std::string>(resX) + " x " + boost::lexical_cast<std::string>(resY);
|
|
|
|
|
resolutions.push_back(std::make_pair(resX, resY));
|
|
|
|
|
}
|
|
|
|
|
std::sort(resolutions.begin(), resolutions.end(), sortResolutions);
|
|
|
|
|
for (std::vector < std::pair<int, int> >::const_iterator it=resolutions.begin();
|
|
|
|
|
it!=resolutions.end(); ++it)
|
|
|
|
|
{
|
|
|
|
|
std::string str = boost::lexical_cast<std::string>(it->first) + " x " + boost::lexical_cast<std::string>(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()
|
|
|
|
|