hedgewars/uStore.pas
changeset 12186 322aaad4a93d
parent 12175 9237bfb198c7
child 12189 31184d9b9bfc
equal deleted inserted replaced
12185:cb7d5fd2e515 12186:322aaad4a93d
    24 uses SysUtils, uConsts, SDLh, GLunit, uTypes, uLandTexture, uCaptions, uChat;
    24 uses SysUtils, uConsts, SDLh, GLunit, uTypes, uLandTexture, uCaptions, uChat;
    25 
    25 
    26 procedure initModule;
    26 procedure initModule;
    27 procedure freeModule;
    27 procedure freeModule;
    28 
    28 
       
    29 procedure LoadFonts();
    29 procedure StoreLoad(reload: boolean);
    30 procedure StoreLoad(reload: boolean);
    30 procedure StoreRelease(reload: boolean);
    31 procedure StoreRelease(reload: boolean);
    31 procedure RenderHealth(var Hedgehog: THedgehog);
    32 procedure RenderHealth(var Hedgehog: THedgehog);
    32 function makeHealthBarTexture(w, h, Color: Longword): PTexture;
    33 function makeHealthBarTexture(w, h, Color: Longword): PTexture;
    33 procedure AddProgress;
    34 procedure AddProgress;
    70     SDLwindow: PSDL_Window;
    71     SDLwindow: PSDL_Window;
    71     SDLGLcontext: PSDL_GLContext;
    72     SDLGLcontext: PSDL_GLContext;
    72     squaresize : LongInt;
    73     squaresize : LongInt;
    73     numsquares : LongInt;
    74     numsquares : LongInt;
    74     ProgrTex: PTexture;
    75     ProgrTex: PTexture;
       
    76     LoadingText: PTexture;
    75 
    77 
    76     prevHat: shortstring;
    78     prevHat: shortstring;
    77     tmpHatSurf: PSDL_Surface;
    79     tmpHatSurf: PSDL_Surface;
    78 
    80 
    79 const
    81 const
   346             GraveTex:= Surface2Tex(texsurf, false);
   348             GraveTex:= Surface2Tex(texsurf, false);
   347             SDL_FreeSurface(texsurf)
   349             SDL_FreeSurface(texsurf)
   348             end
   350             end
   349 end;
   351 end;
   350 
   352 
   351 procedure StoreLoad(reload: boolean);
   353 procedure LoadFonts();
   352 var s: shortstring;
   354 var s: shortstring;
   353     ii: TSprite;
       
   354     fi: THWFont;
   355     fi: THWFont;
   355     ai: TAmmoType;
   356 begin
   356     tmpsurf: PSDL_Surface;
   357 AddFileLog('LoadFonts();');
   357     i, imflags: LongInt;
   358 
   358 begin
   359 if (not cOnlyStats) then
   359 AddFileLog('StoreLoad()');
       
   360 
       
   361 if (not reload) and (not cOnlyStats) then
       
   362     for fi:= Low(THWFont) to High(THWFont) do
   360     for fi:= Low(THWFont) to High(THWFont) do
   363         with Fontz[fi] do
   361         with Fontz[fi] do
   364             begin
   362             begin
   365             s:= cPathz[ptFonts] + '/' + Name;
   363             s:= cPathz[ptFonts] + '/' + Name;
   366             WriteToConsole(msgLoading + s + ' (' + inttostr(Height) + 'pt)... ');
   364             WriteToConsole(msgLoading + s + ' (' + inttostr(Height) + 'pt)... ');
   367             Handle:= TTF_OpenFontRW(rwopsOpenRead(s), true, Height);
   365             Handle:= TTF_OpenFontRW(rwopsOpenRead(s), true, Height);
   368             if SDLCheck(Handle <> nil, 'TTF_OpenFontRW', true) then exit;
   366             if SDLCheck(Handle <> nil, 'TTF_OpenFontRW', true) then exit;
   369             TTF_SetFontStyle(Handle, style);
   367             TTF_SetFontStyle(Handle, style);
   370             WriteLnToConsole(msgOK)
   368             WriteLnToConsole(msgOK)
   371             end;
   369             end;
       
   370 end;
       
   371 
       
   372 procedure StoreLoad(reload: boolean);
       
   373 var s: shortstring;
       
   374     ii: TSprite;
       
   375     fi: THWFont;
       
   376     ai: TAmmoType;
       
   377     tmpsurf: PSDL_Surface;
       
   378     i, imflags: LongInt;
       
   379 begin
       
   380 AddFileLog('StoreLoad()');
   372 
   381 
   373 if not cOnlyStats then
   382 if not cOnlyStats then
   374     begin
   383     begin
   375     MakeCrossHairs;
   384     MakeCrossHairs;
   376     LoadGraves;
   385     LoadGraves;
   772         WriteToConsole(msgLoading + 'progress sprite: ');
   781         WriteToConsole(msgLoading + 'progress sprite: ');
   773         texsurf:= LoadDataImage(ptGraphics, 'Progress', ifCritical or ifTransparent);
   782         texsurf:= LoadDataImage(ptGraphics, 'Progress', ifCritical or ifTransparent);
   774 
   783 
   775         ProgrTex:= Surface2Tex(texsurf, false);
   784         ProgrTex:= Surface2Tex(texsurf, false);
   776 
   785 
       
   786         LoadingText:= RenderStringTex(trmsg[sidLoading], $FFF39EE8, fntBig);
       
   787 
   777         squaresize:= texsurf^.w shr 1;
   788         squaresize:= texsurf^.w shr 1;
   778         numsquares:= texsurf^.h div squaresize;
   789         numsquares:= texsurf^.h div squaresize;
   779         SDL_FreeSurface(texsurf);
   790         SDL_FreeSurface(texsurf);
       
   791 
   780         {$IFNDEF PAS2C}
   792         {$IFNDEF PAS2C}
   781         with mobileRecord do
   793         with mobileRecord do
   782             if GameLoading <> nil then
   794             if GameLoading <> nil then
   783                 GameLoading();
   795                 GameLoading();
   784         {$ENDIF}
   796         {$ENDIF}
   795     r.y:= (Step mod numsquares) * squaresize;
   807     r.y:= (Step mod numsquares) * squaresize;
   796     r.w:= squaresize;
   808     r.w:= squaresize;
   797     r.h:= squaresize;
   809     r.h:= squaresize;
   798 
   810 
   799     DrawTextureFromRect( -squaresize div 2, (cScreenHeight - squaresize) shr 1, @r, ProgrTex);
   811     DrawTextureFromRect( -squaresize div 2, (cScreenHeight - squaresize) shr 1, @r, ProgrTex);
       
   812     DrawTexture( -LoadingText^.w div 2, (cScreenHeight - LoadingText^.h) shr 1 - (squaresize div 2) - (LoadingText^.h div 2) - 8, LoadingText);
   800 
   813 
   801     SwapBuffers;
   814     SwapBuffers;
   802 
   815 
   803     inc(Step);
   816     inc(Step);
   804 end;
   817 end;
   808     {$IFNDEF PAS2C}
   821     {$IFNDEF PAS2C}
   809     with mobileRecord do
   822     with mobileRecord do
   810         if GameLoaded <> nil then
   823         if GameLoaded <> nil then
   811             GameLoaded();
   824             GameLoaded();
   812     {$ENDIF}
   825     {$ENDIF}
   813     WriteLnToConsole('Freeing progress surface... ');
   826     WriteLnToConsole('Freeing progress textures... ');
   814     FreeAndNilTexture(ProgrTex);
   827     FreeAndNilTexture(ProgrTex);
       
   828     FreeAndNilTexture(LoadingText);
   815     Step:= 0
   829     Step:= 0
   816 end;
   830 end;
   817 
   831 
   818 function RenderHelpWindow(caption, subcaption, description, extra: ansistring; extracolor: LongInt; iconsurf: PSDL_Surface; iconrect: PSDL_Rect): PTexture;
   832 function RenderHelpWindow(caption, subcaption, description, extra: ansistring; extracolor: LongInt; iconsurf: PSDL_Surface; iconrect: PSDL_Rect): PTexture;
   819 var tmpsurf: PSDL_SURFACE;
   833 var tmpsurf: PSDL_SURFACE;