Skip to content

Commit

Permalink
Merge pull request #72 from jeremiah-k/installer-fix-2
Browse files Browse the repository at this point in the history
Increase window height
  • Loading branch information
jeremiah-k authored Jul 3, 2024
2 parents a487ada + 70488eb commit 8da7839
Showing 1 changed file with 74 additions and 88 deletions.
162 changes: 74 additions & 88 deletions mmrelay.iss
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ Filename: "{app}\mmrelay.bat"; Description: "Launch MM Relay"; Flags: nowait pos
var
TokenInfoLabel: TLabel;
TokenInfoLink: TNewStaticText;
MatrixPage : TInputQueryWizardPage;
MatrixPage: TInputQueryWizardPage;
OverwriteConfig: TInputOptionWizardPage;
MatrixMeshtasticPage : TInputQueryWizardPage;
MeshtasticPage : TInputQueryWizardPage;
OptionsPage : TInputOptionWizardPage;
MatrixMeshtasticPage: TInputQueryWizardPage;
MeshtasticPage: TInputQueryWizardPage;
OptionsPage: TInputOptionWizardPage;
Connection: string;
procedure TokenInfoLinkClick(Sender: TObject);
Expand Down Expand Up @@ -60,6 +60,9 @@ begin
OptionsPage := CreateInputOptionPage(MatrixMeshtasticPage.ID,
'Additional Options', 'Provide additional options',
'Set logging and broadcast options, you can keep the defaults.', False, False);
// Increase page height
WizardForm.ClientHeight := WizardForm.ClientHeight + 50;
OverwriteConfig.Add('Generate configuration (overwrite any current config files)');
OverwriteConfig.Values[0] := False;
Expand Down Expand Up @@ -109,26 +112,9 @@ begin
OptionsPage.Add('Radio broadcasts enabled');
OptionsPage.Values[0] := True;
OptionsPage.Values[1] := True;
// Adjust the layout to add more space between elements
AdjustPageElements(MatrixPage);
AdjustPageElements(MeshtasticPage);
AdjustPageElements(MatrixMeshtasticPage);
end;
procedure AdjustPageElements(Page: TInputQueryWizardPage);
var
i, NewTop: Integer;
begin
NewTop := 0;
for i := 0 to Page.Edits.Count - 1 do
begin
Page.Edits[i].Top := NewTop;
NewTop := NewTop + Page.Edits[i].Height + 12; // Add more space between elements
end;
end;
function BoolToStr(Value : Boolean): String;
function BoolToStr(Value: Boolean): String;
begin
if Value then
result := 'true'
Expand All @@ -140,76 +126,76 @@ end;
function ShouldSkipPage(PageID: Integer): Boolean;
begin
if PageID = OverwriteConfig.ID then
Result := False
Result := False
else
Result := Not OverwriteConfig.Values[0];
Result := Not OverwriteConfig.Values[0];
end;
procedure AfterInstall(sAppDir: string);
var
config: string;
connection_type: string;
serial_port: string;
host: string;
ble_address: string;
log_level: string;
batch_file: string;
config: string;
connection_type: string;
serial_port: string;
host: string;
ble_address: string;
log_level: string;
batch_file: string;
begin
If Not OverwriteConfig.Values[0] then
Exit;
if (FileExists(sAppDir+'/config.yaml')) then
begin
RenameFile(sAppDir+'/config.yaml', sAppDir+'/config-old.yaml');
end;
connection_type := MeshtasticPage.Values[0];
serial_port := MeshtasticPage.Values[1];
host := MeshtasticPage.Values[2];
ble_address := MeshtasticPage.Values[3];
if OptionsPage.Values[0] then
begin
log_level := 'debug';
end
else
begin
log_level := 'info';
end;
config := 'matrix:' + #13#10 +
' homeserver: "' + MatrixPage.Values[0] + '"' + #13#10 +
' bot_user_id: "' + MatrixPage.Values[1] + '"' + #13#10 +
' access_token: "' + MatrixPage.Values[2] + '"' + #13#10 +
'matrix_rooms:' + #13#10 +
' - id: "' + MatrixMeshtasticPage.Values[0] + '"' + #13#10 +
' meshtastic_channel: ' + MatrixMeshtasticPage.Values[1] + #13#10 +
'meshtastic:' + #13#10 +
' connection_type: "' + connection_type + '"' + #13#10;
if connection_type = 'serial' then
config := config + ' serial_port: "' + serial_port + '"' + #13#10
else if connection_type = 'network' then
config := config + ' host: "' + host + '"' + #13#10
else if connection_type = 'ble' then
config := config + ' ble_address: "' + ble_address + '"' + #13#10;
config := config + ' meshnet_name: "' + MeshtasticPage.Values[4] + '"' + #13#10 +
' broadcast_enabled: ' + BoolToStr(OptionsPage.Values[1]) + #13#10 +
'logging:' + #13#10 +
' level: "' + log_level + '"' + #13#10 +
'plugins:' + #13#10;
if Not SaveStringToFile(sAppDir+'/config.yaml', config, false) then
begin
MsgBox('Could not create config file "config.yaml". Close any applications that may have it open and re-run setup', mbInformation, MB_OK);
end;
batch_file := '"' + sAppDir+ '\mmrelay.exe" config.yaml ' + #13#10 +
'pause';
if Not SaveStringToFile(sAppDir+'/mmrelay.bat', batch_file, false) then
begin
MsgBox('Could not create batch file "relay.bat". Close any applications that may have it open and re-run setup', mbInformation, MB_OK);
end;
If Not OverwriteConfig.Values[0] then
Exit;
if (FileExists(sAppDir + '/config.yaml')) then
begin
RenameFile(sAppDir + '/config.yaml', sAppDir + '/config-old.yaml');
end;
connection_type := MeshtasticPage.Values[0];
serial_port := MeshtasticPage.Values[1];
host := MeshtasticPage.Values[2];
ble_address := MeshtasticPage.Values[3];
if OptionsPage.Values[0] then
begin
log_level := 'debug';
end
else
begin
log_level := 'info';
end;
config := 'matrix:' + #13#10 +
' homeserver: "' + MatrixPage.Values[0] + '"' + #13#10 +
' bot_user_id: "' + MatrixPage.Values[1] + '"' + #13#10 +
' access_token: "' + MatrixPage.Values[2] + '"' + #13#10 +
'matrix_rooms:' + #13#10 +
' - id: "' + MatrixMeshtasticPage.Values[0] + '"' + #13#10 +
' meshtastic_channel: ' + MatrixMeshtasticPage.Values[1] + #13#10 +
'meshtastic:' + #13#10 +
' connection_type: "' + connection_type + '"' + #13#10;
if connection_type = 'serial' then
config := config + ' serial_port: "' + serial_port + '"' + #13#10
else if connection_type = 'network' then
config := config + ' host: "' + host + '"' + #13#10
else if connection_type = 'ble' then
config := config + ' ble_address: "' + ble_address + '"' + #13#10;
config := config + ' meshnet_name: "' + MeshtasticPage.Values[4] + '"' + #13#10 +
' broadcast_enabled: ' + BoolToStr(OptionsPage.Values[1]) + #13#10 +
'logging:' + #13#10 +
' level: "' + log_level + '"' + #13#10 +
'plugins:' + #13#10;
if Not SaveStringToFile(sAppDir + '/config.yaml', config, false) then
begin
MsgBox('Could not create config file "config.yaml". Close any applications that may have it open and re-run setup', mbInformation, MB_OK);
end;
batch_file := '"' + sAppDir + '\mmrelay.exe" config.yaml ' + #13#10 +
'pause';
if Not SaveStringToFile(sAppDir + '/mmrelay.bat', batch_file, false) then
begin
MsgBox('Could not create batch file "relay.bat". Close any applications that may have it open and re-run setup', mbInformation, MB_OK);
end;
end;

0 comments on commit 8da7839

Please sign in to comment.