mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-02-21 09:39:41 +00:00
Modified sorting of the values in the Graphics Page
This commit is contained in:
parent
77ac8760d1
commit
e5159a1950
3 changed files with 61 additions and 54 deletions
|
@ -1,22 +1,10 @@
|
||||||
#include "graphicspage.hpp"
|
|
||||||
|
|
||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
|
|
||||||
#include <boost/lexical_cast.hpp>
|
|
||||||
|
|
||||||
#include <components/files/configurationmanager.hpp>
|
#include <components/files/configurationmanager.hpp>
|
||||||
#include <components/settings/settings.hpp>
|
#include <components/settings/settings.hpp>
|
||||||
|
|
||||||
//sort resolutions descending
|
#include "graphicspage.hpp"
|
||||||
bool resolutionLessThan(const QString &str1, const QString &str2)
|
#include "naturalsort.hpp"
|
||||||
{
|
|
||||||
// Get the first parts of the resolution strings
|
|
||||||
int width1 = str1.left(str1.indexOf(" ")).toInt();
|
|
||||||
int width2 = str2.left(str2.indexOf(" ")).toInt();
|
|
||||||
|
|
||||||
return (width1 > width2);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
GraphicsPage::GraphicsPage(Files::ConfigurationManager &cfg, QWidget *parent)
|
GraphicsPage::GraphicsPage(Files::ConfigurationManager &cfg, QWidget *parent)
|
||||||
: QWidget(parent)
|
: QWidget(parent)
|
||||||
|
@ -77,11 +65,11 @@ bool GraphicsPage::setupOgre()
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
#if defined(ENABLE_PLUGIN_GL) || defined(ENABLE_PLUGIN_Direct3D9)
|
#if defined(ENABLE_PLUGIN_GL) || defined(ENABLE_PLUGIN_Direct3D9)
|
||||||
mOgre = new Ogre::Root("", "", "./launcherOgre.log");
|
mOgre = new Ogre::Root("", "", "./launcherOgre.log");
|
||||||
#else
|
#else
|
||||||
mOgre = new Ogre::Root(pluginCfg.toStdString(), "", "./launcherOgre.log");
|
mOgre = new Ogre::Root(pluginCfg.toStdString(), "", "./launcherOgre.log");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
catch(Ogre::Exception &ex)
|
catch(Ogre::Exception &ex)
|
||||||
{
|
{
|
||||||
|
@ -100,14 +88,14 @@ bool GraphicsPage::setupOgre()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_PLUGIN_GL
|
#ifdef ENABLE_PLUGIN_GL
|
||||||
mGLPlugin = new Ogre::GLPlugin();
|
mGLPlugin = new Ogre::GLPlugin();
|
||||||
mOgre->installPlugin(mGLPlugin);
|
mOgre->installPlugin(mGLPlugin);
|
||||||
#endif
|
#endif
|
||||||
#ifdef ENABLE_PLUGIN_Direct3D9
|
#ifdef ENABLE_PLUGIN_Direct3D9
|
||||||
mD3D9Plugin = new Ogre::D3D9Plugin();
|
mD3D9Plugin = new Ogre::D3D9Plugin();
|
||||||
mOgre->installPlugin(mD3D9Plugin);
|
mOgre->installPlugin(mD3D9Plugin);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Get the available renderers and put them in the combobox
|
// Get the available renderers and put them in the combobox
|
||||||
const Ogre::RenderSystemList &renderers = mOgre->getAvailableRenderers();
|
const Ogre::RenderSystemList &renderers = mOgre->getAvailableRenderers();
|
||||||
|
@ -117,30 +105,16 @@ bool GraphicsPage::setupOgre()
|
||||||
mRendererComboBox->addItem((*r)->getName().c_str());
|
mRendererComboBox->addItem((*r)->getName().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
int index = mRendererComboBox->findText(QString::fromStdString(Settings::Manager::getString("render system", "Video")));
|
QString openGLName = QString("OpenGL Rendering Subsystem");
|
||||||
|
QString direct3DName = QString("Direct3D9 Rendering Subsystem");
|
||||||
if ( index != -1) {
|
|
||||||
mRendererComboBox->setCurrentIndex(index);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
|
|
||||||
mRendererComboBox->setCurrentIndex(mRendererComboBox->findText("Direct3D9 Rendering Subsystem"));
|
|
||||||
#else
|
|
||||||
mRendererComboBox->setCurrentIndex(mRendererComboBox->findText("OpenGL Rendering Subsystem"));
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create separate rendersystems
|
// Create separate rendersystems
|
||||||
QString openGLName = mRendererComboBox->itemText(mRendererComboBox->findText(QString("OpenGL"), Qt::MatchStartsWith));
|
|
||||||
QString direct3DName = mRendererComboBox->itemText(mRendererComboBox->findText(QString("Direct3D"), Qt::MatchStartsWith));
|
|
||||||
|
|
||||||
mOpenGLRenderSystem = mOgre->getRenderSystemByName(openGLName.toStdString());
|
mOpenGLRenderSystem = mOgre->getRenderSystemByName(openGLName.toStdString());
|
||||||
mDirect3DRenderSystem = mOgre->getRenderSystemByName(direct3DName.toStdString());
|
mDirect3DRenderSystem = mOgre->getRenderSystemByName(direct3DName.toStdString());
|
||||||
|
|
||||||
if (!mOpenGLRenderSystem && !mDirect3DRenderSystem) {
|
if (!mOpenGLRenderSystem && !mDirect3DRenderSystem) {
|
||||||
QMessageBox msgBox;
|
QMessageBox msgBox;
|
||||||
msgBox.setWindowTitle("Error creating renderer");
|
msgBox.setWindowTitle(tr("Error creating renderer"));
|
||||||
msgBox.setIcon(QMessageBox::Critical);
|
msgBox.setIcon(QMessageBox::Critical);
|
||||||
msgBox.setStandardButtons(QMessageBox::Ok);
|
msgBox.setStandardButtons(QMessageBox::Ok);
|
||||||
msgBox.setText(tr("<br><b>Could not select a valid render system</b><br><br> \
|
msgBox.setText(tr("<br><b>Could not select a valid render system</b><br><br> \
|
||||||
|
@ -151,6 +125,20 @@ bool GraphicsPage::setupOgre()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now fill the GUI elements
|
// Now fill the GUI elements
|
||||||
|
int index = mRendererComboBox->findText(QString::fromStdString(Settings::Manager::getString("render system", "Video")));
|
||||||
|
|
||||||
|
if ( index != -1) {
|
||||||
|
mRendererComboBox->setCurrentIndex(index);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
|
||||||
|
mRendererComboBox->setCurrentIndex(mRendererComboBox->findText(direct3DName));
|
||||||
|
#else
|
||||||
|
mRendererComboBox->setCurrentIndex(mRendererComboBox->findText(openGLName));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
mAntiAliasingComboBox->clear();
|
mAntiAliasingComboBox->clear();
|
||||||
mResolutionComboBox->clear();
|
mResolutionComboBox->clear();
|
||||||
mAntiAliasingComboBox->addItems(getAvailableOptions(QString("FSAA"), mSelectedRenderSystem));
|
mAntiAliasingComboBox->addItems(getAvailableOptions(QString("FSAA"), mSelectedRenderSystem));
|
||||||
|
@ -172,9 +160,10 @@ void GraphicsPage::readConfig()
|
||||||
if (aaIndex != -1)
|
if (aaIndex != -1)
|
||||||
mAntiAliasingComboBox->setCurrentIndex(aaIndex);
|
mAntiAliasingComboBox->setCurrentIndex(aaIndex);
|
||||||
|
|
||||||
std::string resolution = boost::lexical_cast<std::string>(Settings::Manager::getInt("resolution x", "Video"))
|
QString resolution = QString::number(Settings::Manager::getInt("resolution x", "Video"));
|
||||||
+ " x " + boost::lexical_cast<std::string>(Settings::Manager::getInt("resolution y", "Video"));
|
resolution.append(" x " + QString::number(Settings::Manager::getInt("resolution y", "Video")));
|
||||||
int resIndex = mResolutionComboBox->findText(QString::fromStdString(resolution));
|
|
||||||
|
int resIndex = mResolutionComboBox->findText(resolution);
|
||||||
if (resIndex != -1)
|
if (resIndex != -1)
|
||||||
mResolutionComboBox->setCurrentIndex(resIndex);
|
mResolutionComboBox->setCurrentIndex(resIndex);
|
||||||
}
|
}
|
||||||
|
@ -189,8 +178,9 @@ void GraphicsPage::writeConfig()
|
||||||
// parse resolution x and y from a string like "800 x 600"
|
// parse resolution x and y from a string like "800 x 600"
|
||||||
QString resolution = mResolutionComboBox->currentText();
|
QString resolution = mResolutionComboBox->currentText();
|
||||||
QStringList tokens = resolution.split(" ", QString::SkipEmptyParts);
|
QStringList tokens = resolution.split(" ", QString::SkipEmptyParts);
|
||||||
int resX = boost::lexical_cast<int>(tokens.at(0).toStdString());
|
|
||||||
int resY = boost::lexical_cast<int>(tokens.at(2).toStdString());
|
int resX = tokens.at(0).toInt();
|
||||||
|
int resY = tokens.at(2).toInt();
|
||||||
Settings::Manager::setInt("resolution x", "Video", resX);
|
Settings::Manager::setInt("resolution x", "Video", resX);
|
||||||
Settings::Manager::setInt("resolution y", "Video", resY);
|
Settings::Manager::setInt("resolution y", "Video", resY);
|
||||||
}
|
}
|
||||||
|
@ -212,17 +202,21 @@ QStringList GraphicsPage::getAvailableOptions(const QString &key, Ogre::RenderSy
|
||||||
|
|
||||||
if (strcmp (key.toStdString().c_str(), i->first.c_str()) == 0)
|
if (strcmp (key.toStdString().c_str(), i->first.c_str()) == 0)
|
||||||
{
|
{
|
||||||
if (key == "FSAA" && *opt_it == "0")
|
result << ((key == "FSAA") ? QString("MSAA ") : QString("")) + QString::fromStdString((*opt_it).c_str()).simplified();
|
||||||
result << QString("none");
|
|
||||||
else
|
|
||||||
result << ((key == "FSAA") ? QString("MSAA ") : QString("")) + QString::fromStdString((*opt_it).c_str()).simplified();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sort ascending
|
// Sort ascending
|
||||||
result.sort();
|
qSort(result.begin(), result.end(), naturalSortLessThanCI);
|
||||||
|
|
||||||
|
// Replace the zero option with Off
|
||||||
|
int index = result.indexOf("MSAA 0");
|
||||||
|
|
||||||
|
if (index != -1)
|
||||||
|
result.replace(index, tr("Off"));
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -260,7 +254,8 @@ QStringList GraphicsPage::getAvailableResolutions(Ogre::RenderSystem *renderer)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sort the resolutions in descending order
|
// Sort the resolutions in descending order
|
||||||
qSort(result.begin(), result.end(), resolutionLessThan);
|
qSort(result.begin(), result.end(), naturalSortGreaterThanCI);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -93,3 +93,13 @@ bool naturalSortLessThanCI( const QString &left, const QString &right )
|
||||||
{
|
{
|
||||||
return (naturalCompare( left, right, Qt::CaseInsensitive ) < 0);
|
return (naturalCompare( left, right, Qt::CaseInsensitive ) < 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool naturalSortGreaterThanCS( const QString &left, const QString &right )
|
||||||
|
{
|
||||||
|
return (naturalCompare( left, right, Qt::CaseSensitive ) > 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool naturalSortGreaterThanCI( const QString &left, const QString &right )
|
||||||
|
{
|
||||||
|
return (naturalCompare( left, right, Qt::CaseInsensitive ) > 0);
|
||||||
|
}
|
||||||
|
|
|
@ -5,5 +5,7 @@
|
||||||
|
|
||||||
bool naturalSortLessThanCS( const QString &left, const QString &right );
|
bool naturalSortLessThanCS( const QString &left, const QString &right );
|
||||||
bool naturalSortLessThanCI( const QString &left, const QString &right );
|
bool naturalSortLessThanCI( const QString &left, const QString &right );
|
||||||
|
bool naturalSortGreaterThanCS( const QString &left, const QString &right );
|
||||||
|
bool naturalSortGreaterThanCI( const QString &left, const QString &right );
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue