44 |
44 |
45 type TRectsArray = array[0..MaxRects] of TSDL_Rect; |
45 type TRectsArray = array[0..MaxRects] of TSDL_Rect; |
46 PRectArray = ^TRectsArray; |
46 PRectArray = ^TRectsArray; |
47 TThemeObject = record |
47 TThemeObject = record |
48 Surf, Mask: PSDL_Surface; |
48 Surf, Mask: PSDL_Surface; |
49 inland: TSDL_Rect; |
49 inland: array[0..Pred(MAXOBJECTRECTS)] of TSDL_Rect; |
50 outland: array[0..Pred(MAXOBJECTRECTS)] of TSDL_Rect; |
50 outland: array[0..Pred(MAXOBJECTRECTS)] of TSDL_Rect; |
51 rectcnt: Longword; |
51 rectcnt: Longword; |
|
52 rectcnt2: Longword; |
52 Width, Height: Longword; |
53 Width, Height: Longword; |
53 Maxcnt: Longword; |
54 Maxcnt: Longword; |
54 end; |
55 end; |
55 TThemeObjects = record |
56 TThemeObjects = record |
56 Count: LongInt; |
57 Count: LongInt; |
353 |
354 |
354 function CheckCanPlace(x, y: Longword; var Obj: TThemeObject): boolean; |
355 function CheckCanPlace(x, y: Longword; var Obj: TThemeObject): boolean; |
355 var i: Longword; |
356 var i: Longword; |
356 bRes: boolean; |
357 bRes: boolean; |
357 begin |
358 begin |
358 with Obj do |
359 with Obj do begin |
359 if CheckLand(inland, x, y, lfBasic) then |
|
360 begin |
|
361 bRes:= true; |
360 bRes:= true; |
362 i:= 1; |
361 i:= 1; |
|
362 while bRes and (i <= rectcnt2) do |
|
363 begin |
|
364 bRes:= CheckLand(inland[i], x, y, lfBasic); |
|
365 inc(i) |
|
366 end; |
|
367 |
|
368 i:= 1; |
363 while bRes and (i <= rectcnt) do |
369 while bRes and (i <= rectcnt) do |
364 begin |
370 begin |
365 bRes:= CheckLand(outland[i], x, y, 0); |
371 bRes:= CheckLand(outland[i], x, y, 0); |
366 inc(i) |
372 inc(i) |
367 end; |
373 end; |
|
374 |
368 if bRes then |
375 if bRes then |
369 bRes:= not CheckIntersect(x, y, Width, Height) |
376 bRes:= not CheckIntersect(x, y, Width, Height); |
370 end |
377 |
371 else |
378 CheckCanPlace:= bRes; |
372 bRes:= false; |
379 end |
373 CheckCanPlace:= bRes; |
|
374 end; |
380 end; |
375 |
381 |
376 function TryPut(var Obj: TThemeObject): boolean; |
382 function TryPut(var Obj: TThemeObject): boolean; |
377 const MaxPointsIndex = 2047; |
383 const MaxPointsIndex = 2047; |
378 var x, y: Longword; |
384 var x, y: Longword; |
660 i:= Pos(',', s); |
666 i:= Pos(',', s); |
661 Maxcnt:= StrToInt(Trim(Copy(s, 1, Pred(i)))); |
667 Maxcnt:= StrToInt(Trim(Copy(s, 1, Pred(i)))); |
662 Delete(s, 1, i); |
668 Delete(s, 1, i); |
663 if (Maxcnt < 1) or (Maxcnt > MAXTHEMEOBJECTS) then |
669 if (Maxcnt < 1) or (Maxcnt > MAXTHEMEOBJECTS) then |
664 OutError('Object''s max count should be between 1 and '+ inttostr(MAXTHEMEOBJECTS) +' (it was '+ inttostr(Maxcnt) +').', true); |
670 OutError('Object''s max count should be between 1 and '+ inttostr(MAXTHEMEOBJECTS) +' (it was '+ inttostr(Maxcnt) +').', true); |
665 with inland do |
671 rectcnt2 := 0; |
666 begin |
672 for ii := 1 to Length(S) do |
667 i:= Pos(',', s); |
673 if S[ii] = ',' then |
668 x:= StrToInt(Trim(Copy(s, 1, Pred(i)))); |
674 inc(rectcnt2); |
669 Delete(s, 1, i); |
675 |
670 i:= Pos(',', s); |
676 if rectcnt2 mod 2 = 0 then |
671 y:= StrToInt(Trim(Copy(s, 1, Pred(i)))); |
677 rectcnt2 := 1 |
672 Delete(s, 1, i); |
678 else begin |
673 i:= Pos(',', s); |
679 i:= Pos(',', s); |
674 w:= StrToInt(Trim(Copy(s, 1, Pred(i)))); |
680 rectcnt2:= StrToInt(Trim(Copy(s, 1, Pred(i)))); |
675 Delete(s, 1, i); |
681 Delete(s, 1, i); |
676 i:= Pos(',', s); |
682 end; |
677 h:= StrToInt(Trim(Copy(s, 1, Pred(i)))); |
683 |
678 Delete(s, 1, i); |
684 for ii:= 1 to rectcnt2 do |
679 CheckRect(Width, Height, x, y, w, h) |
685 with inland[ii] do |
680 end; |
686 begin |
|
687 i:= Pos(',', s); |
|
688 x:= StrToInt(Trim(Copy(s, 1, Pred(i)))); |
|
689 Delete(s, 1, i); |
|
690 i:= Pos(',', s); |
|
691 y:= StrToInt(Trim(Copy(s, 1, Pred(i)))); |
|
692 Delete(s, 1, i); |
|
693 i:= Pos(',', s); |
|
694 w:= StrToInt(Trim(Copy(s, 1, Pred(i)))); |
|
695 Delete(s, 1, i); |
|
696 i:= Pos(',', s); |
|
697 h:= StrToInt(Trim(Copy(s, 1, Pred(i)))); |
|
698 Delete(s, 1, i); |
|
699 CheckRect(Width, Height, x, y, w, h) |
|
700 end; |
|
701 |
681 i:= Pos(',', s); |
702 i:= Pos(',', s); |
682 rectcnt:= StrToInt(Trim(Copy(s, 1, Pred(i)))); |
703 rectcnt:= StrToInt(Trim(Copy(s, 1, Pred(i)))); |
683 Delete(s, 1, i); |
704 Delete(s, 1, i); |
684 for ii:= 1 to rectcnt do |
705 for ii:= 1 to rectcnt do |
685 with outland[ii] do |
706 with outland[ii] do |