hedgewars/uStore.pas
changeset 191 a03c2d037e24
parent 190 206aabea2229
child 196 993cf173218b
equal deleted inserted replaced
190:206aabea2229 191:a03c2d037e24
    48 var StoreSurface,
    48 var StoreSurface,
    49        HHSurface: PSDL_Surface;
    49        HHSurface: PSDL_Surface;
    50 
    50 
    51 procedure StoreInit;
    51 procedure StoreInit;
    52 begin
    52 begin
    53 StoreSurface:= SDL_CreateRGBSurface(SDL_HWSURFACE, 576, 1024, cBits, PixelFormat.RMask, PixelFormat.GMask, PixelFormat.BMask, 0);
    53 StoreSurface:= SDL_CreateRGBSurface(SDL_HWSURFACE, 576, 1024, cBits, PixelFormat.RMask, PixelFormat.GMask, PixelFormat.BMask, PixelFormat.AMask);
    54 TryDo( StoreSurface <> nil, errmsgCreateSurface + ': store' , true);
    54 TryDo( StoreSurface <> nil, errmsgCreateSurface + ': store' , true);
    55 SDL_FillRect(StoreSurface, nil, 0);
    55 SDL_FillRect(StoreSurface, nil, 0);
    56 
    56 
    57 TryDo(SDL_SetColorKey( StoreSurface, SDL_SRCCOLORKEY or SDL_RLEACCEL, 0) = 0, errmsgTransparentSet, true);
    57 TryDo(SDL_SetColorKey( StoreSurface, SDL_SRCCOLORKEY or SDL_RLEACCEL, 0) = 0, errmsgTransparentSet, true);
    58 end;
    58 end;
   105 Result.h:= h + 2;
   105 Result.h:= h + 2;
   106 DrawRoundRect(@Result, cWhiteColor, cColorNearBlack, Surface);
   106 DrawRoundRect(@Result, cWhiteColor, cColorNearBlack, Surface);
   107 clr.r:= Color shr 16;
   107 clr.r:= Color shr 16;
   108 clr.g:= (Color shr 8) and $FF;
   108 clr.g:= (Color shr 8) and $FF;
   109 clr.b:= Color and $FF;
   109 clr.b:= Color and $FF;
   110 clr.a:= $FF;
       
   111 tmpsurf:= TTF_RenderUTF8_Blended(Fontz[Font].Handle, PChar(s), clr);
   110 tmpsurf:= TTF_RenderUTF8_Blended(Fontz[Font].Handle, PChar(s), clr);
   112 Result.x:= X + 3;
   111 Result.x:= X + 3;
   113 Result.y:= Y + 1;
   112 Result.y:= Y + 1;
   114 SDL_UpperBlit(tmpsurf, nil, Surface, @Result);
   113 SDL_UpperBlit(tmpsurf, nil, Surface, @Result);
   115 SDL_FreeSurface(tmpsurf);
   114 SDL_FreeSurface(tmpsurf);
   249     Closefile(f);
   248     Closefile(f);
   250     {$I+}
   249     {$I+}
   251     TryDo(IOResult = 0, msgFailed, true);
   250     TryDo(IOResult = 0, msgFailed, true);
   252     WriteLnToConsole(msgOK);
   251     WriteLnToConsole(msgOK);
   253     val(s, cExplosionBorderColor, c);
   252     val(s, cExplosionBorderColor, c);
   254     if cFullScreen then
   253     AdjustColor(cExplosionBorderColor);
   255     cExplosionBorderColor:= SDL_MapRGB(PixelFormat, (cExplosionBorderColor shr 16) and $FF,
       
   256                                                     (cExplosionBorderColor shr 8) and $FF,
       
   257                                                      cExplosionBorderColor and $FF)
       
   258     else
       
   259     cExplosionBorderColor:= SDL_MapRGB(LandSurface.format, (cExplosionBorderColor shr 16) and $FF,
       
   260                                                            (cExplosionBorderColor shr 8) and $FF,
       
   261                                                             cExplosionBorderColor and $FF)
       
   262     end;
   254     end;
   263 
   255 
   264 begin
   256 begin
   265 for fi:= Low(THWFont) to High(THWFont) do
   257 for fi:= Low(THWFont) to High(THWFont) do
   266     with Fontz[fi] do
   258     with Fontz[fi] do
   380 r.x:= X;
   372 r.x:= X;
   381 r.y:= Y;
   373 r.y:= Y;
   382 clr.r:= $FF;
   374 clr.r:= $FF;
   383 clr.g:= $FF;
   375 clr.g:= $FF;
   384 clr.b:= $FF;
   376 clr.b:= $FF;
   385 clr.a:= $FF;
       
   386 tmpsurf:= TTF_RenderUTF8_Solid(Fontz[Font].Handle, PChar(s), clr);
   377 tmpsurf:= TTF_RenderUTF8_Solid(Fontz[Font].Handle, PChar(s), clr);
   387 SDL_UpperBlit(tmpsurf, nil, Surface, @r);
   378 SDL_UpperBlit(tmpsurf, nil, Surface, @r);
   388 SDL_FreeSurface(tmpsurf)
   379 SDL_FreeSurface(tmpsurf)
   389 end;
   380 end;
   390 
   381 
   437 
   428 
   438 function  RenderString(s: string; Color: integer; font: THWFont): PSDL_Surface;
   429 function  RenderString(s: string; Color: integer; font: THWFont): PSDL_Surface;
   439 var w, h: integer;
   430 var w, h: integer;
   440 begin
   431 begin
   441 TTF_SizeUTF8(Fontz[font].Handle, PChar(s), w, h);
   432 TTF_SizeUTF8(Fontz[font].Handle, PChar(s), w, h);
   442 Result:= SDL_CreateRGBSurface(SDL_HWSURFACE, w + 6, h + 2, cBits, PixelFormat.RMask, PixelFormat.GMask, PixelFormat.BMask, 0);
   433 Result:= SDL_CreateRGBSurface(SDL_HWSURFACE, w + 6, h + 2, cBits, PixelFormat.RMask, PixelFormat.GMask, PixelFormat.BMask, PixelFormat.AMask);
   443 TryDo(Result <> nil, 'RenderString: fail to create surface', true);
   434 TryDo(Result <> nil, 'RenderString: fail to create surface', true);
   444 WriteInRoundRect(Result, 0, 0, Color, font, s);
   435 WriteInRoundRect(Result, 0, 0, Color, font, s);
   445 TryDo(SDL_SetColorKey(Result, SDL_SRCCOLORKEY or SDL_RLEACCEL, 0) = 0, errmsgTransparentSet, true)
   436 TryDo(SDL_SetColorKey(Result, SDL_SRCCOLORKEY or SDL_RLEACCEL, 0) = 0, errmsgTransparentSet, true)
   446 end;
   437 end;
   447 
   438