-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathwpSelectComponents.iss
328 lines (295 loc) · 9.65 KB
/
wpSelectComponents.iss
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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
[Code]
var
CompTitle : TLabel;
CompDescription : TLabel;
iTotalCompSize : Int64;
iTotalCompCount : integer;
TypesComboOnChangePrev : TNotifyEvent;
ComponentsListClickCheckPrev : TNotifyEvent;
// Customize ComponentsList according to our needs
procedure update_ComponentsList();
var
i: integer;
compIndex: integer;
begin
// Reset component lists
iTotalCompCount := 0;
iTotalCompSize := 0;
// Update ComponentsList sizes when using localInstallMode
if localInstallMode then
begin
for i := 0 to GetArrayLength(LocalCompsArray) - 1 do begin
if not (LocalCompsArray[i].id = 'setup_tool') then
begin
with Wizardform.ComponentsList do
begin
ItemSubItem[i - 1] := FileSizeArray[i - 1].String
if (LocalCompsArray[i].fileName = 'notDownloaded') then
begin
Checked[i - 1] := false;
ItemEnabled[i - 1] := false;
ItemSubItem[i - 1] := CustomMessage('MissingPackage');
end;
// Calculate how many components are selected
if Checked[i - 1] then
begin
iTotalCompCount := iTotalCompCount + 1;
iTotalCompSize := iTotalCompSize + FileSizeArray[i - 1].Bytes;
end;
end;
end;
end;
end;
// Update component SubItem
for i := 0 to GetArrayLength(WebCompsArray) - 1 do
begin
if not (WebCompsArray[i].id = 'setup_tool') then
begin
with Wizardform.ComponentsList do
begin
if not maintenanceMode then
ItemSubItem[i - 1] := FileSizeArray[i - 1].String
else
begin
compIndex := GetCompIndexByID(WebCompsArray[i].id);
if compIndex > -1 then
begin
// Show custom text if the component is already installed
if MaintenanceCompsArray[compIndex].isInstalled then
ItemSubItem[i - 1] := CustomMessage('AlreadyInstalled') + ' - ' + FileSizeArray[i - 1].String
else if installRadioBtn.Checked then // "Install/Repair" page
ItemSubItem[i - 1] := FileSizeArray[i - 1].String;
if updateRadioBtn.Checked or updateMode then // "Update" page
ItemSubItem[i - 1] := wpUVersionLabel(WebCompsArray[i].Version, MaintenanceCompsArray[compIndex].Version, MaintenanceCompsArray[compIndex].isInstalled);
end;
end;
// Calculate how many components are selected
if Checked[i - 1] then
begin
iTotalCompCount := iTotalCompCount + 1;
iTotalCompSize := iTotalCompSize + FileSizeArray[i - 1].Bytes;
end;
end;
end;
end;
if {#DEBUG} then Log('# ' + IntToStr(iTotalCompCount) + ' components selected, with a total size of ' + BytesToString(iTotalCompSize));
// Replace DiskSpaceLabel //-> TODO: Maybe create a new label and hide the old one?
WizardForm.ComponentsDiskSpaceLabel.Caption := FmtMessage(CustomMessage('CurrentSelectionSpace'), [BytesToString(iTotalCompSize)]);
// Show disk space label if components are selected
if not (iTotalCompCount = 0) then
WizardForm.ComponentsDiskSpaceLabel.Visible := True
else
WizardForm.ComponentsDiskSpaceLabel.Visible := False
end;
// Called when you change the installation type in the components list
procedure NewTypesComboOnChange(Sender: TObject);
begin
// Call Inno's original OnChange action
TypesComboOnChangePrev(Sender);
// Customize ComponentsList
update_ComponentsList();
end;
// Called when you click somewhere in the components list
procedure NewComponentsListClickCheck(Sender: TObject);
begin
// Call Inno's original OnClick action
ComponentsListClickCheckPrev(Sender);
// Customize ComponentsList
update_ComponentsList();
end;
procedure customize_wpSelectComponents();
begin
// Register new ComponentsList OnClick event
with WizardForm.ComponentsList do
begin
ComponentsListClickCheckPrev := OnClickCheck;
OnClickCheck := @NewComponentsListClickCheck;
end;
// Register new TypesCombo OnChange event
with WizardForm.TypesCombo do
begin
TypesComboOnChangePrev := OnChange;
OnChange := @NewTypesComboOnChange;
end;
end;
// Create new labels for name and descriptions
procedure create_CompNameDesc();
begin
CompTitle := TLabel.Create(WizardForm);
with CompTitle do
begin
Caption := '';
Font.Style := [fsBold];
Parent := WizardForm.SelectComponentsPage;
Left := WizardForm.ComponentsList.Left;
Width := WizardForm.ComponentsList.Width;
Height := ScaleY(35);
Top := WizardForm.ComponentsList.Top + WizardForm.ComponentsList.Height - CompTitle.Height - ScaleY(25);
Anchors := [akLeft, akBottom];
AutoSize := False;
WordWrap := True;
end;
CompDescription := TLabel.Create(WizardForm);
with CompDescription do
begin
Caption := '';
Parent := WizardForm.SelectComponentsPage;
Left := WizardForm.ComponentsList.Left;
Width := WizardForm.ComponentsList.Width;
Height := ScaleY(60);
Top := CompTitle.Top + CompTitle.Height - ScaleY(20);
Anchors := [akLeft, akBottom];
AutoSize := False;
WordWrap := True;
end;
WizardForm.ComponentsList.Height := WizardForm.ComponentsList.Height - CompTitle.Height - ScaleY(30);
end;
// "On hover" item descriptions
var
LastMouse : TPoint;
function GetCursorPos(var lpPoint: TPoint): BOOL;
external '[email protected] stdcall';
function SetTimer(
hWnd: longword; nIDEvent, uElapse: LongWord; lpTimerFunc: LongWord): LongWord;
external '[email protected] stdcall';
function ScreenToClient(hWnd: HWND; var lpPoint: TPoint): BOOL;
external '[email protected] stdcall';
function ClientToScreen(hWnd: HWND; var lpPoint: TPoint): BOOL;
external '[email protected] stdcall';
function ListBox_GetItemRect(
const hWnd: HWND; const Msg: Integer; Index: LongInt; var Rect: TRect): LongInt;
external '[email protected] stdcall';
const
LB_GETITEMRECT = $0198;
LB_GETTOPINDEX = $018E;
function FindControl(Parent: TWinControl; P: TPoint): TControl;
var
Control: TControl;
WinControl: TWinControl;
I: Integer;
P2: TPoint;
begin
for I := 0 to Parent.ControlCount - 1 do
begin
Control := Parent.Controls[I];
if Control.Visible and
(Control.Left <= P.X) and (P.X < Control.Left + Control.Width) and
(Control.Top <= P.Y) and (P.Y < Control.Top + Control.Height) then
begin
if Control is TWinControl then
begin
P2 := P;
ClientToScreen(Parent.Handle, P2);
WinControl := TWinControl(Control);
ScreenToClient(WinControl.Handle, P2);
Result := FindControl(WinControl, P2);
if Result <> nil then Exit;
end;
Result := Control;
Exit;
end;
end;
Result := nil;
end;
function PointInRect(const Rect: TRect; const Point: TPoint): Boolean;
begin
Result :=
(Point.X >= Rect.Left) and (Point.X <= Rect.Right) and
(Point.Y >= Rect.Top) and (Point.Y <= Rect.Bottom);
end;
function ListBoxItemAtPos(ListBox: TCustomListBox; Pos: TPoint): Integer;
var
Count: Integer;
ItemRect: TRect;
begin
Result := SendMessage(ListBox.Handle, LB_GETTOPINDEX, 0, 0);
Count := ListBox.Items.Count;
while Result < Count do
begin
ListBox_GetItemRect(ListBox.Handle, LB_GETITEMRECT, Result, ItemRect);
if PointInRect(ItemRect, Pos) then Exit;
Inc(Result);
end;
Result := -1;
end;
procedure HoverComponentChanged(Index: Integer);
var
Title : string;
Description : string;
begin
case Index of
0: begin
Title := '{#eeModuleName}';
Description := CustomMessage('eeModuleDescription');
end;
1: begin
Title := '{#wine_stubName}';
Description := CustomMessage('wine_stubDescription');
end;
2: begin
Title := '{#ee_exeName}';
Description := CustomMessage('eeExeDescription');
end;
3: begin
Title := '{#ee_essentialsName}';
Description := CustomMessage('eeEssentialsDescription');
end;
4: begin
Title := '{#img_packName}';
Description := CustomMessage('img_packDescription');
end;
5: begin
Title := '{#fmv_packName}';
Description := CustomMessage('fmv_packDescription');
end;
6: begin
Title := '{#audio_pack}';
Description := CustomMessage('audio_packDescription');
end;
7: begin
Title := '{#xidiName}';
Description := CustomMessage('xidiDescription');
end;
8: begin
Title := '{#creditsName}';
Description := CustomMessage('creditsDescription');
end;
else
Title := CustomMessage('DescriptionTip');
end;
CompTitle.Caption := Title;
CompDescription.Caption := Description;
CompDescription.Width := WizardForm.ComponentsList.Width;
end;
procedure HoverTimerProc(
H: LongWord; Msg: LongWord; IdEvent: LongWord; Time: LongWord);
var
P: TPoint;
Control: TControl;
Index: Integer;
begin
GetCursorPos(P);
if P <> LastMouse then { just optimization }
begin
LastMouse := P;
ScreenToClient(WizardForm.Handle, P);
if (P.X < 0) or (P.Y < 0) or
(P.X > WizardForm.ClientWidth) or (P.Y > WizardForm.ClientHeight) then
begin
Control := nil;
end
else
begin
Control := FindControl(WizardForm, P);
end;
Index := -1;
if (Control = WizardForm.ComponentsList) and
(not WizardForm.TypesCombo.DroppedDown) then
begin
P := LastMouse;
ScreenToClient(WizardForm.ComponentsList.Handle, P);
Index := ListBoxItemAtPos(WizardForm.ComponentsList, P);
end;
HoverComponentChanged(Index);
end;
end;