hedgewars/uLand.pas
changeset 2171 8208946331ba
parent 2163 12730f5e79b9
child 2221 ef52dae4130b
equal deleted inserted replaced
2170:aa77f2a6b4f1 2171:8208946331ba
   313 procedure ColorizeLand(Surface: PSDL_Surface);
   313 procedure ColorizeLand(Surface: PSDL_Surface);
   314 var tmpsurf: PSDL_Surface;
   314 var tmpsurf: PSDL_Surface;
   315     r, rr: TSDL_Rect;
   315     r, rr: TSDL_Rect;
   316     x, yd, yu: LongInt;
   316     x, yd, yu: LongInt;
   317 begin
   317 begin
   318 tmpsurf:= LoadImage(Pathz[ptCurrTheme] + '/LandTex', false, true, false);
   318 tmpsurf:= LoadImage(Pathz[ptCurrTheme] + '/LandTex', ifCritical or ifIgnoreCaps);
   319 r.y:= 0;
   319 r.y:= 0;
   320 while r.y < LAND_HEIGHT do
   320 while r.y < LAND_HEIGHT do
   321 	begin
   321 	begin
   322 	r.x:= 0;
   322 	r.x:= 0;
   323 	while r.x < LAND_WIDTH do
   323 	while r.x < LAND_WIDTH do
   324 		begin
   324 		begin
       
   325 		{$IFDEF IPHONEOS}
       
   326 		//does not draw border with SDL_UpperBlit function, so we will use our own copy
       
   327 		copyToXY(tmpsurf,Surface, r.x,r.y);
       
   328 		{$ELSE}
   325 		SDL_UpperBlit(tmpsurf, nil, Surface, @r);
   329 		SDL_UpperBlit(tmpsurf, nil, Surface, @r);
       
   330 		{$ENDIF}
   326 		inc(r.x, tmpsurf^.w)
   331 		inc(r.x, tmpsurf^.w)
   327 		end;
   332 		end;
   328 	inc(r.y, tmpsurf^.h)
   333 	inc(r.y, tmpsurf^.h)
   329 	end;
   334 	end;
   330 SDL_FreeSurface(tmpsurf);
   335 SDL_FreeSurface(tmpsurf);
   331 
   336 
   332 tmpsurf:= LoadImage(Pathz[ptCurrTheme] + '/Border', false, true, true);
   337 tmpsurf:= LoadImage(Pathz[ptCurrTheme] + '/Border', ifCritical or ifIgnoreCaps or ifTransparent);
   333 for x:= 0 to LAND_WIDTH - 1 do
   338 for x:= 0 to LAND_WIDTH - 1 do
   334 	begin
   339 	begin
   335 	yd:= LAND_HEIGHT - 1;
   340 	yd:= LAND_HEIGHT - 1;
   336 	repeat
   341 	repeat
   337 		while (yd > 0) and (Land[yd, x] =  0) do dec(yd);
   342 		while (yd > 0) and (Land[yd, x] =  0) do dec(yd);
   608 end;
   613 end;
   609 
   614 
   610 procedure MakeFortsMap;
   615 procedure MakeFortsMap;
   611 var tmpsurf: PSDL_Surface;
   616 var tmpsurf: PSDL_Surface;
   612 begin
   617 begin
   613 // For now, defining a fort's playable area as 3072x1200 - there are no tall forts.  The extra height is to avoid triggering border with current code, also if user turns on a border, it'll give a bit more maneuvering room.
   618 // For now, defining a fort is playable area as 3072x1200 - there are no tall forts.  The extra height is to avoid triggering border with current code, also if user turns on a border, it will give a bit more maneuvering room.
   614 playHeight:= 1200;
   619 playHeight:= 1200;
   615 playWidth:= 2560;
   620 playWidth:= 2560;
   616 leftX:= (LAND_WIDTH - playWidth) div 2;
   621 leftX:= (LAND_WIDTH - playWidth) div 2;
   617 rightX:= ((playWidth + (LAND_WIDTH - playWidth) div 2) - 1);
   622 rightX:= ((playWidth + (LAND_WIDTH - playWidth) div 2) - 1);
   618 topY:= LAND_HEIGHT - playHeight;
   623 topY:= LAND_HEIGHT - playHeight;
   619 
   624 
   620 WriteLnToConsole('Generating forts land...');
   625 WriteLnToConsole('Generating forts land...');
   621 
   626 
   622 tmpsurf:= LoadImage(Pathz[ptForts] + '/' + ClansArray[0]^.Teams[0]^.FortName + 'L', true, true, true);
   627 tmpsurf:= LoadImage(Pathz[ptForts] + '/' + ClansArray[0]^.Teams[0]^.FortName + 'L', ifAlpha or ifCritical or ifTransparent or ifIgnoreCaps);
   623 BlitImageAndGenerateCollisionInfo(leftX+150, LAND_HEIGHT - tmpsurf^.h, tmpsurf^.w, tmpsurf);
   628 BlitImageAndGenerateCollisionInfo(leftX+150, LAND_HEIGHT - tmpsurf^.h, tmpsurf^.w, tmpsurf);
   624 SDL_FreeSurface(tmpsurf);
   629 SDL_FreeSurface(tmpsurf);
   625 
   630 
   626 tmpsurf:= LoadImage(Pathz[ptForts] + '/' + ClansArray[1]^.Teams[0]^.FortName + 'R', true, true, true);
   631 tmpsurf:= LoadImage(Pathz[ptForts] + '/' + ClansArray[1]^.Teams[0]^.FortName + 'R', ifAlpha or ifCritical or ifTransparent or ifIgnoreCaps);
   627 BlitImageAndGenerateCollisionInfo(rightX - 150 - tmpsurf^.w, LAND_HEIGHT - tmpsurf^.h, tmpsurf^.w, tmpsurf);
   632 BlitImageAndGenerateCollisionInfo(rightX - 150 - tmpsurf^.w, LAND_HEIGHT - tmpsurf^.h, tmpsurf^.w, tmpsurf);
   628 SDL_FreeSurface(tmpsurf);
   633 SDL_FreeSurface(tmpsurf);
   629 end;
   634 end;
   630 
   635 
   631 // Hi unC0Rr.
   636 // Hi unC0Rr.
   637 procedure LoadMask;
   642 procedure LoadMask;
   638 var tmpsurf: PSDL_Surface;
   643 var tmpsurf: PSDL_Surface;
   639     p: PLongwordArray;
   644     p: PLongwordArray;
   640     x, y, cpX, cpY: Longword;
   645     x, y, cpX, cpY: Longword;
   641 begin
   646 begin
   642 tmpsurf:= LoadImage(Pathz[ptMapCurrent] + '/mask', true, false, true);
   647 tmpsurf:= LoadImage(Pathz[ptMapCurrent] + '/mask', ifAlpha or ifTransparent or ifIgnoreCaps);
   643 if (tmpsurf <> nil) and (tmpsurf^.w <= LAND_WIDTH) and (tmpsurf^.h <= LAND_HEIGHT) and (tmpsurf^.format^.BytesPerPixel = 4) then
   648 if (tmpsurf <> nil) and (tmpsurf^.w <= LAND_WIDTH) and (tmpsurf^.h <= LAND_HEIGHT) and (tmpsurf^.format^.BytesPerPixel = 4) then
   644     begin
   649     begin
   645 	cpX:= (LAND_WIDTH - tmpsurf^.w) div 2;
   650 	cpX:= (LAND_WIDTH - tmpsurf^.w) div 2;
   646 	cpY:= LAND_HEIGHT - tmpsurf^.h;
   651 	cpY:= LAND_HEIGHT - tmpsurf^.h;
   647     if SDL_MustLock(tmpsurf) then
   652     if SDL_MustLock(tmpsurf) then
   671 	s: string;
   676 	s: string;
   672 	f: textfile;
   677 	f: textfile;
   673 begin
   678 begin
   674 WriteLnToConsole('Loading land from file...');
   679 WriteLnToConsole('Loading land from file...');
   675 AddProgress;
   680 AddProgress;
   676 tmpsurf:= LoadImage(Pathz[ptMapCurrent] + '/map', true, true, true);
   681 tmpsurf:= LoadImage(Pathz[ptMapCurrent] + '/map', ifAlpha or ifCritical or ifTransparent or ifIgnoreCaps);
   677 TryDo((tmpsurf^.w <= LAND_WIDTH) and (tmpsurf^.h <= LAND_HEIGHT), 'Map dimensions too big!', true);
   682 TryDo((tmpsurf^.w <= LAND_WIDTH) and (tmpsurf^.h <= LAND_HEIGHT), 'Map dimensions too big!', true);
   678 
   683 
   679 // unC0Rr - should this be passed from the GUI? I am not sure which layer does what
   684 // unC0Rr - should this be passed from the GUI? I am not sure which layer does what
   680 s:= Pathz[ptMapCurrent] + '/map.cfg';
   685 s:= Pathz[ptMapCurrent] + '/map.cfg';
   681 WriteLnToConsole('Fetching map HH limit');
   686 WriteLnToConsole('Fetching map HH limit');