hedgewars/uWorld.pas
changeset 175 d226d976d836
parent 174 0b2c5b22f644
child 176 533d03041dcd
equal deleted inserted replaced
174:0b2c5b22f644 175:d226d976d836
    59       SoundTimerTicks: Longword = 0;
    59       SoundTimerTicks: Longword = 0;
    60       prevPoint: TPoint = (X: 0; Y: 0);
    60       prevPoint: TPoint = (X: 0; Y: 0);
    61 
    61 
    62 type TCaptionStr = record
    62 type TCaptionStr = record
    63                    Surf: PSDL_Surface;
    63                    Surf: PSDL_Surface;
    64                    Group: TCapGroup;
       
    65                    EndTime: LongWord;
    64                    EndTime: LongWord;
    66                    end;
    65                    end;
    67 
    66 
    68 var cWaterSprCount: integer;
    67 var cWaterSprCount: integer;
    69     Captions: array[0..Pred(cMaxCaptions)] of TCaptionStr;
    68     Captions: array[TCapGroup] of TCaptionStr;
    70     AMxLeft, AMxCurr, SlotsNum: integer;
    69     AMxLeft, AMxCurr, SlotsNum: integer;
    71 
    70 
    72 procedure InitWorld;
    71 procedure InitWorld;
    73 begin
    72 begin
    74 cWaterSprCount:= 1 + cScreenWidth div (SpritesData[sprWater].Width);
    73 cWaterSprCount:= 1 + cScreenWidth div (SpritesData[sprWater].Width);
   167 procedure DrawWorld(Lag: integer; Surface: PSDL_Surface);
   166 procedure DrawWorld(Lag: integer; Surface: PSDL_Surface);
   168 var i, t: integer;
   167 var i, t: integer;
   169     r: TSDL_Rect;
   168     r: TSDL_Rect;
   170     team: PTeam;
   169     team: PTeam;
   171     tdx, tdy: Double;
   170     tdx, tdy: Double;
       
   171     grp: TCapGroup;
   172     s: string[15];
   172     s: string[15];
   173 
   173 
   174     procedure DrawRepeated(spr: TSprite; Shift: integer);
   174     procedure DrawRepeated(spr: TSprite; Shift: integer);
   175     var i, w: integer;
   175     var i, w: integer;
   176     begin
   176     begin
   301 
   301 
   302 // Target
   302 // Target
   303 if TargetPoint.X <> NoPointX then DrawSprite(sprTargetP, TargetPoint.X + WorldDx - 16, TargetPoint.Y + WorldDy - 16, 0, Surface);
   303 if TargetPoint.X <> NoPointX then DrawSprite(sprTargetP, TargetPoint.X + WorldDx - 16, TargetPoint.Y + WorldDy - 16, 0, Surface);
   304 
   304 
   305 // Captions
   305 // Captions
   306 i:= 0;
   306 i:= 8;
   307 while (i < cMaxCaptions) do
   307 for grp:= Low(TCapGroup) to High(TCapGroup) do
   308     begin
   308     with Captions[grp] do
   309     with Captions[i] do
       
   310          if EndTime > 0 then
   309          if EndTime > 0 then
   311             DrawCentered(cScreenWidth div 2, 8 + i * (Surf.h + 2) + cConsoleYAdd, Surf, Surface);
   310             begin
   312     inc(i)
   311             DrawCentered(cScreenWidth div 2, i + cConsoleYAdd, Surf, Surface);
   313     end;
   312             inc(i, Surf.h + 2);
   314 while (Captions[0].EndTime > 0) and (Captions[0].EndTime <= RealTicks) do
   313             if EndTime <= RealTicks then
   315     begin
   314                begin
   316     SDL_FreeSurface(Captions[0].Surf);
   315                SDL_FreeSurface(Surf);
   317     Captions[0].Surf:= nil;
   316                Surf:= nil;
   318     for i:= 1 to Pred(cMaxCaptions) do
   317                EndTime:= 0
   319         Captions[Pred(i)]:= Captions[i];
   318                end
   320     Captions[Pred(cMaxCaptions)].EndTime:= 0
   319             end;
   321     end;
       
   322 
   320 
   323 // Teams Healths
   321 // Teams Healths
   324 team:= TeamsList;
   322 team:= TeamsList;
   325 while team <> nil do
   323 while team <> nil do
   326       begin
   324       begin
   399    begin
   397    begin
   400    SoundTimerTicks:= 0;
   398    SoundTimerTicks:= 0;
   401    if cVolumeDelta <> 0 then
   399    if cVolumeDelta <> 0 then
   402       begin
   400       begin
   403       str(ChangeVolume(cVolumeDelta), s);
   401       str(ChangeVolume(cVolumeDelta), s);
   404       AddCaption(Format('Volume %1%', s), $FFFFFF, capgrpVolume)
   402       AddCaption(Format(trmsg[sidVolume], s), $FFFFFF, capgrpVolume)
   405       end
   403       end
   406    end
   404    end
   407 end;
   405 end;
   408 
   406 
   409 procedure AddCaption(s: string; Color: Longword; Group: TCapGroup);
   407 procedure AddCaption(s: string; Color: Longword; Group: TCapGroup);
   410 var i, m: LongWord;
       
   411 begin
   408 begin
   412 if Group in [capgrpGameState, capgrpNetSay] then WriteLnToConsole(s);
   409 if Group in [capgrpGameState, capgrpNetSay] then WriteLnToConsole(s);
   413 i:= 0;
   410 if Captions[Group].Surf <> nil then SDL_FreeSurface(Captions[Group].Surf);
   414 while (i < cMaxCaptions) and (Captions[i].Group <> Group) do inc(i);
   411 
   415 if i < cMaxCaptions then
   412 Captions[Group].Surf:= RenderString(s, Color, fntBig);
   416    begin
   413 Captions[Group].EndTime:= RealTicks + 1200
   417    SDL_FreeSurface(Captions[i].Surf);
       
   418    while (i < Pred(cMaxCaptions)) do
       
   419          begin
       
   420          Captions[i]:= Captions[Succ(i)];
       
   421          inc(i)
       
   422          end;
       
   423    Captions[Pred(cMaxCaptions)].EndTime:= 0
       
   424    end;
       
   425    
       
   426 if Captions[Pred(cMaxCaptions)].EndTime > 0 then
       
   427    begin
       
   428    SDL_FreeSurface(Captions[0].Surf);
       
   429    m:= Pred(cMaxCaptions);
       
   430    for i:= 1 to m do
       
   431        Captions[Pred(i)]:= Captions[i];
       
   432    Captions[m].EndTime:= 0
       
   433    end else
       
   434    begin
       
   435    m:= 0;
       
   436    while (m < cMaxCaptions)and(Captions[m].EndTime > 0) do inc(m)
       
   437    end;
       
   438 
       
   439 
       
   440 Captions[m].Surf:= RenderString(s, Color, fntBig);
       
   441 Captions[m].Group:= Group;
       
   442 Captions[m].EndTime:= RealTicks + 1200
       
   443 end;
   414 end;
   444 
   415 
   445 procedure MoveCamera;
   416 procedure MoveCamera;
   446 const PrevSentPointTime: LongWord = 0;
   417 const PrevSentPointTime: LongWord = 0;
   447 begin
   418 begin