mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-21 12:09:43 +00:00
Made the GraphicsPage use a .ui file and added support for custom res
This commit is contained in:
parent
0a6e3701ab
commit
fb5213a754
3 changed files with 92 additions and 88 deletions
|
@ -30,48 +30,17 @@ GraphicsPage::GraphicsPage(Files::ConfigurationManager &cfg, GraphicsSettings &g
|
||||||
, mGraphicsSettings(graphicsSetting)
|
, mGraphicsSettings(graphicsSetting)
|
||||||
, QWidget(parent)
|
, QWidget(parent)
|
||||||
{
|
{
|
||||||
QGroupBox *rendererGroup = new QGroupBox(tr("Renderer"), this);
|
setupUi(this);
|
||||||
|
|
||||||
QLabel *rendererLabel = new QLabel(tr("Rendering Subsystem:"), rendererGroup);
|
// Set the maximum res we can set in windowed mode
|
||||||
mRendererComboBox = new QComboBox(rendererGroup);
|
QRect res = QApplication::desktop()->screenGeometry();
|
||||||
|
customWidthSpinBox->setMaximum(res.width());
|
||||||
|
customHeightSpinBox->setMaximum(res.height());
|
||||||
|
|
||||||
// Layout for the combobox and label
|
connect(rendererComboBox, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(rendererChanged(const QString&)));
|
||||||
QGridLayout *renderSystemLayout = new QGridLayout();
|
connect(fullScreenCheckBox, SIGNAL(stateChanged(int)), this, SLOT(slotFullScreenChanged(int)));
|
||||||
renderSystemLayout->addWidget(rendererLabel, 0, 0, 1, 1);
|
connect(standardRadioButton, SIGNAL(toggled(bool)), this, SLOT(slotStandardToggled(bool)));
|
||||||
renderSystemLayout->addWidget(mRendererComboBox, 0, 1, 1, 1);
|
|
||||||
|
|
||||||
// Display
|
|
||||||
QGroupBox *displayGroup = new QGroupBox(tr("Display"), this);
|
|
||||||
|
|
||||||
mVSyncCheckBox = new QCheckBox(tr("Vertical Sync"), displayGroup);
|
|
||||||
mFullScreenCheckBox = new QCheckBox(tr("Full Screen"), displayGroup);
|
|
||||||
|
|
||||||
QLabel *antiAliasingLabel = new QLabel(tr("Antialiasing:"), displayGroup);
|
|
||||||
QLabel *resolutionLabel = new QLabel(tr("Resolution:"), displayGroup);
|
|
||||||
|
|
||||||
mResolutionComboBox = new QComboBox(displayGroup);
|
|
||||||
mAntiAliasingComboBox = new QComboBox(displayGroup);
|
|
||||||
|
|
||||||
QVBoxLayout *rendererGroupLayout = new QVBoxLayout(rendererGroup);
|
|
||||||
rendererGroupLayout->addLayout(renderSystemLayout);
|
|
||||||
|
|
||||||
QGridLayout *displayGroupLayout = new QGridLayout(displayGroup);
|
|
||||||
displayGroupLayout->addWidget(mVSyncCheckBox, 0, 0, 1, 1);
|
|
||||||
displayGroupLayout->addWidget(mFullScreenCheckBox, 1, 0, 1, 1);
|
|
||||||
displayGroupLayout->addWidget(antiAliasingLabel, 2, 0, 1, 1);
|
|
||||||
displayGroupLayout->addWidget(mAntiAliasingComboBox, 2, 1, 1, 1);
|
|
||||||
displayGroupLayout->addWidget(resolutionLabel, 3, 0, 1, 1);
|
|
||||||
displayGroupLayout->addWidget(mResolutionComboBox, 3, 1, 1, 1);
|
|
||||||
|
|
||||||
// Layout for the whole page
|
|
||||||
QVBoxLayout *pageLayout = new QVBoxLayout(this);
|
|
||||||
QSpacerItem *vSpacer1 = new QSpacerItem(20, 10, QSizePolicy::Minimum, QSizePolicy::Expanding);
|
|
||||||
|
|
||||||
pageLayout->addWidget(rendererGroup);
|
|
||||||
pageLayout->addWidget(displayGroup);
|
|
||||||
pageLayout->addItem(vSpacer1);
|
|
||||||
|
|
||||||
connect(mRendererComboBox, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(rendererChanged(const QString&)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GraphicsPage::setupOgre()
|
bool GraphicsPage::setupOgre()
|
||||||
|
@ -138,7 +107,7 @@ bool GraphicsPage::setupOgre()
|
||||||
|
|
||||||
for (Ogre::RenderSystemList::const_iterator r = renderers.begin(); r != renderers.end(); ++r) {
|
for (Ogre::RenderSystemList::const_iterator r = renderers.begin(); r != renderers.end(); ++r) {
|
||||||
mSelectedRenderSystem = *r;
|
mSelectedRenderSystem = *r;
|
||||||
mRendererComboBox->addItem((*r)->getName().c_str());
|
rendererComboBox->addItem((*r)->getName().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
QString openGLName = QString("OpenGL Rendering Subsystem");
|
QString openGLName = QString("OpenGL Rendering Subsystem");
|
||||||
|
@ -160,21 +129,21 @@ bool GraphicsPage::setupOgre()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now fill the GUI elements
|
// Now fill the GUI elements
|
||||||
int index = mRendererComboBox->findText(mGraphicsSettings.value(QString("Video/render system")));
|
int index = rendererComboBox->findText(mGraphicsSettings.value(QString("Video/render system")));
|
||||||
if ( index != -1) {
|
if ( index != -1) {
|
||||||
mRendererComboBox->setCurrentIndex(index);
|
rendererComboBox->setCurrentIndex(index);
|
||||||
} else {
|
} else {
|
||||||
#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
|
#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
|
||||||
mRendererComboBox->setCurrentIndex(mRendererComboBox->findText(direct3DName));
|
rendererComboBox->setCurrentIndex(rendererComboBox->findText(direct3DName));
|
||||||
#else
|
#else
|
||||||
mRendererComboBox->setCurrentIndex(mRendererComboBox->findText(openGLName));
|
rendererComboBox->setCurrentIndex(rendererComboBox->findText(openGLName));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
mAntiAliasingComboBox->clear();
|
antiAliasingComboBox->clear();
|
||||||
mResolutionComboBox->clear();
|
resolutionComboBox->clear();
|
||||||
mAntiAliasingComboBox->addItems(getAvailableOptions(QString("FSAA"), mSelectedRenderSystem));
|
antiAliasingComboBox->addItems(getAvailableOptions(QString("FSAA"), mSelectedRenderSystem));
|
||||||
mResolutionComboBox->addItems(getAvailableResolutions(mSelectedRenderSystem));
|
resolutionComboBox->addItems(getAvailableResolutions(mSelectedRenderSystem));
|
||||||
|
|
||||||
// Load the rest of the values
|
// Load the rest of the values
|
||||||
loadSettings();
|
loadSettings();
|
||||||
|
@ -184,38 +153,46 @@ bool GraphicsPage::setupOgre()
|
||||||
void GraphicsPage::loadSettings()
|
void GraphicsPage::loadSettings()
|
||||||
{
|
{
|
||||||
if (mGraphicsSettings.value(QString("Video/vsync")) == QLatin1String("true"))
|
if (mGraphicsSettings.value(QString("Video/vsync")) == QLatin1String("true"))
|
||||||
mVSyncCheckBox->setCheckState(Qt::Checked);
|
vSyncCheckBox->setCheckState(Qt::Checked);
|
||||||
|
|
||||||
if (mGraphicsSettings.value(QString("Video/fullscreen")) == QLatin1String("true"))
|
if (mGraphicsSettings.value(QString("Video/fullscreen")) == QLatin1String("true"))
|
||||||
mFullScreenCheckBox->setCheckState(Qt::Checked);
|
fullScreenCheckBox->setCheckState(Qt::Checked);
|
||||||
|
|
||||||
int aaIndex = mAntiAliasingComboBox->findText(mGraphicsSettings.value(QString("Video/antialiasing")));
|
int aaIndex = antiAliasingComboBox->findText(mGraphicsSettings.value(QString("Video/antialiasing")));
|
||||||
if (aaIndex != -1)
|
if (aaIndex != -1)
|
||||||
mAntiAliasingComboBox->setCurrentIndex(aaIndex);
|
antiAliasingComboBox->setCurrentIndex(aaIndex);
|
||||||
|
|
||||||
QString resolution = mGraphicsSettings.value(QString("Video/resolution x"));
|
QString width = mGraphicsSettings.value(QString("Video/resolution x"));
|
||||||
resolution.append(QString(" x ") + mGraphicsSettings.value(QString("Video/resolution y")));
|
QString height = mGraphicsSettings.value(QString("Video/resolution y"));
|
||||||
|
QString resolution = width + QString(" x ") + height;
|
||||||
|
|
||||||
int resIndex = mResolutionComboBox->findText(resolution, Qt::MatchStartsWith);
|
int resIndex = resolutionComboBox->findText(resolution, Qt::MatchStartsWith);
|
||||||
|
|
||||||
if (resIndex != -1)
|
if (resIndex != -1) {
|
||||||
mResolutionComboBox->setCurrentIndex(resIndex);
|
standardRadioButton->toggle();
|
||||||
|
resolutionComboBox->setCurrentIndex(resIndex);
|
||||||
|
} else {
|
||||||
|
customRadioButton->toggle();
|
||||||
|
customWidthSpinBox->setValue(width.toInt());
|
||||||
|
customHeightSpinBox->setValue(height.toInt());
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphicsPage::saveSettings()
|
void GraphicsPage::saveSettings()
|
||||||
{
|
{
|
||||||
mVSyncCheckBox->checkState() ? mGraphicsSettings.setValue(QString("Video/vsync"), QString("true"))
|
vSyncCheckBox->checkState() ? mGraphicsSettings.setValue(QString("Video/vsync"), QString("true"))
|
||||||
: mGraphicsSettings.setValue(QString("Video/vsync"), QString("false"));
|
: mGraphicsSettings.setValue(QString("Video/vsync"), QString("false"));
|
||||||
|
|
||||||
mFullScreenCheckBox->checkState() ? mGraphicsSettings.setValue(QString("Video/fullscreen"), QString("true"))
|
fullScreenCheckBox->checkState() ? mGraphicsSettings.setValue(QString("Video/fullscreen"), QString("true"))
|
||||||
: mGraphicsSettings.setValue(QString("Video/fullscreen"), QString("false"));
|
: mGraphicsSettings.setValue(QString("Video/fullscreen"), QString("false"));
|
||||||
|
|
||||||
mGraphicsSettings.setValue(QString("Video/antialiasing"), mAntiAliasingComboBox->currentText());
|
mGraphicsSettings.setValue(QString("Video/antialiasing"), antiAliasingComboBox->currentText());
|
||||||
mGraphicsSettings.setValue(QString("Video/render system"), mRendererComboBox->currentText());
|
mGraphicsSettings.setValue(QString("Video/render system"), rendererComboBox->currentText());
|
||||||
|
|
||||||
QRegExp resolutionRe(QString("(\\d+) x (\\d+).*"));
|
QRegExp resolutionRe(QString("(\\d+) x (\\d+).*"));
|
||||||
|
|
||||||
if (resolutionRe.exactMatch(mResolutionComboBox->currentText().simplified())) {
|
if (resolutionRe.exactMatch(resolutionComboBox->currentText().simplified())) {
|
||||||
mGraphicsSettings.setValue(QString("Video/resolution x"), resolutionRe.cap(1));
|
mGraphicsSettings.setValue(QString("Video/resolution x"), resolutionRe.cap(1));
|
||||||
mGraphicsSettings.setValue(QString("Video/resolution y"), resolutionRe.cap(2));
|
mGraphicsSettings.setValue(QString("Video/resolution y"), resolutionRe.cap(2));
|
||||||
}
|
}
|
||||||
|
@ -277,6 +254,7 @@ QStringList GraphicsPage::getAvailableResolutions(Ogre::RenderSystem *renderer)
|
||||||
// remove extra tokens after the resolution (for example bpp, can be there or not depending on rendersystem)
|
// remove extra tokens after the resolution (for example bpp, can be there or not depending on rendersystem)
|
||||||
QStringList tokens = qval.split(" ", QString::SkipEmptyParts);
|
QStringList tokens = qval.split(" ", QString::SkipEmptyParts);
|
||||||
assert (tokens.size() >= 3);
|
assert (tokens.size() >= 3);
|
||||||
|
|
||||||
QString resolutionStr = tokens.at(0) + QString(" x ") + tokens.at(2);
|
QString resolutionStr = tokens.at(0) + QString(" x ") + tokens.at(2);
|
||||||
|
|
||||||
QString aspect = getAspect(tokens.at(0).toInt(),tokens.at(2).toInt());
|
QString aspect = getAspect(tokens.at(0).toInt(),tokens.at(2).toInt());
|
||||||
|
@ -304,9 +282,36 @@ void GraphicsPage::rendererChanged(const QString &renderer)
|
||||||
{
|
{
|
||||||
mSelectedRenderSystem = mOgre->getRenderSystemByName(renderer.toStdString());
|
mSelectedRenderSystem = mOgre->getRenderSystemByName(renderer.toStdString());
|
||||||
|
|
||||||
mAntiAliasingComboBox->clear();
|
antiAliasingComboBox->clear();
|
||||||
mResolutionComboBox->clear();
|
resolutionComboBox->clear();
|
||||||
|
|
||||||
mAntiAliasingComboBox->addItems(getAvailableOptions(QString("FSAA"), mSelectedRenderSystem));
|
antiAliasingComboBox->addItems(getAvailableOptions(QString("FSAA"), mSelectedRenderSystem));
|
||||||
mResolutionComboBox->addItems(getAvailableResolutions(mSelectedRenderSystem));
|
resolutionComboBox->addItems(getAvailableResolutions(mSelectedRenderSystem));
|
||||||
|
}
|
||||||
|
|
||||||
|
void GraphicsPage::slotFullScreenChanged(int state)
|
||||||
|
{
|
||||||
|
if (state == Qt::Checked) {
|
||||||
|
standardRadioButton->toggle();
|
||||||
|
customRadioButton->setEnabled(false);
|
||||||
|
customWidthSpinBox->setEnabled(false);
|
||||||
|
customHeightSpinBox->setEnabled(false);
|
||||||
|
} else {
|
||||||
|
customRadioButton->setEnabled(true);
|
||||||
|
customWidthSpinBox->setEnabled(true);
|
||||||
|
customHeightSpinBox->setEnabled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void GraphicsPage::slotStandardToggled(bool checked)
|
||||||
|
{
|
||||||
|
if (checked) {
|
||||||
|
resolutionComboBox->setEnabled(true);
|
||||||
|
customWidthSpinBox->setEnabled(false);
|
||||||
|
customHeightSpinBox->setEnabled(false);
|
||||||
|
} else {
|
||||||
|
resolutionComboBox->setEnabled(false);
|
||||||
|
customWidthSpinBox->setEnabled(true);
|
||||||
|
customHeightSpinBox->setEnabled(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,16 +16,13 @@
|
||||||
# include "OgreD3D9Plugin.h"
|
# include "OgreD3D9Plugin.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
class QComboBox;
|
#include "ui_graphicspage.h"
|
||||||
class QCheckBox;
|
|
||||||
class QStackedWidget;
|
|
||||||
class QSettings;
|
|
||||||
|
|
||||||
class GraphicsSettings;
|
class GraphicsSettings;
|
||||||
|
|
||||||
namespace Files { struct ConfigurationManager; }
|
namespace Files { struct ConfigurationManager; }
|
||||||
|
|
||||||
class GraphicsPage : public QWidget
|
class GraphicsPage : public QWidget, private Ui::GraphicsPage
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
@ -38,6 +35,10 @@ public:
|
||||||
public slots:
|
public slots:
|
||||||
void rendererChanged(const QString &renderer);
|
void rendererChanged(const QString &renderer);
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void slotFullScreenChanged(int state);
|
||||||
|
void slotStandardToggled(bool checked);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ogre::Root *mOgre;
|
Ogre::Root *mOgre;
|
||||||
Ogre::RenderSystem *mSelectedRenderSystem;
|
Ogre::RenderSystem *mSelectedRenderSystem;
|
||||||
|
@ -50,22 +51,12 @@ private:
|
||||||
Ogre::D3D9Plugin* mD3D9Plugin;
|
Ogre::D3D9Plugin* mD3D9Plugin;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
QComboBox *mRendererComboBox;
|
|
||||||
|
|
||||||
QStackedWidget *mDisplayStackedWidget;
|
|
||||||
|
|
||||||
QComboBox *mAntiAliasingComboBox;
|
|
||||||
QComboBox *mResolutionComboBox;
|
|
||||||
QCheckBox *mVSyncCheckBox;
|
|
||||||
QCheckBox *mFullScreenCheckBox;
|
|
||||||
|
|
||||||
Files::ConfigurationManager &mCfgMgr;
|
Files::ConfigurationManager &mCfgMgr;
|
||||||
GraphicsSettings &mGraphicsSettings;
|
GraphicsSettings &mGraphicsSettings;
|
||||||
|
|
||||||
QStringList getAvailableOptions(const QString &key, Ogre::RenderSystem *renderer);
|
QStringList getAvailableOptions(const QString &key, Ogre::RenderSystem *renderer);
|
||||||
QStringList getAvailableResolutions(Ogre::RenderSystem *renderer);
|
QStringList getAvailableResolutions(Ogre::RenderSystem *renderer);
|
||||||
|
|
||||||
void createPages();
|
|
||||||
void loadSettings();
|
void loadSettings();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>400</width>
|
<width>332</width>
|
||||||
<height>300</height>
|
<height>297</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
@ -33,7 +33,7 @@
|
||||||
<item>
|
<item>
|
||||||
<widget class="QGroupBox" name="displayGroup">
|
<widget class="QGroupBox" name="displayGroup">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>GroupBox</string>
|
<string>Display</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout_4" columnstretch="1,1">
|
<layout class="QGridLayout" name="gridLayout_4" columnstretch="1,1">
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
|
@ -73,9 +73,13 @@
|
||||||
<item row="3" column="1">
|
<item row="3" column="1">
|
||||||
<layout class="QGridLayout" name="resolutionLayout">
|
<layout class="QGridLayout" name="resolutionLayout">
|
||||||
<item row="1" column="2">
|
<item row="1" column="2">
|
||||||
<layout class="QHBoxLayout" name="customResolutionLayout">
|
<layout class="QHBoxLayout" name="customResolutionLayout" stretch="1,0,1">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLineEdit" name="customWidthLineEdit"/>
|
<widget class="QSpinBox" name="customWidthSpinBox">
|
||||||
|
<property name="minimum">
|
||||||
|
<number>800</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="multiplyLabel">
|
<widget class="QLabel" name="multiplyLabel">
|
||||||
|
@ -85,7 +89,11 @@
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLineEdit" name="customHeightLineEdit"/>
|
<widget class="QSpinBox" name="customHeightSpinBox">
|
||||||
|
<property name="minimum">
|
||||||
|
<number>600</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
@ -101,7 +109,7 @@
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Standard:</string>
|
<string>Standard:</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="checked">
|
<property name="checkable">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
|
|
Loading…
Reference in a new issue