'Reduce quality' patch by nemo
authorunc0rr
Fri, 20 Feb 2009 14:12:16 +0000
changeset 1812 3d4692e825e7
parent 1811 1b9e33623b7e
child 1813 cfe1481e0247
'Reduce quality' patch by nemo + my addition to save some CPU time (don't even create visual gears)
QTfrontend/game.cpp
QTfrontend/gameuiconfig.cpp
QTfrontend/gameuiconfig.h
QTfrontend/pages.cpp
QTfrontend/pages.h
hedgewars/hwengine.dpr
hedgewars/uMisc.pas
hedgewars/uVisualGears.pas
hedgewars/uWorld.pas
--- a/QTfrontend/game.cpp	Fri Feb 20 11:58:58 2009 +0000
+++ b/QTfrontend/game.cpp	Fri Feb 20 14:12:16 2009 +0000
@@ -279,6 +279,7 @@
 	arguments << (config->isAltDamageEnabled() ? "1" : "0");
 	arguments << config->netNick().toUtf8().toBase64();
 	arguments << (config->isMusicEnabled() ? "1" : "0");
+	arguments << (config->isReducedQuality() ? "1" : "0");
 	return arguments;
 }
 
--- a/QTfrontend/gameuiconfig.cpp	Fri Feb 20 11:58:58 2009 +0000
+++ b/QTfrontend/gameuiconfig.cpp	Fri Feb 20 14:12:16 2009 +0000
@@ -44,6 +44,7 @@
 	bool ffscr=value("video/frontendfullscreen", false).toBool();
 	Form->ui.pageOptions->CBFrontendFullscreen->setChecked(ffscr);
 
+	Form->ui.pageOptions->CBReduceQuality->setChecked(value("video/reducequality", false).toBool());
 	Form->ui.pageOptions->CBEnableSound->setChecked(value("audio/sound", true).toBool());
 	Form->ui.pageOptions->CBEnableMusic->setChecked(value("audio/music", true).toBool());
 	Form->ui.pageOptions->volumeBox->setValue(value("audio/volume", 100).toUInt());
@@ -88,6 +89,9 @@
 {
 	setValue("video/resolution", Form->ui.pageOptions->CBResolution->currentText());
 	setValue("video/fullscreen", vid_Fullscreen());
+
+	setValue("video/reducequality", isReducedQuality());
+
 	bool ffscr=isFrontendFullscreen();
 	setValue("video/frontendfullscreen", ffscr);
 	emit frontendFullscreen(ffscr);
@@ -132,6 +136,11 @@
 	return Form->ui.pageOptions->CBFullscreen->isChecked();
 }
 
+bool GameUIConfig::isReducedQuality() const
+{
+  return Form->ui.pageOptions->CBReduceQuality->isChecked();
+}
+
 bool GameUIConfig::isFrontendFullscreen() const
 {
   return Form->ui.pageOptions->CBFrontendFullscreen->isChecked();
--- a/QTfrontend/gameuiconfig.h	Fri Feb 20 11:58:58 2009 +0000
+++ b/QTfrontend/gameuiconfig.h	Fri Feb 20 14:12:16 2009 +0000
@@ -44,6 +44,7 @@
 	quint8 timerInterval();
 	quint8 bitDepth();
 	QString netNick();
+	bool isReducedQuality() const;
 	bool isFrontendFullscreen() const;
 	void resizeToConfigValues();
 
--- a/QTfrontend/pages.cpp	Fri Feb 20 11:58:58 2009 +0000
+++ b/QTfrontend/pages.cpp	Fri Feb 20 14:12:16 2009 +0000
@@ -384,6 +384,10 @@
 		GBAfpslayout->addWidget(maxfps);
 		GBAlayout->addLayout(GBAfpslayout);
 
+		CBReduceQuality = new QCheckBox(AGGroupBox);
+		CBReduceQuality->setText(QCheckBox::tr("Reduce Quality"));
+		GBAlayout->addWidget(CBReduceQuality);
+
 		CBFullscreen = new QCheckBox(AGGroupBox);
 		CBFullscreen->setText(QCheckBox::tr("Fullscreen"));
 		GBAlayout->addWidget(CBFullscreen);
--- a/QTfrontend/pages.h	Fri Feb 20 11:58:58 2009 +0000
+++ b/QTfrontend/pages.h	Fri Feb 20 14:12:16 2009 +0000
@@ -216,6 +216,7 @@
 	QLabel *labelNN;
 	QSpinBox * volumeBox;
 	QLineEdit *editNetNick;
+	QCheckBox *CBReduceQuality;
 };
 
 class PageNet : public AbstractPage
--- a/hedgewars/hwengine.dpr	Fri Feb 20 11:58:58 2009 +0000
+++ b/hedgewars/hwengine.dpr	Fri Feb 20 14:12:16 2009 +0000
@@ -187,7 +187,7 @@
 {$ENDIF}
 
 case ParamCount of
-15: begin
+16: begin
      val(ParamStr(2), cScreenWidth);
      val(ParamStr(3), cScreenHeight);
      cInitWidth:= cScreenWidth;
