routine for loading lower resolution horizont and sky for nature theme when bigger images are not supported; right now they are not installed, but they could be useful for less powerful machines in general
authorkoda
Thu, 09 Jul 2009 00:56:26 +0000
changeset 2244 853a1db1cff6
parent 2243 b4764993f833
child 2245 c011aecc95e5
routine for loading lower resolution horizont and sky for nature theme when bigger images are not supported; right now they are not installed, but they could be useful for less powerful machines in general
hedgewars/hwengine.dpr
hedgewars/uConsts.pas
hedgewars/uLand.pas
hedgewars/uStore.pas
share/hedgewars/Data/Themes/nature/Sky-lowres.png
share/hedgewars/Data/Themes/nature/horizont-lowres.png
--- a/hedgewars/hwengine.dpr	Wed Jul 08 15:03:57 2009 +0000
+++ b/hedgewars/hwengine.dpr	Thu Jul 09 00:56:26 2009 +0000
@@ -143,10 +143,7 @@
 SendKB;
 CloseIPC;
 TTF_Quit;
-{$IFNDEF IPHONEOS or DEBUGFILE}
-//i know it is not clean but it is better than a crash
 SDL_Quit;
-{$ENDIF}
 halt
 end;
 
--- a/hedgewars/uConsts.pas	Wed Jul 08 15:03:57 2009 +0000
+++ b/hedgewars/uConsts.pas	Thu Jul 09 00:56:26 2009 +0000
@@ -163,7 +163,7 @@
     ifCritical    = $00000002; // image is critical for gameplay (exit game if unable to load)
     ifTransparent = $00000004; // image uses transparent pixels (color keying)
     ifIgnoreCaps  = $00000008; // ignore hardware capabilities when loading (i.e. image will not be drawn using OpenGL)
-	
+    ifLowRes      = $00000010; // try loading a low resolution image when it is critical
 const
 	cMaxPower     = 1500;
 	cMaxAngle     = 2048;
@@ -192,7 +192,6 @@
     COLOR_LAND           = $FFFF;  // white
 	COLOR_INDESTRUCTIBLE = $88FF;  // red
 
-
     //some opengl headers do not have these macros
     GL_BGR  = $80E0;
     GL_BGRA = $80E1;
--- a/hedgewars/uLand.pas	Wed Jul 08 15:03:57 2009 +0000
+++ b/hedgewars/uLand.pas	Thu Jul 09 00:56:26 2009 +0000
@@ -322,7 +322,7 @@
 		begin
 		{$IFDEF IPHONEOS}
 		//does not draw border with SDL_UpperBlit function, so we will use our own copy
-		copyToXY(tmpsurf,Surface, r.x,r.y);
+		copyToXY(tmpsurf, Surface, r.x, r.y);
 		{$ELSE}
 		SDL_UpperBlit(tmpsurf, nil, Surface, @r);
 		{$ENDIF}
--- a/hedgewars/uStore.pas	Wed Jul 08 15:03:57 2009 +0000
+++ b/hedgewars/uStore.pas	Thu Jul 09 00:56:26 2009 +0000
@@ -281,15 +281,15 @@
         if (not cReducedQuality) or ((ii <> sprSky) and (ii <> sprHorizont) and (ii <> sprFlake)) then
 		begin
 			if AltPath = ptNone then
-{$IFDEF IPHONEOS}
-				tmpsurf:= LoadImage(Pathz[Path] + '/' + FileName, ifAlpha or ifTransparent)
-{$ELSE}
-				tmpsurf:= LoadImage(Pathz[Path] + '/' + FileName, ifAlpha or ifCritical or ifTransparent)
-{$ENDIF}
+//{$IFDEF IPHONEOS}
+//				tmpsurf:= LoadImage(Pathz[Path] + '/' + FileName, ifAlpha or ifTransparent)
+//{$ELSE}
+				tmpsurf:= LoadImage(Pathz[Path] + '/' + FileName, ifAlpha or ifTransparent or ifCritical or ifLowRes)
+//{$ENDIF}
 			else begin
 				tmpsurf:= LoadImage(Pathz[Path] + '/' + FileName, ifAlpha or ifTransparent);
 				if tmpsurf = nil then
-					tmpsurf:= LoadImage(Pathz[AltPath] + '/' + FileName, ifALpha or ifCritical or ifTransparent);
+					tmpsurf:= LoadImage(Pathz[AltPath] + '/' + FileName, ifAlpha or ifCritical or ifTransparent);
 				end;
 			if imageWidth = 0 then imageWidth := tmpsurf^.w;
 			if imageHeight = 0 then imageHeight := tmpsurf^.h;
@@ -888,13 +888,31 @@
 WriteToConsole(msgLoading + filename + '... ');
 s:= filename + '.' + cBitsStr + '.png';
 tmpsurf:= IMG_Load(Str2PChar(s));
-
+WriteToConsole(inttostr(imageFlags));
 if tmpsurf = nil then
    begin
    s:= filename + '.png';
    tmpsurf:= IMG_Load(Str2PChar(s));
    end;
 
+if ((imageFlags and ifLowRes) <> 0) then
+	begin
+		s:= filename + '-lowres.png';
+		if (tmpsurf <> nil) then
+		begin 
+			if ((tmpsurf^.w > MaxTextureSize) or (tmpsurf^.h > MaxTextureSize)) then
+			begin
+				WriteLnToConsole('Image too big, trying to load lowres version: ' + s);
+				tmpsurf:= IMG_Load(Str2PChar(s))
+			end;
+		end
+		else
+		begin
+			WriteLnToConsole('Image not found, trying to load lowres version: ' + s);
+			tmpsurf:= IMG_Load(Str2PChar(s))
+		end;
+	end;
+	
 if tmpsurf = nil then
 	begin
 	OutError(msgFailed, (imageFlags and ifCritical) <> 0);
@@ -903,9 +921,9 @@
 
 if ((imageFlags and ifIgnoreCaps) = 0) and ((tmpsurf^.w > MaxTextureSize) or (tmpsurf^.h > MaxTextureSize)) then
 	begin
-	SDL_FreeSurface(tmpsurf);
-	OutError(msgFailedSize, (imageFlags and ifCritical) <> 0);
-	exit(SDL_CreateRGBSurface(SDL_SWSURFACE, 32, 32, 32, RMask, GMask, BMask, AMask))
+		SDL_FreeSurface(tmpsurf);
+		OutError(msgFailedSize, (imageFlags and ifCritical) <> 0);
+		exit(SDL_CreateRGBSurface(SDL_SWSURFACE, 32, 32, 32, RMask, GMask, BMask, AMask));
 	end;
 
 if (imageFlags and ifTransparent) <> 0 then TryDo(SDL_SetColorKey(tmpsurf, SDL_SRCCOLORKEY, 0) = 0, errmsgTransparentSet, true);
Binary file share/hedgewars/Data/Themes/nature/Sky-lowres.png has changed
Binary file share/hedgewars/Data/Themes/nature/horizont-lowres.png has changed