--- a/QTfrontend/game.cpp Sun Dec 30 03:00:51 2012 +0100
+++ b/QTfrontend/game.cpp Mon Dec 31 12:12:23 2012 +0200
@@ -23,6 +23,8 @@
#include <QStringListModel>
#include <QTextStream>
+#include "hwform.h"
+#include "ui/page/pageoptions.h"
#include "game.h"
#include "hwconsts.h"
#include "gameuiconfig.h"
@@ -297,6 +299,16 @@
writeCampaignVar(msg.right(msg.size() - 3));
break;
}
+ case 'W':
+ {
+ // fetch new window resolution via IPC and save it in the settings
+ int size = msg.size();
+ QString newResolution = QString().append(msg.mid(2)).left(size - 4);
+ QStringList wh = newResolution.split('x');
+ config->Form->ui.pageOptions->windowWidthEdit->setText(wh[0]);
+ config->Form->ui.pageOptions->windowHeightEdit->setText(wh[1]);
+ break;
+ }
default:
{
if (gameType == gtNet && !netSuspend)
--- a/QTfrontend/gameuiconfig.cpp Sun Dec 30 03:00:51 2012 +0100
+++ b/QTfrontend/gameuiconfig.cpp Mon Dec 31 12:12:23 2012 +0200
@@ -34,6 +34,7 @@
#include "fpsedit.h"
#include "HWApplication.h"
#include "DataManager.h"
+#include "SDL.h"
const QNetworkProxy::ProxyType proxyTypesMap[] = {
@@ -81,6 +82,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();
@@ -216,6 +231,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());
@@ -338,11 +355,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;
}
--- a/QTfrontend/ui/page/pageoptions.cpp Sun Dec 30 03:00:51 2012 +0100
+++ b/QTfrontend/ui/page/pageoptions.cpp Mon Dec 31 12:12:23 2012 +0200
@@ -271,7 +271,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);
@@ -306,16 +308,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);
@@ -638,6 +660,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;
}
@@ -672,7 +698,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());
@@ -703,7 +732,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();
--- a/QTfrontend/ui/page/pageoptions.h Sun Dec 30 03:00:51 2012 +0100
+++ b/QTfrontend/ui/page/pageoptions.h Mon Dec 31 12:12:23 2012 +0200
@@ -58,6 +58,8 @@
QComboBox *CBTeamName;
IconedGroupBox *AGGroupBox;
QComboBox *CBResolution;
+ QLineEdit *windowWidthEdit;
+ QLineEdit *windowHeightEdit;
QComboBox *CBStereoMode;
QCheckBox *CBFrontendSound;
QCheckBox *CBFrontendMusic;
--- a/hedgewars/hwengine.pas Sun Dec 30 03:00:51 2012 +0100
+++ b/hedgewars/hwengine.pas Mon Dec 31 12:12:23 2012 +0200
@@ -279,6 +279,7 @@
ScriptOnScreenResize();
InitCameraBorders();
InitTouchInterface();
+ SendIPC('W' + IntToStr(cScreenWidth) + 'x' + IntToStr(cScreenHeight));
end;
CurrTime:= SDL_GetTicks();