256 fi: THWFont; |
256 fi: THWFont; |
257 ai: TAmmoType; |
257 ai: TAmmoType; |
258 tmpsurf: PSDL_Surface; |
258 tmpsurf: PSDL_Surface; |
259 i: LongInt; |
259 i: LongInt; |
260 begin |
260 begin |
|
261 |
261 for fi:= Low(THWFont) to High(THWFont) do |
262 for fi:= Low(THWFont) to High(THWFont) do |
262 with Fontz[fi] do |
263 with Fontz[fi] do |
263 begin |
264 begin |
264 s:= Pathz[ptFonts] + '/' + Name; |
265 s:= Pathz[ptFonts] + '/' + Name; |
265 WriteToConsole(msgLoading + s + '... '); |
266 WriteToConsole(msgLoading + s + '... '); |
266 Handle:= TTF_OpenFont(Str2PChar(s), Height); |
267 Handle:= TTF_OpenFont(Str2PChar(s), Height); |
267 SDLTry(Handle <> nil, true); |
268 SDLTry(Handle <> nil, true); |
268 TTF_SetFontStyle(Handle, style); |
269 TTF_SetFontStyle(Handle, style); |
269 WriteLnToConsole(msgOK) |
270 WriteLnToConsole(msgOK) |
270 end; |
271 end; |
271 AddProgress; |
|
272 |
272 |
273 WriteNames(fnt16); |
273 WriteNames(fnt16); |
274 MakeCrossHairs; |
274 MakeCrossHairs; |
275 LoadGraves; |
275 LoadGraves; |
276 |
276 |
310 begin |
310 begin |
311 tmpsurf:= TTF_RenderUTF8_Blended(Fontz[fnt16].Handle, Str2PChar(trAmmo[NameId]), $FFFFFF); |
311 tmpsurf:= TTF_RenderUTF8_Blended(Fontz[fnt16].Handle, Str2PChar(trAmmo[NameId]), $FFFFFF); |
312 NameTex:= Surface2Tex(tmpsurf); |
312 NameTex:= Surface2Tex(tmpsurf); |
313 SDL_FreeSurface(tmpsurf) |
313 SDL_FreeSurface(tmpsurf) |
314 end; |
314 end; |
315 |
315 |
316 for i:= Low(CountTexz) to High(CountTexz) do |
316 for i:= Low(CountTexz) to High(CountTexz) do |
317 begin |
317 begin |
318 tmpsurf:= TTF_RenderUTF8_Blended(Fontz[fnt16].Handle, Str2PChar(IntToStr(i) + 'x'), $FFFFFF); |
318 tmpsurf:= TTF_RenderUTF8_Blended(Fontz[fnt16].Handle, Str2PChar(IntToStr(i) + 'x'), $FFFFFF); |
319 CountTexz[i]:= Surface2Tex(tmpsurf); |
319 CountTexz[i]:= Surface2Tex(tmpsurf); |
320 SDL_FreeSurface(tmpsurf) |
320 SDL_FreeSurface(tmpsurf) |
322 |
322 |
323 {$IFDEF DUMP} |
323 {$IFDEF DUMP} |
324 SDL_SaveBMP_RW(LandSurface, SDL_RWFromFile('LandSurface.bmp', 'wb'), 1); |
324 SDL_SaveBMP_RW(LandSurface, SDL_RWFromFile('LandSurface.bmp', 'wb'), 1); |
325 SDL_SaveBMP_RW(StoreSurface, SDL_RWFromFile('StoreSurface.bmp', 'wb'), 1); |
325 SDL_SaveBMP_RW(StoreSurface, SDL_RWFromFile('StoreSurface.bmp', 'wb'), 1); |
326 {$ENDIF} |
326 {$ENDIF} |
|
327 AddProgress; |
327 end; |
328 end; |
328 |
329 |
329 procedure DrawFromRect(X, Y: LongInt; r: PSDL_Rect; SourceTexture: PTexture); |
330 procedure DrawFromRect(X, Y: LongInt; r: PSDL_Rect; SourceTexture: PTexture); |
330 var rr: TSDL_Rect; |
331 var rr: TSDL_Rect; |
331 _l, _r, _t, _b: real; |
332 _l, _r, _t, _b: real; |
513 DrawFromRect(X, Y, @r, SpritesData[Sprite].Texture) |
514 DrawFromRect(X, Y, @r, SpritesData[Sprite].Texture) |
514 end; |
515 end; |
515 |
516 |
516 procedure DrawSprite (Sprite: TSprite; X, Y, Frame: LongInt); |
517 procedure DrawSprite (Sprite: TSprite; X, Y, Frame: LongInt); |
517 var r: TSDL_Rect; |
518 var r: TSDL_Rect; |
518 begin |
519 var flag: integer = 0; |
519 r.x:= 0; |
520 begin |
|
521 if flag = 0 then r.x:= 0 |
|
522 else r.x := 0; |
520 r.w:= SpritesData[Sprite].Width; |
523 r.w:= SpritesData[Sprite].Width; |
521 r.y:= Frame * SpritesData[Sprite].Height; |
524 r.y:= Frame * SpritesData[Sprite].Height; |
522 r.h:= SpritesData[Sprite].Height; |
525 r.h:= SpritesData[Sprite].Height; |
523 DrawFromRect(X, Y, @r, SpritesData[Sprite].Texture) |
526 DrawFromRect(X, Y, @r, SpritesData[Sprite].Texture) |
524 end; |
527 end; |
937 end; |
940 end; |
938 |
941 |
939 //////////////////////////////////////////////////////////////////////////////// |
942 //////////////////////////////////////////////////////////////////////////////// |
940 var ProgrTex: PTexture = nil; |
943 var ProgrTex: PTexture = nil; |
941 Step: integer = 0; |
944 Step: integer = 0; |
942 |
945 squaresize : LongInt; |
|
946 numsquares : integer; |
943 procedure AddProgress; |
947 procedure AddProgress; |
944 var r: TSDL_Rect; |
948 var r: TSDL_Rect; |
945 texsurf: PSDL_Surface; |
949 texsurf: PSDL_Surface; |
946 begin |
950 begin |
947 if Step = 0 then |
951 if Step = 0 then |
948 begin |
952 begin |
949 WriteToConsole(msgLoading + 'progress sprite: '); |
953 WriteToConsole(msgLoading + 'progress sprite: '); |
950 texsurf:= LoadImage(Pathz[ptGraphics] + '/Progress', ifCritical or ifTransparent); |
954 texsurf:= LoadImage(Pathz[ptGraphics] + '/Progress', ifCritical or ifTransparent); |
951 ProgrTex:= Surface2Tex(texsurf); |
955 ProgrTex:= Surface2Tex(texsurf); |
952 SDL_FreeSurface(texsurf) |
956 SDL_FreeSurface(texsurf); |
|
957 squaresize:= ProgrTex^.w shr 1; |
|
958 numsquares:= ProgrTex^.h div squaresize; |
953 end; |
959 end; |
954 |
960 |
955 glClear(GL_COLOR_BUFFER_BIT); |
961 glClear(GL_COLOR_BUFFER_BIT); |
956 glEnable(GL_TEXTURE_2D); |
962 glEnable(GL_TEXTURE_2D); |
957 r.x:= 0; |
963 if Step < numsquares then r.x:= 0 |
958 r.w:= ProgrTex^.w; |
964 else r.x:= squaresize; |
959 r.h:= ProgrTex^.w; |
965 r.y:= (Step mod numsquares) * squaresize; |
960 r.y:= (Step mod (ProgrTex^.h div ProgrTex^.w)) * ProgrTex^.w; |
966 r.w:= squaresize; |
961 DrawFromRect( -ProgrTex^.w div 2, |
967 r.h:= squaresize; |
962 (cScreenHeight - ProgrTex^.w) div 2, @r, ProgrTex); |
968 DrawFromRect( -squaresize div 2, (cScreenHeight - squaresize) shr 1, @r, ProgrTex); |
963 glDisable(GL_TEXTURE_2D); |
969 glDisable(GL_TEXTURE_2D); |
964 SDL_GL_SwapBuffers(); |
970 SDL_GL_SwapBuffers(); |
965 inc(Step); |
971 inc(Step); |
966 end; |
972 end; |
|
973 |
967 |
974 |
968 procedure FinishProgress; |
975 procedure FinishProgress; |
969 begin |
976 begin |
970 WriteLnToConsole('Freeing progress surface... '); |
977 WriteLnToConsole('Freeing progress surface... '); |
971 FreeTexture(ProgrTex) |
978 FreeTexture(ProgrTex) |