276 |
276 |
277 AddProgress; |
277 AddProgress; |
278 for ii:= Low(TSprite) to High(TSprite) do |
278 for ii:= Low(TSprite) to High(TSprite) do |
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 |
281 if (not cReducedQuality) or ((ii <> sprSky) and (ii <> sprHorizont) and (ii <> sprFlake)) then |
282 ((ii <> sprSky) and (ii <> sprHorizont) and (ii <> sprFlake)) then |
282 begin |
283 begin |
|
284 if AltPath = ptNone then |
283 if AltPath = ptNone then |
285 tmpsurf:= LoadImage(Pathz[Path] + '/' + FileName, ifAlpha or ifCritical or ifTransparent) |
284 tmpsurf:= LoadImage(Pathz[Path] + '/' + FileName, ifAlpha or ifCritical or ifTransparent) |
286 else begin |
285 else begin |
287 tmpsurf:= LoadImage(Pathz[Path] + '/' + FileName, ifAlpha or ifTransparent); |
286 tmpsurf:= LoadImage(Pathz[Path] + '/' + FileName, ifAlpha or ifTransparent); |
288 if tmpsurf = nil then |
287 if tmpsurf = nil then |
289 tmpsurf:= LoadImage(Pathz[AltPath] + '/' + FileName, ifALpha or ifCritical or ifTransparent) |
288 tmpsurf:= LoadImage(Pathz[AltPath] + '/' + FileName, ifALpha or ifCritical or ifTransparent); |
290 end; |
289 end; |
|
290 if imageWidth = 0 then imageWidth := tmpsurf^.w; |
|
291 if imageHeight = 0 then imageHeight := tmpsurf^.h; |
291 if Width = 0 then Width:= tmpsurf^.w; |
292 if Width = 0 then Width:= tmpsurf^.w; |
292 if Height = 0 then Height:= tmpsurf^.h; |
293 if Height = 0 then Height:= tmpsurf^.h; |
293 Texture:= Surface2Tex(tmpsurf); |
294 Texture:= Surface2Tex(tmpsurf); |
294 if saveSurf then Surface:= tmpsurf else SDL_FreeSurface(tmpsurf) |
295 if saveSurf then Surface:= tmpsurf else SDL_FreeSurface(tmpsurf) |
295 end; |
296 end; |
296 |
297 |
297 AddProgress; |
298 AddProgress; |
298 |
299 |
299 tmpsurf:= LoadImage(Pathz[ptGraphics] + '/' + cHHFileName, ifAlpha or ifCritical or ifTransparent); |
300 tmpsurf:= LoadImage(Pathz[ptGraphics] + '/' + cHHFileName, ifAlpha or ifCritical or ifTransparent); |
300 HHTexture:= Surface2Tex(tmpsurf); |
301 HHTexture:= Surface2Tex(tmpsurf); |
513 r.h:= Height; |
514 r.h:= Height; |
514 DrawFromRect(X, Y, @r, SpritesData[Sprite].Texture) |
515 DrawFromRect(X, Y, @r, SpritesData[Sprite].Texture) |
515 end; |
516 end; |
516 |
517 |
517 procedure DrawSprite (Sprite: TSprite; X, Y, Frame: LongInt); |
518 procedure DrawSprite (Sprite: TSprite; X, Y, Frame: LongInt); |
518 begin |
519 var row, col, numFramesFirstCol: LongInt; |
519 DrawSprite2 (Sprite, X, Y, 0, Frame); |
520 begin |
|
521 numFramesFirstCol:= SpritesData[Sprite].imageHeight div SpritesData[Sprite].Height; |
|
522 row:= Frame mod numFramesFirstCol; |
|
523 col:= Frame div numFramesFirstCol; |
|
524 DrawSprite2 (Sprite, X, Y, col, row); |
520 end; |
525 end; |
521 |
526 |
522 procedure DrawSpriteClipped(Sprite: TSprite; X, Y, TopY, RightX, BottomY, LeftX: LongInt); |
527 procedure DrawSpriteClipped(Sprite: TSprite; X, Y, TopY, RightX, BottomY, LeftX: LongInt); |
523 var r: TSDL_Rect; |
528 var r: TSDL_Rect; |
524 begin |
529 numFramesFirstCol: LongInt; |
|
530 begin |
|
531 numFramesFirstCol:= SpritesData[Sprite].imageHeight div SpritesData[Sprite].Height; |
|
532 |
525 r.x:= 0; |
533 r.x:= 0; |
526 r.y:= 0; |
534 r.y:= 0; |
527 r.w:= SpritesData[Sprite].Width; |
535 r.w:= SpritesData[Sprite].Width; |
528 r.h:= SpritesData[Sprite].Height; |
536 r.h:= SpritesData[Sprite].Height; |
529 |
537 |
537 if (X + SpritesData[Sprite].Width > RightX) then |
545 if (X + SpritesData[Sprite].Width > RightX) then |
538 r.w:= RightX - X + 1; |
546 r.w:= RightX - X + 1; |
539 |
547 |
540 dec(r.h, r.y); |
548 dec(r.h, r.y); |
541 dec(r.w, r.x); |
549 dec(r.w, r.x); |
542 |
|
543 DrawFromRect(X + r.x, Y + r.y, @r, SpritesData[Sprite].Texture) |
550 DrawFromRect(X + r.x, Y + r.y, @r, SpritesData[Sprite].Texture) |
544 end; |
551 end; |
545 |
552 |
546 procedure DrawSprite2(Sprite: TSprite; X, Y, FrameX, FrameY: LongInt); |
553 procedure DrawSprite2(Sprite: TSprite; X, Y, FrameX, FrameY: LongInt); |
547 var r: TSDL_Rect; |
554 var r: TSDL_Rect; |