|
|
|
@ -3,6 +3,7 @@
|
|
|
|
|
#include <QDesktopWidget>
|
|
|
|
|
#include <QMessageBox>
|
|
|
|
|
#include <QDir>
|
|
|
|
|
#include <SDL.h>
|
|
|
|
|
|
|
|
|
|
#include <cstdlib>
|
|
|
|
|
|
|
|
|
@ -42,6 +43,7 @@ GraphicsPage::GraphicsPage(Files::ConfigurationManager &cfg, GraphicsSettings &g
|
|
|
|
|
connect(rendererComboBox, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(rendererChanged(const QString&)));
|
|
|
|
|
connect(fullScreenCheckBox, SIGNAL(stateChanged(int)), this, SLOT(slotFullScreenChanged(int)));
|
|
|
|
|
connect(standardRadioButton, SIGNAL(toggled(bool)), this, SLOT(slotStandardToggled(bool)));
|
|
|
|
|
connect(screenComboBox, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(screenChanged(const QString&)));
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -144,17 +146,84 @@ bool GraphicsPage::setupOgre()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
antiAliasingComboBox->clear();
|
|
|
|
|
resolutionComboBox->clear();
|
|
|
|
|
antiAliasingComboBox->addItems(getAvailableOptions(QString("FSAA"), mSelectedRenderSystem));
|
|
|
|
|
resolutionComboBox->addItems(getAvailableResolutions(mSelectedRenderSystem));
|
|
|
|
|
|
|
|
|
|
// Load the rest of the values
|
|
|
|
|
loadSettings();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void GraphicsPage::loadSettings()
|
|
|
|
|
bool GraphicsPage::setupSDL()
|
|
|
|
|
{
|
|
|
|
|
// FIXME: do setupSDLWordaround here instead.
|
|
|
|
|
// seems like Qt, SDL and Ogre don't like each other
|
|
|
|
|
// results in a segfault if SDL is initialized after Qt
|
|
|
|
|
|
|
|
|
|
QStringList screens;
|
|
|
|
|
for (int i = 0; i < mScreenCount; i++)
|
|
|
|
|
{
|
|
|
|
|
screens.append(QString("Screen ") + QString::number(i + 1));
|
|
|
|
|
}
|
|
|
|
|
screenComboBox->addItems(screens);
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::vector<VideoMode> GraphicsPage::mVideoModes;
|
|
|
|
|
int GraphicsPage::mScreenCount;
|
|
|
|
|
|
|
|
|
|
bool GraphicsPage::setupSDLWordaround() {
|
|
|
|
|
if (SDL_Init(SDL_INIT_VIDEO) != 0)
|
|
|
|
|
{
|
|
|
|
|
std::cout << "SDL_Init failed: " << SDL_GetError() << std::endl;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SDL_DisplayMode mode;
|
|
|
|
|
int displayIndex, modeIndex, displays = SDL_GetNumVideoDisplays();
|
|
|
|
|
mScreenCount = displays;
|
|
|
|
|
|
|
|
|
|
if(displays < 0)
|
|
|
|
|
{
|
|
|
|
|
std::cout << "SDL_GetNumVideoDisplays failed: " << SDL_GetError() << std::endl;
|
|
|
|
|
SDL_Quit();
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (displayIndex = 0; displayIndex < displays; displayIndex++)
|
|
|
|
|
{
|
|
|
|
|
int modes = SDL_GetNumDisplayModes(displayIndex);
|
|
|
|
|
if(modes < 0)
|
|
|
|
|
{
|
|
|
|
|
std::cout << "SDL_GetNumDisplayModes failed: " << SDL_GetError() << std::endl;
|
|
|
|
|
SDL_Quit();
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
for (modeIndex = 0; modeIndex < modes; modeIndex++)
|
|
|
|
|
{
|
|
|
|
|
if (SDL_GetDisplayMode(displayIndex, modeIndex, &mode) < 0)
|
|
|
|
|
{
|
|
|
|
|
std::cout << "SDL_GetDisplayMode failed: " << SDL_GetError() << std::endl;
|
|
|
|
|
SDL_Quit();
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
VideoMode vmode;
|
|
|
|
|
vmode.w = mode.w;
|
|
|
|
|
vmode.h = mode.h;
|
|
|
|
|
vmode.screen = displayIndex;
|
|
|
|
|
mVideoModes.push_back(vmode);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SDL_Quit();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool GraphicsPage::loadSettings()
|
|
|
|
|
{
|
|
|
|
|
if (!setupSDL())
|
|
|
|
|
return false;
|
|
|
|
|
if (!setupOgre())
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
if (mGraphicsSettings.value(QString("Video/vsync")) == QLatin1String("true"))
|
|
|
|
|
vSyncCheckBox->setCheckState(Qt::Checked);
|
|
|
|
|
|
|
|
|
@ -168,6 +237,9 @@ void GraphicsPage::loadSettings()
|
|
|
|
|
QString width = mGraphicsSettings.value(QString("Video/resolution x"));
|
|
|
|
|
QString height = mGraphicsSettings.value(QString("Video/resolution y"));
|
|
|
|
|
QString resolution = width + QString(" x ") + height;
|
|
|
|
|
QString screen = mGraphicsSettings.value(QString("Video/screen"));
|
|
|
|
|
|
|
|
|
|
screenComboBox->setCurrentIndex(screenComboBox->findText(QString("Screen ") + screen));
|
|
|
|
|
|
|
|
|
|
int resIndex = resolutionComboBox->findText(resolution, Qt::MatchStartsWith);
|
|
|
|
|
|
|
|
|
@ -180,6 +252,8 @@ void GraphicsPage::loadSettings()
|
|
|
|
|
customHeightSpinBox->setValue(height.toInt());
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void GraphicsPage::saveSettings()
|
|
|
|
@ -205,6 +279,11 @@ void GraphicsPage::saveSettings()
|
|
|
|
|
mGraphicsSettings.setValue(QString("Video/resolution x"), QString::number(customWidthSpinBox->value()));
|
|
|
|
|
mGraphicsSettings.setValue(QString("Video/resolution y"), QString::number(customHeightSpinBox->value()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QRegExp screenRe(QString(".*(\\d+)"));
|
|
|
|
|
if(screenRe.exactMatch(screenComboBox->currentText())) {
|
|
|
|
|
mGraphicsSettings.setValue(QString("Video/screen"), screenRe.cap(1));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QStringList GraphicsPage::getAvailableOptions(const QString &key, Ogre::RenderSystem *renderer)
|
|
|
|
@ -240,6 +319,33 @@ QStringList GraphicsPage::getAvailableOptions(const QString &key, Ogre::RenderSy
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#if 1
|
|
|
|
|
QStringList GraphicsPage::getAvailableResolutions(int screen)
|
|
|
|
|
{
|
|
|
|
|
QStringList result;
|
|
|
|
|
for (std::vector<VideoMode>::iterator it = mVideoModes.begin(); it != mVideoModes.end(); it++)
|
|
|
|
|
{
|
|
|
|
|
VideoMode mode = *it;
|
|
|
|
|
if(mode.screen != screen)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
QString aspect = getAspect(mode.w, mode.h);
|
|
|
|
|
QString resolution = QString::number(mode.w) + QString(" x ") + QString::number(mode.h);
|
|
|
|
|
|
|
|
|
|
if (aspect == QLatin1String("16:9") || aspect == QLatin1String("16:10")) {
|
|
|
|
|
resolution.append(tr("\t(Wide ") + aspect + ")");
|
|
|
|
|
|
|
|
|
|
} else if (aspect == QLatin1String("4:3")) {
|
|
|
|
|
resolution.append(tr("\t(Standard 4:3)"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
result.append(resolution);
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
|
QStringList GraphicsPage::getAvailableResolutions(Ogre::RenderSystem *renderer)
|
|
|
|
|
{
|
|
|
|
|
QString key("Video Mode");
|
|
|
|
@ -288,14 +394,15 @@ QStringList GraphicsPage::getAvailableResolutions(Ogre::RenderSystem *renderer)
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
QRect GraphicsPage::getMaximumResolution()
|
|
|
|
|
{
|
|
|
|
|
QRect max, res;
|
|
|
|
|
QRect max;
|
|
|
|
|
int i, screens = QApplication::desktop()->screenCount();
|
|
|
|
|
for (i = 0; i < screens; i++)
|
|
|
|
|
{
|
|
|
|
|
res = QApplication::desktop()->screenGeometry(i);
|
|
|
|
|
QRect res = QApplication::desktop()->screenGeometry(i);
|
|
|
|
|
if (res.width() > max.width())
|
|
|
|
|
max.setWidth(res.width());
|
|
|
|
|
if (res.height() > max.height())
|
|
|
|
@ -309,10 +416,17 @@ void GraphicsPage::rendererChanged(const QString &renderer)
|
|
|
|
|
mSelectedRenderSystem = mOgre->getRenderSystemByName(renderer.toStdString());
|
|
|
|
|
|
|
|
|
|
antiAliasingComboBox->clear();
|
|
|
|
|
resolutionComboBox->clear();
|
|
|
|
|
|
|
|
|
|
antiAliasingComboBox->addItems(getAvailableOptions(QString("FSAA"), mSelectedRenderSystem));
|
|
|
|
|
resolutionComboBox->addItems(getAvailableResolutions(mSelectedRenderSystem));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void GraphicsPage::screenChanged(const QString &screen)
|
|
|
|
|
{
|
|
|
|
|
QRegExp screenRe(QString(".*(\\d+)"));
|
|
|
|
|
if(screenRe.exactMatch(screen)) {
|
|
|
|
|
resolutionComboBox->clear();
|
|
|
|
|
resolutionComboBox->addItems(getAvailableResolutions(screenRe.cap(1).toInt() - 1));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void GraphicsPage::slotFullScreenChanged(int state)
|
|
|
|
|