unit VLFOptionsForm;

interface

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

type
  TOptionsForm = class(TForm)
    OKBtn: TButton;
    CancelBtn: TButton;
    PageControl: TPageControl;
    TabSheet1: TTabSheet;
    TabSheet2: TTabSheet;
    Label1: TLabel;
    FuzzyAttackGroup: TRadioGroup;
    EnergyPerStepEdit: TEdit;
    EnergyPerStepUpDown: TUpDown;
    DistributeEnergyCheck: TCheckBox;
    ChemGoAwayCheck: TCheckBox;
    GroupBox1: TGroupBox;
    Label2: TLabel;
    GammaBar: TTrackBar;
    Label3: TLabel;
    Label4: TLabel;
    GroupBox2: TGroupBox;
    CompressENVFilesCheck: TCheckBox;
    GammaLabel: TLabel;
    procedure EnergyPerStepEditChange(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure GammaBarChange(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure FormHide(Sender: TObject);
  private
    { Private declarations }
    OldGamma: Single;
  public
    { Public declarations }
  end;

var
  OptionsForm: TOptionsForm;

implementation

uses Tahoma, AppMainForm, Prefs;

{$R *.DFM}

procedure TOptionsForm.EnergyPerStepEditChange(Sender: TObject);
begin
  try
    EnergyPerStepUpDown.Position := StrToInt(EnergyPerStepEdit.Text);
  except
    // tichá vyjímka
  end;
end;

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

procedure TOptionsForm.GammaBarChange(Sender: TObject);
begin
  GammaLabel.Caption := IntToStr(GammaBar.Position div 10) + ',' + IntToStr(GammaBar.Position mod 10);
  FoodGamma := GammaBar.Position / 10;
  MainForm.Document.Env.RecalcGamma;
  MainForm.BigPaint;
end;

procedure TOptionsForm.FormShow(Sender: TObject);
begin
  GammaBar.OnChange(Self);
  PageControl.ActivePageIndex := 0;
  ActiveControl := FuzzyAttackGroup;
  OldGamma := FoodGamma;
end;

procedure TOptionsForm.FormHide(Sender: TObject);
begin
  if ModalResult = mrCancel then
  begin
    FoodGamma := OldGamma;
    MainForm.Document.Env.RecalcGamma;
    MainForm.BigPaint;
  end;
end;

end.
