hedgewars/uStore.pas
changeset 202 8603c0420461
parent 201 c9610ad20fef
child 203 0ee86f9d9ba6
equal deleted inserted replaced
201:c9610ad20fef 202:8603c0420461
   100     clr: TSDL_Color;
   100     clr: TSDL_Color;
   101 begin
   101 begin
   102 TTF_SizeUTF8(Fontz[Font].Handle, PChar(s), w, h);
   102 TTF_SizeUTF8(Fontz[Font].Handle, PChar(s), w, h);
   103 Result.x:= X;
   103 Result.x:= X;
   104 Result.y:= Y;
   104 Result.y:= Y;
   105 Result.w:= w + 6;
   105 Result.w:= w + FontBorder * 2 + 4;
   106 Result.h:= h + 2;
   106 Result.h:= h + FontBorder * 2;
   107 DrawRoundRect(@Result, cWhiteColor, cColorNearBlack, Surface);
   107 DrawRoundRect(@Result, cWhiteColor, cColorNearBlack, Surface);
   108 clr.r:= Color shr 16;
   108 clr.r:= Color shr 16;
   109 clr.g:= (Color shr 8) and $FF;
   109 clr.g:= (Color shr 8) and $FF;
   110 clr.b:= Color and $FF;
   110 clr.b:= Color and $FF;
   111 clr.a:= $FF;
       
   112 tmpsurf:= TTF_RenderUTF8_Blended(Fontz[Font].Handle, PChar(s), clr);
   111 tmpsurf:= TTF_RenderUTF8_Blended(Fontz[Font].Handle, PChar(s), clr);
   113 Result.x:= X + 3;
   112 Result.x:= X + FontBorder + 2;
   114 Result.y:= Y + 1;
   113 Result.y:= Y + FontBorder;
   115 SDLTry(tmpsurf <> nil, true);
   114 SDLTry(tmpsurf <> nil, true);
   116 SDL_UpperBlit(tmpsurf, nil, Surface, @Result);
   115 SDL_UpperBlit(tmpsurf, nil, Surface, @Result);
   117 SDL_FreeSurface(tmpsurf);
   116 SDL_FreeSurface(tmpsurf);
   118 Result.x:= X;
   117 Result.x:= X;
   119 Result.y:= Y;
   118 Result.y:= Y;
   120 Result.w:= w + 6;
   119 Result.w:= w + FontBorder * 2 + 4;
   121 Result.h:= h + 2
   120 Result.h:= h + FontBorder * 2
   122 end;
   121 end;
   123 
   122 
   124 procedure StoreLoad;
   123 procedure StoreLoad;
   125 var i: TStuff;
   124 var i: TStuff;
   126     ii: TSprite;
   125     ii: TSprite;
   255          begin
   254          begin
   256          s:= Pathz[ptFonts] + '/' + Name;
   255          s:= Pathz[ptFonts] + '/' + Name;
   257          WriteToConsole(msgLoading + s + '... ');
   256          WriteToConsole(msgLoading + s + '... ');
   258          Handle:= TTF_OpenFont(PChar(s), Height);
   257          Handle:= TTF_OpenFont(PChar(s), Height);
   259          SDLTry(Handle <> nil, true);
   258          SDLTry(Handle <> nil, true);
       
   259          TTF_SetFontStyle(Handle, style);
   260          WriteLnToConsole(msgOK)
   260          WriteLnToConsole(msgOK)
   261          end;
   261          end;
   262 AddProgress;
   262 AddProgress;
   263 
   263 
   264 WriteToConsole('LandSurface tuning... ');
   264 WriteToConsole('LandSurface tuning... ');
   373 r.x:= X;
   373 r.x:= X;
   374 r.y:= Y;
   374 r.y:= Y;
   375 clr.r:= $FF;
   375 clr.r:= $FF;
   376 clr.g:= $FF;
   376 clr.g:= $FF;
   377 clr.b:= $FF;
   377 clr.b:= $FF;
   378 clr.a:= $FF;
       
   379 tmpsurf:= TTF_RenderUTF8_Solid(Fontz[Font].Handle, PChar(s), clr);
   378 tmpsurf:= TTF_RenderUTF8_Solid(Fontz[Font].Handle, PChar(s), clr);
   380 SDLTry(tmpsurf <> nil, true);
   379 SDLTry(tmpsurf <> nil, true);
   381 SDL_UpperBlit(tmpsurf, nil, Surface, @r);
   380 SDL_UpperBlit(tmpsurf, nil, Surface, @r);
   382 SDL_FreeSurface(tmpsurf)
   381 SDL_FreeSurface(tmpsurf)
   383 end;
   382 end;
   431 
   430 
   432 function  RenderString(s: string; Color: integer; font: THWFont): PSDL_Surface;
   431 function  RenderString(s: string; Color: integer; font: THWFont): PSDL_Surface;
   433 var w, h: integer;
   432 var w, h: integer;
   434 begin
   433 begin
   435 TTF_SizeUTF8(Fontz[font].Handle, PChar(s), w, h);
   434 TTF_SizeUTF8(Fontz[font].Handle, PChar(s), w, h);
   436 Result:= SDL_CreateRGBSurface(SDL_HWSURFACE, w + 6, h + 2, cBits, PixelFormat.RMask, PixelFormat.GMask, PixelFormat.BMask, PixelFormat.AMask);
   435 Result:= SDL_CreateRGBSurface(SDL_HWSURFACE, w + FontBorder * 2 + 4, h + FontBorder * 2,
       
   436          cBits, PixelFormat.RMask, PixelFormat.GMask, PixelFormat.BMask, PixelFormat.AMask);
   437 TryDo(Result <> nil, 'RenderString: fail to create surface', true);
   437 TryDo(Result <> nil, 'RenderString: fail to create surface', true);
   438 WriteInRoundRect(Result, 0, 0, Color, font, s);
   438 WriteInRoundRect(Result, 0, 0, Color, font, s);
   439 TryDo(SDL_SetColorKey(Result, SDL_SRCCOLORKEY or SDL_RLEACCEL, 0) = 0, errmsgTransparentSet, true)
   439 TryDo(SDL_SetColorKey(Result, SDL_SRCCOLORKEY or SDL_RLEACCEL, 0) = 0, errmsgTransparentSet, true)
   440 end;
   440 end;
   441 
   441