Engine:
authorsmxx
Fri, 07 May 2010 10:54:07 +0000
changeset 3445 1ce844170014
parent 3444 9d501dc22f71
child 3446 1be74e601960
Engine: * Added possibility to use hats with areas tinted with team color Frontend: * Updated hat preview to include tinted areas
QTfrontend/hats.cpp
hedgewars/GearDrawing.inc
hedgewars/uStore.pas
hedgewars/uWorld.pas
share/hedgewars/Data/Graphics/Hats/TeamCap.png
share/hedgewars/Data/Graphics/Hats/TeamHair.png
--- a/QTfrontend/hats.cpp	Fri May 07 09:57:12 2010 +0000
+++ b/QTfrontend/hats.cpp	Fri May 07 10:54:07 2010 +0000
@@ -48,6 +48,8 @@
         QPainter painter(&tmppix);
         painter.drawPixmap(QPoint(0, 5), hhpix);
         painter.drawPixmap(QPoint(0, 0), pix.copy(0, 0, 32, 32));
+        if(pix.width() > 32)
+            painter.drawPixmap(QPoint(0, 0), pix.copy(32, 0, 32, 32));
         painter.end();
 
         hats.append(qMakePair(str, QIcon(tmppix)));
--- a/hedgewars/GearDrawing.inc	Fri May 07 09:57:12 2010 +0000
+++ b/hedgewars/GearDrawing.inc	Fri May 07 10:54:07 2010 +0000
@@ -184,8 +184,17 @@
                            DxDy2Angle(CurAmmoGear^.dY, CurAmmoGear^.dX) + dAngle);
                    with HH^ do
                        if (HatTex <> nil) then
+                           begin
                            DrawRotatedTextureF(HatTex, 1.0, -1.0, -6.0, sx, sy, 0, i, 32, 32,
                                i*DxDy2Angle(CurAmmoGear^.dY, CurAmmoGear^.dX) + hAngle);
+                           if HatTex^.w > 32 then
+                               begin
+                               Tint(HH^.Team^.Clan^.Color);
+                               DrawRotatedTextureF(HatTex, 1.0, -1.0, -6.0, sx, sy, 32, i, 32, 32,
+                                   i*DxDy2Angle(CurAmmoGear^.dY, CurAmmoGear^.dX) + hAngle);
+                               Tint($FF, $FF, $FF, $FF)
+                               end
+                           end
                    end;
                 DrawAltWeapon(Gear, sx, sy);
                 defaultPos:= false
@@ -199,14 +208,29 @@
                         0);
                 with HH^ do
                     if (HatTex <> nil) then
-                       DrawTextureF(HatTex,
-                           1,
-                           sx,
-                           hwRound(Gear^.Y) - 8 + WorldDy,
-                           0,
-                           hwSign(Gear^.dX),
-                           32,
-                           32);
+                        begin
+                        DrawTextureF(HatTex,
+                            1,
+                            sx,
+                            hwRound(Gear^.Y) - 8 + WorldDy,
+                            0,
+                            hwSign(Gear^.dX),
+                            32,
+                            32);
+                        if HatTex^.w > 32 then
+                            begin
+                            Tint(HH^.Team^.Clan^.Color);
+                            DrawTextureF(HatTex,
+                                1,
+                                sx,
+                                hwRound(Gear^.Y) - 8 + WorldDy,
+                                32,
+                                hwSign(Gear^.dX),
+                                32,
+                                32);
+                            Tint($FF, $FF, $FF, $FF)
+                            end
+                        end;
                 defaultPos:= false
                 end;
             gtShover: DrawRotated(sprHandBaseball, hx, hy, hwSign(Gear^.dX), aangle + 180);
@@ -478,6 +502,7 @@
     if (HatTex <> nil)
     and (HatVisibility > 0) then
         if DefaultPos then
+            begin
             DrawTextureF(HatTex,
                 HatVisibility,
                 sx,
@@ -485,8 +510,23 @@
                 (RealTicks div 128 + Gear^.Pos) mod 19,
                 hwSign(Gear^.dX),
                 32,
-                32)
+                32);
+            if HatTex^.w > 32 then
+                begin
+                Tint(HH^.Team^.Clan^.Color);
+                DrawTextureF(HatTex,
+                    HatVisibility,
+                    sx,
+                    hwRound(Gear^.Y) - 8 + WorldDy,
+                    (RealTicks div 128 + Gear^.Pos) mod 19 + 32,
+                    hwSign(Gear^.dX),
+                    32,
+                    32);
+                Tint($FF, $FF, $FF, $FF)
+                end
+            end
         else
+            begin
             DrawTextureF(HatTex,
                 HatVisibility,
                 sx,
@@ -495,6 +535,20 @@
                 hwSign(Gear^.dX)*m,
                 32,
                 32);
+            if HatTex^.w > 32 then
+                begin
+                Tint(HH^.Team^.Clan^.Color);
+                DrawTextureF(HatTex,
+                    HatVisibility,
+                    sx,
+                    hwRound(Gear^.Y) - 8 + WorldDy,
+                    32,
+                    hwSign(Gear^.dX)*m,
+                    32,
+                    32);
+                Tint($FF, $FF, $FF, $FF)
+                end
+            end
     end;
 if (Gear^.State and gstHHDriven) <> 0 then
     begin
--- a/hedgewars/uStore.pas	Fri May 07 09:57:12 2010 +0000
+++ b/hedgewars/uStore.pas	Fri May 07 10:54:07 2010 +0000
@@ -81,6 +81,7 @@
 procedure ShowWeaponTooltip(x, y: LongInt);
 procedure FreeWeaponTooltip;
 procedure Tint(r, g, b, a: Byte); inline;
+procedure Tint(c: Longword); inline;
 
 implementation
 uses uMisc, uConsole, uLocale{$IFDEF IPHONEOS}, PascalExports{$ENDIF};
@@ -102,6 +103,11 @@
 lastTint:= nc;
 end;
 
+procedure Tint(c: Longword); inline;
+begin
+Tint(((c shr 16) and $FF), ((c shr 8) and $FF), (c and $FF), $FF);
+end;
+
 procedure DrawRoundRect(rect: PSDL_Rect; BorderColor, FillColor: Longword; Surface: PSDL_Surface; Clear: boolean);
 var r: TSDL_Rect;
 begin
--- a/hedgewars/uWorld.pas	Fri May 07 09:57:12 2010 +0000
+++ b/hedgewars/uWorld.pas	Fri May 07 10:54:07 2010 +0000
@@ -758,7 +758,7 @@
       highlight:= bShowFinger and (CurrentTeam = TeamsArray[t]) and ((RealTicks mod 1000) < 500);
       
       if highlight then
-         Tint(((Clan^.Color shr 16) and $FF), ((Clan^.Color shr 8) and $FF), (Clan^.Color and $FF), $FF);
+         Tint(Clan^.Color);
 
       // draw name
       DrawTexture(-NameTagTex^.w - 16, cScreenHeight + DrawHealthY, NameTagTex);
Binary file share/hedgewars/Data/Graphics/Hats/TeamCap.png has changed
Binary file share/hedgewars/Data/Graphics/Hats/TeamHair.png has changed