[Setup] AppName=Dark Sector AppVerName=Dark Sector DefaultDirName={pf}\Dark Sector OutputDir=. WizardImageFile=C:\ds\WizardImageFile.bmp WizardSmallImageFile=C:\ds\WizardSmallImageFile.bmp DisableReadyPage=true UninstallFilesDir={app}\Uninstall Compression=lzma/ultra64 DefaultGroupName=Dark Sector DisableProgramGroupPage=true InternalCompressLevel=ultra64 SolidCompression=true DiskSpanning=true SlicesPerDisk=1 DiskSliceSize=2100000000 DiskClusterSize=512 ReserveBytes=5120 [Languages] Name: RUS; MessagesFile: compiler:Languages\Russian.isl [Icons] Name: {group}\Запустить игру; Filename: {app}\DS.exe; WorkingDir: {app} Name: {group}\Руководство пользователя; Filename: {app}\manual.pdf; WorkingDir: {app} Name: {group}\Readme; Filename: {app}\Readme.rtf; WorkingDir: {app} Name: {group}\Удалить игру; Filename: {app}\Uninstall\unins000; WorkingDir: {app} Name: {userdesktop}\Dark Sector; Filename: {app}\DS.exe; WorkingDir: {app} [Files] Source: C:\ds\ISSkin.dll; DestDir: {app}; Flags: dontcopy Source: C:\Program Files\ISSkin\Styles\Vista.cjstyles; DestDir: {tmp}; Flags: dontcopy Source: C:\ds\3.bmp; DestDir: {tmp}; Flags: dontcopy Source: C:\ds\1.bmp; Flags: dontcopy Source: D:\Dark Sector\*; DestDir: {app}; Flags: ignoreversion recursesubdirs createallsubdirs [Run] Filename: {src}\DirectX\DXSETUP.exe; StatusMsg: ExpandConstant('{cm:UP}'); Check: DirectX Filename: {src}\Redist\PhysX_8.04.25_SystemSoftware.exe; WorkingDir: {src}\Redist; Check: PhysX1 [CustomMessages] RUS.PAGE_CAPTION=Программа Dark Sector установлена на Ваш компютер. RUS.STR=Нажмите «Завершить», чтобы выйти из программы установки. RUS.BUT=Установить RUS.SPACE=Доступно места на диске: RUS.SPACE1=Требуется места на диске: RUS.DRT=Обновить DirectX RUS.UP=Идет обновление DirectX... [Code] const Archives = '{src}\*.arc'; // укажите расположение архивов FreeArc; для внешних файлов строку в Files добавлять необязательно type PAnsiChar=PChar; // Удалите строку, если установлен Inno Setup версии 5.3.0 и выше TMyMsg = record hwnd: HWND; message: UINT; wParam: Longint; lParam: Longint; time: DWORD; pt: TPoint; end; TFreeArcCallback = function (what: PAnsiChar; int1, int2: Integer; str: PAnsiChar): Integer; TArc = record Path: string; Size: Extended; end; const PM_REMOVE = 1; function PeekMessage(var lpMsg: TMyMsg; hWnd: HWND; wMsgFilterMin, wMsgFilterMax, wRemoveMsg: UINT): BOOL; external 'PeekMessageA@user32.dll stdcall'; function TranslateMessage(const lpMsg: TMyMsg): BOOL; external 'TranslateMessage@user32.dll stdcall'; function DispatchMessage(const lpMsg: TMyMsg): Longint; external 'DispatchMessageA@user32.dll stdcall'; function WrapFreeArcCallback (callback: TFreeArcCallback; paramcount: integer):longword; external 'wrapcallback@files:innocallback.dll stdcall'; function FreeArcExtract (callback: longword; cmd1,cmd2,cmd3,cmd4,cmd5,cmd6,cmd7,cmd8,cmd9,cmd10: PAnsiChar): integer; external 'FreeArcExtract@files:unarc.dll cdecl'; var ProgressBar: TNewProgressBar; ExtractFile: TNewStaticText; Button1: TButton; Cancel: Integer; n: Integer; Arcs: array of TArc; m: Extended; Abort: Boolean; mes: string; Upload, PhysX: TCheckBox; bottom_img:TBitmapImage; lblCheckBox, lblSelectDir, lblSelectDirBrowse, lblPhysX: TLabel; PageNameLabel, PageDescriptionLabel: TLabel; WLabel1, WLabel2, FLabel1, FLabel2, FLabel3: TLabel; NeedSize:Integer; FreeMB, TotalMB: Cardinal; NeedSpaceLabel,FreeSpaceLabel: TLabel; BmpFile: TBitmapImage; procedure AppProcessMessage; var Msg: TMyMsg; begin while PeekMessage(Msg, WizardForm.Handle, 0, 0, PM_REMOVE) do begin TranslateMessage(Msg); DispatchMessage(Msg); end; end; function cm(Message: String): String; Begin Result:= ExpandConstant('{cm:'+ Message +'}') End; Function NumToStr(Float: Extended): String; {Перевод числа в строку с точностью 3 знака (%.3n) с округлением дробной части, если она есть} Begin Result:= Format('%.3n', [Float]); StringChange(Result, ',', '.'); while (Pos('.', Result) > 0) and ((Result[Length(Result)] = '0') or (Result[Length(Result)] = '.')) do SetLength(Result, Length(Result)-1); End; Function Size64(Hi, Lo: Integer): Extended; Begin Result:= Lo; if Lo< 0 then Result:= Result + $7FFFFFFF + $7FFFFFFF + 2; for Hi:= Hi-1 Downto 0 do Result:= Result + $7FFFFFFF + $7FFFFFFF + 2; End; procedure Button1OnClick(Sender: TObject); begin Cancel := -127; end; function FindArcs(dir: string): Extended; var FSR: TFindRec; Begin if FindFirst(ExpandConstant(dir), FSR) then try repeat if FSR.Attributes and FILE_ATTRIBUTE_DIRECTORY > 0 then CONTINUE n:= GetArrayLength(Arcs) SetArrayLength(Arcs, n +1) Arcs[n].Path:= ExtractFilePath(ExpandConstant(Archives)) + FSR.Name Arcs[n].Size:= Size64(FSR.SizeHigh, FSR.SizeLow) Result:= Result + Arcs[n].Size; until not FindNext(FSR); finally FindClose(FSR); end; End; function FreeArcCallback (what: PAnsiChar; Mb, sizeArc: Integer; str: PAnsiChar): Integer; var percents: Integer; begin if string(what)='filename' then // ExtractFile.Caption:= str // желательно сделать перекодировку строки из utf8 в ansi например, при помощи WinAPI MultiByteToWideChar else if (string(what)='progress') and (sizeArc>0) then begin percents:= (Mb*1000) div sizeArc; ProgressBar.Position:= percents; ExtractFile.Caption:= FmtMessage(cm('ArcInfo'), [IntToStr(Mb), IntToStr(sizeArc), Format('%.1n', [Abs(percents/10)]), IntToStr(n+1), IntToStr(GetArrayLength(Arcs)) ]); WizardForm.ProgressGauge.Position:= WizardForm.ProgressGauge.Tag + round(ProgressBar.Position * m) percents:= (WizardForm.ProgressGauge.Position-WizardForm.ProgressGauge.Min)/((WizardForm.ProgressGauge.Max - WizardForm.ProgressGauge.Min)/1000) WizardForm.FileNameLabel.Caption:= FmtMessage(cm('AllProgress'), [Format('%.1n', [Abs(percents/10)])]); end; AppProcessMessage; Result := Cancel; end; function UnPack(Archives: string): Integer; var allSize: Extended; callback: longword; FreeMB, TotalMB: Cardinal; begin Button1.Show; WizardForm.ActiveControl:= Button1; WizardForm.ProgressGauge.Position:= 0; WizardForm.ProgressGauge.Max:= 1000 allSize:= FindArcs(Archives) for n:= 0 to GetArrayLength(Arcs) -1 do begin m:= Arcs[n].Size/allSize //объём текущего архива WizardForm.ProgressGauge.Tag:= WizardForm.ProgressGauge.Position Cancel:= 0; AppProcessMessage; callback:= WrapFreeArcCallback(@FreeArcCallback,4); //FreeArcCallback has 4 arguments try Result:= FreeArcExtract (callback, 'x', '-o+', '-dp'+ ExpandConstant('{app}'), '--', Arcs[n].Path, '', '', '', '', ''); if Result = 0 then Result:= Cancel; except Result:= -63; // ArcFail end; if Result <> 0 then begin mes:= FmtMessage(cm('ArcError'), [IntToStr(Result)]); GetSpaceOnDisk(ExtractFileDrive(ExpandConstant('{app}')), True, FreeMB, TotalMB); case Result of -1: if FreeMB < 32 {Мб на диске} then mes:= SetupMessage(msgDiskSpaceWarningTitle) else mes:= mes + #13#10 + FmtMessage(cm('ArcBroken'), [ExtractFileName(Arcs[n].Path)]); -127: mes:= cm('ArcBreak'); //Cancel button -63: mes:= cm('ArcFail'); end; // MsgBox(mes, mbInformation, MB_OK); //сообщение показывается на странице завершения Log(mes); Break; //прервать цикл распаковки end; end; Button1.visible:= false; end; procedure CurStepChanged(CurStep: TSetupStep); begin if CurStep = ssPostInstall then if UnPack(Archives) <> 0 then begin Abort:= true; //замена текста на странице wpFinished Exec(ExpandConstant('{uninstallexe}'), '/SILENT','', sw_Hide, ewWaitUntilTerminated, n); end; end; function DirectX: Boolean; begin Result:=Upload.Checked; end; function PhysX1: Boolean; begin Result:=PhysX.Checked; end; procedure PhysXOnClick(Sender: TObject); begin if PhysX.Checked = False then PhysX.Checked:= True else PhysX.Checked:= False; end; procedure GetFreeSpaceCaption(Sender: TObject); var Path: String; begin Path := ExtractFileDrive(WizardForm.DirEdit.Text); GetSpaceOnDisk(Path, True, FreeMB, TotalMB); if FreeMB > 1024 then FreeSpaceLabel.Caption := ExpandConstant('{cm:SPACE} ')+ FloatToStr(round(FreeMB/1024*100)/100) + ' GB' else FreeSpaceLabel.Caption := ExpandConstant('{cm:SPACE} ')+ IntToStr(FreeMB)+ ' MB'; if FreeMB < NeedSize then WizardForm.NextButton.Enabled := False else WizardForm.NextButton.Enabled := True; end; procedure GetNeedSpaceCaption; begin if NeedSize > 1024 then NeedSpaceLabel.Caption := ExpandConstant('{cm:SPACE1} ')+ FloatToStr(round(NeedSize/1024*100)/100) + ' GB' else NeedSpaceLabel.Caption := ExpandConstant('{cm:SPACE1} ')+ IntToStr(NeedSize)+ ' MB'; end; // задал процедуру, чтоб отмечался чебокс еси кликнуть по надписи lblCheckBox procedure lblCheckBoxOnClick(Sender: TObject); begin if Upload.Checked = False then Upload.Checked:= True else Upload.Checked:= False; end; 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; begin ExtractTemporaryFile('Vista.cjstyles'); LoadSkin(ExpandConstant('{tmp}\Vista.cjstyles'), ''); Result := True; end; procedure DeinitializeSetup(); begin ShowWindow(StrToInt(ExpandConstant('{wizardhwnd}')), 0); UnloadSkin(); end; procedure InitializeWizard(); begin ProgressBar := TNewProgressBar.Create(WizardForm); ExtractFile:=TNewStaticText.Create(WizardForm); with WizardForm.ProgressGauge do begin ProgressBar.SetBounds(Left, Top + ScaleX(55), Width, Height) ProgressBar.Parent := WizardForm.InstallingPage; ProgressBar.max := 1000; ProgressBar.Position := 0; ExtractFile.parent:=WizardForm.InstallingPage; ExtractFile.autosize:=false; ExtractFile.Width := Width; ExtractFile.top:=Top + ScaleX(35); ExtractFile.caption:=cm('ArcTitle'); end; Button1:=TButton.create(WizardForm); Button1.parent:=WizardForm; Button1.SetBounds(260, WizardForm.cancelbutton.top, 135, WizardForm.cancelbutton.Height); Button1.caption:=cm('ArcCancel'); Button1.OnClick:=@Button1OnClick; Button1.Hide; ExtractTemporaryFile('1.bmp'); ExtractTemporaryFile('3.bmp'); NeedSize:= 5580; BmpFile:= TBitmapImage.Create(WizardForm); BmpFile.Bitmap.LoadFromFile(ExpandConstant('{tmp}\1.bmp')); BmpFile.Width:= ScaleX(497); BmpFile.Height:= ScaleY(252); BmpFile.Parent:= WizardForm.SelectDirPage; bottom_img:= TBitmapImage.Create(WizardForm); bottom_img.Bitmap.LoadFromFile(ExpandConstant('{tmp}\3.bmp')); {первые 2 параметра - координаты левогого верхнего угла по горизонтали и вертикали, дальше ширина и высота, до которой растянуть} bottom_img.SetBounds(0, 315, 497, 58); bottom_img.Parent:= WizardForm; bottom_img.Stretch:= True; with WizardForm do begin PageNameLabel.Hide; PageDescriptionLabel.Hide; WelcomeLabel1.Hide; WelcomeLabel2.Hide; DiskSpaceLabel.Hide; SelectDirBitmapImage.Hide; SelectDirBrowseLabel.Hide; SelectDirLabel.Hide; FinishedHeadingLabel.Hide; FinishedLabel.Hide; DirBrowseButton.Left:= DirBrowseButton.Left + ScaleX(40); DirBrowseButton.Top:= DirBrowseButton.Top + ScaleY(12); DirEdit.Left:= DirEdit.Left + ScaleX(40); DirEdit.Top:= DirEdit.Top + ScaleY(12); WizardBitmapImage.Width:= 497; WizardBitmapImage.Height:= 314; WizardBitmapImage2.Width:= 497; WizardBitmapImage2.Height:= 314; with MainPanel do begin with WizardSmallBitmapImage do begin Left:= Mainpanel.Left; Top:= Mainpanel.Top; Width:= Mainpanel.Width; Height:= MainPanel.Height; end; end; end; WLabel1:= TLabel.Create(WizardForm); with WLabel1 do begin Left:= ScaleX(176); Top:= ScaleY(16); Width:= ScaleX(301); Height:= ScaleY(54); AutoSize:= False; end; WLabel2:=TLabel.Create(WizardForm); with WLabel2 do begin Top:= ScaleY(76); Left:= ScaleX(176); Width:= ScaleX(301); Height:= ScaleY(234); AutoSize:= False; end; FLabel1:= TLabel.Create(WizardForm); with FLabel1 do begin Left:= ScaleX(176); Top:= ScaleY(16); Width:= ScaleX(301); Height:= ScaleY(54); AutoSize:= False; end; FLabel2:=TLabel.Create(WizardForm); with FLabel2 do begin Top:= ScaleY(76); Left:= ScaleX(176); Width:= ScaleX(301); Height:= ScaleY(53); AutoSize:= False; end; FLabel3 :=TLabel.Create(WizardForm); with FLabel3 do begin Top := ScaleY(110); Left := ScaleX(176); Width := ScaleX(301); Height := ScaleY(53); AutoSize := False; end; // уменьшил размер CheckBox'а, по другому никак Upload:= TCheckBox.Create(WizardForm); with Upload do begin Parent:= WizardForm.SelectDirPage; Left:= WizardForm.DirEdit.Left; Top:= WizardForm.DirEdit.Top + 35; Width:= ScaleX(14); Height:= ScaleY(14); TabOrder:= 0; Checked:= False; end; // создаём надпись для CheckBox'а lblCheckBox:= TLabel.Create(WizardForm); with lblCheckBox do begin Caption:= ExpandConstant('{cm:DRT}'); Left:= WizardForm.DirEdit.Left + 20; Top:= WizardForm.DirEdit.Top + 35; Width:= ScaleX(150); Height:= ScaleY(13); Transparent := True; Parent:= WizardForm.SelectDirPage; OnClick:= @lblCheckBoxOnClick; end; PhysX:= TCheckBox.Create(WizardForm); with PhysX do begin Parent:= WizardForm.SelectDirPage; Left:= Upload.Left; Top:= Upload.Top + 35; Width:= ScaleX(14); Height:= ScaleY(14); TabOrder:= 0; Checked:= False; end; lblPhysX:= TLabel.Create(WizardForm); with lblPhysX do begin Caption:=' Установить PhysX'; Left:= PhysX.Left + 15; Top:= PhysX.Top ; Width:= ScaleX(150); Height:= ScaleY(13); Transparent := True; Parent:= WizardForm.SelectDirPage; OnClick:= @PhysXOnClick; end; // создаём lblSelectDir lblSelectDir:= TLabel.Create(WizardForm); with lblSelectDir do begin Caption:= WizardForm.SelectDirLabel.Caption; Left:= ScaleX(40); Top:= WizardForm.SelectDirLabel.Top + ScaleY(12); Width:= WizardForm.SelectDirLabel.Width; Height:= WizardForm.SelectDirLabel.Height; Transparent := True; Parent:= WizardForm.SelectDirPage; end; // создаём lblSelectDirBrowse lblSelectDirBrowse:= TLabel.Create(WizardForm); with lblSelectDirBrowse do begin Caption:= WizardForm.SelectDirBrowseLabel.Caption; Left:= ScaleX(40); Top:= WizardForm.SelectDirBrowseLabel.Top + ScaleY(12); Width:= WizardForm.SelectDirBrowseLabel.Width; Height:= WizardForm.SelectDirBrowseLabel.Height; WordWrap:= True; Transparent:= True; Parent:= WizardForm.SelectDirPage; end; NeedSpaceLabel:= TLabel.Create(WizardForm); with NeedSpaceLabel do begin Parent:= WizardForm.SelectDirPage; Left:= WizardForm.DirEdit.Left; Top:= ScaleY(202); Width:= ScaleX(209); Height:= ScaleY(13); Transparent:= True; end; FreeSpaceLabel:= TLabel.Create(WizardForm); with FreeSpaceLabel do begin Parent:= WizardForm.SelectDirPage; Left:= WizardForm.DirEdit.Left; Top:= ScaleY(220); Width:= ScaleX(209); Height:= ScaleY(13); Transparent:= True; end; WizardForm.DirEdit.OnChange:= @GetFreeSpaceCaption; WizardForm.DirEdit.Text:= WizardForm.DirEdit.Text + #0; PageNameLabel:= TLabel.Create(WizardForm); with PageNameLabel do begin Left:= ScaleX(10); Top:= ScaleY(10); Width:= ScaleX(300); Height:= ScaleY(14); AutoSize:= False; end; PageDescriptionLabel:= TLabel.Create(WizardForm); with PageDescriptionLabel do begin Left:= ScaleX(15); Top:= ScaleY(25); Width:= ScaleX(475); Height:= ScaleY(30); AutoSize:= False; end; WizardForm.Font.Color:=clWhite; WizardForm.CancelButton.BringToFront; WizardForm.DirEdit.Color:=clBlack; BmpFile:= TBitmapImage.Create(WizardForm); BmpFile.Bitmap.LoadFromFile(ExpandConstant('{tmp}\1.bmp')); BmpFile.Width:= ScaleX(497); BmpFile.Height:= ScaleY(252); BmpFile.Parent:= WizardForm.InstallingPage; WizardForm.FilenameLabel.Hide; WizardForm.StatusLabel.Hide; WizardForm.ProgressGauge.Top:=ScaleY(220); WizardForm.ProgressGauge.Left:=ScaleY(20); WizardForm.ProgressGauge.Width:=260; end; // стандартный способ отката (не нужна CurPageChanged), но архивы распаковываются до извлечения файлов инсталлятора // if CurStep = ssInstall then // if UnPack(Archives) <> 0 then Abort; procedure CurPageChanged(CurPageID: Integer); begin PageNameLabel.Caption:= WizardForm.PageNameLabel.Caption; PageDescriptionLabel.Caption:= WizardForm.PageDescriptionLabel.Caption; if CurPageID = wpSelectDir then begin WizardForm.NextButton.Caption:= ExpandConstant('{cm:BUT}'); GetNeedSpaceCaption; if FreeMB < NeedSize then WizardForm.NextButton.Enabled:=False; with WizardForm do begin InnerNotebook.Left := ScaleX(0); InnerNotebook.Top := ScaleY(60); InnerNotebook.Width := ScaleX(497); InnerNotebook.Height := ScaleY(252) end; end; // if CurPageID=wpInstalling then if CurPageID=wpFinished then begin WizardForm.Width:=497; WizardForm.Height:=358; WizardForm.Position:=poScreenCenter; end if (CurPageID = wpFinished) and Abort then begin WizardForm.FinishedLabel.Font.Color:= $0000C0; //красный WizardForm.FinishedLabel.Height:= WizardForm.FinishedLabel.Height * 2 WizardForm.FinishedLabel.Caption:= SetupMessage(msgSetupAborted) + #13#10#13#10 + mes; end; end; |