Separated fullscreen and windowed hwengine resolution parameters.
authorvitiv <nikita.utiu@gmail.com>
Thu, 03 Jan 2013 15:59:30 +0200
changeset 8354 c25bee85d6f8
parent 8352 ab7f22530ae0
child 8356 b5cf1f29ab14
Separated fullscreen and windowed hwengine resolution parameters.
QTfrontend/game.cpp
QTfrontend/gameuiconfig.cpp
QTfrontend/gameuiconfig.h
QTfrontend/hwform.cpp
hedgewars/ArgParsers.inc
hedgewars/hwengine.pas
hedgewars/uStore.pas
hedgewars/uVariables.pas
--- a/QTfrontend/game.cpp	Thu Jan 03 15:58:23 2013 +0200
+++ b/QTfrontend/game.cpp	Thu Jan 03 15:59:30 2013 +0200
@@ -22,6 +22,7 @@
 #include <QColor>
 #include <QStringListModel>
 #include <QTextStream>
+#include <utility>
 
 #include "hwform.h"
 #include "ui/page/pageoptions.h"
@@ -348,7 +349,7 @@
 QStringList HWGame::getArguments()
 {
     QStringList arguments;
-    QRect resolution = config->vid_Resolution();
+    std::pair<QRect, QRect> resolutions = config->vid_ResolutionPair();
     QString nick = config->netNick().toUtf8().toBase64();
 
     arguments << "--internal"; //Must be passed as first argument
@@ -364,10 +365,14 @@
     arguments << QString::number(config->timerInterval());
     arguments << "--volume";
     arguments << QString::number(config->volume());
+    arguments << "--fullscreen-width";
+    arguments << QString::number(resolutions.first.width());
+    arguments << "--fullscreen-height";
+    arguments << QString::number(resolutions.first.height());
     arguments << "--width";
-    arguments << QString::number(resolution.width());
+    arguments << QString::number(resolutions.second.width());
     arguments << "--height";
-    arguments << QString::number(resolution.height());
+    arguments << QString::number(resolutions.second.height());
     arguments << "--raw-quality";
     arguments << QString::number(config->translateQuality());
     arguments << "--stereo";
--- a/QTfrontend/gameuiconfig.cpp	Thu Jan 03 15:58:23 2013 +0200
+++ b/QTfrontend/gameuiconfig.cpp	Thu Jan 03 15:59:30 2013 +0200
@@ -24,6 +24,7 @@
 #include <QStandardItemModel>
 #include <QNetworkProxy>
 #include <QNetworkProxyFactory>
+#include <utility>
 
 #include "gameuiconfig.h"
 #include "hwform.h"
@@ -352,22 +353,28 @@
     return Form->ui.pageOptions->CBLanguage->itemData(Form->ui.pageOptions->CBLanguage->currentIndex()).toString();
 }
 
+std::pair<QRect, QRect> GameUIConfig::vid_ResolutionPair() {
+    // returns a pair of both the fullscreen and the windowed resolution
+    QRect full(0, 0, 640, 480);
+    QRect windowed(0, 0, 640, 480);
+    QStringList wh = Form->ui.pageOptions->CBResolution->currentText().split('x');
+    if (wh.size() == 2)
+    {
+        full.setWidth(wh[0].toInt());
+        full.setHeight(wh[1].toInt());
+    }
+    windowed.setWidth(Form->ui.pageOptions->windowWidthEdit->text().toInt());
+    windowed.setHeight(Form->ui.pageOptions->windowHeightEdit->text().toInt());
+    return std::make_pair(full, windowed);
+}
+
 QRect GameUIConfig::vid_Resolution()
 {
-    QRect result(0, 0, 640, 480);
-    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;
+    std::pair<QRect, QRect> result = vid_ResolutionPair();
+    if(Form->ui.pageOptions->CBFullscreen->isChecked())
+        return result.first;
+    else 
+        return result.second;
 }
 
 bool GameUIConfig::vid_Fullscreen()
--- a/QTfrontend/gameuiconfig.h	Thu Jan 03 15:58:23 2013 +0200
+++ b/QTfrontend/gameuiconfig.h	Thu Jan 03 15:59:30 2013 +0200
@@ -24,6 +24,7 @@
 #include <QRect>
 #include <QEvent>
 #include <QList>
+#include <utility>
 #include "binds.h"
 
 class HWForm;
@@ -38,6 +39,7 @@
         GameUIConfig(HWForm * FormWidgets, const QString & fileName);
         QStringList GetTeamsList();
         QRect vid_Resolution();
+        std::pair<QRect, QRect> vid_ResolutionPair();
         bool vid_Fullscreen();
         quint32 translateQuality();
         bool isSoundEnabled();
