hedgewars/uStore.pas
changeset 4901 d1e2d82d9ccc
parent 4900 8ad0e23e6d63
child 4911 5d10bd725efe
equal deleted inserted replaced
4900:8ad0e23e6d63 4901:d1e2d82d9ccc
   327 HHTexture:= Surface2Tex(tmpsurf, false);
   327 HHTexture:= Surface2Tex(tmpsurf, false);
   328 SDL_FreeSurface(tmpsurf);
   328 SDL_FreeSurface(tmpsurf);
   329 
   329 
   330 InitHealth;
   330 InitHealth;
   331 
   331 
   332 // TODO: are those textures ever freed?
       
   333 PauseTexture:= RenderStringTex(trmsg[sidPaused], cYellowColor, fntBig);
   332 PauseTexture:= RenderStringTex(trmsg[sidPaused], cYellowColor, fntBig);
   334 ConfirmTexture:= RenderStringTex(trmsg[sidConfirm], cYellowColor, fntBig);
   333 ConfirmTexture:= RenderStringTex(trmsg[sidConfirm], cYellowColor, fntBig);
   335 SyncTexture:= RenderStringTex(trmsg[sidSync], cYellowColor, fntBig);
   334 SyncTexture:= RenderStringTex(trmsg[sidSync], cYellowColor, fntBig);
   336 
   335 
   337 AddProgress;
   336 AddProgress;
   342     begin
   341     begin
   343         TryDo(trAmmo[NameId] <> '','No default text/translation found for ammo type #' + intToStr(ord(ai)) + '!',true);
   342         TryDo(trAmmo[NameId] <> '','No default text/translation found for ammo type #' + intToStr(ord(ai)) + '!',true);
   344         tmpsurf:= TTF_RenderUTF8_Blended(Fontz[CheckCJKFont(trAmmo[NameId],fnt16)].Handle, Str2PChar(trAmmo[NameId]), cWhiteColorChannels);
   343         tmpsurf:= TTF_RenderUTF8_Blended(Fontz[CheckCJKFont(trAmmo[NameId],fnt16)].Handle, Str2PChar(trAmmo[NameId]), cWhiteColorChannels);
   345         TryDo(tmpsurf <> nil,'Name-texture creation for ammo type #' + intToStr(ord(ai)) + ' failed!',true);
   344         TryDo(tmpsurf <> nil,'Name-texture creation for ammo type #' + intToStr(ord(ai)) + ' failed!',true);
   346         tmpsurf:= doSurfaceConversion(tmpsurf);
   345         tmpsurf:= doSurfaceConversion(tmpsurf);
       
   346         if (NameTex <> nil) then
       
   347             FreeTexture(NameTex);
   347         NameTex:= Surface2Tex(tmpsurf, false);
   348         NameTex:= Surface2Tex(tmpsurf, false);
   348         SDL_FreeSurface(tmpsurf)
   349         SDL_FreeSurface(tmpsurf)
   349     end;
   350     end;
   350 
   351 
   351 // number of weapons in ammo menu
   352 // number of weapons in ammo menu
   352 for i:= Low(CountTexz) to High(CountTexz) do
   353 for i:= Low(CountTexz) to High(CountTexz) do
   353 begin
   354 begin
   354     tmpsurf:= TTF_RenderUTF8_Blended(Fontz[fnt16].Handle, Str2PChar(IntToStr(i) + 'x'), cWhiteColorChannels);
   355     tmpsurf:= TTF_RenderUTF8_Blended(Fontz[fnt16].Handle, Str2PChar(IntToStr(i) + 'x'), cWhiteColorChannels);
   355     tmpsurf:= doSurfaceConversion(tmpsurf);
   356     tmpsurf:= doSurfaceConversion(tmpsurf);
       
   357     if (CountTexz[i] <> nil) then
       
   358         FreeTexture(CountTexz[i]);
   356     CountTexz[i]:= Surface2Tex(tmpsurf, false);
   359     CountTexz[i]:= Surface2Tex(tmpsurf, false);
   357     SDL_FreeSurface(tmpsurf)
   360     SDL_FreeSurface(tmpsurf)
   358 end;
   361 end;
   359 
   362 
   360 AddProgress;
   363 AddProgress;
   364 {$ENDIF}
   367 {$ENDIF}
   365 end;
   368 end;
   366 
   369 
   367 procedure StoreRelease;
   370 procedure StoreRelease;
   368 var ii: TSprite;
   371 var ii: TSprite;
       
   372     ai: TAmmoType;
       
   373     i, t: LongInt;
   369 begin
   374 begin
   370     for ii:= Low(TSprite) to High(TSprite) do
   375     for ii:= Low(TSprite) to High(TSprite) do
   371     begin
   376     begin
   372         FreeTexture(SpritesData[ii].Texture);
   377         FreeTexture(SpritesData[ii].Texture);
   373         SpritesData[ii].Texture:= nil;
   378         SpritesData[ii].Texture:= nil;
   376         SpritesData[ii].Surface:= nil;
   381         SpritesData[ii].Surface:= nil;
   377     end;
   382     end;
   378     SDL_FreeSurface(MissionIcons);
   383     SDL_FreeSurface(MissionIcons);
   379     FreeTexture(ropeIconTex);
   384     FreeTexture(ropeIconTex);
   380     FreeTexture(HHTexture);
   385     FreeTexture(HHTexture);
       
   386     FreeTexture(PauseTexture);
       
   387     FreeTexture(ConfirmTexture);
       
   388     FreeTexture(SyncTexture);
       
   389     // free all ammo name textures
       
   390     for ai:= Low(TAmmoType) to High(TAmmoType) do
       
   391     begin
       
   392         FreeTexture(Ammoz[ai].NameTex);
       
   393     end;
       
   394     // free all count textures
       
   395     for i:= Low(CountTexz) to High(CountTexz) do
       
   396     begin
       
   397         FreeTexture(CountTexz[i]);
       
   398     end;
       
   399     // free all team and hedgehog textures
       
   400     for t:= 0 to Pred(TeamsCount) do
       
   401     begin
       
   402         if TeamsArray[t] <> nil then
       
   403         begin
       
   404             FreeTexture(TeamsArray[t]^.NameTagTex);
       
   405             FreeTexture(TeamsArray[t]^.CrosshairTex);
       
   406             FreeTexture(TeamsArray[t]^.GraveTex);
       
   407             FreeTexture(TeamsArray[t]^.HealthTex);
       
   408             FreeTexture(TeamsArray[t]^.AIKillsTex);
       
   409             FreeTexture(TeamsArray[t]^.FlagTex);
       
   410             for i:= 0 to cMaxHHIndex do
       
   411             begin
       
   412                 FreeTexture(TeamsArray[t]^.Hedgehogs[i].NameTagTex);
       
   413                 FreeTexture(TeamsArray[t]^.Hedgehogs[i].HealthTagTex);
       
   414                 FreeTexture(TeamsArray[t]^.Hedgehogs[i].HatTex);
       
   415             end;
       
   416         end;
       
   417     end;
   381 {$IFNDEF S3D_DISABLED}
   418 {$IFNDEF S3D_DISABLED}
   382     if (cStereoMode = smHorizontal) or (cStereoMode = smVertical) or (cStereoMode = smAFR) then
   419     if (cStereoMode = smHorizontal) or (cStereoMode = smVertical) or (cStereoMode = smAFR) then
   383     begin
   420     begin
   384         glDeleteTextures(1, @texl);
   421         glDeleteTextures(1, @texl);
   385         glDeleteRenderbuffersEXT(1, @depthl);
   422         glDeleteRenderbuffersEXT(1, @depthl);