Browse Source

Add ComponentsDiskSpaceGBLabel and DiskSpaceGBLabel messages: These messages are used by Setup to display required disk spaces of 1000.0 MB or more in gigabytes instead of in megabytes. If these messages are not set by a translation, Setup will instead use ComponentsDiskSpaceMBLabel and DiskSpaceMBLabel as before.

The component list sizes are still always in MB (or KB) because here it uses same units for all items always, which seems nice for easy quick comparison of component sizes.
Martijn Laan 6 years ago
parent
commit
e7ef0d37cd
5 changed files with 39 additions and 6 deletions
  1. 2 0
      Files/Default.isl
  2. 2 0
      Files/Languages/Dutch.isl
  3. 2 1
      Projects/Compile.pas
  4. 2 0
      Projects/MsgIDs.pas
  5. 31 5
      Projects/Wizard.pas

+ 2 - 0
Files/Default.isl

@@ -151,6 +151,7 @@ WizardSelectDir=Select Destination Location
 SelectDirDesc=Where should [name] be installed?
 SelectDirLabel3=Setup will install [name] into the following folder.
 SelectDirBrowseLabel=To continue, click Next. If you would like to select a different folder, click Browse.
+DiskSpaceGBLabel=At least [gb] GB of free disk space is required.
 DiskSpaceMBLabel=At least [mb] MB of free disk space is required.
 CannotInstallToNetworkDrive=Setup cannot install to a network drive.
 CannotInstallToUNCPath=Setup cannot install to a UNC path.
@@ -178,6 +179,7 @@ NoUninstallWarningTitle=Components Exist
 NoUninstallWarning=Setup has detected that the following components are already installed on your computer:%n%n%1%n%nDeselecting these components will not uninstall them.%n%nWould you like to continue anyway?
 ComponentSize1=%1 KB
 ComponentSize2=%1 MB
+ComponentsDiskSpaceGBLabel=Current selection requires at least [gb] GB of disk space.
 ComponentsDiskSpaceMBLabel=Current selection requires at least [mb] MB of disk space.
 
 ; *** "Select Additional Tasks" wizard page

+ 2 - 0
Files/Languages/Dutch.isl

@@ -134,6 +134,7 @@ WizardSelectDir=Kies de doelmap
 SelectDirDesc=Waar moet [name] geïnstalleerd worden?
 SelectDirLabel3=Setup zal [name] in de volgende map installeren.
 SelectDirBrowseLabel=Klik op Volgende om door te gaan. Klik op Bladeren om een andere map te kiezen.
+DiskSpaceGBLabel=Er is ten minste [gb] GB vrije schijfruimte vereist.
 DiskSpaceMBLabel=Er is ten minste [mb] MB vrije schijfruimte vereist.
 CannotInstallToNetworkDrive=Setup kan niet installeren naar een netwerkstation.
 CannotInstallToUNCPath=Setup kan niet installeren naar een UNC-pad.
@@ -160,6 +161,7 @@ NoUninstallWarningTitle=Component bestaat
 NoUninstallWarning=Setup heeft gedetecteerd dat de volgende componenten al geïnstalleerd zijn op uw computer:%n%n%1%n%nAls u de selectie van deze componenten ongedaan maakt, worden ze niet verwijderd.%n%nWilt u toch doorgaan?
 ComponentSize1=%1 KB
 ComponentSize2=%1 MB
+ComponentsDiskSpaceGBLabel=De huidige selectie vereist ten minste [gb] GB vrije schijfruimte.
 ComponentsDiskSpaceMBLabel=De huidige selectie vereist ten minste [mb] MB vrije schijfruimte.
 
 ; *** "Select Additional Tasks" wizard page

+ 2 - 1
Projects/Compile.pas

@@ -7387,7 +7387,8 @@ begin
   for I := 0 to LanguageEntries.Count-1 do begin
     LangData := LangDataList[I];
     for J := Low(LangData.Messages) to High(LangData.Messages) do
