hedgewars/uStore.pas
changeset 10634 35d059bd0932
parent 10626 2562797ab3cf
child 10640 efa069762cb2
equal deleted inserted replaced
10633:2f062fac5791 10634:35d059bd0932
    48 
    48 
    49 procedure SetupOpenGL;
    49 procedure SetupOpenGL;
    50 function  RenderHelpWindow(caption, subcaption, description, extra: ansistring; extracolor: LongInt; iconsurf: PSDL_Surface; iconrect: PSDL_Rect): PTexture;
    50 function  RenderHelpWindow(caption, subcaption, description, extra: ansistring; extracolor: LongInt; iconsurf: PSDL_Surface; iconrect: PSDL_Rect): PTexture;
    51 procedure RenderWeaponTooltip(atype: TAmmoType);
    51 procedure RenderWeaponTooltip(atype: TAmmoType);
    52 procedure ShowWeaponTooltip(x, y: LongInt);
    52 procedure ShowWeaponTooltip(x, y: LongInt);
    53 procedure FreeWeaponTooltip;
       
    54 procedure MakeCrossHairs;
    53 procedure MakeCrossHairs;
    55 {$IFDEF USE_VIDEO_RECORDING}
    54 {$IFDEF USE_VIDEO_RECORDING}
    56 procedure InitOffscreenOpenGL;
    55 procedure InitOffscreenOpenGL;
    57 {$ENDIF}
    56 {$ENDIF}
    58 
    57 
   472             begin
   471             begin
   473             TryDo(length(trAmmo[NameId]) > 0,'No default text/translation found for ammo type #' + intToStr(ord(ai)) + '!',true);
   472             TryDo(length(trAmmo[NameId]) > 0,'No default text/translation found for ammo type #' + intToStr(ord(ai)) + '!',true);
   474             tmpsurf:= TTF_RenderUTF8_Blended(Fontz[CheckCJKFont(trAmmo[NameId],fnt16)].Handle, PChar(trAmmo[NameId]), cWhiteColorChannels);
   473             tmpsurf:= TTF_RenderUTF8_Blended(Fontz[CheckCJKFont(trAmmo[NameId],fnt16)].Handle, PChar(trAmmo[NameId]), cWhiteColorChannels);
   475             TryDo(tmpsurf <> nil,'Name-texture creation for ammo type #' + intToStr(ord(ai)) + ' failed!',true);
   474             TryDo(tmpsurf <> nil,'Name-texture creation for ammo type #' + intToStr(ord(ai)) + ' failed!',true);
   476             tmpsurf:= doSurfaceConversion(tmpsurf);
   475             tmpsurf:= doSurfaceConversion(tmpsurf);
   477             FreeTexture(NameTex);
   476             FreeAndNilTexture(NameTex);
   478             NameTex:= Surface2Tex(tmpsurf, false);
   477             NameTex:= Surface2Tex(tmpsurf, false);
   479             SDL_FreeSurface(tmpsurf)
   478             SDL_FreeSurface(tmpsurf)
   480             end;
   479             end;
   481 
   480 
   482     // number of weapons in ammo menu
   481     // number of weapons in ammo menu
   483     for i:= Low(CountTexz) to High(CountTexz) do
   482     for i:= Low(CountTexz) to High(CountTexz) do
   484         begin
   483         begin
   485         tmpsurf:= TTF_RenderUTF8_Blended(Fontz[fnt16].Handle, Str2PChar(IntToStr(i) + 'x'), cWhiteColorChannels);
   484         tmpsurf:= TTF_RenderUTF8_Blended(Fontz[fnt16].Handle, Str2PChar(IntToStr(i) + 'x'), cWhiteColorChannels);
   486         tmpsurf:= doSurfaceConversion(tmpsurf);
   485         tmpsurf:= doSurfaceConversion(tmpsurf);
   487         FreeTexture(CountTexz[i]);
   486         FreeAndNilTexture(CountTexz[i]);
   488         CountTexz[i]:= Surface2Tex(tmpsurf, false);
   487         CountTexz[i]:= Surface2Tex(tmpsurf, false);
   489         SDL_FreeSurface(tmpsurf)
   488         SDL_FreeSurface(tmpsurf)
   490         end;
   489         end;
   491 
   490 
   492     if not reload then
   491     if not reload then
   577 
   576 
   578 procedure RenderHealth(var Hedgehog: THedgehog);
   577 procedure RenderHealth(var Hedgehog: THedgehog);
   579 var s: shortstring;
   578 var s: shortstring;
   580 begin
   579 begin
   581 str(Hedgehog.Gear^.Health, s);
   580 str(Hedgehog.Gear^.Health, s);
   582 FreeTexture(Hedgehog.HealthTagTex);
   581 FreeAndNilTexture(Hedgehog.HealthTagTex);
   583 Hedgehog.HealthTagTex:= RenderStringTex(ansistring(s), Hedgehog.Team^.Clan^.Color, fnt16)
   582 Hedgehog.HealthTagTex:= RenderStringTex(ansistring(s), Hedgehog.Team^.Clan^.Color, fnt16)
   584 end;
   583 end;
   585 
   584 
   586 function LoadImage(const filename: shortstring; imageFlags: LongInt): PSDL_Surface;
   585 function LoadImage(const filename: shortstring; imageFlags: LongInt): PSDL_Surface;
   587 var tmpsurf: PSDL_Surface;
   586 var tmpsurf: PSDL_Surface;
   694 
   693 
   695 procedure LoadHedgehogHat2(var HH: THedgehog; newHat: shortstring; allowSurfReuse: boolean);
   694 procedure LoadHedgehogHat2(var HH: THedgehog; newHat: shortstring; allowSurfReuse: boolean);
   696 begin
   695 begin
   697     // free the mem of any previously assigned texture.  This was previously only if the new one could be loaded, but, NoHat is usually a better choice
   696     // free the mem of any previously assigned texture.  This was previously only if the new one could be loaded, but, NoHat is usually a better choice
   698     if HH.HatTex <> nil then
   697     if HH.HatTex <> nil then
   699         begin
   698         FreeAndNilTexture(HH.HatTex);
   700         FreeTexture(HH.HatTex);
       
   701         HH.HatTex:= nil
       
   702         end;
       
   703 
   699 
   704     // load new hat surface if this hat is different than the one already loaded
   700     // load new hat surface if this hat is different than the one already loaded
   705     if newHat <> prevHat then
   701     if newHat <> prevHat then
   706         begin
   702         begin
   707         freeTmpHatSurf();
   703         freeTmpHatSurf();
   840     with mobileRecord do
   836     with mobileRecord do
   841         if GameLoaded <> nil then
   837         if GameLoaded <> nil then
   842             GameLoaded();
   838             GameLoaded();
   843     {$ENDIF}
   839     {$ENDIF}
   844     WriteLnToConsole('Freeing progress surface... ');
   840     WriteLnToConsole('Freeing progress surface... ');
   845     FreeTexture(ProgrTex);
   841     FreeAndNilTexture(ProgrTex);
   846     ProgrTex:= nil;
       
   847     Step:= 0
   842     Step:= 0
   848 end;
   843 end;
   849 
   844 
   850 function RenderHelpWindow(caption, subcaption, description, extra: ansistring; extracolor: LongInt; iconsurf: PSDL_Surface; iconrect: PSDL_Rect): PTexture;
   845 function RenderHelpWindow(caption, subcaption, description, extra: ansistring; extracolor: LongInt; iconsurf: PSDL_Surface; iconrect: PSDL_Rect): PTexture;
   851 var tmpsurf: PSDL_SURFACE;
   846 var tmpsurf: PSDL_SURFACE;
   979         WeaponTooltipTex:= nil;
   974         WeaponTooltipTex:= nil;
   980         exit
   975         exit
   981         end;
   976         end;
   982 
   977 
   983 // free old texture
   978 // free old texture
   984 FreeWeaponTooltip;
   979 FreeAndNilTexture(WeaponTooltipTex);
   985 
   980 
   986 // image region
   981 // image region
   987 i:= LongInt(atype) - 1;
   982 i:= LongInt(atype) - 1;
   988 r.x:= (i shr 4) * 32;
   983 r.x:= (i shr 4) * 32;
   989 r.y:= (i mod 16) * 32;
   984 r.y:= (i mod 16) * 32;
  1017 procedure ShowWeaponTooltip(x, y: LongInt);
  1012 procedure ShowWeaponTooltip(x, y: LongInt);
  1018 begin
  1013 begin
  1019 // draw the texture if it exists
  1014 // draw the texture if it exists
  1020 if WeaponTooltipTex <> nil then
  1015 if WeaponTooltipTex <> nil then
  1021     DrawTexture(x, y, WeaponTooltipTex)
  1016     DrawTexture(x, y, WeaponTooltipTex)
  1022 end;
       
  1023 
       
  1024 procedure FreeWeaponTooltip;
       
  1025 begin
       
  1026 // free the existing texture (if there is any)
       
  1027 FreeTexture(WeaponTooltipTex);
       
  1028 WeaponTooltipTex:= nil
       
  1029 end;
  1017 end;
  1030 
  1018 
  1031 {$IFDEF USE_VIDEO_RECORDING}
  1019 {$IFDEF USE_VIDEO_RECORDING}
  1032 {$IFDEF SDL2}
  1020 {$IFDEF SDL2}
  1033 procedure InitOffscreenOpenGL;
  1021 procedure InitOffscreenOpenGL;