--- 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;
}