hedgewars/uStore.pas
changeset 13484 480ea997036b
parent 13453 8f746b6a477c
child 13489 8935dcc0e130
equal deleted inserted replaced
13476:c265a3e6f6da 13484:480ea997036b
   622 end;
   622 end;
   623 
   623 
   624 function LoadImage(const filename: shortstring; imageFlags: LongInt): PSDL_Surface;
   624 function LoadImage(const filename: shortstring; imageFlags: LongInt): PSDL_Surface;
   625 var tmpsurf: PSDL_Surface;
   625 var tmpsurf: PSDL_Surface;
   626     s: shortstring;
   626     s: shortstring;
       
   627     logMsg: shortstring;
   627     rwops: PSDL_RWops;
   628     rwops: PSDL_RWops;
   628 begin
   629 begin
   629     LoadImage:= nil;
   630     LoadImage:= nil;
   630     WriteToConsole(msgLoading + filename + '.png [flags: ' + inttostr(imageFlags) + '] ');
   631     logMsg:= msgLoading + filename + '.png [flags: ' + inttostr(imageFlags) + ']';
   631 
   632 
   632     s:= filename + '.png';
   633     s:= filename + '.png';
   633 
   634 
   634     rwops:= nil;
   635     rwops:= nil;
   635     tmpsurf:= nil;
   636     tmpsurf:= nil;
   649         begin
   650         begin
   650         // output sdl error if loading failed when data source was available
   651         // output sdl error if loading failed when data source was available
   651         if rwops <> nil then
   652         if rwops <> nil then
   652             begin
   653             begin
   653             // anounce that loading failed
   654             // anounce that loading failed
   654             OutError(msgFailed, false);
   655             OutError(logMsg + ' ' + msgFailed, false);
   655 
   656 
   656             if SDLCheck(false, 'LoadImage', (imageFlags and ifCritical) <> 0) then exit;
   657             if SDLCheck(false, 'LoadImage: ' + logMsg + ' ' + msgFailed, (imageFlags and ifCritical) <> 0) then
       
   658                 exit;
   657             // rwops was already freed by IMG_Load_RW
   659             // rwops was already freed by IMG_Load_RW
   658             rwops:= nil;
   660             rwops:= nil;
   659             end else
   661             end
   660             OutError(msgFailed, (imageFlags and ifCritical) <> 0);
   662         else
       
   663             OutError(logMsg + ' ' + msgFailed, (imageFlags and ifCritical) <> 0);
   661         exit;
   664         exit;
   662         end;
   665         end;
   663 
   666 
   664     if ((imageFlags and ifIgnoreCaps) = 0) and ((tmpsurf^.w > MaxTextureSize) or (tmpsurf^.h > MaxTextureSize)) then
   667     if ((imageFlags and ifIgnoreCaps) = 0) and ((tmpsurf^.w > MaxTextureSize) or (tmpsurf^.h > MaxTextureSize)) then
   665         begin
   668         begin
   666         SDL_FreeSurface(tmpsurf);
   669         SDL_FreeSurface(tmpsurf);
   667         OutError(msgFailedSize, ((not cOnlyStats) and ((imageFlags and ifCritical) <> 0)));
   670         OutError(logMsg + ' ' + msgFailedSize, ((not cOnlyStats) and ((imageFlags and ifCritical) <> 0)));
   668         // dummy surface to replace non-critical textures that failed to load due to their size
   671         // dummy surface to replace non-critical textures that failed to load due to their size
   669         LoadImage:= SDL_CreateRGBSurface(SDL_SWSURFACE, 2, 2, 32, RMask, GMask, BMask, AMask);
   672         LoadImage:= SDL_CreateRGBSurface(SDL_SWSURFACE, 2, 2, 32, RMask, GMask, BMask, AMask);
   670         exit;
   673         exit;
   671         end;
   674         end;
   672 
   675 
   673     tmpsurf:= doSurfaceConversion(tmpsurf);
   676     tmpsurf:= doSurfaceConversion(tmpsurf);
   674 
   677 
   675     if (imageFlags and ifColorKey) <> 0 then
   678     if (imageFlags and ifColorKey) <> 0 then
   676         if checkFails(SDL_SetColorKey(tmpsurf, SDL_TRUE, 0) = 0, errmsgTransparentSet, true) then exit;
   679         if checkFails(SDL_SetColorKey(tmpsurf, SDL_TRUE, 0) = 0, errmsgTransparentSet, true) then exit;
   677 
   680 
   678     WriteLnToConsole(msgOK + ' (' + inttostr(tmpsurf^.w) + 'x' + inttostr(tmpsurf^.h) + ')');
   681     // log success
       
   682     WriteLnToConsole(logMsg + ' ' + msgOK + ' (' + inttostr(tmpsurf^.w) + 'x' + inttostr(tmpsurf^.h) + ')');
   679 
   683 
   680     LoadImage:= tmpsurf //Result
   684     LoadImage:= tmpsurf //Result
   681 end;
   685 end;
   682 
   686 
   683 
   687