@@ -56,19 +56,11 @@ Filename: "{tmp}\_offlineinstaller\Output\elixir-v0.14.1-setup.exe"; Flags: wait
56
56
57
57
[Code]
58
58
type
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;
66
60
67
61
var
68
- PSelectVerPage: TWizardPage;
69
- PSelectVerListBox: TNewCheckListBox;
70
- ReleasesProcessed: Boolean;
71
- ElixirReleases: TArrayOfElixirRelease;
62
+ PSelRelease: TWizardPage;
63
+ PSelReleaseListBox: TNewCheckListBox;
72
64
73
65
function SplitStringRec (Str: String; Delim: String; StrList: TStringList): TStringList;
74
66
var
@@ -100,89 +92,94 @@ begin
100
92
Result := SplitStringRec(Str, Delim, StrList)
101
93
end ;
102
94
103
- procedure ParseReleasesCSV ;
95
+ function CSVToStringTable (Filename: String): TStringTable ;
104
96
var
105
- ReleaseStrings : TArrayOfString;
97
+ Rows : TArrayOfString;
106
98
NumReleases: Integer;
107
99
i: Integer;
108
- LineValues: TStringList;
100
+ Values: TStringList;
101
+ ReturnArray: TStringTable;
109
102
begin
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);
113
107
114
108
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], ' ,' );
120
110
end ;
111
+
112
+ Result := ReturnArray;
121
113
end ;
122
114
123
- procedure PopulateListOfReleases ( );
115
+ procedure PopulatePSelReleaseListBox (StringTable: TStringTable );
124
116
var
125
- LatestRelease: Boolean ;
117
+ PrereleaseLabel: String ;
126
118
MatchesCompatMask: Boolean;
127
119
VersionLabel: String;
128
120
i: Integer;
129
121
begin
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' ;
135
131
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 ;
141
134
end ;
142
135
end ;
143
136
144
- function GetSelectedRelease (): TElixirRelease ;
137
+ function GetSelectedReleaseValues (): TStrings ;
145
138
var
146
139
i: Integer;
147
140
begin
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]) ;
151
144
end ;
152
145
end ;
153
146
end ;
154
147
155
148
function GetSelectedReleaseVersion (Param: String): String;
156
149
begin
157
- Result := GetSelectedRelease().Version;
150
+ Result := GetSelectedReleaseValues[0 ];
151
+ end ;
152
+
153
+ function GetSelectedReleaseURL (): String;
154
+ begin
155
+ Result := GetSelectedReleaseValues[1 ];
158
156
end ;
159
157
160
158
procedure CurPageChanged (CurPageID: Integer);
161
159
begin
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
164
162
idpDownloadFile(' http://elixir-lang.org/releases.csv' , ExpandConstant(' {tmp}\releases.csv' ));
165
- ParseReleasesCSV;
166
- PopulateListOfReleases;
167
163
168
- ReleasesProcessed := True;
169
- end ;
164
+ PopulatePSelReleaseListBox(
165
+ CSVToStringTable(
166
+ ExpandConstant(' {tmp}\releases.csv' )));
170
167
end ;
171
168
172
169
if CurPageID = wpReady then begin
173
- idpAddFile(GetSelectedRelease().URL , ExpandConstant(' {tmp}\Precompiled.zip' ));
170
+ idpAddFile(GetSelectedReleaseURL , ExpandConstant(' {tmp}\Precompiled.zip' ));
174
171
idpDownloadAfter(wpPreparing);
175
172
end ;
176
173
end ;
177
174
178
175
procedure CreatePages ();
179
176
begin
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.' );
181
178
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;
186
183
end ;
187
184
188
185
function ErlangIsInstalled : Boolean;
194
191
195
192
procedure InitializeWizard ();
196
193
begin
197
- ReleasesProcessed := False ;
194
+ idpSetOption( ' DetailsButton ' , ' 0 ' ) ;
198
195
CreatePages;
199
196
end ;
200
197
0 commit comments