# HG changeset patch # User vitiv # Date 1356784820 -7200 # Node ID aa4ea3cade3c93e7e7fe9935247ddbd964370df2 # Parent 44d65d9bfda4e556e5af666d51c97e6c1902791b Added Support for variable windowed resolution. diff -r 44d65d9bfda4 -r aa4ea3cade3c QTfrontend/gameuiconfig.cpp --- a/QTfrontend/gameuiconfig.cpp Fri Dec 28 11:00:12 2012 +0100 +++ b/QTfrontend/gameuiconfig.cpp Sat Dec 29 14:40:20 2012 +0200 @@ -34,6 +34,7 @@ #include "fpsedit.h" #include "HWApplication.h" #include "DataManager.h" +#include "SDL.h" const QNetworkProxy::ProxyType proxyTypesMap[] = { @@ -74,6 +75,20 @@ Form->ui.pageOptions->CBResolution->setCurrentIndex(0); } else Form->ui.pageOptions->CBResolution->setCurrentIndex(t); + + // Default the windowed resolution to 2/3 of the screen size + int screenWidth = SDL_GetVideoInfo()->current_w * 2 / 3; + int screenHeight = SDL_GetVideoInfo()->current_h * 2 / 3; + QString widthStr; widthStr.setNum(screenWidth); + QString heightStr; heightStr.setNum(screenHeight); + QString wWidth = value("video/windowedWidth", widthStr).toString(); + QString wHeight = value("video/windowedHeight", heightStr).toString(); + // If left blank reset the resolution to the default + wWidth = (wWidth == "" ? widthStr : wWidth); + wHeight = (wHeight == "" ? heightStr : wHeight); + Form->ui.pageOptions->windowWidthEdit->setText(wWidth); + Form->ui.pageOptions->windowHeightEdit->setText(wHeight); + Form->ui.pageOptions->CBResolution->setCurrentIndex((t < 0) ? 1 : t); Form->ui.pageOptions->CBFullscreen->setChecked(value("video/fullscreen", false).toBool()); bool ffscr=value("frontend/fullscreen", false).toBool(); @@ -200,6 +215,8 @@ void GameUIConfig::SaveOptions() { setValue("video/resolution", Form->ui.pageOptions->CBResolution->currentText()); + setValue("video/windowedWidth", Form->ui.pageOptions->windowWidthEdit->text()); + setValue("video/windowedHeight", Form->ui.pageOptions->windowHeightEdit->text()); setValue("video/fullscreen", vid_Fullscreen()); setValue("video/quality", Form->ui.pageOptions->SLQuality->value()); @@ -322,11 +339,17 @@ QRect GameUIConfig::vid_Resolution() { QRect result(0, 0, 640, 480); - QStringList wh = Form->ui.pageOptions->CBResolution->currentText().split('x'); - if (wh.size() == 2) - { - result.setWidth(wh[0].toInt()); - result.setHeight(wh[1].toInt()); + if(Form->ui.pageOptions->CBFullscreen->isChecked()) { + QStringList wh = Form->ui.pageOptions->CBResolution->currentText().split('x'); + if (wh.size() == 2) + { + result.setWidth(wh[0].toInt()); + result.setHeight(wh[1].toInt()); + } + } + else { + result.setWidth(Form->ui.pageOptions->windowWidthEdit->text().toInt()); + result.setHeight(Form->ui.pageOptions->windowHeightEdit->text().toInt()); } return result; } diff -r 44d65d9bfda4 -r aa4ea3cade3c QTfrontend/ui/page/pageoptions.cpp --- a/QTfrontend/ui/page/pageoptions.cpp Fri Dec 28 11:00:12 2012 +0100 +++ b/QTfrontend/ui/page/pageoptions.cpp Sat Dec 29 14:40:20 2012 +0200 @@ -260,7 +260,9 @@ QVBoxLayout * GBAlayout = new QVBoxLayout(AGGroupBox); QGridLayout * GBAfrontendlayout = new QGridLayout(0); - QHBoxLayout * GBAreslayout = new QHBoxLayout(0); + QGridLayout * GBAreslayout = new QGridLayout(0); + QHBoxLayout * GBAfullreslayout = new QHBoxLayout(0); + QHBoxLayout * GBAwindowedreslayout = new QHBoxLayout(0); QHBoxLayout * GBAstereolayout = new QHBoxLayout(0); QHBoxLayout * GBAqualayout = new QHBoxLayout(0); @@ -295,16 +297,36 @@ QLabel * resolution = new QLabel(AGGroupBox); resolution->setText(QLabel::tr("Resolution")); - GBAreslayout->addWidget(resolution); + GBAreslayout->addWidget(resolution, 0, 0); CBResolution = new QComboBox(AGGroupBox); - GBAreslayout->addWidget(CBResolution); - GBAlayout->addLayout(GBAreslayout); + GBAfullreslayout->addWidget(CBResolution); CBFullscreen = new QCheckBox(AGGroupBox); CBFullscreen->setText(QCheckBox::tr("Fullscreen")); - GBAreslayout->addWidget(CBFullscreen); - + GBAfullreslayout->addWidget(CBFullscreen); + GBAreslayout->addLayout(GBAfullreslayout, 0, 1); + + QLabel * windowedResolution = new QLabel(AGGroupBox); + windowedResolution->setText(QLabel::tr("Windowed Resolution")); + GBAreslayout->addWidget(windowedResolution, 1, 0); + + // decorational X + QLabel *winLabelX = new QLabel(AGGroupBox); + winLabelX->setText("X"); + + windowWidthEdit = new QLineEdit(AGGroupBox); + windowWidthEdit->setValidator(new QIntValidator(this)); + windowHeightEdit = new QLineEdit(AGGroupBox); + windowHeightEdit->setValidator(new QIntValidator(this)); + + GBAwindowedreslayout->addWidget(windowWidthEdit); + GBAwindowedreslayout->addWidget(winLabelX); + GBAwindowedreslayout->addWidget(windowHeightEdit); + GBAreslayout->addLayout(GBAwindowedreslayout, 1, 1); + + GBAlayout->addLayout(GBAreslayout); + QLabel * quality = new QLabel(AGGroupBox); quality->setText(QLabel::tr("Quality")); quality->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); @@ -627,6 +649,10 @@ previousQuality = this->SLQuality->value(); previousResolutionIndex = this->CBResolution->currentIndex(); previousFullscreenValue = this->CBFullscreen->isChecked(); + // mutually exclude window and fullscreen resolution + CBResolution->setEnabled(this->CBFullscreen->isChecked()); + windowHeightEdit->setEnabled(!this->CBFullscreen->isChecked()); + windowWidthEdit->setEnabled(!this->CBFullscreen->isChecked()); return pageLayout; } @@ -661,7 +687,10 @@ void PageOptions::forceFullscreen(int index) { bool forced = (index == 7 || index == 8 || index == 9); - + CBResolution->setEnabled(this->CBFullscreen->isChecked()); + windowHeightEdit->setEnabled(!this->CBFullscreen->isChecked()); + windowWidthEdit->setEnabled(!this->CBFullscreen->isChecked()); + if (index != 0) { this->SLQuality->setValue(this->SLQuality->maximum()); @@ -692,7 +721,10 @@ void PageOptions::setFullscreen(int state) { Q_UNUSED(state); - + CBResolution->setEnabled(this->CBFullscreen->isChecked()); + windowHeightEdit->setEnabled(!this->CBFullscreen->isChecked()); + windowWidthEdit->setEnabled(!this->CBFullscreen->isChecked()); + int index = this->CBStereoMode->currentIndex(); if (index != 7 && index != 8 && index != 9) previousFullscreenValue = this->CBFullscreen->isChecked(); diff -r 44d65d9bfda4 -r aa4ea3cade3c QTfrontend/ui/page/pageoptions.h --- a/QTfrontend/ui/page/pageoptions.h Fri Dec 28 11:00:12 2012 +0100 +++ b/QTfrontend/ui/page/pageoptions.h Sat Dec 29 14:40:20 2012 +0200 @@ -57,6 +57,8 @@ QComboBox *CBTeamName; IconedGroupBox *AGGroupBox; QComboBox *CBResolution; + QLineEdit *windowWidthEdit; + QLineEdit *windowHeightEdit; QComboBox *CBStereoMode; QCheckBox *CBFrontendSound; QCheckBox *CBFrontendMusic;