@@ -224,12 +224,17 @@ procedure ElixirReleasesToListBox(Releases: array of TElixirRelease; ListBox: TN
224224var
225225 i: Integer;
226226begin
227- PSelRelease.CheckListBox .Items.Clear;
227+ ListBox .Items.Clear;
228228 for i := 0 to GetArrayLength(Releases) - 1 do begin
229229 with Releases[i] do begin
230- if ReleaseType <> rtIncompatible then begin
231- PSelRelease.CheckListBox.AddRadioButton(' Elixir version ' + Version, ReleaseTypeToString(ReleaseType), 0 , (ReleaseType = rtLatestRelease), True, Ref);
232- end ;
230+ ListBox.AddRadioButton(
231+ ' Elixir version ' + Version,
232+ ReleaseTypeToString(ReleaseType),
233+ 0 ,
234+ (ReleaseType = rtLatestRelease),
235+ (ReleaseType <> rtIncompatible),
236+ Ref
237+ );
233238 end
234239 end ;
235240end ;
@@ -297,16 +302,64 @@ begin
297302 end ;
298303end ;
299304
305+ function GetFirstReleaseOfType (Releases: array of TElixirRelease; ReleaseType: TElixirReleaseType): TElixirRelease;
306+ var
307+ i: Integer;
308+ begin
309+ Result := Null;
310+ for i := 0 to GetArrayLength(Releases) - 1 do begin
311+ if Releases[i].ReleaseType = ReleaseType then begin
312+ Result := Releases[i];
313+ exit;
314+ end ;
315+ end ;
316+ end ;
317+
318+ function GetFirstReleaseMatchingRef (Releases: array of TElixirRelease; RefMatch: TObject): TElixirRelease;
319+ var
320+ i: Integer;
321+ begin
322+ Result := Null;
323+ for i := 0 to GetArrayLength(Releases) - 1 do begin
324+ if Releases[i].Ref = RefMatch then begin
325+ Result := Releases[i];
326+ exit;
327+ end ;
328+ end ;
329+ end ;
330+
331+ function GetSelectedRelease (ListBoxes: array of TNewCheckListBox; Releases: array of TElixirRelease): TElixirRelease;
332+ var
333+ i, j, k: Integer;
334+ begin
335+ Result := Null;
336+ for i := 0 to GetArrayLength(ListBoxes) - 1 do begin
337+ for j := 0 to ListBoxes[i].Items.Count - 1 do begin
338+ if ListBoxes[i].ItemObject[j] <> Null then begin
339+ Result := GetFirstReleaseMatchingRef(Releases, ListBoxes[i].ItemObject[j]);
340+ exit;
341+ end ;
342+ end ;
343+ end ;
344+ end ;
345+
300346procedure CurPageChanged (CurPageID: Integer);
347+ var
348+ ListBoxesToCheck: array [0 ..1 ] of TNewCheckListBox;
301349begin
302350 if CurPageID = wpPreparing then begin
303- if IsTaskSelected(' erlang\32' ) then begin
304- idpAddFile(ErlangInfo.URL32, GetOTP32Exe);
351+ with GlobalErlangData do begin
352+ if IsTaskSelected(' erlang\32' ) then
353+ idpAddFile(URL32, Exe32);
354+ if IsTaskSelected(' erlang\64' ) then
355+ idpAddFile(URL64, Exe64);
305356 end ;
306- if IsTaskSelected(' erlang\64' ) then begin
307- idpAddFile(ErlangInfo.URL64, GetOTP64Exe);
308- end ;
309- idpAddFile(GetURL(GetSelectedRelease()), ExpandConstant(' {tmp}\Precompiled.zip' ));
357+
358+ ListBoxesToCheck[0 ] := GlobalPageSelInstallType.CheckListBox;
359+ ListBoxesToCheck[1 ] := GlobalPageSelRelease.CheckListBox;
360+
361+ CacheSelectedRelease := GetSelectedRelease(ListBoxesToCheck, GlobalElixirReleases);
362+ idpAddFile(CacheSelectedRelease.URL, ExpandConstant(' {tmp}\Precompiled.zip' ));
310363 idpDownloadAfter(wpPreparing);
311364 end ;
312365end ;
@@ -321,26 +374,35 @@ begin
321374end ;
322375
323376procedure InitializeWizard ();
324- var
325- LatestRelease, LatestPrerelease: TStrings;
326- ErlangFile: TArrayOfString;
327377begin
328- PSelInstallType := CreateInputOptionPage(wpWelcome, ' Select Elixir installation type' , ' Select which installation type you want to perform, then click Next.' , ' I want to:' , True, False);
329-
330- PSelRelease := CreateInputOptionPage(PSelInstallType.ID, ' Select Elixir release' , ' Setup will download and install the Elixir release you select.' , ' All releases available to install are listed below, from newest to oldest.' , True, True);
331-
332- PopulatePSelReleaseListBox(CSVToStringTable(GetElixirCSVFilePath));
333- LatestRelease := GetListBoxLatestRelease(False);
334- LatestPrerelease := GetListBoxLatestRelease(True);
335-
336- PSelInstallType.CheckListBox.AddRadioButton(' Install the latest stable release (v' + GetVersion(LatestRelease) + ' )' , ' ' , 0 , True, True, LatestRelease);
337- if not (LatestPrerelease = nil ) then begin
338- PSelInstallType.CheckListBox.AddRadioButton(' Install the latest prerelease (v' + GetVersion(LatestPrerelease) + ' )' , ' ' , 0 , False, True, LatestPrerelease);
378+ CacheSelectedRelease := Null;
379+
380+ GlobalPageSelInstallType := CreateInputOptionPage(
381+ wpWelcome,
382+ ' Select Elixir installation type' ,
383+ ' Select which installation type you want to perform, then click Next.' ,
384+ ' I want to:' ,
385+ True, False
386+ );
387+
388+ GlobalPageSelRelease := CreateInputOptionPage(
389+ GlobalPageSelInstallType.ID,
390+ ' Select Elixir release' ,
391+ ' Setup will download and install the Elixir release you select.' ,
392+ ' All releases available to install are listed below, from newest to oldest.' ,
393+ True, True
394+ );
395+
396+ CSVToElixirReleases(GetElixirCSVFilePath, GlobalElixirReleases);
397+ ElixirReleasesToListBox(GlobalElixirReleases, GlobalPageSelRelease.CheckListBox);
398+
399+ with GetFirstReleaseOfType(GlobalElixirReleases, rtLatestRelease) do begin
400+ GlobalPageSelInstallType.CheckListBox.AddRadioButton(
401+ ' Install the latest stable release (v' + Version + ' )' ,
402+ ' ' , 0 , True, True, Ref
403+ );
339404 end ;
340- PSelInstallType.CheckListBox.AddRadioButton(' Select another release to install' , ' ' , 0 , False, True, nil );
341-
342- LoadStringsFromFile(GetErlangCSVFilePath, ErlangFile);
343- ErlangCSVInfo := SplitString(ErlangFile[0 ], ' ,' );
405+ GlobalPageSelInstallType.CheckListBox.AddRadioButton(' Select another release to install' , ' ' , 0 , False, True, nil );
344406end ;
345407
346408function InitializeSetup (): Boolean;
0 commit comments