Engine:
authorsmxx
Sat, 27 Mar 2010 14:03:30 +0000
changeset 3107 1fa539758c10
parent 3106 3610efab8a32
child 3108 2d666993854a
Engine: * Added possibility to fade the screen in/out using black or white * Added flash effect to screenshot key * Added fade in for round start * Added fade out for round end * Goal display now ignores first tick. So long loading times no longer "eat" their visibility time.
hedgewars/GSHandlers.inc
hedgewars/uConsts.pas
hedgewars/uGears.pas
hedgewars/uMisc.pas
hedgewars/uWorld.pas
--- a/hedgewars/GSHandlers.inc	Sat Mar 27 12:05:01 2010 +0000
+++ b/hedgewars/GSHandlers.inc	Sat Mar 27 14:03:30 2010 +0000
@@ -694,7 +694,9 @@
     gtATStartGame: begin
                    AllInactive:= false;
                    if Gear^.Timer = 0 then
+                      begin
                       AddCaption(trmsg[sidStartFight], cWhiteColor, capgrpGameState);
+                      end
                    end;
  gtATSmoothWindCh: begin
                    if Gear^.Timer = 0 then
@@ -706,6 +708,12 @@
                    end;
    gtATFinishGame: begin
                    AllInactive:= false;
+                   if Gear^.Timer = 1000 then
+                      begin
+                      ScreenFade:= sfToBlack;
+                      ScreenFadeValue:= 0;
+                      ScreenFadeSpeed:= 1;
+                      end;
                    if Gear^.Timer = 0 then
                       begin
                       SendIPC('N');
--- a/hedgewars/uConsts.pas	Sat Mar 27 12:05:01 2010 +0000
+++ b/hedgewars/uConsts.pas	Sat Mar 27 14:03:30 2010 +0000
@@ -172,6 +172,9 @@
             PrevTexture, NextTexture: PTexture;
             end;
 
+    TScreenFade = (sfNone, sfInit, sfToBlack, sfFromBlack, sfToWhite, sfFromWhite);
+const sfMax = 1000;
+
 const
     // message constants
     errmsgCreateSurface   = 'Error creating SDL surface';
--- a/hedgewars/uGears.pas	Sat Mar 27 12:05:01 2010 +0000
+++ b/hedgewars/uGears.pas	Sat Mar 27 14:03:30 2010 +0000
@@ -1249,7 +1249,7 @@
                                   cWaterLine+WorldDy,
                                   LongInt(leftX)+WorldDx)
                 end;
-            amBee: DrawRotated(sprHandBee, hx, hy, hwSign(Gear^.dX), aangle);
+//            amBee: DrawRotated(sprHandBee, hx, hy, hwSign(Gear^.dX), aangle);
         end;
 
         case amt of
--- a/hedgewars/uMisc.pas	Sat Mar 27 12:05:01 2010 +0000
+++ b/hedgewars/uMisc.pas	Sat Mar 27 14:03:30 2010 +0000
@@ -38,6 +38,7 @@
     isSEBackup      : boolean;
     isInMultiShoot  : boolean;
     isSpeed         : boolean;
+    isFirstFrame    : boolean;
 
     fastUntilLag    : boolean;
 
@@ -126,6 +127,10 @@
 
     TextureList : PTexture;
 
+    ScreenFade : TScreenFade;
+    ScreenFadeValue : Longword;
+    ScreenFadeSpeed : Longword;
+
 
 procedure initModule;
 procedure freeModule;
@@ -554,6 +559,11 @@
 begin
 playSound(sndShutter);
 
+// flash
+ScreenFade:= sfFromWhite;
+ScreenFadeValue:= sfMax;
+ScreenFadeSpeed:= 5;
+
 size:= cScreenWidth * cScreenHeight * 3;
 p:= GetMem(size);
 
@@ -715,6 +725,7 @@
     isInMultiShoot  := false;
     isSpeed         := false;
     fastUntilLag    := false;
+    isFirstFrame    := true;
     cVSyncInUse     := true;    
     isSoundEnabled  := true;
     isSEBackup      := true;
@@ -735,6 +746,8 @@
     cHasFocus       := true;
     cInactDelay     := 1250;
     cAltDamage      := true;
+
+    ScreenFade      := sfNone;
 {$IFDEF DEBUGFILE}
 {$I-}
 {$IFDEF IPHONEOS}
