hedgewars/uStore.pas
changeset 2426 9d674c5c828d
parent 2397 2ca4ca6b4bab
child 2428 6800f8aa0184
equal deleted inserted replaced
2425:a4af95e6382c 2426:9d674c5c828d
   277 
   277 
   278 AddProgress;
   278 AddProgress;
   279 for ii:= Low(TSprite) to High(TSprite) do
   279 for ii:= Low(TSprite) to High(TSprite) do
   280 	with SpritesData[ii] do
   280 	with SpritesData[ii] do
   281         // FIXME - add a sprite attribute
   281         // FIXME - add a sprite attribute
   282         if (not cReducedQuality) or ((ii <> sprSky) and (ii <> sprHorizont) and (ii <> sprFlake)) then
   282         if (not cReducedQuality) or (not (ii in [sprSky, sprSkyL, sprSkyR, sprHorizont, sprHorizontL, sprHorizontR, sprFlake])) then // FIXME: hack
   283 		begin
   283 		begin
   284 			if AltPath = ptNone then
   284 			if AltPath = ptNone then
   285 				tmpsurf:= LoadImage(Pathz[Path] + '/' + FileName, ifAlpha or ifTransparent or ifCritical or ifLowRes)
   285 				if ii in [sprHorizontL, sprHorizontR, sprSkyL, sprSkyR] then // FIXME: hack
       
   286 					tmpsurf:= LoadImage(Pathz[Path] + '/' + FileName, ifAlpha or ifTransparent or ifLowRes)
       
   287 				else
       
   288 					tmpsurf:= LoadImage(Pathz[Path] + '/' + FileName, ifAlpha or ifTransparent or ifCritical or ifLowRes)
   286 			else begin
   289 			else begin
   287 				tmpsurf:= LoadImage(Pathz[Path] + '/' + FileName, ifAlpha or ifTransparent);
   290 				tmpsurf:= LoadImage(Pathz[Path] + '/' + FileName, ifAlpha or ifTransparent);
   288 				if tmpsurf = nil then
   291 				if tmpsurf = nil then
   289 					tmpsurf:= LoadImage(Pathz[AltPath] + '/' + FileName, ifAlpha or ifCritical or ifTransparent);
   292 						tmpsurf:= LoadImage(Pathz[AltPath] + '/' + FileName, ifAlpha or ifCritical or ifTransparent);
   290 				end;
   293 				end;
   291 			if imageWidth = 0 then imageWidth := tmpsurf^.w;
   294 
   292 			if imageHeight = 0 then imageHeight := tmpsurf^.h;
   295 			if tmpsurf <> nil then
   293 			if Width = 0 then Width:= tmpsurf^.w;
   296 				begin
   294 			if Height = 0 then Height:= tmpsurf^.h;
   297 				if imageWidth = 0 then imageWidth := tmpsurf^.w;
   295             if (ii = sprSky) then
   298 				if imageHeight = 0 then imageHeight := tmpsurf^.h;
   296 			    Texture:= Surface2Tex(tmpsurf, true)
   299 				if Width = 0 then Width:= tmpsurf^.w;
   297             else
   300 				if Height = 0 then Height:= tmpsurf^.h;
   298 			    Texture:= Surface2Tex(tmpsurf, false);
   301 				if (ii = sprSky) then
   299 			if saveSurf then Surface:= tmpsurf else SDL_FreeSurface(tmpsurf)
   302 					Texture:= Surface2Tex(tmpsurf, true)
       
   303 				else
       
   304 					Texture:= Surface2Tex(tmpsurf, false);
       
   305 				if saveSurf then Surface:= tmpsurf else SDL_FreeSurface(tmpsurf)
       
   306 				end
       
   307 			else
       
   308 				Surface:= nil
   300 		end;
   309 		end;
   301 
   310 
   302 AddProgress;
   311 AddProgress;
   303 
   312 
   304 tmpsurf:= LoadImage(Pathz[ptGraphics] + '/' + cHHFileName, ifAlpha or ifCritical or ifTransparent);
   313 tmpsurf:= LoadImage(Pathz[ptGraphics] + '/' + cHHFileName, ifAlpha or ifCritical or ifTransparent);
   905             colorkey: 0;
   914             colorkey: 0;
   906             alpha : 255);
   915             alpha : 255);
   907 {$ENDIF}
   916 {$ENDIF}
   908 begin
   917 begin
   909 WriteToConsole(msgLoading + filename + '... ');
   918 WriteToConsole(msgLoading + filename + '... ');
   910 s:= filename + '.' + cBitsStr + '.png';
   919 
       
   920 s:= filename + '.png';
   911 tmpsurf:= IMG_Load(Str2PChar(s));
   921 tmpsurf:= IMG_Load(Str2PChar(s));
   912 
       
   913 if tmpsurf = nil then
       
   914    begin
       
   915    s:= filename + '.png';
       
   916    tmpsurf:= IMG_Load(Str2PChar(s));
       
   917    end;
       
   918 
   922 
   919 if ((imageFlags and ifLowRes) <> 0) then
   923 if ((imageFlags and ifLowRes) <> 0) then
   920 	begin
   924 	begin
   921 		s:= filename + '-lowres.png';
   925 		s:= filename + '-lowres.png';
   922 		if (tmpsurf <> nil) then
   926 		if (tmpsurf <> nil) then
   923 		begin
   927 		begin
   924 			if ((tmpsurf^.w > MaxTextureSize) or (tmpsurf^.h > MaxTextureSize)) then
   928 			if ((tmpsurf^.w > MaxTextureSize) or (tmpsurf^.h > MaxTextureSize)) then
   925 			begin
   929 			begin
       
   930 				SDL_FreeSurface(tmpsurf);
   926 				WriteLnToConsole('Image too big, trying to load lowres version: ' + s);
   931 				WriteLnToConsole('Image too big, trying to load lowres version: ' + s);
   927 				tmpsurf:= IMG_Load(Str2PChar(s))
   932 				tmpsurf:= IMG_Load(Str2PChar(s))
   928 			end;
   933 			end;
   929 		end
   934 		end
   930 		else
   935 		else