Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifdef MULTi
- function ShellExecute(hwnd: HWND; lpOperation: string; lpFile: string; lpParameters: string; lpDirectory: string; nShowCmd: Integer): THandle;
- external 'ShellExecuteW@shell32.dll stdcall';
- procedure SelectLanguage();
- var
- LanguageForm: TSetupForm;
- CancelButton: TNewButton;
- OKButton: TNewButton;
- LangCombo: TNewComboBox;
- SelectLabel: TNewStaticText;
- Languages: TStrings;
- Params: string;
- Instance: THandle;
- P, I: Integer;
- S, L: string;
- begin
- Languages := TStringList.Create();
- Languages.Add('EN=English');
- Languages.Add('FR=Français');
- LanguageForm := CreateCustomForm;
- LanguageForm.Caption := SetupMessage(msgSelectLanguageTitle);
- LanguageForm.ClientWidth := ScaleX(297);
- LanguageForm.ClientHeight := ScaleY(125);
- LanguageForm.BorderStyle := bsDialog;
- LanguageForm.Center;
- CancelButton := TNewButton.Create(LanguageForm);
- CancelButton.Parent := LanguageForm;
- CancelButton.Left := ScaleX(214);
- CancelButton.Top := ScaleY(93);
- CancelButton.Width := ScaleY(75);
- CancelButton.Height := ScaleY(23);
- CancelButton.TabOrder := 3;
- CancelButton.ModalResult := mrCancel;
- CancelButton.Caption := SetupMessage(msgButtonCancel);
- OKButton := TNewButton.Create(LanguageForm);
- OKButton.Parent := LanguageForm;
- OKButton.Left := ScaleX(133);
- OKButton.Top := ScaleY(93);
- OKButton.Width := ScaleX(75);
- OKButton.Height := ScaleY(23);
- OKButton.Caption := SetupMessage(msgButtonOK);
- OKButton.Default := True
- OKButton.ModalResult := mrOK;
- OKButton.TabOrder := 2;
- LangCombo := TNewComboBox.Create(LanguageForm);
- LangCombo.Parent := LanguageForm;
- LangCombo.Left := ScaleX(16);
- LangCombo.Top := ScaleY(56);
- LangCombo.Width := ScaleX(273);
- LangCombo.Height := ScaleY(21);
- LangCombo.Style := csDropDownList;
- LangCombo.DropDownCount := 16;
- LangCombo.TabOrder := 1;
- SelectLabel := TNewStaticText.Create(LanguageForm);
- SelectLabel.Parent := LanguageForm;
- SelectLabel.Left := ScaleX(16);
- SelectLabel.Top := ScaleY(8);
- SelectLabel.Width := ScaleX(273);
- SelectLabel.Height := ScaleY(39);
- SelectLabel.AutoSize := False
- SelectLabel.Caption := SetupMessage(msgSelectLanguageLabel);
- SelectLabel.TabOrder := 0;
- SelectLabel.WordWrap := True;
- for I := 0 to Languages.Count - 1 do
- begin
- P := Pos('=', Languages.Strings[I]);
- L := Copy(Languages.Strings[I], 0, P - 1);
- S := Copy(Languages.Strings[I], P + 1, Length(Languages.Strings[I]) - P);
- LangCombo.Items.Add(S);
- if L = ActiveLanguage then
- LangCombo.ItemIndex := I;
- end;
- if LanguageForm.ShowModal = mrOK then
- begin
- for I := 1 to ParamCount do
- begin
- S := ParamStr(I);
- if CompareText(Copy(S, 1, 5), '/LOG=') = 0 then
- begin
- S := S + '-localized';
- end;
- if CompareText(Copy(S, 1, 5), '/SL5=') <> 0 then
- begin
- Params := Params + AddQuotes(S) + ' ';
- end;
- end;
- L := Languages.Strings[LangCombo.ItemIndex];
- P := Pos('=', L);
- L := Copy(L, 0, P-1);
- Params := Params + '/LANG=' + L;
- Instance := ShellExecute(0, '', ExpandConstant('{srcexe}'), Params, '', SW_SHOW);
- if Instance <= 32 then
- begin
- MsgBox(
- Format('Running installer with selected language failed. Code: %d', [Instance]),
- mbError, MB_OK);
- end;
- end;
- end;
- #endif
- #ifdef Musique
- const
- BASS_SAMPLE_LOOP = 4;
- BASS_ACTIVE_STOPPED = 0;
- BASS_ACTIVE_PLAYING = 1;
- BASS_ACTIVE_STALLED = 2;
- BASS_ACTIVE_PAUSED = 3;
- BASS_UNICODE = $80000000;
- BASS_CONFIG_GVOL_STREAM = 5;
- const
- #ifndef UNICODE
- EncodingFlag = 0;
- #else
- EncodingFlag = BASS_UNICODE;
- #endif
- type
- HSTREAM = DWORD;
- function BASS_Init(device: LongInt; freq, flags: DWORD; win: HWND; clsid: Cardinal): BOOL;
- external 'BASS_Init@files:bass.dll stdcall';
- function BASS_StreamCreateFile(mem: BOOL; f: string; offset1: DWORD; offset2: DWORD; length1: DWORD; length2: DWORD; flags: DWORD): HSTREAM;
- external 'BASS_StreamCreateFile@files:bass.dll stdcall';
- function BASS_Start: BOOL;
- external 'BASS_Start@files:bass.dll stdcall';
- function BASS_Pause: BOOL;
- external 'BASS_Pause@files:bass.dll stdcall';
- function BASS_ChannelPlay(handle: DWORD; restart: BOOL): BOOL;
- external 'BASS_ChannelPlay@files:bass.dll stdcall';
- function BASS_SetConfig(option: DWORD; value: DWORD ): BOOL;
- external 'BASS_SetConfig@files:bass.dll stdcall';
- function BASS_ChannelIsActive(handle: DWORD): DWORD;
- external 'BASS_ChannelIsActive@files:bass.dll stdcall';
- function BASS_Free: BOOL;
- external 'BASS_Free@files:bass.dll stdcall';
- var
- SoundStream: HSTREAM;
- SoundCtrlButton: TNewButton;
- procedure SoundCtrlButtonClick(Sender: TObject);
- begin
- case BASS_ChannelIsActive(SoundStream) of
- BASS_ACTIVE_PLAYING:
- begin
- if BASS_Pause then
- SoundCtrlButton.Caption :=
- ExpandConstant('{cm:SoundCtrlButtonCaptionSoundOn}');
- end;
- BASS_ACTIVE_PAUSED:
- begin
- if BASS_Start then
- SoundCtrlButton.Caption :=
- ExpandConstant('{cm:SoundCtrlButtonCaptionSoundOff}');
- end;
- end;
- end;
- #endif
- #ifdef CJS
- procedure LoadSkin(lpszPath: String; lpszIniFileName: String);
- external 'LoadSkin@files:isskin.dll stdcall';
- procedure UnloadSkin();
- external 'UnloadSkin@files:isskin.dll stdcall';
- function ShowWindow(hWnd: Integer; uType: Integer): Integer;
- external 'ShowWindow@user32.dll stdcall';
- function InitializeSetup(): Boolean;
- #ifdef MULTi
- var
- Language: string;
- #endif
- begin
- ExtractTemporaryFile('Setup.cjstyles');
- LoadSkin(ExpandConstant('{tmp}\Setup.cjstyles'), '');
- Result := True;
- #ifdef MULTi
- Language := ExpandConstant('{param:LANG}');
- if Language = '' then
- begin
- Log('No language specified, showing language dialog');
- SelectLanguage();
- Result := False;
- Exit;
- end
- else
- begin
- Log('Language specified, proceeding with installation');
- end;
- #endif
- end;
- #endif
- #ifdef VCLStyles
- procedure LoadVCLStyle(VClStyleFile: String);
- external 'LoadVCLStyleW@files:Nocturne.dll stdcall setuponly';
- procedure UnLoadVCLStyles;
- external 'UnLoadVCLStyles@files:Nocturne.dll stdcall setuponly';
- procedure LoadVCLStyle_UnInstall(VClStyleFile: String);
- external 'LoadVCLStyleW@{#VCLStylesPath}\Nocturne.dll stdcall uninstallonly';
- function InitializeSetup(): Boolean;
- #ifdef MULTi
- var
- Language: string;
- #endif
- begin
- ExtractTemporaryFile('{#VCLSkinFile}');
- LoadVCLStyle(ExpandConstant('{tmp}\{#VCLSkinFile}'));
- Result := True;
- #ifdef MULTi
- Language := ExpandConstant('{param:LANG}');
- if Language = '' then
- begin
- Log('No language specified, showing language dialog');
- SelectLanguage();
- Result := False;
- Exit;
- end
- else
- begin
- Log('Language specified, proceeding with installation');
- #endif
- end;
- #endif
- end;
- #ifdef Progress
- function GetTickCount: DWORD;
- external 'GetTickCount@kernel32.dll stdcall';
- var
- StartTick: DWORD;
- PercentLabel: TNewStaticText;
- ElapsedLabel: TNewStaticText;
- RemainingLabel: TNewStaticText;
- function TicksToStr(Value: DWORD): string;
- var
- I: DWORD;
- Hours, Minutes, Seconds: Integer;
- begin
- I := Value div 1000;
- Seconds := I mod 60;
- I := I div 60;
- Minutes := I mod 60;
- I := I div 60;
- Hours := I mod 24;
- Result := Format('%.2d:%.2d:%.2d', [Hours, Minutes, Seconds]);
- end;
- #endif
- procedure InitializeWizard;
- var
- BitmapImage: TBitmapImage;
- ImgInstall: TBitmapImage;
- ImgInstallFile: String;
- BmpFile: TBitmapImage;
- begin
- #ifdef Header
- ExtractTemporaryFile('{#HeaderFile}');
- BitmapImage := TBitmapImage.Create(WizardForm);
- BitmapImage.Parent := WizardForm.MainPanel;
- BitmapImage.Width := WizardForm.MainPanel.Width;
- BitmapImage.Height := WizardForm.MainPanel.Height;
- BitmapImage.Stretch := True;
- BitmapImage.AutoSize := False;
- BitmapImage.Bitmap.LoadFromFile(ExpandConstant('{tmp}\{#HeaderFile}'));
- WizardForm.WizardSmallBitmapImage.Visible := False;
- WizardForm.PageDescriptionLabel.Visible := False;
- WizardForm.PageNameLabel.Visible := False;
- #endif
- #ifdef Wellcome
- WizardForm.WelcomeLabel1.Visible := False;
- WizardForm.WelcomeLabel2.Visible := False;
- WizardForm.WizardBitmapImage.Width := WizardForm.WizardBitmapImage.Parent.Width;
- ExtractTemporaryFile('{#WellcomeBG}');
- WizardForm.WizardBitmapImage.Bitmap.LoadFromFile(ExpandConstant('{tmp}\{#WellcomeBG}'));
- #endif
- #ifdef Finish
- WizardForm.FinishedLabel.Visible := False;
- WizardForm.FinishedHeadingLabel.Visible := False;
- WizardForm.WizardBitmapImage2.Width := WizardForm.WizardBitmapImage2.Parent.Width;
- ExtractTemporaryFile('{#FinishBG}');
- WizardForm.WizardBitmapImage2.Bitmap.LoadFromFile(ExpandConstant('{tmp}\{#FinishBG}'));
- #endif
- #ifdef Musique
- ExtractTemporaryFile('{#MusicFile}');
- if BASS_Init(-1, 44100, 0, 0, 0) then
- begin
- SoundStream := BASS_StreamCreateFile(False,
- ExpandConstant('{tmp}\{#MusicFile}'), 0, 0, 0, 0,
- EncodingFlag or BASS_SAMPLE_LOOP);
- BASS_SetConfig(BASS_CONFIG_GVOL_STREAM, 2500);
- BASS_ChannelPlay(SoundStream, False);
- ;SoundCtrlButton := TNewButton.Create(WizardForm);
- SoundCtrlButton.Parent := WizardForm;
- SoundCtrlButton.Left := 4;
- SoundCtrlButton.Top := WizardForm.ClientHeight -
- SoundCtrlButton.Height - 12;
- SoundCtrlButton.Width := 155;
- SoundCtrlButton.Caption :=
- ExpandConstant('{cm:SoundCtrlButtonCaptionSoundOff}');
- SoundCtrlButton.OnClick := @SoundCtrlButtonClick;
- end;
- #endif
- #ifdef Progress
- begin
- //PercentLabel := TNewStaticText.Create(WizardForm);
- //PercentLabel.Parent := WizardForm.ProgressGauge.Parent;
- //PercentLabel.Left := 190;
- //PercentLabel.Top := WizardForm.ProgressGauge.Top +
- //WizardForm.ProgressGauge.Height + 80;
- //PercentLabel.Font.Style := [fsBold]
- //PercentLabel.Font.Size := 14
- //PercentLabel.Font.Color := clAqua;
- ElapsedLabel := TNewStaticText.Create(WizardForm);
- ElapsedLabel.Parent := WizardForm.ProgressGauge.Parent;
- ElapsedLabel.Left := 0;
- ElapsedLabel.Top := WizardForm.ProgressGauge.Top +
- WizardForm.ProgressGauge.Height + 12;
- ElapsedLabel.Font.Style := [fsBold]
- //ElapsedLabel.Font.Color := clAqua;
- RemainingLabel := TNewStaticText.Create(WizardForm);
- RemainingLabel.Parent := WizardForm.ProgressGauge.Parent;
- RemainingLabel.Left := 357;
- RemainingLabel.Top := ElapsedLabel.Top;
- RemainingLabel.Font.Style := [fsBold]
- //RemainingLabel.Font.Color := clAqua;
- end;
- end;
- procedure CurInstallProgressChanged(CurProgress, MaxProgress: Integer);
- var
- CurTick: DWORD;
- begin
- CurTick := GetTickCount;
- //PercentLabel.Caption :=
- //Format('%.2f %%', [(CurProgress * 100.0) / MaxProgress]);
- ElapsedLabel.Caption :=
- Format('[%s]', [TicksToStr(CurTick - StartTick)]);
- if CurProgress > 0 then
- begin
- RemainingLabel.Caption :=
- Format('[%s]', [TicksToStr(((CurTick - StartTick) / CurProgress) * (MaxProgress - CurProgress))]);
- end;
- #endif
- end;
- function InitializeUninstall: Boolean;
- #ifdef VCLStyles
- begin
- Result := True;
- LoadVCLStyle_UnInstall(ExpandConstant('{#VCLStylesPath}\Nocturne.vsf'));
- end;
- #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement