49 procedure DrawFromStoreRect(X, Y: integer; Rect: PSDL_Rect; Surface: PSDL_Surface); |
49 procedure DrawFromStoreRect(X, Y: integer; Rect: PSDL_Rect; Surface: PSDL_Surface); |
50 procedure DrawHedgehog(X, Y: integer; Dir: integer; Pos, Step: LongWord; Surface: PSDL_Surface); |
50 procedure DrawHedgehog(X, Y: integer; Dir: integer; Pos, Step: LongWord; Surface: PSDL_Surface); |
51 procedure RenderHealth(var Hedgehog: THedgehog); |
51 procedure RenderHealth(var Hedgehog: THedgehog); |
52 function RenderString(var s: shortstring; Color, Pos: integer): TSDL_Rect; |
52 function RenderString(var s: shortstring; Color, Pos: integer): TSDL_Rect; |
53 procedure AddProgress; |
53 procedure AddProgress; |
54 function LoadImage(filename: string; hasAlpha: boolean): PSDL_Surface; |
54 function LoadImage(filename: string; hasAlpha: boolean; const critical: boolean = true): PSDL_Surface; |
55 |
55 |
56 var PixelFormat: PSDL_PixelFormat; |
56 var PixelFormat: PSDL_PixelFormat; |
57 SDLPrimSurface: PSDL_Surface; |
57 SDLPrimSurface: PSDL_Surface; |
58 |
58 |
59 implementation |
59 implementation |
246 end; |
246 end; |
247 |
247 |
248 procedure GetSkyColor; |
248 procedure GetSkyColor; |
249 var p: Longword; |
249 var p: Longword; |
250 begin |
250 begin |
251 if SDL_MustLock(StoreSurface) then |
251 if SDL_MustLock(SpritesData[sprSky].Surface) then |
252 SDLTry(SDL_LockSurface(StoreSurface) >= 0, true); |
252 SDLTry(SDL_LockSurface(SpritesData[sprSky].Surface) >= 0, true); |
253 p:= Longword(StoreSurface.pixels) + Word(StuffPoz[sSky].x) * StoreSurface.format.BytesPerPixel; |
253 p:= Longword(SpritesData[sprSky].Surface.pixels); |
254 case StoreSurface.format.BytesPerPixel of |
254 case SpritesData[sprSky].Surface.format.BytesPerPixel of |
255 1: cSkyColor:= PByte(p)^; |
255 1: cSkyColor:= PByte(p)^; |
256 2: cSkyColor:= PWord(p)^; |
256 2: cSkyColor:= PWord(p)^; |
257 3: cSkyColor:= (PByte(p)^) or (PByte(p + 1)^ shl 8) or (PByte(p + 2)^ shl 16); |
257 3: cSkyColor:= (PByte(p)^) or (PByte(p + 1)^ shl 8) or (PByte(p + 2)^ shl 16); |
258 4: cSkyColor:= PLongword(p)^; |
258 4: cSkyColor:= PLongword(p)^; |
259 end; |
259 end; |
260 if SDL_MustLock(StoreSurface) then |
260 if SDL_MustLock(SpritesData[sprSky].Surface) then |
261 SDL_UnlockSurface(StoreSurface) |
261 SDL_UnlockSurface(SpritesData[sprSky].Surface) |
262 end; |
262 end; |
263 |
263 |
264 procedure GetExplosionBorderColor; |
264 procedure GetExplosionBorderColor; |
265 var f: textfile; |
265 var f: textfile; |
266 c: integer; |
266 c: integer; |
267 begin |
267 begin |
268 s:= Pathz[ptThemeCurrent] + '/' + cThemeCFGFilename; |
268 s:= Pathz[ptCurrTheme] + '/' + cThemeCFGFilename; |
269 WriteToConsole(msgLoading + s + ' '); |
269 WriteToConsole(msgLoading + s + ' '); |
270 AssignFile(f, s); |
270 AssignFile(f, s); |
271 {$I-} |
271 {$I-} |
272 Reset(f); |
272 Reset(f); |
273 Readln(f, s); |
273 Readln(f, s); |
317 AddProgress; |
317 AddProgress; |
318 WriteNames(fnt16); |
318 WriteNames(fnt16); |
319 MakeCrossHairs; |
319 MakeCrossHairs; |
320 LoadGraves; |
320 LoadGraves; |
321 |
321 |
322 GetSkyColor; |
|
323 |
|
324 AddProgress; |
322 AddProgress; |
325 for ii:= Low(TSprite) to High(TSprite) do |
323 for ii:= Low(TSprite) to High(TSprite) do |
326 with SpritesData[ii] do |
324 with SpritesData[ii] do |
327 Surface:= LoadImage(Pathz[Path] + '/' + FileName, hasAlpha); |
325 begin |
|
326 if AltPath = ptNone then |
|
327 Surface:= LoadImage(Pathz[Path] + '/' + FileName, hasAlpha) |
|
328 else begin |
|
329 Surface:= LoadImage(Pathz[Path] + '/' + FileName, hasAlpha, false); |
|
330 if Surface = nil then |
|
331 Surface:= LoadImage(Pathz[AltPath] + '/' + FileName, hasAlpha) |
|
332 end; |
|
333 if Width = 0 then Width:= Surface.w; |
|
334 if Height = 0 then Height:= Surface.h |
|
335 end; |
|
336 |
|
337 GetSkyColor; |
328 |
338 |
329 AddProgress; |
339 AddProgress; |
330 tmpsurf:= LoadImage(Pathz[ptGraphics] + '/' + cHHFileName, false); |
340 tmpsurf:= LoadImage(Pathz[ptGraphics] + '/' + cHHFileName, false); |
331 TryDo(SDL_SetColorKey(tmpsurf, SDL_SRCCOLORKEY or SDL_RLEACCEL, 0) = 0, errmsgTransparentSet, true); |
341 TryDo(SDL_SetColorKey(tmpsurf, SDL_SRCCOLORKEY or SDL_RLEACCEL, 0) = 0, errmsgTransparentSet, true); |
332 HHSurface:= SDL_DisplayFormat(tmpsurf); |
342 HHSurface:= SDL_DisplayFormat(tmpsurf); |
482 WriteLnToConsole('Freeing progress surface... '); |
492 WriteLnToConsole('Freeing progress surface... '); |
483 SDL_FreeSurface(ProgrSurf) |
493 SDL_FreeSurface(ProgrSurf) |
484 end; |
494 end; |
485 end; |
495 end; |
486 |
496 |
487 function LoadImage(filename: string; hasAlpha: boolean): PSDL_Surface; |
497 function LoadImage(filename: string; hasAlpha: boolean; const critical: boolean = true): PSDL_Surface; |
488 var tmpsurf: PSDL_Surface; |
498 var tmpsurf: PSDL_Surface; |
489 begin |
499 begin |
490 WriteToConsole(msgLoading + filename + '... '); |
500 WriteToConsole(msgLoading + filename + '... '); |
491 tmpsurf:= IMG_Load(PChar(filename + '.' + cBitsStr + '.png')); |
501 tmpsurf:= IMG_Load(PChar(filename + '.' + cBitsStr + '.png')); |
492 if tmpsurf = nil then |
502 if tmpsurf = nil then |
493 tmpsurf:= IMG_Load(PChar(filename + '.png')); |
503 tmpsurf:= IMG_Load(PChar(filename + '.png')); |
494 TryDo(tmpsurf <> nil, msgFailed, true); |
504 |
|
505 if tmpsurf = nil then |
|
506 if critical then OutError(msgFailed, true) |
|
507 else begin |
|
508 WriteLnToConsole(msgFailed); |
|
509 Result:= nil; |
|
510 exit |
|
511 end; |
|
512 |
495 TryDo(SDL_SetColorKey(tmpsurf, SDL_SRCCOLORKEY or SDL_RLEACCEL, 0) = 0, errmsgTransparentSet, true); |
513 TryDo(SDL_SetColorKey(tmpsurf, SDL_SRCCOLORKEY or SDL_RLEACCEL, 0) = 0, errmsgTransparentSet, true); |
496 if cFullScreen then |
514 if hasAlpha then Result:= SDL_DisplayFormatAlpha(tmpsurf) |
497 begin |
515 else Result:= SDL_DisplayFormat(tmpsurf); |
498 if hasAlpha then Result:= SDL_DisplayFormatAlpha(tmpsurf) |
|
499 else Result:= SDL_DisplayFormat(tmpsurf); |
|
500 SDL_FreeSurface(tmpsurf); |
|
501 end else Result:= tmpsurf; |
|
502 WriteLnToConsole(msgOK) |
516 WriteLnToConsole(msgOK) |
503 end; |
517 end; |
504 |
518 |
505 end. |
519 end. |