Skip to content
This repository was archived by the owner on May 1, 2024. It is now read-only.

Commit ee022a1

Browse files
committed
remove inst type page, simplify/inline telixirrelease code
1 parent cf96a04 commit ee022a1

File tree

2 files changed

+47
-155
lines changed

2 files changed

+47
-155
lines changed

ElixirWeb.iss

Lines changed: 41 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ Name: "defer"; Description: "Defer installation (advanced)"; Flags: unchecked
9797
9898
var
9999
GlobalPageSelRelease: TInputOptionWizardPage;
100-
GlobalPageSelInstallType: TInputOptionWizardPage;
101100
102101
GlobalElixirReleases: array of TElixirRelease;
103102
GlobalErlangData: TErlangData;
@@ -141,13 +140,6 @@ begin
141140
idpAddFile(URL64, Tmp(Exe64));
142141
end;
143142
144-
// Look in these two listboxes for the selected release to install
145-
ListBoxesToCheck[0] := GlobalPageSelInstallType.CheckListBox;
146-
ListBoxesToCheck[1] := GlobalPageSelRelease.CheckListBox;
147-
148-
// Store the selected release for use during the installation process
149-
CacheSelectedRelease := FindSelectedRelease(ListBoxesToCheck, GlobalElixirReleases);
150-
151143
// Download the Precompiled.zip archive for the selected release
152144
idpAddFile(CacheSelectedRelease.URL, Tmp('Precompiled.zip'));
153145
@@ -156,53 +148,63 @@ begin
156148
end;
157149
end;
158150
159-
function ShouldSkipPage(PageID: Integer): Boolean;
151+
function NextButtonClick(CurPageID: Integer): Boolean;
152+
var
153+
i: Integer;
154+
RefMatch: TObject;
160155
begin
161-
if PageID = GlobalPageSelRelease.ID then begin
162-
// We should skip the page for selecting an Elixir release if the install type selection page
163-
// has some Elixir release set (such as the latest stable release)
164-
Result := not (GlobalPageSelInstallType.CheckListBox.ItemObject[GlobalPageSelInstallType.SelectedValueIndex] = nil);
165-
end else begin
166-
Result := False;
156+
Result := True;
157+
158+
// Search for the selected release
159+
if CurPageID = GlobalPageSelRelease.ID then begin
160+
for i := 0 to GlobalPageSelRelease.CheckListBox.Items.Count - 1 do begin
161+
if GlobalPageSelRelease.CheckListBox.Checked[i] then begin
162+
RefMatch := GlobalPageSelRelease.CheckListBox.ItemObject[i];
163+
break;
164+
end;
165+
end;
166+
167+
for i := 0 to GetArrayLength(GlobalElixirReleases) - 1 do begin
168+
if GlobalElixirReleases[i].Ref = RefMatch then begin
169+
CacheSelectedRelease := GlobalElixirReleases[i];
170+
break;
171+
end;
172+
end;
167173
end;
168174
end;
169175
170176
procedure InitializeWizard();
177+
var
178+
latest: Boolean;
179+
i: Integer;
171180
begin
172-
// Define the installation type page
173-
GlobalPageSelInstallType := CreateInputOptionPage(
174-
wpWelcome,
175-
'Select Elixir installation type',
176-
'Select which installation type you want to perform, then click Next.',
177-
'I want to:',
178-
True, False // (Use Radio Buttons), (Don't put them in a scrollable list box)
179-
);
180-
181181
// Define the custom release selection page
182182
GlobalPageSelRelease := CreateInputOptionPage(
183-
GlobalPageSelInstallType.ID,
183+
wpWelcome,
184184
'Select Elixir release',
185185
'Setup will download and install the Elixir release you select.',
186186
'All releases available to install are listed below, from newest to oldest.',
187187
True, True // (Use Radio Buttons), (Put them in a scrollable list box)
188188
);
189189
190-
// Use the global Elixir release array to populate the custom Elixir release list box
191-
ElixirReleasesToListBox(GlobalElixirReleases, GlobalPageSelRelease.CheckListBox);
190+
latest := True;
192191
193-
// Find the latest release and put it as a selection on the installation type page
194-
with FindFirstReleaseOfType(GlobalElixirReleases, rtLatestRelease) do begin
195-
GlobalPageSelInstallType.CheckListBox.AddRadioButton(
196-
'Install the latest stable release (v' + Version + ')',
197-
'', 0, True, True, Ref
198-
);
192+
// Use the global Elixir release array to populate the custom Elixir release list box
193+
for i := 0 to GetArrayLength(GlobalElixirReleases) - 1 do begin
194+
with GlobalElixirReleases[i] do begin
195+
GlobalPageSelRelease.CheckListBox.AddRadioButton(
196+
'Elixir version ' + Version, // Label next to radio button
197+
ReleaseType, // Label right-justified in list box
198+
0, // All choices on the same level
199+
(latest) and (ReleaseType = 'release'), // Radio button selected by default if it's the latest release
200+
(ReleaseType <> 'incompatible'), // Incompatible releases can't be selected
201+
Ref // Pointer to release's reference object
202+
);
203+
204+
if ReleaseType = 'release' then
205+
latest := False;
206+
end
199207
end;
200-
201-
// Create a selection which will allow the custom Elixir release page to show up next
202-
GlobalPageSelInstallType.CheckListBox.AddRadioButton(
203-
'Select another release to install',
204-
'', 0, False, True, nil
205-
);
206208
end;
207209
208210
function InitializeSetup(): Boolean;

