hedgewars/uStore.pas
changeset 9656 18422d205080
parent 9655 e154ccca4dad
child 9670 1954f692e8c6
equal deleted inserted replaced
9655:e154ccca4dad 9656:18422d205080
    27 procedure freeModule;
    27 procedure freeModule;
    28 
    28 
    29 procedure StoreLoad(reload: boolean);
    29 procedure StoreLoad(reload: boolean);
    30 procedure StoreRelease(reload: boolean);
    30 procedure StoreRelease(reload: boolean);
    31 procedure RenderHealth(var Hedgehog: THedgehog);
    31 procedure RenderHealth(var Hedgehog: THedgehog);
       
    32 function makeHealthBarTexture(w, h, Color: Longword): PTexture;
    32 procedure AddProgress;
    33 procedure AddProgress;
    33 procedure FinishProgress;
    34 procedure FinishProgress;
    34 function  LoadImage(const filename: shortstring; imageFlags: LongInt): PSDL_Surface;
    35 function  LoadImage(const filename: shortstring; imageFlags: LongInt): PSDL_Surface;
    35 
    36 
    36 // loads an image from the games data files
    37 // loads an image from the games data files
   117     CrosshairTexture:= Surface2Tex(tmpsurf, false);
   118     CrosshairTexture:= Surface2Tex(tmpsurf, false);
   118 
   119 
   119     SDL_FreeSurface(tmpsurf)
   120     SDL_FreeSurface(tmpsurf)
   120 end;
   121 end;
   121 
   122 
       
   123 function makeHealthBarTexture(w, h, Color: Longword): PTexture;
       
   124 var
       
   125     rr: TSDL_Rect;
       
   126     texsurf: PSDL_Surface;
       
   127 begin
       
   128     rr.x:= 0;
       
   129     rr.y:= 0;
       
   130     rr.w:= w;
       
   131     rr.h:= h;
       
   132 
       
   133     texsurf:= SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, 32, RMask, GMask, BMask, AMask);
       
   134     TryDo(texsurf <> nil, errmsgCreateSurface, true);
       
   135     TryDo(SDL_SetColorKey(texsurf, SDL_SRCCOLORKEY, 0) = 0, errmsgTransparentSet, true);
       
   136 
       
   137     DrawRoundRect(@rr, cWhiteColor, cNearBlackColor, texsurf, true);
       
   138 
       
   139     rr.x:= 2;
       
   140     rr.y:= 2;
       
   141     rr.w:= w - 4;
       
   142     rr.h:= h - 4;
       
   143 
       
   144     DrawRoundRect(@rr, Color, Color, texsurf, false);
       
   145     makeHealthBarTexture:= Surface2Tex(texsurf, false);
       
   146     SDL_FreeSurface(texsurf);
       
   147 end;
   122 
   148 
   123 procedure WriteNames(Font: THWFont);
   149 procedure WriteNames(Font: THWFont);
   124 var t: LongInt;
   150 var t: LongInt;
   125     i, maxLevel: LongInt;
   151     i, maxLevel: LongInt;
   126     r, rr: TSDL_Rect;
   152     r: TSDL_Rect;
   127     drY: LongInt;
   153     drY: LongInt;
   128     texsurf, flagsurf, iconsurf: PSDL_Surface;
   154     texsurf, flagsurf, iconsurf: PSDL_Surface;
   129     foundBot: boolean;
   155     foundBot: boolean;
   130 begin
   156 begin
   131     if cOnlyStats then exit;
   157     if cOnlyStats then exit;
   134 drY:= - 4;
   160 drY:= - 4;
   135 for t:= 0 to Pred(TeamsCount) do
   161 for t:= 0 to Pred(TeamsCount) do
   136     with TeamsArray[t]^ do
   162     with TeamsArray[t]^ do
   137         begin
   163         begin
   138         NameTagTex:= RenderStringTexLim(TeamName, Clan^.Color, Font, cTeamHealthWidth);
   164         NameTagTex:= RenderStringTexLim(TeamName, Clan^.Color, Font, cTeamHealthWidth);
   139 
       
   140         r.w:= cTeamHealthWidth + 5;
       
   141         r.h:= NameTagTex^.h;
       
   142 
       
   143         texsurf:= SDL_CreateRGBSurface(SDL_SWSURFACE, r.w, r.h, 32, RMask, GMask, BMask, AMask);
       
   144         TryDo(texsurf <> nil, errmsgCreateSurface, true);
       
   145         TryDo(SDL_SetColorKey(texsurf, SDL_SRCCOLORKEY, 0) = 0, errmsgTransparentSet, true);
       
   146 
       
   147         DrawRoundRect(@r, cWhiteColor, cNearBlackColor, texsurf, true);
       
   148         rr:= r;
       
   149         inc(rr.x, 2); dec(rr.w, 4); inc(rr.y, 2); dec(rr.h, 4);
       
   150         DrawRoundRect(@rr, Clan^.Color, Clan^.Color, texsurf, false);
       
   151         HealthTex:= Surface2Tex(texsurf, false);
       
   152         SDL_FreeSurface(texsurf);
       
   153 
   165 
   154         r.x:= 0;
   166         r.x:= 0;
   155         r.y:= 0;
   167         r.y:= 0;
   156         r.w:= 32;
   168         r.w:= 32;
   157         r.h:= 32;
   169         r.h:= 32;
   244         DrawRoundRect(@r, cWhiteColor, cNearBlackColor, iconsurf, true);
   256         DrawRoundRect(@r, cWhiteColor, cNearBlackColor, iconsurf, true);
   245         ropeIconTex:= Surface2Tex(iconsurf, false);
   257         ropeIconTex:= Surface2Tex(iconsurf, false);
   246         SDL_FreeSurface(iconsurf);
   258         SDL_FreeSurface(iconsurf);
   247         iconsurf:= nil;
   259         iconsurf:= nil;
   248         end;
   260         end;
   249 end;
   261 
       
   262 
       
   263 for t:= 0 to Pred(ClansCount) do
       
   264     with ClansArray[t]^ do
       
   265         HealthTex:= makeHealthBarTexture(cTeamHealthWidth + 5, Teams[0]^.NameTagTex^.h, Color);
       
   266 
       
   267 GenericHealthTexture:= makeHealthBarTexture(cTeamHealthWidth + 5, TeamsArray[0]^.NameTagTex^.h, cWhiteColor)
       
   268 end;
       
   269 
   250 
   270 
   251 procedure InitHealth;
   271 procedure InitHealth;
   252 var i, t: LongInt;
   272 var i, t: LongInt;
   253 begin
   273 begin
   254 for t:= 0 to Pred(TeamsCount) do
   274 for t:= 0 to Pred(TeamsCount) do
   465 FreeAndNilTexture(PauseTexture);
   485 FreeAndNilTexture(PauseTexture);
   466 FreeAndNilTexture(SyncTexture);
   486 FreeAndNilTexture(SyncTexture);
   467 FreeAndNilTexture(ConfirmTexture);
   487 FreeAndNilTexture(ConfirmTexture);
   468 FreeAndNilTexture(ropeIconTex);
   488 FreeAndNilTexture(ropeIconTex);
   469 FreeAndNilTexture(HHTexture);
   489 FreeAndNilTexture(HHTexture);
   470 
   490 FreeAndNilTexture(GenericHealthTexture);
   471 // free all ammo name textures
   491 // free all ammo name textures
   472 for ai:= Low(TAmmoType) to High(TAmmoType) do
   492 for ai:= Low(TAmmoType) to High(TAmmoType) do
   473     FreeAndNilTexture(Ammoz[ai].NameTex);
   493     FreeAndNilTexture(Ammoz[ai].NameTex);
   474 
   494 
   475 // free all count textures
   495 // free all count textures
   477     begin
   497     begin
   478     FreeAndNilTexture(CountTexz[i]);
   498     FreeAndNilTexture(CountTexz[i]);
   479     CountTexz[i]:= nil
   499     CountTexz[i]:= nil
   480     end;
   500     end;
   481 
   501 
       
   502     for t:= 0 to Pred(ClansCount) do
       
   503         begin
       
   504         if ClansArray[t] <> nil then
       
   505             FreeAndNilTexture(ClansArray[t]^.HealthTex);
       
   506         end;
       
   507 
   482     // free all team and hedgehog textures
   508     // free all team and hedgehog textures
   483     for t:= 0 to Pred(TeamsCount) do
   509     for t:= 0 to Pred(TeamsCount) do
   484         begin
   510         begin
   485         if TeamsArray[t] <> nil then
   511         if TeamsArray[t] <> nil then
   486             begin
   512             begin
   487             FreeAndNilTexture(TeamsArray[t]^.NameTagTex);
   513             FreeAndNilTexture(TeamsArray[t]^.NameTagTex);
   488             FreeAndNilTexture(TeamsArray[t]^.GraveTex);
   514             FreeAndNilTexture(TeamsArray[t]^.GraveTex);
   489             FreeAndNilTexture(TeamsArray[t]^.HealthTex);
       
   490             FreeAndNilTexture(TeamsArray[t]^.AIKillsTex);
   515             FreeAndNilTexture(TeamsArray[t]^.AIKillsTex);
   491             FreeAndNilTexture(TeamsArray[t]^.FlagTex);
   516             FreeAndNilTexture(TeamsArray[t]^.FlagTex);
   492 
   517 
   493             for i:= 0 to cMaxHHIndex do
   518             for i:= 0 to cMaxHHIndex do
   494                 begin
   519                 begin