Make sd-tint a theme variable so cophernue can tweak his sky tinting
authornemo
Wed, 16 Nov 2016 12:26:26 -0500
changeset 11900 19cb0de79287
parent 11899 dd3cbbde7876
child 11901 cb36d6df3814
Make sd-tint a theme variable so cophernue can tweak his sky tinting
hedgewars/uGears.pas
hedgewars/uLandObjects.pas
hedgewars/uStore.pas
hedgewars/uVariables.pas
hedgewars/uWorld.pas
--- a/hedgewars/uGears.pas	Wed Nov 16 18:06:02 2016 +0100
+++ b/hedgewars/uGears.pas	Wed Nov 16 12:26:26 2016 -0500
@@ -336,7 +336,7 @@
 
                     ChangeToSDClouds;
                     ChangeToSDFlakes;
-                    SetSkyColor(SDSkyColor.r * (SDTint/255) / 255, SDSkyColor.g * (SDTint/255) / 255, SDSkyColor.b * (SDTint/255) / 255);
+                    SetSkyColor(SDSkyColor.r * (SDTint.r/255) / 255, SDSkyColor.g * (SDTint.r/255) / 255, SDSkyColor.b * (SDTint.b/255) / 255);
                     Ammoz[amTardis].SkipTurns:= 9999;
                     Ammoz[amTardis].Probability:= 0;
                     end;
--- a/hedgewars/uLandObjects.pas	Wed Nov 16 18:06:02 2016 +0100
+++ b/hedgewars/uLandObjects.pas	Wed Nov 16 12:26:26 2016 -0500
@@ -567,6 +567,26 @@
         SDSkyColor.g:= SkyColor.g;
         SDSkyColor.b:= SkyColor.b;
         end
+    else if key = 'sd-tint' then
+        begin
+        i:= Pos(',', s);
+        SDTint.r:= StrToInt(Trim(Copy(s, 1, Pred(i))));
+        Delete(s, 1, i);
+        i:= Pos(',', s);
+        SDTint.g:= StrToInt(Trim(Copy(s, 1, Pred(i))));
+        Delete(s, 1, i);
+        SDTint.b:= StrToInt(Trim(s));
+        if GrayScale
+            then
+            begin
+            t:= round(SDTint.r * RGB_LUMINANCE_RED + SDTint.g * RGB_LUMINANCE_GREEN + SDTint.b * RGB_LUMINANCE_BLUE);
+            if t > 255 then
+                t:= 255;
+            SDTint.r:= t;
+            SDTint.g:= t;
+            SDTint.b:= t
+            end;
+        end
     else if key = 'border' then
         begin
         i:= Pos(',', s);
--- a/hedgewars/uStore.pas	Wed Nov 16 18:06:02 2016 +0100
+++ b/hedgewars/uStore.pas	Wed Nov 16 12:26:26 2016 -0500
@@ -1131,7 +1131,7 @@
         // clean the window from any previous content
         RenderClear();
         if SuddenDeathDmg then
-            SetSkyColor(SDSkyColor.r * (SDTint/255) / 255, SDSkyColor.g * (SDTint/255) / 255, SDSkyColor.b * (SDTint/255) / 255)
+            SetSkyColor(SDSkyColor.r * (SDTint.r/255) / 255, SDSkyColor.g * (SDTint.g/255) / 255, SDSkyColor.b * (SDTint.b/255) / 255)
         else if ((cReducedQuality and rqNoBackground) = 0) then
             SetSkyColor(SkyColor.r / 255, SkyColor.g / 255, SkyColor.b / 255)
         else
--- a/hedgewars/uVariables.pas	Wed Nov 16 18:06:02 2016 +0100
+++ b/hedgewars/uVariables.pas	Wed Nov 16 12:26:26 2016 -0500
@@ -206,7 +206,6 @@
 
     WaterColorArray : array[0..7] of HwColor4f;
     SDWaterColorArray : array[0..7] of HwColor4f;
-    SDTint          : LongInt;
 
     TargetCursorPoint     : TPoint;
     CursorPoint           : TPoint;
@@ -2407,7 +2406,7 @@
     bShowFinger: boolean;
     Frames: Longword;
     WaterColor, DeepWaterColor: TSDL_Color;
-    SkyColor, RQSkyColor, SDSkyColor: TSDL_Color;
+    SDTint, SkyColor, RQSkyColor, SDSkyColor: TSDL_Color;
     SkyOffset: LongInt;
 {$IFDEF COUNTTICKS}
     cntTicks: LongWord;
@@ -2592,7 +2591,11 @@
 
     SDWaterOpacity:= $80;
 
-    SDTint:= $80;
+    SDTint.r := $80;
+    SDTint.g := $80;
+    SDTint.b := $80;
+    SDTint.a := $FF;
+
     ExplosionBorderColorR:= 80;
     ExplosionBorderColorG:= 80;
     ExplosionBorderColorB:= 80;
--- a/hedgewars/uWorld.pas	Wed Nov 16 18:06:02 2016 +0100
+++ b/hedgewars/uWorld.pas	Wed Nov 16 12:26:26 2016 -0500
@@ -1193,7 +1193,7 @@
         // background
         ChangeDepth(RM, cStereo_Sky);
         if SuddenDeathDmg then
-            Tint(SDTint, SDTint, SDTint, $FF);
+            Tint(SDTint.r, SDTint.g, SDTint.b, $FF);
         DrawRepeated(sprSky, sprSkyL, sprSkyR, (WorldDx + LAND_WIDTH div 2) * 3 div 8, SkyOffset);
         ChangeDepth(RM, -cStereo_Horizon);
         DrawRepeated(sprHorizont, sprHorizontL, sprHorizontR, (WorldDx + LAND_WIDTH div 2) * 3 div 5, HorizontOffset);