--- a/QTfrontend/hwform.cpp	Thu Jan 03 15:58:23 2013 +0200
+++ b/QTfrontend/hwform.cpp	Thu Jan 03 15:59:30 2013 +0200
@@ -1883,11 +1883,13 @@
     userPrefix = userPrefix.replace("/","\\");
 #endif
 
-    QRect resolution = config->vid_Resolution();
+    std::pair<QRect, QRect> resolutions = config->vid_ResolutionPair();
     return QString("--prefix " + prefix
                    + " --user-prefix " + userPrefix
-                   + " --width " + QString::number(resolution.width())
-                   + " --height " + QString::number(resolution.height())
+                   + " --fullscreen-width " + QString::number(resolutions.first.width())
+                   + " --fullscreen-height " + QString::number(resolutions.first.height())
+                   + " --width " + QString::number(resolutions.second.width())
+                   + " --height " + QString::number(resolutions.second.height())
                    + " --volume " + QString::number(config->volume())
                    + (config->isMusicEnabled() ? "" : " --nomusic")
                    + (config->isSoundEnabled() ? "" : " --nosound")
--- a/hedgewars/ArgParsers.inc	Thu Jan 03 15:58:23 2013 +0200
+++ b/hedgewars/ArgParsers.inc	Thu Jan 03 15:59:30 2013 +0200
@@ -43,8 +43,10 @@
     WriteLn(stdout, ' --user-prefix [path to folder]');
     WriteLn(stdout, ' --locale [name of language file]');
     WriteLn(stdout, ' --nick [string]');
-    WriteLn(stdout, ' --width [screen width in pixels]');
-    WriteLn(stdout, ' --height [screen height in pixels]');
+    WriteLn(stdout, ' --fullscreen-width [fullscreen width in pixels]');
+    WriteLn(stdout, ' --fullscreen-height [fullscreen height in pixels]');
+    WriteLn(stdout, ' --width [window width in pixels]');
+    WriteLn(stdout, ' --height [window height in pixels]');
     WriteLn(stdout, ' --volume [sound level]');
     WriteLn(stdout, ' --frame-interval [milliseconds]');
     Writeln(stdout, ' --stereo [value]');
@@ -159,14 +161,15 @@
 procedure parseClassicParameter(cmdArray: Array of String; size:LongInt; var paramIndex:LongInt); Forward;
 
 function parseParameter(cmd:String; arg:String; var paramIndex:LongInt): Boolean;
-const videoArray: Array [1..3] of String = ('--width','--height','--depth');
+const videoArray: Array [1..5] of String = ('--fullscreen-width','--fullscreen-height', '--width', '--height', '--depth');
       audioArray: Array [1..3] of String = ('--volume','--nomusic','--nosound');
       otherArray: Array [1..3] of String = ('--locale','--fullscreen','--showfps');
-      mediaArray: Array [1..8] of String = ('--width','--height','--depth','--volume','--nomusic','--nosound','--locale','--fullscreen');
-      allArray: Array [1..12] of String = ('--width','--height','--depth','--volume','--nomusic','--nosound','--locale','--fullscreen','--showfps','--altdmg','--frame-interval','--low-quality');
-      reallyAll: array[0..28] of shortstring = (
-                '--prefix', '--user-prefix', '--locale', '--width', '--height', '--frame-interval', '--volume','--nomusic', '--nosound',
-                '--fullscreen', '--showfps', '--altdmg', '--low-quality', '--raw-quality', '--stereo', '--nick',
+      mediaArray: Array [1..10] of String = ('--fullscreen-width', '--fullscreen-height', '--width', '--height', '--depth', '--volume','--nomusic','--nosound','--locale','--fullscreen');
+      allArray: Array [1..14] of String = ('--fullscreen-width','--fullscreen-height', '--width', '--height', '--depth','--volume','--nomusic','--nosound','--locale','--fullscreen','--showfps','--altdmg','--frame-interval','--low-quality');
+      reallyAll: array[0..30] of shortstring = (
+                '--prefix', '--user-prefix', '--locale', '--fullscreen-width', '--fullscreen-height', '--width', 
+                '--height', '--frame-interval', '--volume','--nomusic', '--nosound',
+                '--fullscreen', '--showfps', '--altdmg', '--low-quality', '--raw-quality', '--stereo', '--nick', 
   {deprecated}  '--depth', '--set-video', '--set-audio', '--set-other', '--set-multimedia', '--set-everything',
   {internal}    '--internal', '--port', '--recorder', '--landpreview',
   {misc}        '--stats-only', '--gci', '--help');
@@ -180,38 +183,40 @@
 
     while (cmdIndex <= High(reallyAll)) and (cmd <> reallyAll[cmdIndex]) do inc(cmdIndex);
     case cmdIndex of
-        {--prefix}          0 : PathPrefix     := getStringParameter (arg, paramIndex, parseParameter);
-        {--user-prefix}     1 : UserPathPrefix := getStringParameter (arg, paramIndex, parseParameter);
-        {--locale}          2 : cLocaleFName   := getStringParameter (arg, paramIndex, parseParameter);
-        {--width}           3 : cScreenWidth   := getLongIntParameter(arg, paramIndex, parseParameter);
-        {--height}          4 : cScreenHeight  := getLongIntParameter(arg, paramIndex, parseParameter);
-        {--frame-interval}  5 : cTimerInterval := getLongIntParameter(arg, paramIndex, parseParameter);
-        {--volume}          6 : SetVolume       ( getLongIntParameter(arg, paramIndex, parseParameter) );
-        {--nomusic}         7 : SetMusic        ( false );
-        {--nosound}         8 : SetSound        ( false );
-        {--fullscreen}      9 : cFullScreen    := true;
-        {--showfps}        10 : cShowFPS       := true;
-        {--altdmg}         11 : cAltDamage     := true;
-        {--low-quality}    12 : cReducedQuality:= $FFFFFFFF xor rqLowRes;
-        {--raw-quality}    13 : cReducedQuality:= getLongIntParameter(arg, paramIndex, parseParameter);
-        {--stereo}         14 : setStereoMode   ( getLongIntParameter(arg, paramIndex, parseParameter) );
-        {--nick}           15 : UserNick       := parseNick( getStringParameter(arg, paramIndex, parseParameter) );
+        {--prefix}               0 : PathPrefix        := getStringParameter (arg, paramIndex, parseParameter);
+        {--user-prefix}          1 : UserPathPrefix    := getStringParameter (arg, paramIndex, parseParameter);
+        {--locale}               2 : cLocaleFName      := getStringParameter (arg, paramIndex, parseParameter);
+        {--fullscreen-width}     3 : cFullscreenWidth  := getLongIntParameter(arg, paramIndex, parseParameter);
+        {--fullscreen-height}    4 : cFullscreenHeight := getLongIntParameter(arg, paramIndex, parseParameter);
+        {--width}       5 : cWindowedWidth    := getLongIntParameter(arg, paramIndex, parseParameter);
+        {--height}      6 : cWindowedHeight   := getLongIntParameter(arg, paramIndex, parseParameter);
+        {--frame-interval}       7 : cTimerInterval    := getLongIntParameter(arg, paramIndex, parseParameter);
+        {--volume}               8 : SetVolume          ( getLongIntParameter(arg, paramIndex, parseParameter) );
+        {--nomusic}              9 : SetMusic           ( false );
+        {--nosound}             10 : SetSound           ( false );
+        {--fullscreen}          11 : cFullScreen       := true;
+        {--showfps}             12 : cShowFPS          := true;
+        {--altdmg}              13 : cAltDamage        := true;
+        {--low-quality}         14 : cReducedQuality   := $FFFFFFFF xor rqLowRes;
+        {--raw-quality}         15 : cReducedQuality   := getLongIntParameter(arg, paramIndex, parseParameter);
+        {--stereo}              16 : setStereoMode      ( getLongIntParameter(arg, paramIndex, parseParameter) );
+        {--nick}                17 : UserNick          := parseNick( getStringParameter(arg, paramIndex, parseParameter) );
         {deprecated options}
-        {--depth}          16 : setDepth(paramIndex);
-        {--set-video}      17 : parseClassicParameter(videoArray,3,paramIndex);
-        {--set-audio}      18 : parseClassicParameter(audioArray,3,paramIndex);
-        {--set-other}      19 : parseClassicParameter(otherArray,3,paramIndex);
-        {--set-multimedia} 20 : parseClassicParameter(mediaArray,8,paramIndex);
-        {--set-everything} 21 : parseClassicParameter(allArray,12,paramIndex);
+        {--depth}               18 : setDepth(paramIndex);
+        {--set-video}           19 : parseClassicParameter(videoArray,5,paramIndex);
+        {--set-audio}           20 : parseClassicParameter(audioArray,3,paramIndex);
+        {--set-other}           21 : parseClassicParameter(otherArray,3,paramIndex);
+        {--set-multimedia}      22 : parseClassicParameter(mediaArray,10,paramIndex);
+        {--set-everything}      23 : parseClassicParameter(allArray,14,paramIndex);
         {"internal" options}
-        {--internal}       22 : {note it, but do nothing};
-        {--port}            23 : setIpcPort( getLongIntParameter(arg, paramIndex, parseParameter), parseParameter );
-        {--recorder}       24 : startVideoRecording(paramIndex);
-        {--landpreview}    25 : GameType := gmtLandPreview;
+        {--internal}            24 : {note it, but do nothing};
+        {--port}                25 : setIpcPort( getLongIntParameter(arg, paramIndex, parseParameter), parseParameter );
+        {--recorder}            26 : startVideoRecording(paramIndex);
+        {--landpreview}         27 : GameType := gmtLandPreview;
         {anything else}
-        {--stats-only}     26 : statsOnlyGame();
-        {--gci}            27 : GciEasterEgg();
-        {--help}           28 : DisplayUsage();
+        {--stats-only}          28 : statsOnlyGame();
+        {--gci}                 29 : GciEasterEgg();
+        {--help}                30 : DisplayUsage();
     else
         begin
         //Asusme the first "non parameter" is the replay file, anything else is invalid
--- a/hedgewars/hwengine.pas	Thu Jan 03 15:58:23 2013 +0200
+++ b/hedgewars/hwengine.pas	Thu Jan 03 15:59:30 2013 +0200
@@ -271,8 +271,10 @@
            ((cNewScreenWidth <> cScreenWidth) or (cNewScreenHeight <> cScreenHeight)) then
         begin
             cScreenResizeDelay:= 0;
-            cScreenWidth:= cNewScreenWidth;
-            cScreenHeight:= cNewScreenHeight;
+            cWindowedWidth:= cNewScreenWidth;
+            cWindowedHeight:= cNewScreenHeight;
+            cScreenWidth:= cWindowedWidth;
+            cScreenHeight:= cWindowedHeight;
 
             ParseCommand('fullscr '+intToStr(LongInt(cFullScreen)), true);
             WriteLnToConsole('window resize: ' + IntToStr(cScreenWidth) + ' x ' + IntToStr(cScreenHeight));
--- a/hedgewars/uStore.pas	Thu Jan 03 15:58:23 2013 +0200
+++ b/hedgewars/uStore.pas	Thu Jan 03 15:59:30 2013 +0200
@@ -1142,6 +1142,17 @@
     if Length(s) = 0 then
          cFullScreen:= (not cFullScreen)
     else cFullScreen:= s = '1';
+    
+    if cFullScreen then
+        begin
+        cScreenWidth:= cFullscreenWidth;
+        cScreenHeight:= cFullscreenHeight;
+        end
+    else
+        begin
+        cScreenWidth:= cWindowedWidth;
+        cScreenHeight:= cWindowedHeight;
+        end;
 
     AddFileLog('Preparing to change video parameters...');
 {$IFDEF SDL13}
@@ -1219,15 +1230,18 @@
 
     if SDLwindow = nil then
         if cFullScreen then
-            SDLwindow:= SDL_CreateWindow('Hedgewars', x, y, cOrigScreenWidth, cOrigScreenHeight, flags or SDL_WINDOW_FULLSCREEN)
+            SDLwindow:= SDL_CreateWindow('Hedgewars', x, y, cScreenWidth, cScreenHeight, flags or SDL_WINDOW_FULLSCREEN)
         else
+            begin
             SDLwindow:= SDL_CreateWindow('Hedgewars', x, y, cScreenWidth, cScreenHeight, flags);
+            end;
     SDLTry(SDLwindow <> nil, true);
 {$ELSE}
     flags:= SDL_OPENGL or SDL_RESIZABLE;
     if cFullScreen then
+        begin
         flags:= flags or SDL_FULLSCREEN;
-
+        end;
     if not cOnlyStats then
         begin
     {$IFDEF WIN32}
--- a/hedgewars/uVariables.pas	Thu Jan 03 15:58:23 2013 +0200
+++ b/hedgewars/uVariables.pas	Thu Jan 03 15:59:30 2013 +0200
@@ -27,10 +27,12 @@
 /////// init flags ///////
     cMinScreenWidth    : LongInt;
     cMinScreenHeight   : LongInt;
+    cFullscreenWidth   : LongInt;
+    cFullscreenHeight  : LongInt;
+    cWindowedWidth     : LongInt;
+    cWindowedHeight    : LongInt;
     cScreenWidth       : LongInt;
     cScreenHeight      : LongInt;
-    cOrigScreenWidth   : LongInt;
-    cOrigScreenHeight  : LongInt;
     cNewScreenWidth    : LongInt;
     cNewScreenHeight   : LongInt;
     cScreenResizeDelay : LongWord;
@@ -2326,6 +2328,10 @@
 
     cScreenWidth    := 1024;
     cScreenHeight   := 768;
+    cFullscreenWidth    := 1024;
+    cFullscreenHeight   := 768;
+    cWindowedWidth    := 1024;
+    cWindowedHeight   := 768;
     cShowFPS        := false;
     cAltDamage      := true;
     cTimerInterval  := 8;
@@ -2508,8 +2514,6 @@
 
     cMinScreenWidth:= min(cScreenWidth, 640);
     cMinScreenHeight:= min(cScreenHeight, 480);
-    cOrigScreenWidth:= cScreenWidth;
-    cOrigScreenHeight:= cScreenHeight;
 
     cNewScreenWidth    := cScreenWidth;
     cNewScreenHeight   := cScreenHeight;