Ignore:
Timestamp:
Oct 4, 2014, 9:05:59 PM (10 years ago)
Author:
chronos
Message:
  • Modified: Show draw time in ms smoothed.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormMain.pas

    r72 r73  
    9595    RedrawPending: Boolean;
    9696    DrawDuration: TDateTime;
     97    LastTimerTime: TDateTime;
     98    TimerPeriod: TDateTime;
    9799  public
    98100    procedure LoadConfig(Config: TXmlConfig; Path: string);
     
    122124begin
    123125  DrawStart := Now;
    124   //if Core.Game.Running then
    125126  if Assigned(Core.Game.CurrentPlayer) then
    126127  with Core.Game.CurrentPlayer do begin
     
    132133      Paint(TempBitmap.Canvas);
    133134      PaintBox1.Canvas.Draw(0, 0, TempBitmap);
    134     end else Paint(PaintBox1.Canvas);
    135   end;
    136   DrawDuration := Now - DrawStart;
     135    end else begin
     136      Paint(PaintBox1.Canvas);
     137    end;
     138  end;
     139  DrawDuration := (9 * DrawDuration + (Now - DrawStart)) / 10;
    137140end;
    138141
     
    153156var
    154157  NewCaption: string;
    155   DrawStart: TDateTime;
    156158begin
    157159  if RedrawPending then begin
    158160    RedrawPending := False;
     161    TimerPeriod := (9 * TimerPeriod + (Now - LastTimerTime)) / 10;
     162    LastTimerTime := Now;
    159163    PaintBox1.Repaint;
    160     StatusBar1.Panels[1].Text := IntToStr(Trunc(DrawDuration / OneMillisecond)) + ' ms';
     164    StatusBar1.Panels[1].Text := IntToStr(Trunc(DrawDuration / OneMillisecond)) + ' / ' +
     165      IntToStr(Trunc(TimerPeriod / OneMillisecond)) + ' ms';
    161166    NewCaption := 'xTactics';
    162167    if Assigned(Core.Game.CurrentPlayer) then
     
    213218  //DoubleBuffered := True;
    214219  TempBitmap := TBitmap.Create;
     220  TimerPeriod := 0;
     221  LastTimerTime := Now;
    215222end;
    216223
Note: See TracChangeset for help on using the changeset viewer.