--- a/hedgewars/uWorld.pas	Sat Mar 27 12:05:01 2010 +0000
+++ b/hedgewars/uWorld.pas	Sat Mar 27 14:03:30 2010 +0000
@@ -139,6 +139,11 @@
 if cDamagePercent <> 100 then
     g:= AddGoal(g, gfAny, gidDamageModifier, cDamagePercent);
 
+// fade in
+ScreenFade:= sfFromBlack;
+ScreenFadeValue:= sfMax;
+ScreenFadeSpeed:= 1;
+
 // modified mine timers?
 if cMinesTime <> 3000 then
     begin
@@ -163,7 +168,7 @@
 prevPoint.Y:= cScreenHeight div 2;
 WorldDx:=  - (LAND_WIDTH div 2) + cScreenWidth div 2;
 WorldDy:=  - (LAND_HEIGHT - (playHeight div 2)) + (cScreenHeight div 2);
-AMxShift:= 210
+AMxShift:= 210;
 end;
 
 procedure ShowAmmoMenu;
@@ -525,9 +530,9 @@
     begin
     with PHedgehog(CurrentHedgehog)^ do
         begin
-        if (Ammo^[CurSlot, CurAmmo].AmmoType = amBee) then
-            DrawRotatedF(sprTargetBee, TargetPoint.X + WorldDx, TargetPoint.Y + WorldDy, 0, 0, (RealTicks shr 3) mod 360)
-        else
+//        if (Ammo^[CurSlot, CurAmmo].AmmoType = amBee) then
+//            DrawRotatedF(sprTargetBee, TargetPoint.X + WorldDx, TargetPoint.Y + WorldDy, 0, 0, (RealTicks shr 3) mod 360)
+//        else
             DrawRotatedF(sprTargetP, TargetPoint.X + WorldDx, TargetPoint.Y + WorldDy, 0, 0, (RealTicks shr 3) mod 360);
         end;
     end;
@@ -725,7 +730,7 @@
 if fastUntilLag then DrawCentered(0, (cScreenHeight shr 1), SyncTexture);
 if isPaused then DrawCentered(0, (cScreenHeight shr 1), PauseTexture);
 
-if missionTimer <> 0 then
+if not isFirstFrame and (missionTimer <> 0) then
     begin
     if missionTimer > 0 then dec(missionTimer, Lag);
     if missionTimer < 0 then missionTimer:= 0; // avoid subtracting below 0
@@ -815,9 +820,39 @@
    DrawSprite(sprArrow, CursorPoint.X, cScreenHeight - CursorPoint.Y, (RealTicks shr 6) mod 8)
    end;
 
+glDisable(GL_TEXTURE_2D);
 
-glDisable(GL_TEXTURE_2D);
-glDisable(GL_BLEND)
+if ScreenFade <> sfNone then
+    begin
+    if not isFirstFrame then
+        case ScreenFade of
+            sfToBlack, sfToWhite:     if ScreenFadeValue + Lag * ScreenFadeSpeed < sfMax then
+                                          inc(ScreenFadeValue, Lag * ScreenFadeSpeed)
+                                      else
+                                          ScreenFade:= sfNone;
+            sfFromBlack, sfFromWhite: if ScreenFadeValue - Lag * ScreenFadeSpeed > 0 then
+                                          dec(ScreenFadeValue, Lag * ScreenFadeSpeed)
+                                      else
+                                          ScreenFade:= sfNone;
+            end;
+    if ScreenFade <> sfNone then
+        begin
+        case ScreenFade of
+            sfToBlack, sfFromBlack: glColor4f(0, 0, 0, ScreenFadeValue / 1000);
+            sfToWhite, sfFromWhite: glColor4f(1, 1, 1, ScreenFadeValue / 1000);
+            end;
+        glBegin(GL_TRIANGLE_FAN);
+        glVertex3f(-cScreenWidth, cScreenHeight, 0);
+        glVertex3f(-cScreenWidth, 0, 0);
+        glVertex3f(cScreenWidth, 0, 0);
+        glVertex3f(cScreenWidth, cScreenHeight, 0);
+        glEnd;
+        glColor4f(1, 1, 1, 1)
+        end
+    end;
+
+glDisable(GL_BLEND);
+isFirstFrame:= false
 end;
 
 procedure AddCaption(s: shortstring; Color: Longword; Group: TCapGroup);