SA-MP/exgui/Settings.pas

81 lines
1.8 KiB
ObjectPascal
Raw Normal View History

2023-11-07 17:10:47 +08:00
unit Settings;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
2023-12-16 23:29:31 +08:00
Dialogs, StdCtrls, Registry, Buttons;
2023-11-07 17:10:47 +08:00
type
2023-11-07 23:44:02 +08:00
TfmSettings = class(TForm)
2023-12-02 20:35:55 +08:00
bnSave: TButton;
bnCancel: TButton;
gbPasswords: TGroupBox;
cbSaveServerPasswords: TCheckBox;
cbSaveRconPasswords: TCheckBox;
edInstallLoc: TEdit;
Label1: TLabel;
sbBrowse: TSpeedButton;
2023-12-02 19:57:04 +08:00
procedure bnSaveClick(Sender: TObject);
procedure bnCancelClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure sbBrowseClick(Sender: TObject);
2023-11-07 17:10:47 +08:00
private
{ Private declarations }
public
{ Public declarations }
end;
var
2023-11-07 23:44:02 +08:00
fmSettings: TfmSettings;
2023-11-07 17:10:47 +08:00
implementation
2023-12-16 23:29:31 +08:00
uses Main;
2023-11-07 17:10:47 +08:00
{$R *.dfm}
2023-12-02 19:57:04 +08:00
procedure TfmSettings.bnSaveClick(Sender: TObject);
2023-12-16 23:29:31 +08:00
var
Reg: TRegistry;
2023-12-02 19:57:04 +08:00
begin
2023-12-16 23:29:31 +08:00
Reg:= TRegistry.Create;
Reg.RootKey:= HKEY_CURRENT_USER;
Reg.OpenKey('SOFTWARE\SAMP', true);
Reg.WriteBool('SaveServPasses', cbSaveServerPasswords.Checked);
Reg.WriteBool('SaveRconPasses', cbSaveRconPasswords.Checked);
Reg.CloseKey;
Reg.Free;
Close;
2023-12-02 19:57:04 +08:00
end;
procedure TfmSettings.bnCancelClick(Sender: TObject);
begin
2023-12-16 23:29:31 +08:00
Close;
2023-12-02 19:57:04 +08:00
end;
procedure TfmSettings.FormCreate(Sender: TObject);
2023-12-16 23:29:31 +08:00
var
Reg: TRegistry;
2023-12-02 19:57:04 +08:00
begin
2023-12-16 23:29:31 +08:00
Reg:= TRegistry.Create;
Reg.RootKey:= HKEY_CURRENT_USER;
Reg.OpenKey('SOFTWARE\SAMP', true);
if Reg.ValueExists('SaveServPasses') then
cbSaveServerPasswords.Checked:= Reg.ReadBool('SaveServPasses');
if Reg.ValueExists('SaveRconPasses') then
cbSaveRconPasswords.Checked:= Reg.ReadBool('SaveRconPasses');
Reg.CloseKey;
Reg.Free;
edInstallLoc.Text:= ExtractFilePath(gta_sa_exe);
2023-12-02 19:57:04 +08:00
end;
procedure TfmSettings.sbBrowseClick(Sender: TObject);
begin
2023-12-16 23:29:31 +08:00
fmMain.GetGTAExe(Handle);
edInstallLoc.Text:= ExtractFilePath(gta_sa_exe);
2023-12-02 19:57:04 +08:00
end;
2023-11-07 17:10:47 +08:00
end.