hedgewars/uStore.pas
changeset 6990 40e5af28d026
parent 6986 409dd3851309
child 6999 486db9d26e4b
equal deleted inserted replaced
6989:4c35e9cf6057 6990:40e5af28d026
   522 str(Hedgehog.Gear^.Health, s);
   522 str(Hedgehog.Gear^.Health, s);
   523 FreeTexture(Hedgehog.HealthTagTex);
   523 FreeTexture(Hedgehog.HealthTagTex);
   524 Hedgehog.HealthTagTex:= RenderStringTex(s, Hedgehog.Team^.Clan^.Color, fnt16)
   524 Hedgehog.HealthTagTex:= RenderStringTex(s, Hedgehog.Team^.Clan^.Color, fnt16)
   525 end;
   525 end;
   526 
   526 
   527 function  LoadImage(const filename: shortstring; imageFlags: LongInt): PSDL_Surface;
   527 function LoadImage(const filename: shortstring; imageFlags: LongInt): PSDL_Surface;
   528 var tmpsurf: PSDL_Surface;
   528 var tmpsurf: PSDL_Surface;
   529     s: shortstring;
   529     s: shortstring;
   530 begin
   530 begin
   531 WriteToConsole(msgLoading + filename + '.png [flags: ' + inttostr(imageFlags) + '] ');
   531     LoadImage:= nil;
   532 
   532     WriteToConsole(msgLoading + filename + '.png [flags: ' + inttostr(imageFlags) + '] ');
   533 s:= filename + '.png';
   533 
   534 tmpsurf:= IMG_Load(Str2PChar(s));
   534     s:= filename + '.png';
       
   535     tmpsurf:= IMG_Load(Str2PChar(s));
   535 
   536 
   536     if tmpsurf = nil then
   537     if tmpsurf = nil then
   537         begin
   538     begin
   538         OutError(msgFailed, (imageFlags and ifCritical) <> 0);
   539         OutError(msgFailed, (imageFlags and ifCritical) <> 0);
   539         exit(nil)
   540         exit;
   540         end;
   541     end;
   541 
   542 
   542     if ((imageFlags and ifIgnoreCaps) = 0) and ((tmpsurf^.w > MaxTextureSize) or (tmpsurf^.h > MaxTextureSize)) then
   543     if ((imageFlags and ifIgnoreCaps) = 0) and ((tmpsurf^.w > MaxTextureSize) or (tmpsurf^.h > MaxTextureSize)) then
   543         begin
   544     begin
   544         SDL_FreeSurface(tmpsurf);
   545         SDL_FreeSurface(tmpsurf);
   545         OutError(msgFailedSize, (imageFlags and ifCritical) <> 0);
   546         OutError(msgFailedSize, (imageFlags and ifCritical) <> 0);
   546         // dummy surface to replace non-critical textures that failed to load due to their size
   547         // dummy surface to replace non-critical textures that failed to load due to their size
   547         exit(SDL_CreateRGBSurface(SDL_SWSURFACE, 2, 2, 32, RMask, GMask, BMask, AMask));
   548         LoadImage:= SDL_CreateRGBSurface(SDL_SWSURFACE, 2, 2, 32, RMask, GMask, BMask, AMask);
   548         end;
   549         exit;
       
   550     end;
   549 
   551 
   550     tmpsurf:= doSurfaceConversion(tmpsurf);
   552     tmpsurf:= doSurfaceConversion(tmpsurf);
   551 
   553 
   552     if (imageFlags and ifTransparent) <> 0 then
   554     if (imageFlags and ifTransparent) <> 0 then
   553         TryDo(SDL_SetColorKey(tmpsurf, SDL_SRCCOLORKEY, 0) = 0, errmsgTransparentSet, true);
   555         TryDo(SDL_SetColorKey(tmpsurf, SDL_SRCCOLORKEY, 0) = 0, errmsgTransparentSet, true);