unit options;

interface

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

type
  TOptionsDlg = class(TForm)
    Bevel1: TBevel;
    Slow: TLabel;
    Fast: TLabel;
    Label1: TLabel;
    Label2: TLabel;
    Speed: TLabel;
    Population: TLabel;
    Time: TLabel;
    OKBtn: TButton;
    CancelBtn: TButton;
    SpeedSet: TTrackBar;
    PopulationSet: TTrackBar;
    GameTimeSet: TEdit;
    procedure OKBtnClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  OptionsDlg: TOptionsDlg;

implementation

uses Main, uswat;

{$R *.dfm}

procedure TOptionsDlg.OKBtnClick(Sender: TObject);
begin
  fswat.LiveTime := SpeedSet.Max + 1 - SpeedSet.Position;
  fswat.Frequence := PopulationSet.Position;
  fswat.GameTime := StrToInt(GameTimeSet.Text);

  // limit the value of GameTime to a reasonable length
  if (fswat.GameTime < 1) then
    fswat.GameTime := 150;
  if (fswat.GameTime > 9999) then
    fswat.GameTime := 9999;
end;

procedure TOptionsDlg.FormShow(Sender: TObject);
begin
  SpeedSet.Position := SpeedSet.Max + 1 - fswat.LiveTime;
  PopulationSet.Position := fswat.Frequence;
  GameTimeSet.Text := inttoStr(fswat.GameTime);
end;

end.
