瀏覽代碼

Moved shared calls into shared unit, put Vista.pas into libwin

tags/0.6.3m1rc1
Michael 15 年之前
父節點
當前提交
38a2aae7e6
共有 5 個檔案被更改,包括 25 行新增118 行删除
  1. 10
    71
      installer/windows/Setup.dpr
  2. 3
    2
      installer/windows/makeInstallerWindows.sh
  3. 5
    39
      launcher/windows/DMDirc.dpr
  4. 7
    6
      launcher/windows/compile.sh
  5. 0
    0
      libwin/Vista.pas

+ 10
- 71
installer/windows/Setup.dpr 查看文件

@@ -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.

+ 3
- 2
installer/windows/makeInstallerWindows.sh 查看文件

@@ -460,7 +460,7 @@ if [ ! -e "Setup.exe"  -o "${compileSetup}" = "true" ]; then
460 460
 		exit 1;
461 461
 	else
462 462
 		echo "Building Setup.exe..."
463
-		extraFlags="-dKOL -FU${PWD}/../../libwin/kolfpc -Fu${PWD}/../../libwin/kolfpc"
463
+		extraFlags="-dKOL -Fu${PWD}/../../libwin/kolfpc -Fu{$PWD}/../../libwin/lcore -Fu{$PWD} -Fu${PWD}/../../libwin"
464 464
 		${FPC} ${compilerFlags} ${extraFlags} Setup.dpr
465 465
 		if [ $? -ne 0 ]; then
466 466
 			if [ -e "Setup.exe" -a "${useOldSetup}" = "true" ]; then
@@ -525,7 +525,8 @@ if [ -e "${jarPath}/launcher/windows" ]; then
525 525
 	done
526 526
 fi
527 527
 
528
-${FPC} ${compilerFlags} ${3}Uninstaller.dpr
528
+extraFlags="-dKOL -Fu${PWD}/../../libwin/kolfpc -Fu{$PWD} -Fu${PWD}/../../libwin"
529
+${FPC} ${compilerFlags} ${extraFlags} ${3}Uninstaller.dpr
529 530
 if [ -e "Uninstaller.exe" ]; then
530 531
 	FILES="${FILES} Uninstaller.exe"
531 532
 #	DELETEFILES="${DELETEFILES} Uninstaller.exe"

+ 5
- 39
launcher/windows/DMDirc.dpr 查看文件

@@ -32,44 +32,10 @@ program DMDirc;
32 32
 {$R icon.rc}
33 33
 {$R version.rc}
34 34
 
35
-uses Windows, SysUtils, classes, StrUtils, Vista;
35
+uses Vista, shared, Windows, SysUtils, classes, StrUtils;
36 36
 procedure InitCommonControls; stdcall; External 'comctl32.dll' name 'InitCommonControls';
37 37
 { ---------------------------------------------------------------------------- }
38 38
 
39
-{ ----------------------------------------------------------------------------
40
-  Ask a question and return True for YES and False for NO
41
-  Uses nifty vista task dialog if available
42
-  ---------------------------------------------------------------------------- }
43
-function askQuestion(Question: String): boolean;
44
-begin
45
-  Result := TaskDialog(0, 'DMDirc', 'Question', Question, TD_ICON_QUESTION, TD_BUTTON_YES + TD_BUTTON_NO) = mrYes;
46
-end;
47
-
48
-{ ----------------------------------------------------------------------------
49
-  Show an error message
50
-  Uses nifty vista task dialog if available
51
-  ---------------------------------------------------------------------------- }
52
-procedure showError(ErrorMessage: String; addFooter: boolean = true);
53
-begin
54
-  if addFooter then begin
55
-    ErrorMessage := ErrorMessage+#13#10;
56
-    ErrorMessage := ErrorMessage+#13#10+'If you feel this is incorrect, or you require some further assistance,';
57
-    ErrorMessage := ErrorMessage+#13#10+'please feel free to contact us.';
58
-  end;
59
-
60
-  TaskDialog(0, 'DMDirc', 'There was an error starting DMDirc', ErrorMessage, TD_ICON_ERROR, TD_BUTTON_OK, false, false);
61
-end;
62
-
63
-{ ----------------------------------------------------------------------------
64
-  Show a message box (information)
65
-  Uses nifty vista task dialog if available
66
-  ---------------------------------------------------------------------------- }
67
-procedure showmessage(message: String; context:String = 'Information');
68
-begin
69
-  TaskDialog(0, 'DMDirc', context, message, TD_ICON_INFORMATION, TD_BUTTON_OK);
70
-end;
71
-
72
-
73 39
 { ----------------------------------------------------------------------------
74 40
   Launch a process (hidden if requested) and wait for it to finish
75 41
   ---------------------------------------------------------------------------- }