@@ -205,6 +205,7 @@
      cAltDamage:= ParamStr(13) = '1';
      UserNick:= DecodeBase64(ParamStr(14));
      isMusicEnabled:= ParamStr(15) = '1';
+     cReducedQuality:= ParamStr(16) = '1';
      for p:= Succ(Low(TPathType)) to High(TPathType) do
          if p <> ptMapCurrent then Pathz[p]:= PathPrefix + '/' + Pathz[p]
      end;
--- a/hedgewars/uMisc.pas	Fri Feb 20 11:58:58 2009 +0000
+++ b/hedgewars/uMisc.pas	Fri Feb 20 14:12:16 2009 +0000
@@ -70,6 +70,7 @@
 	cCaseFactor   : Longword = 5;  {0..9}
 	cLandAdditions: Longword = 4;
 	cFullScreen   : boolean = true;
+	cReducedQuality : boolean = false;
 	cLocaleFName  : shortstring = 'en.txt';
 	cSeed         : shortstring = '';
 	cInitVolume   : LongInt = 128;
--- a/hedgewars/uVisualGears.pas	Fri Feb 20 11:58:58 2009 +0000
+++ b/hedgewars/uVisualGears.pas	Fri Feb 20 14:12:16 2009 +0000
@@ -176,6 +176,12 @@
 		exit
 		end;
 
+if cReducedQuality then
+	begin
+	AddVisualGear:= nil;
+	exit
+	end;
+
 New(Result);
 FillChar(Result^, sizeof(TVisualGear), 0);
 Result^.X:= int2hwFloat(X);
--- a/hedgewars/uWorld.pas	Fri Feb 20 11:58:58 2009 +0000
+++ b/hedgewars/uWorld.pas	Fri Feb 20 14:12:16 2009 +0000
@@ -79,7 +79,10 @@
 if bShowAmmoMenu then
    begin
    if AMxShift = 210 then prevPoint.X:= 0;
-   if AMxShift > 0 then dec(AMxShift, MENUSPEED);
+   if cReducedQuality then
+       AMxShift:= 0
+   else
+       if AMxShift > 0 then dec(AMxShift, MENUSPEED);
    end else
    begin
    if AMxShift = 0 then
@@ -89,7 +92,10 @@
       prevPoint:= CursorPoint;
       SDL_WarpMouse(CursorPoint.X, CursorPoint.Y)
       end;
-   if AMxShift < 210 then inc(AMxShift, MENUSPEED);
+   if cReducedQuality then
+       AMxShift:= 210
+   else
+       if AMxShift < 210 then inc(AMxShift, MENUSPEED);
    end;
 
 if CurrentTeam = nil then exit;
@@ -193,17 +199,21 @@
 
 if not isPaused then MoveCamera;
 
-// background
-DrawRepeated(sprSky, WorldDx * 3 div 8);
-DrawRepeated(sprHorizont, WorldDx * 3 div 5);
+if not cReducedQuality then
+    begin
+    // background
+    DrawRepeated(sprSky, WorldDx * 3 div 8);
+    DrawRepeated(sprHorizont, WorldDx * 3 div 5);
 
-DrawVisualGears(0);
+    DrawVisualGears(0);
 
-// Waves
-{$WARNINGS OFF}
-for i:= -1 to cWaterSprCount do DrawSprite(sprWater,  i * 125  + ((WorldDx + (RealTicks shr 6)      ) mod 125), cWaterLine + WorldDy - 64, 0);
-for i:= -1 to cWaterSprCount do DrawSprite(sprWater,  i * 125  + ((WorldDx - (RealTicks shr 6) + 100) mod 125), cWaterLine + WorldDy - 48, 0);
-{$WARNINGS ON}
+    // Waves
+    {$WARNINGS OFF}
+    for i:= -1 to cWaterSprCount do DrawSprite(sprWater,  i * 125  + ((WorldDx + (RealTicks shr 6)      ) mod 125), cWaterLine + WorldDy - 64, 0);
+    for i:= -1 to cWaterSprCount do DrawSprite(sprWater,  i * 125  + ((WorldDx - (RealTicks shr 6) + 100) mod 125), cWaterLine + WorldDy - 48, 0);
+    {$WARNINGS ON}
+    end;
+
 
 DrawLand(WorldDx, WorldDy);
 // Water
@@ -249,7 +259,7 @@
 
 DrawGears;
 
-DrawVisualGears(1);
+if not cReducedQuality then DrawVisualGears(1);
 
 // Waves
 {$WARNINGS OFF}
@@ -257,7 +267,6 @@
 for i:= -1 to cWaterSprCount do DrawSprite(sprWater,  i * 125  + ((WorldDx - (RealTicks shr 6) +  50) mod 125), cWaterLine + WorldDy - 16, 0);
 for i:= -1 to cWaterSprCount do DrawSprite(sprWater,  i * 125  + ((WorldDx + (RealTicks shr 6) +  75) mod 125), cWaterLine + WorldDy     , 0);
 {$WARNINGS ON}
-
 // Turn time
 if TurnTimeLeft <> 0 then
    begin