|
@@ -75,7 +75,7 @@ program Setup;
|
75
|
75
|
//{$DEFINE FORCEJREDOWNLOAD}
|
76
|
76
|
|
77
|
77
|
uses
|
78
|
|
- kol, Vista, Windows, SysUtils, classes, registry;
|
|
78
|
+ kol, shared, Vista, Windows, SysUtils, classes, registry;
|
79
|
79
|
|
80
|
80
|
const
|
81
|
81
|
// SetupConsts holds build information for this release
|
|
@@ -211,67 +211,6 @@ begin
|
211
|
211
|
applet.createwindow;
|
212
|
212
|
end;
|
213
|
213
|
|
214
|
|
-{ ----------------------------------------------------------------------------
|
215
|
|
- Takes a size, <dsize> in bytes, and converts it a human readable string with
|
216
|
|
- a suffix (MB or GB).
|
217
|
|
- ---------------------------------------------------------------------------- }
|
218
|
|
-function nicesize(dsize: extended): string;
|
219
|
|
-var
|
220
|
|
- kbytes: single;
|
221
|
|
- mbytes: single;
|
222
|
|
- gbytes: single;
|
223
|
|
-begin
|
224
|
|
- kbytes := dsize / 1024;
|
225
|
|
- mbytes := kbytes / 1024;
|
226
|
|
- gbytes := mbytes / 1024;
|
227
|
|
-
|
228
|
|
- if kbytes < 1024 then begin
|
229
|
|
- result := FloatToStrF(kbytes, ffFixed, 10, 2) + ' kB';
|
230
|
|
- exit;
|
231
|
|
- end;
|
232
|
|
-
|
233
|
|
- if mbytes < 1024 then begin
|
234
|
|
- result := FloatToStrF(mbytes, ffFixed, 10, 2) + ' MB';
|
235
|
|
- exit;
|
236
|
|
- end;
|
237
|
|
-
|
238
|
|
- result := FloatToStrF(gbytes, ffFixed, 10, 2) + ' GB';
|
239
|
|
- exit;
|
240
|
|
-end;
|
241
|
|
-
|
242
|
|
-{ ----------------------------------------------------------------------------
|
243
|
|
- Ask a question and return True for YES and False for NO
|
244
|
|
- Uses nifty vista task dialog if available
|
245
|
|
- ---------------------------------------------------------------------------- }
|
246
|
|
-function askQuestion(Question: String): boolean;
|
247
|
|
-begin
|
248
|
|
- Result := TaskDialog(0, 'DMDirc Setup', 'Question', Question, TD_ICON_QUESTION, TD_BUTTON_YES + TD_BUTTON_NO) = mrYes;
|
249
|
|
-end;
|
250
|
|
-
|
251
|
|
-{ ----------------------------------------------------------------------------
|
252
|
|
- Show an error message
|
253
|
|
- Uses nifty vista task dialog if available
|
254
|
|
- ---------------------------------------------------------------------------- }
|
255
|
|
-procedure showError(ErrorMessage: String; addFooter: boolean = true; includeDescInXP: boolean = true);
|
256
|
|
-begin
|
257
|
|
- if addFooter then begin
|
258
|
|
- ErrorMessage := ErrorMessage+#13#10;
|
259
|
|
- ErrorMessage := ErrorMessage+#13#10+'If you feel this is incorrect, or you require some further assistance,';
|
260
|
|
- if not IsWindowsVista then ErrorMessage := ErrorMessage+#13#10;
|
261
|
|
- ErrorMessage := ErrorMessage+'please feel free to contact us.';
|
262
|
|
- end;
|
263
|
|
- TaskDialog(0, 'DMDirc Setup', 'Sorry, setup is unable to continue.', ErrorMessage, TD_ICON_ERROR, TD_BUTTON_OK, includeDescInXP, false);
|
264
|
|
-end;
|
265
|
|
-
|
266
|
|
-{ ----------------------------------------------------------------------------
|
267
|
|
- Show a message box (information)
|
268
|
|
- Uses nifty vista task dialog if available
|
269
|
|
- ---------------------------------------------------------------------------- }
|
270
|
|
-procedure showmessage(message: String; context:String = 'Information');
|
271
|
|
-begin
|
272
|
|
- TaskDialog(0, 'DMDirc Setup', context, message, TD_ICON_INFORMATION, TD_BUTTON_OK);
|
273
|
|
-end;
|
274
|
|
-
|
275
|
214
|
{ ----------------------------------------------------------------------------
|
276
|
215
|
Launch a process (hidden if requested) and immediately return control to
|
277
|
216
|
the current thread
|
|
@@ -374,7 +313,7 @@ begin
|
374
|
313
|
|
375
|
314
|
{ Just incase wget fails ... }
|
376
|
315
|
if not fileexists(dir+'wgetoutput') then begin
|
377
|
|
- showerror('Internal error: wget returned no output.');
|
|
316
|
+ showerror('Internal error: wget returned no output.', 'DMDirc Setup');
|
378
|
317
|
result := false;
|
379
|
318
|
exit;
|
380
|
319
|
end;
|
|
@@ -406,7 +345,7 @@ begin
|
406
|
345
|
end;
|
407
|
346
|
|
408
|
347
|
{ We ask the user if they wish to download the JRE }
|
409
|
|
- if askQuestion(message+' (Download Size: '+AnsiMidStr(bits[2], 2, length(bits[2])-2)+')') then begin
|
|
348
|
+ if askQuestion(message+' (Download Size: '+AnsiMidStr(bits[2], 2, length(bits[2])-2)+')', 'DMDirc Setup') then begin
|
410
|
349
|
{ Create progress window and show it }
|
411
|
350
|
CreateMainWindow;
|
412
|
351
|
{ Get wget to start the download }
|
|
@@ -448,12 +387,12 @@ begin
|
448
|
387
|
if (terminateDownload) then begin
|
449
|
388
|
Result := false;
|
450
|
389
|
TerminateProcess(ProcessInfo.hProcess, 0);
|
451
|
|
- showError('JRE Download was aborted', false);
|
|
390
|
+ showError('JRE Download was aborted', 'DMDirc Setup', false);
|
452
|
391
|
end
|
453
|
392
|
else Result := processResult = 0;
|
454
|
393
|
if not Result then begin
|
455
|
394
|
if not terminateDownload then begin
|
456
|
|
- showError('JRE Download Failed', false);
|
|
395
|
+ showError('JRE Download Failed', 'DMDirc Setup', false);
|
457
|
396
|
end
|
458
|
397
|
else begin
|
459
|
398
|
// If the download was cancelled by the form, this error will already
|
|
@@ -495,8 +434,8 @@ begin
|
495
|
434
|
|
496
|
435
|
if canContinue then begin
|
497
|
436
|
// Final result of this function is the return value of installing java.
|
498
|
|
- if needDownload or askQuestion(question) then begin
|
499
|
|
- showmessage('The Java installer will now run. Please follow the instructions given. '+#13#10+'The DMDirc installation will continue afterwards.');
|
|
437
|
+ if needDownload or askQuestion(question, 'DMDirc Setup') then begin
|
|
438
|
+ showmessage('The Java installer will now run. Please follow the instructions given. '+#13#10+'The DMDirc installation will continue afterwards.', 'DMDirc Setup');
|
500
|
439
|
Result := (ExecAndWait('jre.exe') = 0);
|
501
|
440
|
end;
|
502
|
441
|
end
|
|
@@ -519,7 +458,7 @@ begin
|
519
|
458
|
if FileExists('DMDirc.jar') then begin
|
520
|
459
|
{$IFDEF FORCEJREDOWNLOAD}if (1 <> 0) then begin{$ELSE}if (ExecAndWait(javaCommand+' -version') <> 0) then begin{$ENDIF}
|
521
|
460
|
if not installJRE(false) then begin
|
522
|
|
- showError('DMDirc setup can not continue without Java. Please install Java and try again.', false, false);
|
|
461
|
+ showError('DMDirc setup can not continue without Java. Please install Java and try again.', 'DMDirc Setup', false, false);
|
523
|
462
|
exit;
|
524
|
463
|
end;
|
525
|
464
|
end;
|
|
@@ -540,7 +479,7 @@ begin
|
540
|
479
|
// Check if the installer runs
|
541
|
480
|
if (ExecAndWait(javaCommand+' -cp DMDirc.jar com.dmdirc.installer.Main --help') <> 0) then begin
|
542
|
481
|
if not installJRE(true) then begin
|
543
|
|
- showError('Sorry, DMDirc setup can not continue without an updated version of java.', false, false);
|
|
482
|
+ showError('Sorry, DMDirc setup can not continue without an updated version of java.', 'DMDirc Setup', false, false);
|
544
|
483
|
exit;
|
545
|
484
|
end
|
546
|
485
|
else begin
|
|
@@ -558,6 +497,6 @@ begin
|
558
|
497
|
errorMessage := errorMessage+#13#10;
|
559
|
498
|
errorMessage := errorMessage+#13#10+'This is likely because of a corrupt installer build.';
|
560
|
499
|
errorMessage := errorMessage+#13#10+'Please check http://www.dmdirc.com/ for an updated build.';
|
561
|
|
- showError(errorMessage);
|
|
500
|
+ showError(errorMessage, 'DMDirc Setup');
|
562
|
501
|
end;
|
563
|
502
|
end.
|