hedgewars/uStore.pas
changeset 10102 bab8a3cccdf8
parent 10015 4feced261c68
child 10103 9c24233ca1c5
equal deleted inserted replaced
10101:781f0c19e59b 10102:bab8a3cccdf8
    97 
    97 
    98 const
    98 const
    99     cHHFileName = 'Hedgehog';
    99     cHHFileName = 'Hedgehog';
   100     cCHFileName = 'Crosshair';
   100     cCHFileName = 'Crosshair';
   101 
   101 
   102 function WriteInRect(Surface: PSDL_Surface; X, Y: LongInt; Color: LongWord; Font: THWFont; s: ansistring): TSDL_Rect;
   102 function WriteInRect(Surface: PSDL_Surface; X, Y: LongInt; Color: LongWord; Font: THWFont; s: PChar): TSDL_Rect;
   103 var w, h: LongInt;
   103 var w, h: LongInt;
   104     tmpsurf: PSDL_Surface;
   104     tmpsurf: PSDL_Surface;
   105     clr: TSDL_Color;
   105     clr: TSDL_Color;
   106     finalRect: TSDL_Rect;
   106     finalRect: TSDL_Rect;
   107 begin
   107 begin
   108 w:= 0; h:= 0; // avoid compiler hints
   108 w:= 0; h:= 0; // avoid compiler hints
   109 TTF_SizeUTF8(Fontz[Font].Handle, Str2PChar(s), @w, @h);
   109 TTF_SizeUTF8(Fontz[Font].Handle, s, @w, @h);
   110 finalRect.x:= X + cFontBorder + 2;
   110 finalRect.x:= X + cFontBorder + 2;
   111 finalRect.y:= Y + cFontBorder;
   111 finalRect.y:= Y + cFontBorder;
   112 finalRect.w:= w + cFontBorder * 2 + 4;
   112 finalRect.w:= w + cFontBorder * 2 + 4;
   113 finalRect.h:= h + cFontBorder * 2;
   113 finalRect.h:= h + cFontBorder * 2;
   114 clr.r:= Color shr 16;
   114 clr.r:= Color shr 16;
   115 clr.g:= (Color shr 8) and $FF;
   115 clr.g:= (Color shr 8) and $FF;
   116 clr.b:= Color and $FF;
   116 clr.b:= Color and $FF;
   117 tmpsurf:= TTF_RenderUTF8_Blended(Fontz[Font].Handle, Str2PChar(s), clr);
   117 tmpsurf:= TTF_RenderUTF8_Blended(Fontz[Font].Handle, s, clr);
   118 tmpsurf:= doSurfaceConversion(tmpsurf);
   118 tmpsurf:= doSurfaceConversion(tmpsurf);
   119 SDLTry(tmpsurf <> nil, true);
   119 SDLTry(tmpsurf <> nil, true);
   120 SDL_UpperBlit(tmpsurf, nil, Surface, @finalRect);
   120 SDL_UpperBlit(tmpsurf, nil, Surface, @finalRect);
   121 SDL_FreeSurface(tmpsurf);
   121 SDL_FreeSurface(tmpsurf);
   122 finalRect.x:= X;
   122 finalRect.x:= X;
  1320     tmpline:= tmpdesc;
  1320     tmpline:= tmpdesc;
  1321     SplitByChar(tmpline, tmpdesc, '|');
  1321     SplitByChar(tmpline, tmpdesc, '|');
  1322     r2:= r;
  1322     r2:= r;
  1323     if tmpline <> '' then
  1323     if tmpline <> '' then
  1324         begin
  1324         begin
  1325         r:= WriteInRect(tmpsurf, cFontBorder + 2, r.y + r.h, $ff707070, font, tmpline);
  1325         r:= WriteInRect(tmpsurf, cFontBorder + 2, r.y + r.h, $ff707070, font, Str2PChar(tmpline));
  1326 
  1326 
  1327         // render highlighted caption (if there is a ':')
  1327         // render highlighted caption (if there is a ':')
  1328         tmpline2:= _S'';
  1328         tmpline2:= _S'';
  1329         SplitByChar(tmpline, tmpline2, ':');
  1329         SplitByChar(tmpline, tmpline2, ':');
  1330         if tmpline2 <> _S'' then
  1330         if tmpline2 <> _S'' then
  1331             WriteInRect(tmpsurf, cFontBorder + 2, r2.y + r2.h, $ffc7c7c7, font, tmpline + ':');
  1331             WriteInRect(tmpsurf, cFontBorder + 2, r2.y + r2.h, $ffc7c7c7, font, Str2PChar(tmpline + ':'));
  1332         end
  1332         end
  1333     end;
  1333     end;
  1334 
  1334 
  1335 if extra <> '' then
  1335 if extra <> '' then
  1336     r:= WriteInRect(tmpsurf, cFontBorder + 2, r.y + r.h, extracolor, font, extra);
  1336     r:= WriteInRect(tmpsurf, cFontBorder + 2, r.y + r.h, extracolor, font, extra);