Ignore:
Timestamp:
Mar 19, 2021, 3:31:53 PM (4 years ago)
Author:
chronos
Message:
  • Modified: Optimized drawing of Wonders window.
  • Modified: Used named constants for Wonders CitiID special cases.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/LocalPlayer/Wonders.pas

    r245 r319  
    100100  ax: Integer;
    101101  R: Integer;
    102   I: Integer;
    103102  C: Integer;
    104103  Ch: Integer;
     
    223222  PaintBackgroundShape;
    224223
    225   for I := 0 to 20 do
    226     if Imp[I].Preq <> preNA then
    227     begin
     224  // Draw all bitmaps first
     225  HaveWonder := False;
     226  for I := 0 to 20 do begin
     227    if Imp[I].Preq <> preNA then begin
    228228      case MyRO.Wonder[I].CityID of
    229         - 1: // not built yet
    230           begin
    231             Fill(Offscreen.Canvas, Center.X - xSizeBig div 2 + RingPosition[I].X - 3,
    232               Center.Y - ySizeBig div 2 + RingPosition[I].Y - 3, xSizeBig + 6,
    233               ySizeBig + 6, (wMaintexture - ClientWidth) div 2,
    234               (hMaintexture - ClientHeight) div 2);
    235             DarkIcon(I);
    236           end;
    237         -2: // destroyed
    238           begin
    239             Glow(I, $000000);
    240           end;
    241       else
    242         begin
    243           if MyRO.Wonder[I].EffectiveOwner >= 0 then
    244             Glow(I, Tribe[MyRO.Wonder[I].EffectiveOwner].Color)
    245           else
    246             Glow(I, $000000);
    247         end;
    248       end;
    249     end;
    250 
    251   HaveWonder := False;
    252   for I := 0 to 20 do
    253     if Imp[I].Preq <> preNA then
    254     begin
    255       case MyRO.Wonder[I].CityID of
    256         -1: // not built yet
    257           begin
    258             Fill(Offscreen.Canvas, Center.X - xSizeBig div 2 + RingPosition[I].X - 3,
    259               Center.Y - ySizeBig div 2 + RingPosition[I].Y - 3, xSizeBig + 6,
    260               ySizeBig + 6, (wMaintexture - ClientWidth) div 2,
    261               (hMaintexture - ClientHeight) div 2);
    262             DarkIcon(I);
    263           end;
    264         -2: // destroyed
    265           begin
    266             HaveWonder := True;
    267             BitBltCanvas(Offscreen.Canvas,
    268               Center.X - xSizeBig div 2 + RingPosition[I].X,
    269               Center.Y - ySizeBig div 2 + RingPosition[I].Y, xSizeBig,
    270               ySizeBig, BigImp.Canvas, 0, (SystemIconLines + 3) *
    271               ySizeBig);
    272           end;
    273       else
    274         begin
     229        WonderNotBuiltYet: begin
     230          Fill(Offscreen.Canvas, Center.X - xSizeBig div 2 + RingPosition[I].X - 3,
     231            Center.Y - ySizeBig div 2 + RingPosition[I].Y - 3, xSizeBig + 6,
     232            ySizeBig + 6, (wMaintexture - ClientWidth) div 2,
     233            (hMaintexture - ClientHeight) div 2);
     234        end;
     235        WonderDestroyed: begin
     236          HaveWonder := True;
     237          BitBltCanvas(Offscreen.Canvas,
     238            Center.X - xSizeBig div 2 + RingPosition[I].X,
     239            Center.Y - ySizeBig div 2 + RingPosition[I].Y, xSizeBig,
     240            ySizeBig, BigImp.Canvas, 0, (SystemIconLines + 3) *
     241            ySizeBig);
     242        end;
     243        else begin
    275244          HaveWonder := True;
    276245          BitBltCanvas(Offscreen.Canvas,
     
    282251      end;
    283252    end;
     253  end;
     254
     255  // Do direct pixel postprocessing separately to avoid bitmap copying in memory
     256  Offscreen.Canvas.FillRect(0, 0, 0, 0);
     257  Offscreen.BeginUpdate;
     258  for I := 0 to 20 do begin
     259    if Imp[I].Preq <> preNA then begin
     260      case MyRO.Wonder[I].CityID of
     261        WonderNotBuiltYet: DarkIcon(I);
     262        WonderDestroyed: Glow(I, $000000);
     263        else begin
     264          if MyRO.Wonder[I].EffectiveOwner >= 0 then
     265            Glow(I, Tribe[MyRO.Wonder[I].EffectiveOwner].Color)
     266          else Glow(I, $000000);
     267        end;
     268      end;
     269    end;
     270  end;
     271  Offscreen.EndUpdate;
    284272
    285273  if not HaveWonder then
     
    323311    if Selection >= 0 then
    324312    begin
    325       if MyRO.Wonder[Selection].CityID = -1 then
     313      if MyRO.Wonder[Selection].CityID = WonderNotBuiltYet then
    326314      begin // not built yet
    327315        { S:=Phrases.Lookup('IMPROVEMENTS',Selection);
     
    338326      begin
    339327        S := Phrases.Lookup('IMPROVEMENTS', Selection);
    340         if MyRO.Wonder[Selection].CityID <> -2 then
     328        if MyRO.Wonder[Selection].CityID <> WonderDestroyed then
    341329          S := Format(Phrases.Lookup('WONDEROF'),
    342330            [S, CityName(MyRO.Wonder[Selection].CityID)]);
     
    344332          (ClientWidth - BiColorTextWidth(Canvas, S)) div 2,
    345333          ClientHeight - 3 - 36 - 10, S);
    346         if MyRO.Wonder[Selection].CityID = -2 then
     334        if MyRO.Wonder[Selection].CityID = WonderDestroyed then
    347335          S := Phrases.Lookup('DESTROYED')
    348336        else if MyRO.Wonder[Selection].EffectiveOwner < 0 then
Note: See TracChangeset for help on using the changeset viewer.