unit uPreferences;

interface

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

type
  TFormPreferences = class(TForm)
    PageControlPreferences: TPageControl;
    TabSheetGeneral: TTabSheet;
    DebuggerWindow: TCheckBox;
    LabelSnapshotsPrefix: TLabel;
    SnapshotsPrefix: TEdit;
    GroupBox4: TGroupBox;
    SnapshotsFolder: TComboBoxEx;
    SnapshotsFolder_EditBox: TEdit;
    SnapshotsFolderButtonSelect: TSpeedButton;
    SnapshotsFolderButtonUpdate: TSpeedButton;
    ReadOnlyMessage: TCheckBox;
    ButtonClose: TSpeedButton;
    procedure SnapshotsFolderButtonSelectClick(Sender: TObject);
    procedure SnapshotsFolderButtonUpdateClick(Sender: TObject);
    procedure SnapshotsFolderChange(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure ButtonCloseClick(Sender: TObject);
  private
    procedure SetPlayStationEmulatorType(ScrollBarHolder: TScrollBar; ValueLabel: TLabel);

    { Private declarations }
  public
    { Public declarations }
  end;

var
  FormPreferences: TFormPreferences;

implementation

uses uMain, uFilesUtil;

{$R *.dfm}

procedure TFormPreferences.SetPlayStationEmulatorType(ScrollBarHolder: TScrollBar; ValueLabel: TLabel);
begin
  case ScrollBarHolder.Position of
    0: ValueLabel.Caption:= 'ePSXe';
    1: ValueLabel.Caption:= 'AdriPSX';
    2: ValueLabel.Caption:= 'PCSX';
  end;
end;

procedure TFormPreferences.SnapshotsFolderButtonSelectClick(
  Sender: TObject);
var
  Folder: String;
begin
  if SnapshotsFolder.ItemIndex = -1 then
     Exit;
  SelectDirectory('Select folder for '+SnapshotsFolder.ItemsEx[SnapshotsFolder.ItemIndex].Caption+' snapshots', '', Folder);
  if Folder <> '' then
     begin
       FormMain.SnapshotFolder[SnapshotsFolder.ItemIndex+1]:= Folder;
       SnapshotsFolder_EditBox.Text:= Folder;
     end;
end;

procedure TFormPreferences.SnapshotsFolderButtonUpdateClick(
  Sender: TObject);
begin
  FormMain.SnapshotFolder[SnapshotsFolder.ItemIndex+1]:= SnapshotsFolder_EditBox.Text;
end;

procedure TFormPreferences.SnapshotsFolderChange(Sender: TObject);
begin
  SnapshotsFolder_EditBox.Text:= FormMain.SnapshotFolder[SnapshotsFolder.ItemIndex+1];
end;

procedure TFormPreferences.FormCreate(Sender: TObject);
begin
  FormMain.LoadButtonIcon(ButtonClose, 6, False);
end;

procedure TFormPreferences.ButtonCloseClick(Sender: TObject);
begin
  Close;
end;

end.
