hedgewars/uStore.pas
changeset 2244 853a1db1cff6
parent 2240 7ce9e6b7be3b
child 2248 26e11cb27c61
equal deleted inserted replaced
2243:b4764993f833 2244:853a1db1cff6
   279 	with SpritesData[ii] do
   279 	with SpritesData[ii] do
   280         // FIXME - add a sprite attribute
   280         // FIXME - add a sprite attribute
   281         if (not cReducedQuality) or ((ii <> sprSky) and (ii <> sprHorizont) and (ii <> sprFlake)) then
   281         if (not cReducedQuality) or ((ii <> sprSky) and (ii <> sprHorizont) and (ii <> sprFlake)) then
   282 		begin
   282 		begin
   283 			if AltPath = ptNone then
   283 			if AltPath = ptNone then
   284 {$IFDEF IPHONEOS}
   284 //{$IFDEF IPHONEOS}
   285 				tmpsurf:= LoadImage(Pathz[Path] + '/' + FileName, ifAlpha or ifTransparent)
   285 //				tmpsurf:= LoadImage(Pathz[Path] + '/' + FileName, ifAlpha or ifTransparent)
   286 {$ELSE}
   286 //{$ELSE}
   287 				tmpsurf:= LoadImage(Pathz[Path] + '/' + FileName, ifAlpha or ifCritical or ifTransparent)
   287 				tmpsurf:= LoadImage(Pathz[Path] + '/' + FileName, ifAlpha or ifTransparent or ifCritical or ifLowRes)
   288 {$ENDIF}
   288 //{$ENDIF}
   289 			else begin
   289 			else begin
   290 				tmpsurf:= LoadImage(Pathz[Path] + '/' + FileName, ifAlpha or ifTransparent);
   290 				tmpsurf:= LoadImage(Pathz[Path] + '/' + FileName, ifAlpha or ifTransparent);
   291 				if tmpsurf = nil then
   291 				if tmpsurf = nil then
   292 					tmpsurf:= LoadImage(Pathz[AltPath] + '/' + FileName, ifALpha or ifCritical or ifTransparent);
   292 					tmpsurf:= LoadImage(Pathz[AltPath] + '/' + FileName, ifAlpha or ifCritical or ifTransparent);
   293 				end;
   293 				end;
   294 			if imageWidth = 0 then imageWidth := tmpsurf^.w;
   294 			if imageWidth = 0 then imageWidth := tmpsurf^.w;
   295 			if imageHeight = 0 then imageHeight := tmpsurf^.h;
   295 			if imageHeight = 0 then imageHeight := tmpsurf^.h;
   296 			if Width = 0 then Width:= tmpsurf^.w;
   296 			if Width = 0 then Width:= tmpsurf^.w;
   297 			if Height = 0 then Height:= tmpsurf^.h;
   297 			if Height = 0 then Height:= tmpsurf^.h;
   886     s: shortstring;
   886     s: shortstring;
   887 begin
   887 begin
   888 WriteToConsole(msgLoading + filename + '... ');
   888 WriteToConsole(msgLoading + filename + '... ');
   889 s:= filename + '.' + cBitsStr + '.png';
   889 s:= filename + '.' + cBitsStr + '.png';
   890 tmpsurf:= IMG_Load(Str2PChar(s));
   890 tmpsurf:= IMG_Load(Str2PChar(s));
   891 
   891 WriteToConsole(inttostr(imageFlags));
   892 if tmpsurf = nil then
   892 if tmpsurf = nil then
   893    begin
   893    begin
   894    s:= filename + '.png';
   894    s:= filename + '.png';
   895    tmpsurf:= IMG_Load(Str2PChar(s));
   895    tmpsurf:= IMG_Load(Str2PChar(s));
   896    end;
   896    end;
   897 
   897 
       
   898 if ((imageFlags and ifLowRes) <> 0) then
       
   899 	begin
       
   900 		s:= filename + '-lowres.png';
       
   901 		if (tmpsurf <> nil) then
       
   902 		begin 
       
   903 			if ((tmpsurf^.w > MaxTextureSize) or (tmpsurf^.h > MaxTextureSize)) then
       
   904 			begin
       
   905 				WriteLnToConsole('Image too big, trying to load lowres version: ' + s);
       
   906 				tmpsurf:= IMG_Load(Str2PChar(s))
       
   907 			end;
       
   908 		end
       
   909 		else
       
   910 		begin
       
   911 			WriteLnToConsole('Image not found, trying to load lowres version: ' + s);
       
   912 			tmpsurf:= IMG_Load(Str2PChar(s))
       
   913 		end;
       
   914 	end;
       
   915 	
   898 if tmpsurf = nil then
   916 if tmpsurf = nil then
   899 	begin
   917 	begin
   900 	OutError(msgFailed, (imageFlags and ifCritical) <> 0);
   918 	OutError(msgFailed, (imageFlags and ifCritical) <> 0);
   901 	exit(nil)
   919 	exit(nil)
   902 	end;
   920 	end;
   903 
   921 
   904 if ((imageFlags and ifIgnoreCaps) = 0) and ((tmpsurf^.w > MaxTextureSize) or (tmpsurf^.h > MaxTextureSize)) then
   922 if ((imageFlags and ifIgnoreCaps) = 0) and ((tmpsurf^.w > MaxTextureSize) or (tmpsurf^.h > MaxTextureSize)) then
   905 	begin
   923 	begin
   906 	SDL_FreeSurface(tmpsurf);
   924 		SDL_FreeSurface(tmpsurf);
   907 	OutError(msgFailedSize, (imageFlags and ifCritical) <> 0);
   925 		OutError(msgFailedSize, (imageFlags and ifCritical) <> 0);
   908 	exit(SDL_CreateRGBSurface(SDL_SWSURFACE, 32, 32, 32, RMask, GMask, BMask, AMask))
   926 		exit(SDL_CreateRGBSurface(SDL_SWSURFACE, 32, 32, 32, RMask, GMask, BMask, AMask));
   909 	end;
   927 	end;
   910 
   928 
   911 if (imageFlags and ifTransparent) <> 0 then TryDo(SDL_SetColorKey(tmpsurf, SDL_SRCCOLORKEY, 0) = 0, errmsgTransparentSet, true);
   929 if (imageFlags and ifTransparent) <> 0 then TryDo(SDL_SetColorKey(tmpsurf, SDL_SRCCOLORKEY, 0) = 0, errmsgTransparentSet, true);
   912 //if (imageFlags and ifAlpha) <> 0 then Result:= SDL_DisplayFormatAlpha(tmpsurf)
   930 //if (imageFlags and ifAlpha) <> 0 then Result:= SDL_DisplayFormatAlpha(tmpsurf)
   913 //            else Result:= SDL_DisplayFormat(tmpsurf);
   931 //            else Result:= SDL_DisplayFormat(tmpsurf);