@@ -56,19 +56,11 @@ Filename: "{tmp}\_offlineinstaller\Output\elixir-v0.14.1-setup.exe"; Flags: wait
5656
5757[Code]
5858type
59- TElixirRelease = record
60- Version: String;
61- URL: String;
62- ReleaseType: String;
63- CompatMask: Integer;
64- end ;
65- TArrayOfElixirRelease = array of TElixirRelease;
59+ TStringTable = array of TStringList;
6660
6761var
68- PSelectVerPage: TWizardPage;
69- PSelectVerListBox: TNewCheckListBox;
70- ReleasesProcessed: Boolean;
71- ElixirReleases: TArrayOfElixirRelease;
62+ PSelRelease: TWizardPage;
63+ PSelReleaseListBox: TNewCheckListBox;
7264
7365function SplitStringRec (Str: String; Delim: String; StrList: TStringList): TStringList;
7466var
@@ -100,89 +92,94 @@ begin
10092 Result := SplitStringRec(Str, Delim, StrList)
10193end ;
10294
103- procedure ParseReleasesCSV ;
95+ function CSVToStringTable (Filename: String): TStringTable ;
10496var
105- ReleaseStrings : TArrayOfString;
97+ Rows : TArrayOfString;
10698 NumReleases: Integer;
10799 i: Integer;
108- LineValues: TStringList;
100+ Values: TStringList;
101+ ReturnArray: TStringTable;
109102begin
110- LoadStringsFromFile(ExpandConstant(' {tmp}\releases.csv' ), ReleaseStrings);
111- NumReleases := GetArrayLength(ReleaseStrings);
112- SetArrayLength(ElixirReleases, NumReleases);
103+ LoadStringsFromFile(Filename, Rows);
104+
105+ NumReleases := GetArrayLength(Rows);
106+ SetArrayLength(ReturnArray, NumReleases);
113107
114108 for i := 0 to NumReleases - 1 do begin
115- LineValues := SplitString(ReleaseStrings[i], ' ,' );
116- ElixirReleases[i].Version := LineValues.Strings[0 ];
117- ElixirReleases[i].URL := LineValues.Strings[1 ];
118- ElixirReleases[i].ReleaseType := LineValues.Strings[2 ];
119- ElixirReleases[i].CompatMask := StrToInt(LineValues.Strings[3 ]);
109+ ReturnArray[i] := SplitString(Rows[i], ' ,' );
120110 end ;
111+
112+ Result := ReturnArray;
121113end ;
122114
123- procedure PopulateListOfReleases ( );
115+ procedure PopulatePSelReleaseListBox (StringTable: TStringTable );
124116var
125- LatestRelease: Boolean ;
117+ PrereleaseLabel: String ;
126118 MatchesCompatMask: Boolean;
127119 VersionLabel: String;
128120 i: Integer;
129121begin
130- LatestRelease := True;
131- for i := 0 to GetArrayLength(ElixirReleases) - 1 do begin
132- VersionLabel := ' Version ' + ElixirReleases[i].Version;
133- if LatestRelease then
134- VersionLabel := VersionLabel + ' (Latest)' ;
122+ PSelReleaseListBox.Items.Clear;
123+
124+ for i := 0 to GetArrayLength(StringTable) - 1 do begin
125+ if (StrToInt(StringTable[i][3 ]) = { #COMPAT_MASK} ) then begin
126+ VersionLabel := ' Version ' + StringTable[i][0 ];
127+ if StringTable[i][2 ] = ' true' then begin
128+ PrereleaseLabel := ' Prerelease' ;
129+ end else
130+ PrereleaseLabel := ' Release' ;
135131
136- MatchesCompatMask := (ElixirReleases[i].CompatMask = { #COMPAT_MASK} );
137- PSelectVerListBox.AddRadioButton(VersionLabel, ElixirReleases[i].ReleaseType, 0 , LatestRelease, MatchesCompatMask, nil );
138-
139- if MatchesCompatMask then
140- LatestRelease := False;
132+ PSelReleaseListBox.AddRadioButton(VersionLabel, PrereleaseLabel, 0 , False, True, StringTable[i]);
133+ end ;
141134 end ;
142135end ;
143136
144- function GetSelectedRelease (): TElixirRelease ;
137+ function GetSelectedReleaseValues (): TStrings ;
145138var
146139 i: Integer;
147140begin
148- for i := 0 to GetArrayLength(ElixirReleases) - 1 do begin
149- if PSelectVerListBox .Checked[i] then begin
150- Result := ElixirReleases [i];
141+ for i := 0 to PSelReleaseListBox.Items.Count - 1 do begin
142+ if PSelReleaseListBox .Checked[i] then begin
143+ Result := TStrings(PSelReleaseListBox.ItemObject [i]) ;
151144 end ;
152145 end ;
153146end ;
154147
155148function GetSelectedReleaseVersion (Param: String): String;
156149begin
157- Result := GetSelectedRelease().Version;
150+ Result := GetSelectedReleaseValues[0 ];
151+ end ;
152+
153+ function GetSelectedReleaseURL (): String;
154+ begin
155+ Result := GetSelectedReleaseValues[1 ];
158156end ;
159157
160158procedure CurPageChanged (CurPageID: Integer);
161159begin
162- if CurPageID = PSelectVerPage .ID then begin
163- if not ReleasesProcessed then begin
160+ if CurPageID = PSelRelease .ID then begin
161+ if not FileExists(ExpandConstant( ' {tmp}\releases.csv ' )) then
164162 idpDownloadFile(' http://elixir-lang.org/releases.csv' , ExpandConstant(' {tmp}\releases.csv' ));
165- ParseReleasesCSV;
166- PopulateListOfReleases;
167163
168- ReleasesProcessed := True;
169- end ;
164+ PopulatePSelReleaseListBox(
165+ CSVToStringTable(
166+ ExpandConstant(' {tmp}\releases.csv' )));
170167 end ;
171168
172169 if CurPageID = wpReady then begin
173- idpAddFile(GetSelectedRelease().URL , ExpandConstant(' {tmp}\Precompiled.zip' ));
170+ idpAddFile(GetSelectedReleaseURL , ExpandConstant(' {tmp}\Precompiled.zip' ));
174171 idpDownloadAfter(wpPreparing);
175172 end ;
176173end ;
177174
178175procedure CreatePages ();
179176begin
180- PSelectVerPage := CreateCustomPage(wpWelcome, ' Select Elixir version ' , ' Setup will download and install the Elixir version you select.' );
177+ PSelRelease := CreateCustomPage(wpWelcome, ' Select Elixir release ' , ' Setup will download and install the Elixir release you select.' );
181178
182- PSelectVerListBox := TNewCheckListBox.Create(PSelectVerPage );
183- PSelectVerListBox .Width := PSelectVerPage .SurfaceWidth;
184- PSelectVerListBox .Height := PSelectVerPage .SurfaceHeight - 10 ;
185- PSelectVerListBox .Parent := PSelectVerPage .Surface;
179+ PSelReleaseListBox := TNewCheckListBox.Create(PSelRelease );
180+ PSelReleaseListBox .Width := PSelRelease .SurfaceWidth;
181+ PSelReleaseListBox .Height := PSelRelease .SurfaceHeight - 10 ;
182+ PSelReleaseListBox .Parent := PSelRelease .Surface;
186183end ;
187184
188185function ErlangIsInstalled : Boolean;
194191
195192procedure InitializeWizard ();
196193begin
197- ReleasesProcessed := False ;
194+ idpSetOption( ' DetailsButton ' , ' 0 ' ) ;
198195 CreatePages;
199196end ;
200197
0 commit comments