hedgewars/uStore.pas
changeset 4889 f71e30eb1d37
parent 4874 f508adb769b8
child 4894 efcea232bbf6
equal deleted inserted replaced
4888:3c96e99468c5 4889:f71e30eb1d37
    37 procedure SetScale(f: GLfloat);
    37 procedure SetScale(f: GLfloat);
    38 function  RenderHelpWindow(caption, subcaption, description, extra: ansistring; extracolor: LongInt; iconsurf: PSDL_Surface; iconrect: PSDL_Rect): PTexture;
    38 function  RenderHelpWindow(caption, subcaption, description, extra: ansistring; extracolor: LongInt; iconsurf: PSDL_Surface; iconrect: PSDL_Rect): PTexture;
    39 procedure RenderWeaponTooltip(atype: TAmmoType);
    39 procedure RenderWeaponTooltip(atype: TAmmoType);
    40 procedure ShowWeaponTooltip(x, y: LongInt);
    40 procedure ShowWeaponTooltip(x, y: LongInt);
    41 procedure FreeWeaponTooltip;
    41 procedure FreeWeaponTooltip;
       
    42 procedure MakeCrossHairs;
    42 
    43 
    43 implementation
    44 implementation
    44 uses uMisc, uConsole, uMobile, uVariables, uUtils, uTextures, uRender, uRenderUtils, uCommands, uDebug;
    45 uses uMisc, uConsole, uMobile, uVariables, uUtils, uTextures, uRender, uRenderUtils, uCommands, uDebug;
    45 
    46 
    46 type TGPUVendor = (gvUnknown, gvNVIDIA, gvATI, gvIntel, gvApple);
    47 type TGPUVendor = (gvUnknown, gvNVIDIA, gvATI, gvIntel, gvApple);
    73 finalRect.w:= w + FontBorder * 2 + 4;
    74 finalRect.w:= w + FontBorder * 2 + 4;
    74 finalRect.h:= h + FontBorder * 2;
    75 finalRect.h:= h + FontBorder * 2;
    75 WriteInRect:= finalRect
    76 WriteInRect:= finalRect
    76 end;
    77 end;
    77 
    78 
       
    79 procedure MakeCrossHairs;
       
    80 var t: LongInt;
       
    81     tmpsurf, texsurf: PSDL_Surface;
       
    82     Color, i: Longword;
       
    83     s : shortstring;
       
    84 begin
       
    85 s:= Pathz[ptGraphics] + '/' + cCHFileName;
       
    86 tmpsurf:= LoadImage(s, ifAlpha or ifCritical);
       
    87 
       
    88 for t:= 0 to Pred(TeamsCount) do
       
    89     with TeamsArray[t]^ do
       
    90     begin
       
    91     texsurf:= SDL_CreateRGBSurface(SDL_SWSURFACE, tmpsurf^.w, tmpsurf^.h, 32, RMask, GMask, BMask, AMask);
       
    92     TryDo(texsurf <> nil, errmsgCreateSurface, true);
       
    93 
       
    94     Color:= Clan^.Color;
       
    95     Color:= SDL_MapRGB(texsurf^.format, Color shr 16, Color shr 8, Color and $FF);
       
    96     SDL_FillRect(texsurf, nil, Color);
       
    97 
       
    98     SDL_UpperBlit(tmpsurf, nil, texsurf, nil);
       
    99 
       
   100     TryDo(tmpsurf^.format^.BytesPerPixel = 4, 'Ooops', true);
       
   101 
       
   102     if SDL_MustLock(texsurf) then
       
   103         SDLTry(SDL_LockSurface(texsurf) >= 0, true);
       
   104 
       
   105     // make black pixel be alpha-transparent
       
   106     for i:= 0 to texsurf^.w * texsurf^.h - 1 do
       
   107         if PLongwordArray(texsurf^.pixels)^[i] = AMask then PLongwordArray(texsurf^.pixels)^[i]:= (RMask or GMask or BMask) and Color;
       
   108 
       
   109     if SDL_MustLock(texsurf) then
       
   110         SDL_UnlockSurface(texsurf);
       
   111 
       
   112     if CrosshairTex <> nil then FreeTexture(CrosshairTex);
       
   113     CrosshairTex:= Surface2Tex(texsurf, false);
       
   114     SDL_FreeSurface(texsurf)
       
   115     end;
       
   116 
       
   117 SDL_FreeSurface(tmpsurf)
       
   118 end;
       
   119 
    78 procedure StoreLoad;
   120 procedure StoreLoad;
    79 var s: shortstring;
   121 var s: shortstring;
    80 
   122 
    81     procedure WriteNames(Font: THWFont);
   123     procedure WriteNames(Font: THWFont);
    82     var t: LongInt;
   124     var t: LongInt;
   150         DrawHealthY:= drY;
   192         DrawHealthY:= drY;
   151         for i:= 0 to 7 do
   193         for i:= 0 to 7 do
   152             with Hedgehogs[i] do
   194             with Hedgehogs[i] do
   153                 if Gear <> nil then
   195                 if Gear <> nil then
   154                     begin
   196                     begin
   155                     NameTagTex:= RenderStringTex(Name, Clan^.Color, CheckCJKFont(Name,fnt16));
   197                     NameTagTex:= RenderStringTex(Name, Clan^.Color, fnt16);
   156                     if Hat <> 'NoHat' then
   198                     if Hat <> 'NoHat' then
   157                         begin
   199                         begin
   158                         if (Length(Hat) > 39) and (Copy(Hat,1,8) = 'Reserved') and (Copy(Hat,9,32) = PlayerHash) then
   200                         if (Length(Hat) > 39) and (Copy(Hat,1,8) = 'Reserved') and (Copy(Hat,9,32) = PlayerHash) then
   159                             LoadHedgehogHat(Gear, 'Reserved/' + Copy(Hat,9,Length(s)-8))
   201                             LoadHedgehogHat(Gear, 'Reserved/' + Copy(Hat,9,Length(s)-8))
   160                         else
   202                         else
   173         DrawRoundRect(@r, cWhiteColor, cNearBlackColor, iconsurf, true);
   215         DrawRoundRect(@r, cWhiteColor, cNearBlackColor, iconsurf, true);
   174         ropeIconTex:= Surface2Tex(iconsurf, false);
   216         ropeIconTex:= Surface2Tex(iconsurf, false);
   175         SDL_FreeSurface(iconsurf);
   217         SDL_FreeSurface(iconsurf);
   176         iconsurf:= nil;
   218         iconsurf:= nil;
   177         end;
   219         end;
   178     end;
       
   179 
       
   180     procedure MakeCrossHairs;
       
   181     var t: LongInt;
       
   182         tmpsurf, texsurf: PSDL_Surface;
       
   183         Color, i: Longword;
       
   184     begin
       
   185     s:= Pathz[ptGraphics] + '/' + cCHFileName;
       
   186     tmpsurf:= LoadImage(s, ifAlpha or ifCritical);
       
   187 
       
   188     for t:= 0 to Pred(TeamsCount) do
       
   189         with TeamsArray[t]^ do
       
   190         begin
       
   191         texsurf:= SDL_CreateRGBSurface(SDL_SWSURFACE, tmpsurf^.w, tmpsurf^.h, 32, RMask, GMask, BMask, AMask);
       
   192         TryDo(texsurf <> nil, errmsgCreateSurface, true);
       
   193 
       
   194         Color:= Clan^.Color;
       
   195         Color:= SDL_MapRGB(texsurf^.format, Color shr 16, Color shr 8, Color and $FF);
       
   196         SDL_FillRect(texsurf, nil, Color);
       
   197 
       
   198         SDL_UpperBlit(tmpsurf, nil, texsurf, nil);
       
   199 
       
   200         TryDo(tmpsurf^.format^.BytesPerPixel = 4, 'Ooops', true);
       
   201 
       
   202         if SDL_MustLock(texsurf) then
       
   203             SDLTry(SDL_LockSurface(texsurf) >= 0, true);
       
   204 
       
   205         // make black pixel be alpha-transparent
       
   206         for i:= 0 to texsurf^.w * texsurf^.h - 1 do
       
   207             if PLongwordArray(texsurf^.pixels)^[i] = AMask then PLongwordArray(texsurf^.pixels)^[i]:= (RMask or GMask or BMask) and Color;
       
   208 
       
   209         if SDL_MustLock(texsurf) then
       
   210             SDL_UnlockSurface(texsurf);
       
   211 
       
   212         CrosshairTex:= Surface2Tex(texsurf, false);
       
   213         SDL_FreeSurface(texsurf)
       
   214         end;
       
   215 
       
   216     SDL_FreeSurface(tmpsurf)
       
   217     end;
   220     end;
   218 
   221 
   219     procedure InitHealth;
   222     procedure InitHealth;
   220     var i, t: LongInt;
   223     var i, t: LongInt;
   221     begin
   224     begin