-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathUMake_FormShortcuts.pas
executable file
·200 lines (158 loc) · 6.45 KB
/
UMake_FormShortcuts.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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
unit UMake_FormShortcuts;
interface
uses
UMake_Configuration,
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Buttons, SysTools, Shortcuts, Registry, ExtCtrls, FileCtrl;
(*****************************************************************************)
(* TFormShortcuts
(*****************************************************************************)
type
TFormShortcuts = class(TForm)
BevelAuto: TBevel;
BevelGeneric: TBevel;
BevelProject: TBevel;
ButtonBrowseGame: TBitBtn;
ButtonCancel: TButton;
ButtonCreate: TButton;
ComboBoxGame: TComboBox;
LabelExplanationAuto: TLabel;
LabelExplanationGeneric: TLabel;
LabelExplanationProject: TLabel;
LabelProject: TLabel;
PanelFocus: TPanel;
RadioButtonAuto: TRadioButton;
RadioButtonGeneric: TRadioButton;
RadioButtonProject: TRadioButton;
procedure FormShow(Sender: TObject);
procedure ButtonBrowseGameClick(Sender: TObject);
procedure ButtonCreateClick(Sender: TObject);
procedure ComboBoxGameChange(Sender: TObject);
public
Configuration: TConfiguration;
private
procedure CreateShortcutGeneric;
procedure CreateShortcutProject;
procedure CreateShortcutAuto;
end;
var
FormShortcuts: TFormShortcuts;
implementation
{$R *.DFM}
(*****************************************************************************)
(* TFormShortcuts
(*****************************************************************************)
procedure TFormShortcuts.FormShow(Sender: TObject);
var
IndexKey: Integer;
Registry: TRegistry;
StringListKeys: TStringList;
TextDirGame: string;
begin
PanelFocus.SetFocus;
RadioButtonGeneric.Checked := True;
Registry := TRegistry.Create;
Registry.RootKey := HKEY_LOCAL_MACHINE;
if Registry.OpenKeyReadOnly('\SOFTWARE\Unreal Technology\Installed Apps') then
begin
StringListKeys := TStringList.Create;
Registry.GetKeyNames(StringListKeys);
Registry.CloseKey;
for IndexKey := 0 to StringListKeys.Count - 1 do
begin
if Registry.OpenKeyReadOnly('\SOFTWARE\Unreal Technology\Installed Apps\' + StringListKeys[IndexKey]) then
begin
if Registry.ValueExists('Folder') then
begin
TextDirGame := Registry.ReadString('Folder');
TextDirGame := GetLongPath(TextDirGame);
if FileExists(IncludeTrailingBackslash(TextDirGame) + 'System\ucc.exe') and (ComboBoxGame.Items.IndexOf(TextDirGame) < 0) then
ComboBoxGame.Items.Add(ExcludeTrailingBackslash(TextDirGame));
end;
Registry.CloseKey;
end;
end;
if ComboBoxGame.Items.Count > 0 then
ComboBoxGame.Text := ComboBoxGame.Items[0];
StringListKeys.Free;
end;
Registry.Free;
if Assigned(Configuration) then
begin
LabelProject.Caption := Format('for %s', [Configuration.Package]);
LabelExplanationProject.Caption := Format('Double-click this shortcut to directly compile the currently loaded project, %s.', [Configuration.Package]);
BevelProject.SetBounds(LabelProject.Left + LabelProject.Width + 5, BevelProject.Top, BevelProject.Left + BevelProject.Width - LabelProject.Left - LabelProject.Width - 5, BevelProject.Height);
ComboBoxGame.Text := ExcludeTrailingBackslash(Configuration.DirGame);
end
else begin
RadioButtonProject.Enabled := False;
LabelProject.Hide;
LabelExplanationProject.Enabled := False;
LabelExplanationProject.Caption := 'Load a project first to enable this option.';
BevelProject.SetBounds(LabelProject.Left + 2, BevelProject.Top, BevelProject.Left + BevelProject.Width - LabelProject.Left - 2, BevelProject.Height);
end;
end;
procedure TFormShortcuts.ButtonBrowseGameClick(Sender: TObject);
var
TextDirGame: string;
begin
TextDirGame := BrowseFolder(Handle, 'Select the base directory of the game UMake should search for recently modified projects:');
ComboBoxGame.Text := ExcludeTrailingBackslash(TextDirGame);
ComboBoxGameChange(ComboBoxGame);
ComboBoxGame.SetFocus;
end;
procedure TFormShortcuts.ComboBoxGameChange(Sender: TObject);
begin
RadioButtonAuto.Checked := True;
end;
procedure TFormShortcuts.ButtonCreateClick(Sender: TObject);
begin
if RadioButtonGeneric.Checked then CreateShortcutGeneric
else if RadioButtonProject.Checked then CreateShortcutProject
else if RadioButtonAuto .Checked then CreateShortcutAuto;
end;
procedure TFormShortcuts.CreateShortcutGeneric;
var
ShortcutDesktop: TFileShortcut;
begin
ShortcutDesktop := TFileShortcut.Create;
ShortcutDesktop.Path := GetLongPath(ParamStr(0));
ShortcutDesktop.Description := 'Compile an UnrealScript file by dropping it on this icon.';
ShortcutDesktop.Save(IncludeTrailingBackslash(GetDesktopPath) + 'UMake.lnk');
ShortcutDesktop.Free;
end;
procedure TFormShortcuts.CreateShortcutProject;
var
ShortcutDesktop: TFileShortcut;
begin
ShortcutDesktop := TFileShortcut.Create;
ShortcutDesktop.Path := GetLongPath(ParamStr(0));
ShortcutDesktop.Arguments := GetQuotedParam(Configuration.DirPackage);
ShortcutDesktop.Description := Format('Double-click this icon to compile %s.', [Configuration.Package]);
ShortcutDesktop.Save(IncludeTrailingBackslash(GetDesktopPath) + Format('Compile %s.lnk', [Configuration.Package]));
ShortcutDesktop.Free;
end;
procedure TFormShortcuts.CreateShortcutAuto;
var
ShortcutDesktop: TFileShortcut;
TextDirGame: string;
begin
TextDirGame := GetLongPath(ComboBoxGame.Text);
if FileExists(IncludeTrailingBackslash(TextDirGame) + 'System\ucc.exe') then
begin
ShortcutDesktop := TFileShortcut.Create;
ShortcutDesktop.Path := GetLongPath(ParamStr(0));
ShortcutDesktop.Arguments := Format('/auto %s', [GetQuotedParam(TextDirGame)]);
ShortcutDesktop.Description := Format('Double-click this icon to compile the most recently modified project in %s.', [ExtractFileName(ComboBoxGame.Text)]);
ShortcutDesktop.Save(IncludeTrailingBackslash(GetDesktopPath) + Format('Compile %s Project.lnk', [ExtractFileName(ComboBoxGame.Text)]));
ShortcutDesktop.Free;
end
else begin
if DirectoryExists(TextDirGame)
then Application.MessageBox('Invalid game directory.'#13#10#13#10'The game directory you selected seems to be invalid (no compiler found). Maybe you have to download and install a developer''s toolkit first.', PChar(Application.Title), MB_ICONERROR)
else Application.MessageBox('The selected game directory doesn''t exist.', PChar(Application.Title), MB_ICONERROR);
ComboBoxGame.SetFocus;
ModalResult := mrNone;
end;
end;
end.