@@ -170,7 +136,7 @@ begin
170 136
         errorMessage := errorMessage+#13#10;
171 137
         errorMessage := errorMessage+#13#10+'Please click ''Allow'' on the UAC prompt to complete the update, or click no ';
172 138
         errorMessage := errorMessage+#13#10+'here to continue without updating. ';
173
-        if askQuestion(errorMessage) then begin
139
+        if askQuestion(errorMessage, 'DMDirc') then begin
174 140
           RunProgram('"'+ExtractFileDir(paramstr(0))+'\DMDircUpdater.exe" --UpdateSourceDir "'+directory+'"', not launcherUpdate);
175 141
         end;
176 142
       end
@@ -186,7 +152,7 @@ begin
186 152
       errorMessage := errorMessage+#13#10;
187 153
       errorMessage := errorMessage+#13#10+'DMDirc requires a 1.6.0 compatible JVM, you can get one from:';
188 154
       errorMessage := errorMessage+#13#10+'http://java.com/';
189
-      showError(errorMessage, true);
155
+      showError(errorMessage, 'DMDirc', true);
190 156
     end
191 157
     // Else try and run client. (This only asks for help output to check that client
192 158
     // runs on this OS, otherwise later segfaults or so would cause the error to
@@ -197,7 +163,7 @@ begin
197 163
         errorMessage := errorMessage+#13#10;
198 164
         errorMessage := errorMessage+#13#10+'DMDirc requires a 1.6.0 compatible JVM, you can get one from:';
199 165
         errorMessage := errorMessage+#13#10+'http://java.com/';
200
-        showError(errorMessage, True);
166
+        showError(errorMessage, 'DMDirc', True);
201 167
       end
202 168
       else begin
203 169
         Launch(javaCommand+' -ea -jar "'+jarName+'"'+' -l windows-'+launcherVersion+' '+cliParams)
@@ -207,7 +173,7 @@ begin
207 173
       errorMessage := 'A file required to start DMDirc is missing. Please re-install DMDirc to rectify the problem.';
208 174
       errorMessage := errorMessage+#13#10;
209 175
       errorMessage := errorMessage+#13#10 + 'File: DMDirc.jar';
210
-      showError(errorMessage);
176
+      showError(errorMessage, 'DMDirc');
211 177
     end;
212 178
   end;
213 179
 end.

+ 7
- 6
launcher/windows/compile.sh 查看文件

@@ -1,19 +1,20 @@
1 1
 #!/bin/sh
2
-rm Vista.pas UAC.manifest UAC.rc
2
+rm UAC.manifest UAC.rc
3 3
 if [ ! -e ../../installer/windows/UAC.rc ]; then
4 4
 	echo "1 24 \"UAC.manifest\"" > UAC.rc
5
-	cp ../../installer/windows/Vista.pas ../../installer/windows/UAC.manifest .
5
+	cp ../../installer/windows/UAC.manifest .
6 6
 else
7
-	cp ../../installer/windows/Vista.pas ../../installer/windows/UAC.manifest ../../installer/windows/UAC.rc .
7
+	cp ../../installer/windows/UAC.manifest ../../installer/windows/UAC.rc .
8 8
 fi;
9 9
 
10 10
 rm -Rf ./*.exe
11 11
 compilerFlags="-Xs -XX -O2 -Or -Op1"
12
-fpc -Sd -Twin32 ${compilerFlags} DMDirc.dpr
13
-fpc -Sd -Twin32 ${compilerFlags} DMDircUpdater.dpr
12
+extraFlags="-Fu${PWD}/../../libwin"
13
+fpc -Sd -Twin32 ${compilerFlags} ${extraFlags} DMDirc.dpr
14
+fpc -Sd -Twin32 ${compilerFlags} ${extraFlags} DMDircUpdater.dpr
14 15
 rm -Rf ./*.o ./*.or ./*.ppu
15 16
 if [ -e DMDircUpdater.exe -a -e DMDirc.exe ]; then
16 17
 	exit 0;
17 18
 else
18 19
 	exit 1;
19
-fi
20
+fi

installer/windows/Vista.pas → libwin/Vista.pas 查看文件


Loading…
取消
儲存