src/TElixirRelease.iss

Lines changed: 6 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -16,45 +16,21 @@
1616
[Code]
1717
1818
type
19-
TElixirReleaseType = (rtRelease, rtPrerelease, rtLatestRelease, rtLatestPrerelease, rtIncompatible);
20-
2119
TElixirRelease = record
2220
Version: String;
2321
URL: String;
24-
ReleaseType: TElixirReleaseType;
22+
ReleaseType: String;
2523
Ref: TObject;
2624
end;
2725
28-
// Given an Elixir release type, return its string representation
29-
function ReleaseTypeToString(ReleaseType: TElixirReleaseType): String;
30-
begin
31-
Result := 'Unknown';
32-
if ReleaseType = rtRelease then
33-
Result := 'Release';
34-
if ReleaseType = rtPrerelease then
35-
Result := 'Prerelease';
36-
if ReleaseType = rtLatestRelease then
37-
Result := 'Latest Release';
38-
if ReleaseType = rtLatestPrerelease then
39-
Result := 'Latest Prerelease';
40-
if ReleaseType = rtIncompatible then
41-
Result := 'Incompatible';
42-
end;
43-
4426
// Given a filename to an elixir.csv file, return an array of Elixir releases corresponding to
4527
// the data in the csv file.
4628
function CSVToElixirReleases(Filename: String): array of TElixirRelease;
4729
var
4830
Rows: TArrayOfString;
4931
RowValues: TStrings;
50-
i: Integer;
51-
LatestPrerelease: Boolean;
52-
LatestRelease: Boolean;
32+
i: Integer;
5333
begin
54-
// Initialize as one-way flags
55-
LatestPrerelease := True;
56-
LatestRelease := True;
57-
5834
// Read the file at Filename and store the lines in Rows
5935
if LoadStringsFromFile(Filename, Rows) then begin
6036
// Match length of return array to number of rows
@@ -69,104 +45,18 @@ begin
6945
Version := RowValues[0];
7046
URL := RowValues[1];
7147
48+
// Store release type unless incompatible with installer
7249
if StrToInt(RowValues[3]) = {#COMPAT_MASK} then begin
73-
// Release has a compatibility mask matching this installer
74-
if RowValues[2] = 'prerelease' then begin
75-
// Release is designated as a prerelease
76-
if LatestPrerelease then begin
77-
// This is the first prerelease found, so it's the latest prerelease
78-
ReleaseType := rtLatestPrerelease;
79-
LatestPrerelease := False;
80-
end else begin
81-
// This is not the latest prerelease
82-
ReleaseType := rtPrerelease;
83-
end;
84-
end else begin
85-
if LatestRelease then begin
86-
// This is the first release found, so it's the latest prerelease
87-
ReleaseType := rtLatestRelease;
88-
LatestRelease := False;
89-
end else begin
90-
// This is not the latest release
91-
ReleaseType := rtRelease;
92-
end;
93-
end;
50+
ReleaseType := RowValues[2];
9451
end else begin
95-
// Release can't be installed by this installer
96-
ReleaseType := rtIncompatible;
52+
ReleaseType := 'incompatible';
9753
end;
9854
9955
// Assign this Elixir release a new reference object
100-
if Ref = nil then
101-
Ref := TObject.Create();
56+
Ref := TObject.Create();
10257
end;
10358
end;
10459
end else begin
10560
SetArrayLength(Result, 0);
10661
end;
10762
end;
108-
109-
// Given an array of Elixir release and a list box, populate the list box with radio buttons
110-
// which describe and point to the releases in the Elixir release array
111-
procedure ElixirReleasesToListBox(Releases: array of TElixirRelease; ListBox: TNewCheckListBox);
112-
var
113-
i: Integer;
114-
begin
115-
ListBox.Items.Clear;
116-
for i := 0 to GetArrayLength(Releases) - 1 do begin
117-
with Releases[i] do begin
118-
ListBox.AddRadioButton(
119-
'Elixir version ' + Version, // Label next to radio button
120-
ReleaseTypeToString(ReleaseType), // Label right-justified in list box
121-
0, // All choices on the same level
122-
(ReleaseType = rtLatestRelease), // Radio button selected by default if it's the latest release
123-
(ReleaseType <> rtIncompatible), // Incompatible releases can't be selected
124-
Ref // Pointer to release's reference object
125-
);
126-
end
127-
end;
128-
end;
129-
130-
// Given an array of Elixir releases and a release type, return the first release in the array of that type
131-
function FindFirstReleaseOfType(Releases: array of TElixirRelease; ReleaseType: TElixirReleaseType): TElixirRelease;
132-
var
133-
i: Integer;
134-
begin
135-
for i := 0 to GetArrayLength(Releases) - 1 do begin
136-
if Releases[i].ReleaseType = ReleaseType then begin
137-
Result := Releases[i];
138-
exit;
139-
end;
140-
end;
141-
end;
142-
143-
// Given an array of Elixir releases and a reference object, return the first release in the array which
144-
// points to the same object
145-
function FindFirstReleaseMatchingRef(Releases: array of TElixirRelease; RefMatch: TObject): TElixirRelease;
146-
var
147-
i: Integer;
148-
begin
149-
for i := 0 to GetArrayLength(Releases) - 1 do begin
150-
if Releases[i].Ref = RefMatch then begin
151-
Result := Releases[i];
152-
exit;
153-
end;
154-
end;
155-
end;
156-
157-
// Given an array of list boxes and an array of Elixir releases, search for a selected radio button that
158-
// points to an Elixir release reference object, and return the Elixir release which shares that reference
159-
// object
160-
function FindSelectedRelease(ListBoxes: array of TNewCheckListBox; Releases: array of TElixirRelease): TElixirRelease;
161-
var
162-
i, j: Integer;
163-
begin
164-
for i := 0 to GetArrayLength(ListBoxes) - 1 do begin
165-
for j := 0 to ListBoxes[i].Items.Count - 1 do begin
166-
if ListBoxes[i].ItemObject[j] <> nil then begin
167-
Result := FindFirstReleaseMatchingRef(Releases, ListBoxes[i].ItemObject[j]);
168-
exit;
169-
end;
170-
end;
171-
end;
172-
end;

0 commit comments

Comments
 (0)