hedgewars/uStore.pas
changeset 7503 deaeac102355
parent 7371 911b53e8c00a
parent 7495 2592240b7b62
child 7565 00568d3054d0
equal deleted inserted replaced
7447:01111960a48d 7503:deaeac102355
   133 end;
   133 end;
   134 
   134 
   135 
   135 
   136 procedure WriteNames(Font: THWFont);
   136 procedure WriteNames(Font: THWFont);
   137 var t: LongInt;
   137 var t: LongInt;
   138     i: LongInt;
   138     i, maxLevel: LongInt;
   139     r, rr: TSDL_Rect;
   139     r, rr: TSDL_Rect;
   140     drY: LongInt;
   140     drY: LongInt;
   141     texsurf, flagsurf, iconsurf: PSDL_Surface;
   141     texsurf, flagsurf, iconsurf: PSDL_Surface;
       
   142     foundBot: boolean;
   142 begin
   143 begin
   143 r.x:= 0;
   144 r.x:= 0;
   144 r.y:= 0;
   145 r.y:= 0;
   145 drY:= - 4;
   146 drY:= - 4;
   146 for t:= 0 to Pred(TeamsCount) do
   147 for t:= 0 to Pred(TeamsCount) do
   174         r.h:= 19;
   175         r.h:= 19;
   175 
   176 
   176         DrawRoundRect(@r, cWhiteColor, cNearBlackColor, texsurf, true);
   177         DrawRoundRect(@r, cWhiteColor, cNearBlackColor, texsurf, true);
   177 
   178 
   178         // overwrite flag for cpu teams and keep players from using it
   179         // overwrite flag for cpu teams and keep players from using it
   179         if (Hedgehogs[0].Gear <> nil) and (Hedgehogs[0].BotLevel > 0) then
   180         foundBot:= false;
   180             if Flag = 'hedgewars' then
   181         maxLevel:= -1;
   181                 Flag:= 'cpu'
   182         for i:= 0 to cMaxHHIndex do
   182         else if Flag = 'cpu' then
   183             with Hedgehogs[i] do
   183             Flag:= 'hedgewars';
   184                 if (Gear <> nil) and (BotLevel > 0) then
       
   185                     begin
       
   186                     foundBot:= true;
       
   187                     // initially was going to do the highest botlevel of the team, but for now, just apply if entire team has same bot level
       
   188                     if maxLevel = -1 then maxLevel:= BotLevel
       
   189                     else if (maxLevel > 0) and (maxLevel <> BotLevel) then maxLevel:= 0; 
       
   190                     //if (maxLevel > 0) and (BotLevel < maxLevel) then maxLevel:= BotLevel
       
   191                     end
       
   192                 else if Gear <> nil then  maxLevel:= 0;
       
   193 
       
   194         if foundBot then
       
   195             begin
       
   196             // disabled the plain flag - I think it looks ok even w/ full bars obscuring CPU
       
   197             //if (maxLevel > 0) and (maxLevel < 3) then Flag:= 'cpu_plain' else 
       
   198             Flag:= 'cpu'
       
   199             end
       
   200         else if (Flag = 'cpu') or (Flag = 'cpu_plain') then
       
   201                 Flag:= 'hedgewars';
   184 
   202 
   185         flagsurf:= LoadImage(UserPathz[ptFlags] + '/' + Flag, ifNone);
   203         flagsurf:= LoadImage(UserPathz[ptFlags] + '/' + Flag, ifNone);
   186         if flagsurf = nil then
   204         if flagsurf = nil then
   187             flagsurf:= LoadImage(Pathz[ptFlags] + '/' + Flag, ifNone);
   205             flagsurf:= LoadImage(Pathz[ptFlags] + '/' + Flag, ifNone);
   188         if flagsurf = nil then
   206         if flagsurf = nil then
   189             flagsurf:= LoadImage(UserPathz[ptFlags] + '/hedgewars', ifNone);
   207             flagsurf:= LoadImage(UserPathz[ptFlags] + '/hedgewars', ifNone);
   190         if flagsurf = nil then
   208         if flagsurf = nil then
   191             flagsurf:= LoadImage(Pathz[ptFlags] + '/hedgewars', ifNone);
   209             flagsurf:= LoadImage(Pathz[ptFlags] + '/hedgewars', ifNone);
   192         TryDo(flagsurf <> nil, 'Failed to load flag "' + Flag + '" as well as the default flag', true);
   210         TryDo(flagsurf <> nil, 'Failed to load flag "' + Flag + '" as well as the default flag', true);
       
   211 
       
   212         case maxLevel of
       
   213             1: copyToXY(SpritesData[sprBotlevels].Surface, flagsurf, 0, 0); 
       
   214             2: copyToXYFromRect(SpritesData[sprBotlevels].Surface, flagsurf, 5, 2, 17, 13, 5, 2); 
       
   215             3: copyToXYFromRect(SpritesData[sprBotlevels].Surface, flagsurf, 9, 5, 13, 10, 9, 5); 
       
   216             4: copyToXYFromRect(SpritesData[sprBotlevels].Surface, flagsurf, 13, 9, 9, 6, 13, 9); 
       
   217             5: copyToXYFromRect(SpritesData[sprBotlevels].Surface, flagsurf, 17, 11, 5, 4, 17, 11)
       
   218             end;
       
   219 
   193         copyToXY(flagsurf, texsurf, 2, 2);
   220         copyToXY(flagsurf, texsurf, 2, 2);
   194         SDL_FreeSurface(flagsurf);
   221         SDL_FreeSurface(flagsurf);
   195         flagsurf:= nil;
   222         flagsurf:= nil;
       
   223 
   196 
   224 
   197         // restore black border pixels inside the flag
   225         // restore black border pixels inside the flag
   198         PLongwordArray(texsurf^.pixels)^[32 * 2 +  2]:= cNearBlackColor;
   226         PLongwordArray(texsurf^.pixels)^[32 * 2 +  2]:= cNearBlackColor;
   199         PLongwordArray(texsurf^.pixels)^[32 * 2 + 23]:= cNearBlackColor;
   227         PLongwordArray(texsurf^.pixels)^[32 * 2 + 23]:= cNearBlackColor;
   200         PLongwordArray(texsurf^.pixels)^[32 * 16 +  2]:= cNearBlackColor;
   228         PLongwordArray(texsurf^.pixels)^[32 * 16 +  2]:= cNearBlackColor;
   201         PLongwordArray(texsurf^.pixels)^[32 * 16 + 23]:= cNearBlackColor;
   229         PLongwordArray(texsurf^.pixels)^[32 * 16 + 23]:= cNearBlackColor;
   202 
   230 
       
   231 
   203         FlagTex:= Surface2Tex(texsurf, false);
   232         FlagTex:= Surface2Tex(texsurf, false);
   204         SDL_FreeSurface(texsurf);
   233         SDL_FreeSurface(texsurf);
   205         texsurf:= nil;
   234         texsurf:= nil;
   206 
   235 
   207         AIKillsTex := RenderStringTex(inttostr(stats.AIKills), Clan^.Color, fnt16);
   236         AIKillsTex := RenderStringTex(inttostr(stats.AIKills), Clan^.Color, fnt16);
   208 
   237 
   209         dec(drY, r.h + 2);
   238         dec(drY, r.h + 2);
   210         DrawHealthY:= drY;
   239         DrawHealthY:= drY;
   211         for i:= 0 to 7 do
   240         for i:= 0 to cMaxHHIndex do
   212             with Hedgehogs[i] do
   241             with Hedgehogs[i] do
   213                 if Gear <> nil then
   242                 if Gear <> nil then
   214                     begin
   243                     begin
   215                     NameTagTex:= RenderStringTexLim(Name, Clan^.Color, fnt16, cTeamHealthWidth);
   244                     NameTagTex:= RenderStringTexLim(Name, Clan^.Color, fnt16, cTeamHealthWidth);
   216                     if Hat <> 'NoHat' then
   245                     if Hat <> 'NoHat' then
   296             SDLTry(Handle <> nil, true);
   325             SDLTry(Handle <> nil, true);
   297             TTF_SetFontStyle(Handle, style);
   326             TTF_SetFontStyle(Handle, style);
   298             WriteLnToConsole(msgOK)
   327             WriteLnToConsole(msgOK)
   299             end;
   328             end;
   300 
   329 
   301 WriteNames(fnt16);
       
   302 MakeCrossHairs;
   330 MakeCrossHairs;
   303 LoadGraves;
   331 LoadGraves;
   304 if not reload then
   332 if not reload then
   305     AddProgress;
   333     AddProgress;
   306 
   334 
   393                 end
   421                 end
   394             else
   422             else
   395                 Surface:= nil
   423                 Surface:= nil
   396         end;
   424         end;
   397 
   425 
       
   426 WriteNames(fnt16);
       
   427 
   398 if not reload then
   428 if not reload then
   399     AddProgress;
   429     AddProgress;
   400 
   430 
   401     tmpsurf:= LoadImage(UserPathz[ptGraphics] + '/' + cHHFileName, ifAlpha or ifTransparent);
   431     tmpsurf:= LoadImage(UserPathz[ptGraphics] + '/' + cHHFileName, ifAlpha or ifTransparent);
   402 if tmpsurf = nil then
   432 if tmpsurf = nil then