-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathunit1.pas
107 lines (87 loc) · 2.65 KB
/
unit1.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, Registry, lclintf, Unit2;
type
{ TMainForm }
TMainForm = class(TForm)
ButtonSelectPath: TButton;
ButtonUninstall: TButton;
ButtonInstall: TButton;
EditPath: TEdit;
LabelCaption: TLabel;
LabelSelectGDPath: TLabel;
OpenDialog: TOpenDialog;
procedure ButtonInstallClick(Sender: TObject);
procedure ButtonSelectPathClick(Sender: TObject);
procedure ButtonUninstallClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
public
end;
var
MainForm: TMainForm;
implementation
{$R *.lfm}
{ TMainForm }
procedure TMainForm.FormCreate(Sender: TObject);
var
Registry: TRegistry;
SteamInstallPath: string;
GDInstallPath: String;
begin
Registry := TRegistry.Create;
try
Registry.RootKey := HKEY_LOCAL_MACHINE;
if Registry.OpenKeyReadOnly('SOFTWARE\WOW6432Node\Valve\Steam') then
begin
SteamInstallPath := Registry.ReadString('InstallPath');
Registry.CloseKey;
GDInstallPath := SteamInstallPath + '\steamapps\common\Geometry Dash\GeometryDash.exe';
if FileExists(GDInstallPath) then EditPath.Text := GDInstallPath;
end
finally
Registry.Free;
end;
end;
procedure TMainForm.ButtonSelectPathClick(Sender: TObject);
begin
if OpenDialog.Execute then begin
EditPath.Text := OpenDialog.FileName;
end;
end;
procedure TMainForm.ButtonInstallClick(Sender: TObject);
var
Path: String;
begin
Path := EditPath.Text;
if (Length(Path) <> 0) and FileExists(Path) then begin
if not FileExists(ExtractFilePath(Path) + '\Geode.dll') then begin
MessageDlg('Error', 'Geode is not installed, make sure it is installed', mtError, [mbOK], 0);
OpenURL('https://geode-sdk.org/');
Exit;
end;
FormInstall.GDPath := Path;
FormInstall.ShowModal;
end else begin
MessageDlg('Error', 'Invalid path. Please ensure that you have selected the Geometry Dash file', mtError, [mbOK], 0);
end;
end;
procedure TMainForm.ButtonUninstallClick(Sender: TObject);
var
Path: String;
begin
Path := EditPath.Text;
if (Length(Path) <> 0) and FileExists(Path) then begin
Path := ExtractFilePath(EditPath.Text);
if FileExists(Path + 'geode\mods\tobyadd.gdh.geode') then begin
DeleteFile(Path + 'geode\mods\tobyadd.gdh.geode');
MessageDlg('Inforamiton', 'GDH has been uninstalled', mtInformation, [mbOK], 0);
end else begin
MessageDlg('Error', 'GDH is not installed', mtError, [mbOK], 0);
end;
Exit;
end;
end;
end.