hedgewars/uWorld.pas
changeset 10634 35d059bd0932
parent 10628 9361e7d7c410
child 10662 e0d7d499c851
equal deleted inserted replaced
10633:2f062fac5791 10634:35d059bd0932
   402 end;
   402 end;
   403 
   403 
   404 // for uStore texture resetting
   404 // for uStore texture resetting
   405 procedure ResetWorldTex;
   405 procedure ResetWorldTex;
   406 begin
   406 begin
   407     FreeTexture(fpsTexture);
   407     FreeAndNilTexture(fpsTexture);
   408     fpsTexture:= nil;
   408     FreeAndNilTexture(timeTexture);
   409     FreeTexture(timeTexture);
   409     FreeAndNilTexture(missionTex);
   410     timeTexture:= nil;
   410     FreeAndNilTexture(recTexture);
   411     FreeTexture(missionTex);
   411     FreeAndNilTexture(AmmoMenuTex);
   412     missionTex:= nil;
       
   413     FreeTexture(recTexture);
       
   414     recTexture:= nil;
       
   415     FreeTexture(AmmoMenuTex);
       
   416     AmmoMenuInvalidated:= true;
   412     AmmoMenuInvalidated:= true;
   417     AmmoMenuTex:= nil;
       
   418 end;
   413 end;
   419 
   414 
   420 function GetAmmoMenuTexture(Ammo: PHHAmmo): PTexture;
   415 function GetAmmoMenuTexture(Ammo: PHHAmmo): PTexture;
   421 const BORDERSIZE = 2;
   416 const BORDERSIZE = 2;
   422 var x, y, i, t, SlotsNumY, SlotsNumX, AMFrame: LongInt;
   417 var x, y, i, t, SlotsNumY, SlotsNumX, AMFrame: LongInt;
   564 
   559 
   565 //Init the menu
   560 //Init the menu
   566 if(AmmoMenuInvalidated) then
   561 if(AmmoMenuInvalidated) then
   567     begin
   562     begin
   568     AmmoMenuInvalidated:= false;
   563     AmmoMenuInvalidated:= false;
   569     FreeTexture(AmmoMenuTex);
   564     FreeAndNilTexture(AmmoMenuTex);
   570     AmmoMenuTex:= GetAmmoMenuTexture(Ammo);
   565     AmmoMenuTex:= GetAmmoMenuTexture(Ammo);
   571 
   566 
   572 {$IFDEF USE_LANDSCAPE_AMMOMENU}
   567 {$IFDEF USE_LANDSCAPE_AMMOMENU}
   573     if isPhone() then
   568     if isPhone() then
   574         begin
   569         begin
   747             if bSelected and (Ammoz[Ammo^[Slot, Pos].AmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber < 0) then
   742             if bSelected and (Ammoz[Ammo^[Slot, Pos].AmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber < 0) then
   748                 begin
   743                 begin
   749                 bShowAmmoMenu:= false;
   744                 bShowAmmoMenu:= false;
   750                 SetWeapon(Ammo^[Slot, Pos].AmmoType);
   745                 SetWeapon(Ammo^[Slot, Pos].AmmoType);
   751                 bSelected:= false;
   746                 bSelected:= false;
   752                 FreeWeaponTooltip;
   747                 FreeAndNilTexture(WeaponTooltipTex);
   753 {$IFDEF USE_TOUCH_INTERFACE}//show the aiming buttons + animation
   748 {$IFDEF USE_TOUCH_INTERFACE}//show the aiming buttons + animation
   754                 if (Ammo^[Slot, Pos].Propz and ammoprop_NeedUpDown) <> 0 then
   749                 if (Ammo^[Slot, Pos].Propz and ammoprop_NeedUpDown) <> 0 then
   755                     begin
   750                     begin
   756                     if (not arrowUp.show) then
   751                     if (not arrowUp.show) then
   757                         begin
   752                         begin
   770                 exit
   765                 exit
   771                 end;
   766                 end;
   772             end
   767             end
   773         end
   768         end
   774     else
   769     else
   775         FreeWeaponTooltip;
   770         FreeAndNilTexture(WeaponTooltipTex);
   776 
   771 
   777     if (WeaponTooltipTex <> nil) and (AMShiftX = 0) and (AMShiftY = 0) then
   772     if (WeaponTooltipTex <> nil) and (AMShiftX = 0) and (AMShiftY = 0) then
   778 {$IFDEF USE_LANDSCAPE_AMMOMENU}
   773 {$IFDEF USE_LANDSCAPE_AMMOMENU}
   779         if (not isPhone()) then
   774         if (not isPhone()) then
   780             ShowWeaponTooltip(-WeaponTooltipTex^.w div 2, AmmoRect.y - WeaponTooltipTex^.h - AMSlotSize);
   775             ShowWeaponTooltip(-WeaponTooltipTex^.w div 2, AmmoRect.y - WeaponTooltipTex^.h - AMSlotSize);
  1680         s:= inttostr(i div 60) + ':' + s;
  1675         s:= inttostr(i div 60) + ':' + s;
  1681 
  1676 
  1682 
  1677 
  1683         tmpSurface:= TTF_RenderUTF8_Blended(Fontz[fnt16].Handle, Str2PChar(s), cWhiteColorChannels);
  1678         tmpSurface:= TTF_RenderUTF8_Blended(Fontz[fnt16].Handle, Str2PChar(s), cWhiteColorChannels);
  1684         tmpSurface:= doSurfaceConversion(tmpSurface);
  1679         tmpSurface:= doSurfaceConversion(tmpSurface);
  1685         FreeTexture(timeTexture);
  1680         FreeAndNilTexture(timeTexture);
  1686         timeTexture:= Surface2Tex(tmpSurface, false);
  1681         timeTexture:= Surface2Tex(tmpSurface, false);
  1687         SDL_FreeSurface(tmpSurface)
  1682         SDL_FreeSurface(tmpSurface)
  1688         end;
  1683         end;
  1689 
  1684 
  1690     if timeTexture <> nil then
  1685     if timeTexture <> nil then
  1698             Frames:= 0;
  1693             Frames:= 0;
  1699             CountTicks:= 0;
  1694             CountTicks:= 0;
  1700             s:= inttostr(FPS) + ' fps';
  1695             s:= inttostr(FPS) + ' fps';
  1701             tmpSurface:= TTF_RenderUTF8_Blended(Fontz[fnt16].Handle, Str2PChar(s), cWhiteColorChannels);
  1696             tmpSurface:= TTF_RenderUTF8_Blended(Fontz[fnt16].Handle, Str2PChar(s), cWhiteColorChannels);
  1702             tmpSurface:= doSurfaceConversion(tmpSurface);
  1697             tmpSurface:= doSurfaceConversion(tmpSurface);
  1703             FreeTexture(fpsTexture);
  1698             FreeAndNilTexture(fpsTexture);
  1704             fpsTexture:= Surface2Tex(tmpSurface, false);
  1699             fpsTexture:= Surface2Tex(tmpSurface, false);
  1705             SDL_FreeSurface(tmpSurface)
  1700             SDL_FreeSurface(tmpSurface)
  1706             end;
  1701             end;
  1707         if fpsTexture <> nil then
  1702         if fpsTexture <> nil then
  1708             DrawTexture((cScreenWidth shr 1) - 60 - offsetY, offsetX, fpsTexture);
  1703             DrawTexture((cScreenWidth shr 1) - 60 - offsetY, offsetX, fpsTexture);
  1761     if recTexture = nil then
  1756     if recTexture = nil then
  1762         begin
  1757         begin
  1763         s:= 'rec';
  1758         s:= 'rec';
  1764         tmpSurface:= TTF_RenderUTF8_Blended(Fontz[fntBig].Handle, Str2PChar(s), cWhiteColorChannels);
  1759         tmpSurface:= TTF_RenderUTF8_Blended(Fontz[fntBig].Handle, Str2PChar(s), cWhiteColorChannels);
  1765         tmpSurface:= doSurfaceConversion(tmpSurface);
  1760         tmpSurface:= doSurfaceConversion(tmpSurface);
  1766         FreeTexture(recTexture);
  1761         FreeAndNilTexture(recTexture);
  1767         recTexture:= Surface2Tex(tmpSurface, false);
  1762         recTexture:= Surface2Tex(tmpSurface, false);
  1768         SDL_FreeSurface(tmpSurface)
  1763         SDL_FreeSurface(tmpSurface)
  1769         end;
  1764         end;
  1770     DrawTexture( -(cScreenWidth shr 1) + 50, 20, recTexture);
  1765     DrawTexture( -(cScreenWidth shr 1) + 50, 20, recTexture);
  1771 
  1766 
  1999 r.h:= 32;
  1994 r.h:= 32;
  2000 
  1995 
  2001 if time = 0 then
  1996 if time = 0 then
  2002     time:= 5000;
  1997     time:= 5000;
  2003 missionTimer:= time;
  1998 missionTimer:= time;
  2004 FreeTexture(missionTex);
  1999 FreeAndNilTexture(missionTex);
  2005 
  2000 
  2006 if icon > -1 then
  2001 if icon > -1 then
  2007     begin
  2002     begin
  2008     r.x:= 0;
  2003     r.x:= 0;
  2009     r.y:= icon * 32;
  2004     r.y:= icon * 32;