-      if not LangData.MessagesDefined[J] and (J <> msgPrepareToInstallNeedsRestart) then begin
+      if not LangData.MessagesDefined[J] and
+         not (J in [msgComponentsDiskSpaceGBLabel, msgDiskSpaceGBLabel, msgPrepareToInstallNeedsRestart]) then begin
         { Use the message from Default.isl }
         if not (J in [msgHelpTextNote, msgTranslatorNote]) then
           WarningsList.Add(Format(SCompilerMessagesMissingMessageWarning,

+ 2 - 0
Projects/MsgIDs.pas

@@ -55,6 +55,7 @@ type
     msgCompactInstallation,
     msgComponentSize1,
     msgComponentSize2,
+    msgComponentsDiskSpaceGBLabel,
     msgComponentsDiskSpaceMBLabel,
     msgConfirmDeleteSharedFile2,
     msgConfirmDeleteSharedFileTitle,
@@ -66,6 +67,7 @@ type
     msgDirExists,
     msgDirExistsTitle,
     msgDirNameTooLong,
+    msgDiskSpaceGBLabel,
     msgDiskSpaceMBLabel,
     msgDiskSpaceWarning,
     msgDiskSpaceWarningTitle,

+ 31 - 5
Projects/Wizard.pas

@@ -365,13 +365,24 @@ function IntToMBStr(const I: Integer64): String;
 var
   X: Extended;
 begin
-  X := (Comp(I) / 1048576) * 10;
+  X := (Comp(I) / 1048576) * 10; { * 10 to include a decimal }
   if Frac(X) > 0 then
     X := Int(X) + 1;  { always round up }
   X := X / 10;
   Result := Format('%.1n', [X]);
 end;
 
+function IntToGBStr(const I: Integer64): String;
+var
+  X: Extended;
+begin
+  X := (Comp(I) / 1073741824) * 100; { * 100 to include 2 decimals }
+  if Frac(X) > 0 then
+    X := Int(X) + 1;  { always round up }
+  X := X / 100;
+  Result := Format('%.2n', [X]);
+end;
+
 function ExpandSetupMessageEx(const ID: TSetupMessageID;
   const Space: Integer64): String;
 begin
@@ -381,6 +392,19 @@ begin
   StringChange(Result, '[name/ver]', ExpandedAppVerName);
   StringChange(Result, '[kb]', IntToKBStr(Space));
   StringChange(Result, '[mb]', IntToMBStr(Space));
+  StringChange(Result, '[gb]', IntToGBStr(Space));
+end;
+
+function ExpandMBOrGBSetupMessage(const MBID, GBID: TSetupMessageID;
+  const Space: Integer64): String;
+begin
+  if (SetupMessages[GBID] <> '') and (Comp(Space) > 1048471142) then begin
+    { Don't allow it to display 1000.0 MB or more. Takes the 'always round up' into account:
+      1048471142 bytes = 999.8999996185303 MB = '999.9 MB',
+      1048471143 bytes = 999.9000005722046 MB = '1,000.0 MB'. }
+    Result := ExpandSetupMessageEx(GBID, Space)
+  end else
+    Result := ExpandSetupMessageEx(MBID, Space);
 end;
 
 function ExpandSetupMessage(const ID: TSetupMessageID): String;
@@ -560,8 +584,8 @@ begin
 
   SelectedComponents.Free();
 
-  ComponentsDiskSpaceLabel.Caption := ExpandSetupMessageEx(msgComponentsDiskSpaceMBLabel,
-    CurrentComponentsSpace);
+  ComponentsDiskSpaceLabel.Caption := ExpandMBOrGBSetupMessage(
+    msgComponentsDiskSpaceMBLabel, msgComponentsDiskSpaceGBLabel, CurrentComponentsSpace);
 end;
 
 procedure TWizardForm.UpdateComponentSizesEnum(Index: Integer; HasChildren: Boolean; Ext: LongInt);
@@ -986,7 +1010,8 @@ begin
   DirBrowseButton.SetBounds(InnerNotebook.Width - X,
     DirBrowseButton.Top + I, X, DirBrowseButton.Height);
   DirEdit.Width := DirBrowseButton.Left - ScalePixelsX(10) - DirEdit.Left;
-  DiskSpaceLabel.Caption := ExpandSetupMessage(msgDiskSpaceMBLabel);
+  DiskSpaceLabel.Caption := ExpandMBOrGBSetupMessage(
+    msgDiskSpaceMBLabel, msgDiskSpaceGBLabel, MinimumSpace);
   DiskSpaceLabel.Top := DiskSpaceLabel.Top - AdjustLabelHeight(DiskSpaceLabel);
 
   { Initialize wpSelectComponents page }
@@ -996,7 +1021,8 @@ begin
   I := AdjustLabelHeight(SelectComponentsLabel);
   TypesCombo.Top := TypesCombo.Top + I;
   IncTopDecHeight(ComponentsList, I);
-  ComponentsDiskSpaceLabel.Caption := ExpandSetupMessage(msgComponentsDiskSpaceMBLabel);
+  ComponentsDiskSpaceLabel.Caption := ExpandMBOrGBSetupMessage(
+    msgComponentsDiskSpaceMBLabel, msgComponentsDiskSpaceGBLabel, MinimumSpace);
   AdjustLabelHeight(ComponentsDiskSpaceLabel);
 
   if HasCustomType and (Entries[seType].Count = 1) then begin