unit VLFDebugForm;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ComCtrls;

type
  TDebugForm = class(TForm)
    PageControl: TPageControl;
    TabSheet1: TTabSheet;
    TabSheet2: TTabSheet;
    TimesView: TListView;
    Label1: TLabel;
    Label2: TLabel;
    CountLabel: TLabel;
    SizeLabel: TLabel;
    TabSheet3: TTabSheet;
    FoodView: TListView;
    procedure FormCreate(Sender: TObject);
    procedure FormShow(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    procedure UpdateTimes;
  end;

var
  DebugForm: TDebugForm;

implementation

uses Tahoma, AppMainForm;

{$R *.dfm}

{ Updatuje vypsané časy podle proměnných T1, T2, T3 a T z hlavního formuláře.
  Taky updatuje data o paměti. }
procedure TDebugForm.UpdateTimes;
begin
  if Visible then
  begin
    with FoodView, MainForm, Document do
    begin
      Items[0].SubItems[0] := IntToStr(Env.EnergyInEnv + Env.EnergyInOrgs);
      Items[1].SubItems[0] := IntToStr(Env.EnergyInEnv);
      Items[1].SubItems[1] := FloatToStr(Env.EnergyInEnv / (Env.Width * Env.Height));
      Items[2].SubItems[0] := IntToStr(Env.EnergyInOrgs);
      if Env.Orgs.Count > 0 then
        Items[2].SubItems[1] := FloatToStr(Env.EnergyInOrgs / Env.Orgs.Count)
      else
        Items[2].SubItems[1] := '--';
    end;
    with TimesView, MainForm, Document do
    begin
      Items[0].SubItems[0] := FloatToStr(T);
      if Env.Orgs.Count > 0 then
        Items[0].SubItems[1] := FloatToStr(T / Env.Orgs.Count)
      else
        Items[0].SubItems[1] := '--';
      Items[1].SubItems[0] := FloatToStr(T1);
      if Env.Orgs.Count > 0 then
        Items[1].SubItems[1] := FloatToStr(T1 / Env.Orgs.Count)
      else
        Items[1].SubItems[1] := '--';
      Items[2].SubItems[0] := FloatToStr(T2);
      if Env.Orgs.Count > 0 then
        Items[2].SubItems[1] := FloatToStr(T2 / Env.Orgs.Count)
      else
        Items[2].SubItems[1] := '--';
      Items[3].SubItems[0] := FloatToStr(T3);
      if Env.Orgs.Count > 0 then
        Items[3].SubItems[1] := FloatToStr(T3 / Env.Orgs.Count)
      else
        Items[3].SubItems[1] := '--';
    end;
    CountLabel.Caption := IntToStr(AllocMemCount);
    SizeLabel.Caption := IntToStr(AllocMemSize);
  end;
end;

procedure TDebugForm.FormCreate(Sender: TObject);
begin
  TahomizeForm(Self);
end;

procedure TDebugForm.FormShow(Sender: TObject);
begin
  UpdateTimes;
end;

end.
