Advertisement
Guest User

Untitled

a guest
Oct 10th, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.13 KB | None | 0 0
  1. #ifdef MULTi
  2. function ShellExecute(hwnd: HWND; lpOperation: string; lpFile: string; lpParameters: string; lpDirectory: string; nShowCmd: Integer): THandle;
  3. external 'ShellExecuteW@shell32.dll stdcall';
  4.  
  5. procedure SelectLanguage();
  6. var
  7. LanguageForm: TSetupForm;
  8. CancelButton: TNewButton;
  9. OKButton: TNewButton;
  10. LangCombo: TNewComboBox;
  11. SelectLabel: TNewStaticText;
  12. Languages: TStrings;
  13. Params: string;
  14. Instance: THandle;
  15. P, I: Integer;
  16. S, L: string;
  17.  
  18. begin
  19. Languages := TStringList.Create();
  20.  
  21. Languages.Add('EN=English');
  22. Languages.Add('FR=Français');
  23.  
  24. LanguageForm := CreateCustomForm;
  25.  
  26. LanguageForm.Caption := SetupMessage(msgSelectLanguageTitle);
  27. LanguageForm.ClientWidth := ScaleX(297);
  28. LanguageForm.ClientHeight := ScaleY(125);
  29. LanguageForm.BorderStyle := bsDialog;
  30. LanguageForm.Center;
  31.  
  32. CancelButton := TNewButton.Create(LanguageForm);
  33. CancelButton.Parent := LanguageForm;
  34. CancelButton.Left := ScaleX(214);
  35. CancelButton.Top := ScaleY(93);
  36. CancelButton.Width := ScaleY(75);
  37. CancelButton.Height := ScaleY(23);
  38. CancelButton.TabOrder := 3;
  39. CancelButton.ModalResult := mrCancel;
  40. CancelButton.Caption := SetupMessage(msgButtonCancel);
  41.  
  42. OKButton := TNewButton.Create(LanguageForm);
  43. OKButton.Parent := LanguageForm;
  44. OKButton.Left := ScaleX(133);
  45. OKButton.Top := ScaleY(93);
  46. OKButton.Width := ScaleX(75);
  47. OKButton.Height := ScaleY(23);
  48. OKButton.Caption := SetupMessage(msgButtonOK);
  49. OKButton.Default := True
  50. OKButton.ModalResult := mrOK;
  51. OKButton.TabOrder := 2;
  52.  
  53. LangCombo := TNewComboBox.Create(LanguageForm);
  54. LangCombo.Parent := LanguageForm;
  55. LangCombo.Left := ScaleX(16);
  56. LangCombo.Top := ScaleY(56);
  57. LangCombo.Width := ScaleX(273);
  58. LangCombo.Height := ScaleY(21);
  59. LangCombo.Style := csDropDownList;
  60. LangCombo.DropDownCount := 16;
  61. LangCombo.TabOrder := 1;
  62.  
  63. SelectLabel := TNewStaticText.Create(LanguageForm);
  64. SelectLabel.Parent := LanguageForm;
  65. SelectLabel.Left := ScaleX(16);
  66. SelectLabel.Top := ScaleY(8);
  67. SelectLabel.Width := ScaleX(273);
  68. SelectLabel.Height := ScaleY(39);
  69. SelectLabel.AutoSize := False
  70. SelectLabel.Caption := SetupMessage(msgSelectLanguageLabel);
  71. SelectLabel.TabOrder := 0;
  72. SelectLabel.WordWrap := True;
  73.  
  74. for I := 0 to Languages.Count - 1 do
  75. begin
  76. P := Pos('=', Languages.Strings[I]);
  77. L := Copy(Languages.Strings[I], 0, P - 1);
  78. S := Copy(Languages.Strings[I], P + 1, Length(Languages.Strings[I]) - P);
  79. LangCombo.Items.Add(S);
  80. if L = ActiveLanguage then
  81. LangCombo.ItemIndex := I;
  82. end;
  83.  
  84. if LanguageForm.ShowModal = mrOK then
  85. begin
  86. for I := 1 to ParamCount do
  87. begin
  88. S := ParamStr(I);
  89. if CompareText(Copy(S, 1, 5), '/LOG=') = 0 then
  90. begin
  91. S := S + '-localized';
  92. end;
  93. if CompareText(Copy(S, 1, 5), '/SL5=') <> 0 then
  94. begin
  95. Params := Params + AddQuotes(S) + ' ';
  96. end;
  97. end;
  98.  
  99. L := Languages.Strings[LangCombo.ItemIndex];
  100. P := Pos('=', L);
  101. L := Copy(L, 0, P-1);
  102.  
  103. Params := Params + '/LANG=' + L;
  104.  
  105. Instance := ShellExecute(0, '', ExpandConstant('{srcexe}'), Params, '', SW_SHOW);
  106. if Instance <= 32 then
  107. begin
  108. MsgBox(
  109. Format('Running installer with selected language failed. Code: %d', [Instance]),
  110. mbError, MB_OK);
  111. end;
  112. end;
  113. end;
  114. #endif
  115.  
  116. #ifdef Musique
  117. const
  118. BASS_SAMPLE_LOOP = 4;
  119. BASS_ACTIVE_STOPPED = 0;
  120. BASS_ACTIVE_PLAYING = 1;
  121. BASS_ACTIVE_STALLED = 2;
  122. BASS_ACTIVE_PAUSED = 3;
  123. BASS_UNICODE = $80000000;
  124. BASS_CONFIG_GVOL_STREAM = 5;
  125. const
  126. #ifndef UNICODE
  127. EncodingFlag = 0;
  128. #else
  129. EncodingFlag = BASS_UNICODE;
  130. #endif
  131. type
  132. HSTREAM = DWORD;
  133.  
  134. function BASS_Init(device: LongInt; freq, flags: DWORD; win: HWND; clsid: Cardinal): BOOL;
  135. external 'BASS_Init@files:bass.dll stdcall';
  136. function BASS_StreamCreateFile(mem: BOOL; f: string; offset1: DWORD; offset2: DWORD; length1: DWORD; length2: DWORD; flags: DWORD): HSTREAM;
  137. external 'BASS_StreamCreateFile@files:bass.dll stdcall';
  138. function BASS_Start: BOOL;
  139. external 'BASS_Start@files:bass.dll stdcall';
  140. function BASS_Pause: BOOL;
  141. external 'BASS_Pause@files:bass.dll stdcall';
  142. function BASS_ChannelPlay(handle: DWORD; restart: BOOL): BOOL;
  143. external 'BASS_ChannelPlay@files:bass.dll stdcall';
  144. function BASS_SetConfig(option: DWORD; value: DWORD ): BOOL;
  145. external 'BASS_SetConfig@files:bass.dll stdcall';
  146. function BASS_ChannelIsActive(handle: DWORD): DWORD;
  147. external 'BASS_ChannelIsActive@files:bass.dll stdcall';
  148. function BASS_Free: BOOL;
  149. external 'BASS_Free@files:bass.dll stdcall';
  150.  
  151. var
  152. SoundStream: HSTREAM;
  153. SoundCtrlButton: TNewButton;
  154.  
  155. procedure SoundCtrlButtonClick(Sender: TObject);
  156. begin
  157. case BASS_ChannelIsActive(SoundStream) of
  158. BASS_ACTIVE_PLAYING:
  159. begin
  160. if BASS_Pause then
  161. SoundCtrlButton.Caption :=
  162. ExpandConstant('{cm:SoundCtrlButtonCaptionSoundOn}');
  163. end;
  164. BASS_ACTIVE_PAUSED:
  165. begin
  166. if BASS_Start then
  167. SoundCtrlButton.Caption :=
  168. ExpandConstant('{cm:SoundCtrlButtonCaptionSoundOff}');
  169. end;
  170. end;
  171. end;
  172. #endif
  173.  
  174. #ifdef CJS
  175. procedure LoadSkin(lpszPath: String; lpszIniFileName: String);
  176. external 'LoadSkin@files:isskin.dll stdcall';
  177. procedure UnloadSkin();
  178. external 'UnloadSkin@files:isskin.dll stdcall';
  179.  
  180. function ShowWindow(hWnd: Integer; uType: Integer): Integer;
  181. external 'ShowWindow@user32.dll stdcall';
  182.  
  183. function InitializeSetup(): Boolean;
  184. #ifdef MULTi
  185. var
  186. Language: string;
  187. #endif
  188. begin
  189. ExtractTemporaryFile('Setup.cjstyles');
  190. LoadSkin(ExpandConstant('{tmp}\Setup.cjstyles'), '');
  191.  
  192. Result := True;
  193.  
  194. #ifdef MULTi
  195. Language := ExpandConstant('{param:LANG}');
  196. if Language = '' then
  197. begin
  198. Log('No language specified, showing language dialog');
  199. SelectLanguage();
  200. Result := False;
  201. Exit;
  202. end
  203. else
  204. begin
  205. Log('Language specified, proceeding with installation');
  206. end;
  207. #endif
  208. end;
  209. #endif
  210.  
  211. #ifdef VCLStyles
  212. procedure LoadVCLStyle(VClStyleFile: String);
  213. external 'LoadVCLStyleW@files:Nocturne.dll stdcall setuponly';
  214. procedure UnLoadVCLStyles;
  215. external 'UnLoadVCLStyles@files:Nocturne.dll stdcall setuponly';
  216. procedure LoadVCLStyle_UnInstall(VClStyleFile: String);
  217. external 'LoadVCLStyleW@{#VCLStylesPath}\Nocturne.dll stdcall uninstallonly';
  218.  
  219. function InitializeSetup(): Boolean;
  220. #ifdef MULTi
  221. var
  222. Language: string;
  223. #endif
  224. begin
  225. ExtractTemporaryFile('{#VCLSkinFile}');
  226. LoadVCLStyle(ExpandConstant('{tmp}\{#VCLSkinFile}'));
  227.  
  228. Result := True;
  229. #ifdef MULTi
  230. Language := ExpandConstant('{param:LANG}');
  231. if Language = '' then
  232. begin
  233. Log('No language specified, showing language dialog');
  234. SelectLanguage();
  235. Result := False;
  236. Exit;
  237. end
  238. else
  239. begin
  240. Log('Language specified, proceeding with installation');
  241. #endif
  242. end;
  243. #endif
  244. end;
  245.  
  246. #ifdef Progress
  247. function GetTickCount: DWORD;
  248. external 'GetTickCount@kernel32.dll stdcall';
  249.  
  250. var
  251. StartTick: DWORD;
  252. PercentLabel: TNewStaticText;
  253. ElapsedLabel: TNewStaticText;
  254. RemainingLabel: TNewStaticText;
  255.  
  256. function TicksToStr(Value: DWORD): string;
  257. var
  258. I: DWORD;
  259. Hours, Minutes, Seconds: Integer;
  260. begin
  261. I := Value div 1000;
  262. Seconds := I mod 60;
  263. I := I div 60;
  264. Minutes := I mod 60;
  265. I := I div 60;
  266. Hours := I mod 24;
  267. Result := Format('%.2d:%.2d:%.2d', [Hours, Minutes, Seconds]);
  268. end;
  269. #endif
  270.  
  271. procedure InitializeWizard;
  272.  
  273. var
  274. BitmapImage: TBitmapImage;
  275. ImgInstall: TBitmapImage;
  276. ImgInstallFile: String;
  277. BmpFile: TBitmapImage;
  278.  
  279. begin
  280. #ifdef Header
  281. ExtractTemporaryFile('{#HeaderFile}');
  282. BitmapImage := TBitmapImage.Create(WizardForm);
  283. BitmapImage.Parent := WizardForm.MainPanel;
  284. BitmapImage.Width := WizardForm.MainPanel.Width;
  285. BitmapImage.Height := WizardForm.MainPanel.Height;
  286. BitmapImage.Stretch := True;
  287. BitmapImage.AutoSize := False;
  288. BitmapImage.Bitmap.LoadFromFile(ExpandConstant('{tmp}\{#HeaderFile}'));
  289. WizardForm.WizardSmallBitmapImage.Visible := False;
  290. WizardForm.PageDescriptionLabel.Visible := False;
  291. WizardForm.PageNameLabel.Visible := False;
  292. #endif
  293.  
  294. #ifdef Wellcome
  295. WizardForm.WelcomeLabel1.Visible := False;
  296. WizardForm.WelcomeLabel2.Visible := False;
  297. WizardForm.WizardBitmapImage.Width := WizardForm.WizardBitmapImage.Parent.Width;
  298. ExtractTemporaryFile('{#WellcomeBG}');
  299. WizardForm.WizardBitmapImage.Bitmap.LoadFromFile(ExpandConstant('{tmp}\{#WellcomeBG}'));
  300. #endif
  301.  
  302. #ifdef Finish
  303. WizardForm.FinishedLabel.Visible := False;
  304. WizardForm.FinishedHeadingLabel.Visible := False;
  305. WizardForm.WizardBitmapImage2.Width := WizardForm.WizardBitmapImage2.Parent.Width;
  306. ExtractTemporaryFile('{#FinishBG}');
  307. WizardForm.WizardBitmapImage2.Bitmap.LoadFromFile(ExpandConstant('{tmp}\{#FinishBG}'));
  308. #endif
  309.  
  310. #ifdef Musique
  311. ExtractTemporaryFile('{#MusicFile}');
  312. if BASS_Init(-1, 44100, 0, 0, 0) then
  313. begin
  314. SoundStream := BASS_StreamCreateFile(False,
  315. ExpandConstant('{tmp}\{#MusicFile}'), 0, 0, 0, 0,
  316. EncodingFlag or BASS_SAMPLE_LOOP);
  317. BASS_SetConfig(BASS_CONFIG_GVOL_STREAM, 2500);
  318. BASS_ChannelPlay(SoundStream, False);
  319. ;SoundCtrlButton := TNewButton.Create(WizardForm);
  320. SoundCtrlButton.Parent := WizardForm;
  321. SoundCtrlButton.Left := 4;
  322. SoundCtrlButton.Top := WizardForm.ClientHeight -
  323. SoundCtrlButton.Height - 12;
  324. SoundCtrlButton.Width := 155;
  325. SoundCtrlButton.Caption :=
  326. ExpandConstant('{cm:SoundCtrlButtonCaptionSoundOff}');
  327. SoundCtrlButton.OnClick := @SoundCtrlButtonClick;
  328. end;
  329. #endif
  330.  
  331. #ifdef Progress
  332. begin
  333. //PercentLabel := TNewStaticText.Create(WizardForm);
  334. //PercentLabel.Parent := WizardForm.ProgressGauge.Parent;
  335. //PercentLabel.Left := 190;
  336. //PercentLabel.Top := WizardForm.ProgressGauge.Top +
  337. //WizardForm.ProgressGauge.Height + 80;
  338. //PercentLabel.Font.Style := [fsBold]
  339. //PercentLabel.Font.Size := 14
  340. //PercentLabel.Font.Color := clAqua;
  341.  
  342. ElapsedLabel := TNewStaticText.Create(WizardForm);
  343. ElapsedLabel.Parent := WizardForm.ProgressGauge.Parent;
  344. ElapsedLabel.Left := 0;
  345. ElapsedLabel.Top := WizardForm.ProgressGauge.Top +
  346. WizardForm.ProgressGauge.Height + 12;
  347. ElapsedLabel.Font.Style := [fsBold]
  348. //ElapsedLabel.Font.Color := clAqua;
  349.  
  350. RemainingLabel := TNewStaticText.Create(WizardForm);
  351. RemainingLabel.Parent := WizardForm.ProgressGauge.Parent;
  352. RemainingLabel.Left := 357;
  353. RemainingLabel.Top := ElapsedLabel.Top;
  354. RemainingLabel.Font.Style := [fsBold]
  355. //RemainingLabel.Font.Color := clAqua;
  356. end;
  357. end;
  358.  
  359.  
  360. procedure CurInstallProgressChanged(CurProgress, MaxProgress: Integer);
  361. var
  362. CurTick: DWORD;
  363. begin
  364. CurTick := GetTickCount;
  365. //PercentLabel.Caption :=
  366. //Format('%.2f %%', [(CurProgress * 100.0) / MaxProgress]);
  367. ElapsedLabel.Caption :=
  368. Format('[%s]', [TicksToStr(CurTick - StartTick)]);
  369. if CurProgress > 0 then
  370. begin
  371. RemainingLabel.Caption :=
  372. Format('[%s]', [TicksToStr(((CurTick - StartTick) / CurProgress) * (MaxProgress - CurProgress))]);
  373. end;
  374. #endif
  375. end;
  376.  
  377. function InitializeUninstall: Boolean;
  378. #ifdef VCLStyles
  379. begin
  380. Result := True;
  381. LoadVCLStyle_UnInstall(ExpandConstant('{#VCLStylesPath}\Nocturne.vsf'));
  382. end;
  383. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement