unit uInputBox;

interface

uses
  Windows, Classes, Controls, Forms, StdCtrls, GR32_Image, Buttons,
  Graphics, SysUtils, ExtCtrls;

type
  TFormInputBox = class(TForm)
    ImageBackground: TImage32;
    ButtonOk: TButton;
    ButtonCancel: TButton;
    PanelInput: TPanel;
    NewText: TEdit;
    LabelText: TLabel;
    procedure ButtonOkClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure ButtonCancelClick(Sender: TObject);
    procedure NewTextKeyPress(Sender: TObject; var Key: Char);
  private
    { Private declarations }
  public
    MsgResult: Integer;
    { Public declarations }
  end;

var
  FormInputBox: TFormInputBox;

implementation

uses uMain, uPreferences;

{$R *.dfm}

procedure TFormInputBox.ButtonOkClick(Sender: TObject);
begin
  MsgResult:= mrOk;
  Close;
end;

procedure TFormInputBox.FormCreate(Sender: TObject);
begin
  if FileExists(FormMain.FrontendPath+'resources\images\msgbox.png') then
     ImageBackground.Bitmap.LoadFromFile(FormMain.FrontendPath+'resources\images\msgbox.png');
end;

procedure TFormInputBox.FormShow(Sender: TObject);
begin
  BringToFront;
end;

procedure TFormInputBox.ButtonCancelClick(Sender: TObject);
begin
  MsgResult:= mrCancel;
  Close;
end;

procedure TFormInputBox.NewTextKeyPress(Sender: TObject; var Key: Char);
begin
  if (FormPreferences.HotRodSE.Checked) or (FormPreferences.XArcade.Checked) or
     (FormPreferences.SlikStik.Checked) or (FormPreferences.Devastator2.Checked) then
     begin
       if (Key = 'S') or (Key = 's') then
          ButtonOk.Click
       else
       if (Key = 'q') or (Key = 'q') then
          ButtonCancel.Click;
     end
  else
     begin
       if Key = #13 then
          ButtonOk.Click
       else
       if Key = #27 then
          ButtonCancel.Click;
     end;
end;

end.
