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