Simplify the hat format for unanimated hats
authorWuzzy <almikes@aol.com>
Tue, 15 Nov 2016 01:49:36 +0100
changeset 11882 bbd0cb0564c5
parent 11881 34ede05e4d4f
child 11883 bc738a87d8ab
Simplify the hat format for unanimated hats For simple hats which are not animated, a single 32×32 image is now enough. For simple clan hats, use 64×32 with the color overlay at the right.
ChangeLog.txt
hedgewars/uGearsRender.pas
--- a/ChangeLog.txt	Tue Nov 15 01:25:37 2016 +0100
+++ b/ChangeLog.txt	Tue Nov 15 01:49:36 2016 +0100
@@ -15,6 +15,7 @@
  + Added "Forts" to map type selection. This makes the mode easier selectable/discoverable. Also the slider can be used to adjust the distance between forts.
  + Render graves behind everything else, so that they can't hide mines etc.
  + Several new sound effects for weapons and utilities
+ * Simplified hat format for unanimated hats; a single 32×32 image is enough. For clan hats, use size 64×32, with the color overlay at the right
  + Small visual effects enhancements
  + Briefly show theme and music authors in chat at start of game
  * Fixed air-strikes drops being off-center
--- a/hedgewars/uGearsRender.pas	Tue Nov 15 01:25:37 2016 +0100
+++ b/hedgewars/uGearsRender.pas	Tue Nov 15 01:49:36 2016 +0100
@@ -916,26 +916,66 @@
         and (HatVisibility > 0) then
             if DefaultPos then
                 begin
-                DrawTextureF(curhat,
-                    HatVisibility,
-                    sx,
-                    sy - 5,
-                    (RealTicks div 128 + Gear^.Pos) mod 19,
-                    sign,
-                    32,
-                    32);
-                if curhat^.w > 64 then
+                // Simple hat with automatic offset
+                if (curhat^.h = 32) and ((curhat^.w = 32) or (curhat^.w = 64)) then
                     begin
-                    Tint(HH^.Team^.Clan^.Color shl 8 or $FF);
+                    // Frame
+                    tx := (RealTicks div 128 + Gear^.Pos) mod 19;
+                    // Hat offset
+                    ty := 0;
+                    if (tx = 2) or (tx = 7) or (tx = 12) then
+                        ty := 1
+                    else if tx = 16 then
+                        ty := -1;
+                    // First frame: No tint
+                    DrawTextureF(curhat,
+                        HatVisibility,
+                        sx,
+                        sy - 5 + ty,
+                        0,
+                        sign,
+                        32,
+                        32);
+                    // Second frame: Clan tint (if present)
+                    if (curhat^.w = 64) then
+                        begin
+                        Tint(HH^.Team^.Clan^.Color shl 8 or $FF);
+                        DrawTextureF(curhat,
+                            HatVisibility,
+                            sx,
+                            sy - 5 + ty,
+                            1,
+                            sign,
+                            32,
+                            32);
+                        untint
+                        end
+                    end
+                else
+                    // Classic animated hat (all frames drawn manually)
+                    begin
                     DrawTextureF(curhat,
                         HatVisibility,
                         sx,
                         sy - 5,
-                        (RealTicks div 128 + Gear^.Pos) mod 19 + 32,
+                        (RealTicks div 128 + Gear^.Pos) mod 19,
                         sign,
                         32,
                         32);
-                    untint
+                    // Apply clan tint
+                    if curhat^.w > 64 then
+                        begin
+                        Tint(HH^.Team^.Clan^.Color shl 8 or $FF);
+                        DrawTextureF(curhat,
+                            HatVisibility,
+                            sx,
+                            sy - 5,
+                            (RealTicks div 128 + Gear^.Pos) mod 19 + 32,
+                            sign,
+                            32,
+                            32);
+                        untint
+                        end
                     end;
                 if HH^.Team^.hasGone then untint
                 end
@@ -949,14 +989,18 @@
                     sign*m,
                     32,
                     32);
-                if curhat^.w > 64 then
+                if (curhat^.w > 64) or ((curhat^.w = 64) and (curhat^.h = 32)) then
                     begin
+                    if ((curhat^.w = 64) and (curhat^.h = 32)) then
+                        tx := 1
+                    else
+                        tx := 32;
                     Tint(HH^.Team^.Clan^.Color shl 8 or $FF);
                     DrawTextureF(curhat,
                         HatVisibility,
                         sx,
                         sy - 5,
-                        32,
+                        tx,
                         sign*m,
                         32,
                         32);