Код:
#define ModName "TQRagnarökMod by BioHazardN7"
#define ModVersion "2.3.27"
#define ModShortDescription "Модификация для Titan Quest"
[Setup]
AppId={{70653654-6624-42B4-B9A4-CAE370D75364}
AppName={#ModName} {#ModVersion}
AppVerName={#ModName} {#ModVersion}
// AppPublisher=http://tqrm.zzz.com.ua
// AppPublisherURL=http://tqrm.zzz.com.ua
// AppSupportURL=http://tqrm.zzz.com.ua
// AppUpdatesURL=http://tqrm.zzz.com.ua
DefaultDirName={code:GetInstallationPath}
DefaultGroupName={#ModName}
DirExistsWarning=no
DisableWelcomePage=no
AllowNoIcons=true
InfoBeforeFile=Data\Description.rtf
OutputDir=Release
OutputBaseFilename=TQRagnarokMod2327a_Installer
SetupIconFile=Data\Icon.ico
// Степень сжатия. Сильное: lzma/ultra
Compression=none
SolidCompression=true
VersionInfoVersion={#ModVersion}
// VersionInfoCompany=http://tqrm.zzz.com.ua
VersionInfoDescription={#ModShortDescription}
WizardImageFile=Data\Poster.bmp
// VersionInfoCopyright=(c) http://tqrm.zzz.com.ua
WizardSmallImageFile=Data\Logo.bmp
[Languages]
Name: russian; MessagesFile: compiler:Languages\Russian.isl
[Files]
Source: Files\*; DestDir: {app}; Flags: ignoreversion recursesubdirs createallsubdirs; BeforeInstall: CreateBackup
Source: {app}\Game.dll; DestDir: {app}; DestName: Game.dll.bak; Flags: external skipifsourcedoesntexist
Source: {app}\Game_DX11.dll; DestDir: {app}; DestName: Game_DX11.dll.bak; Flags: external skipifsourcedoesntexist
[Run]
Filename: {app}\xvi32.cmd; Flags: runhidden shellexec skipifdoesntexist
[UninstallDelete]
Type: files; Name: {app}\Game.dll.bak
Type: files; Name: {app}\Game_DX11.dll.bak
[Icons]
Name: {group}\{cm:ProgramOnTheWeb,{#ModName} {#ModVersion}}; Filename: http://tqrm.zzz.com.ua
Name: {group}\Последняя версия {#ModName}; Filename: http://tqrm.zzz.com.ua/ru/#download
Name: {group}\The latest version of {#ModName}; Filename: http://tqrm.zzz.com.ua/en/#download
Name: {group}\www.titanquest.org.ua; Filename: https://titanquest.org.ua/tqragnarokmod_by_biohazardn7
Name: {group}\vk.com; Filename: https://vk.com/tqrm_n7
Name: {group}\Telegram; Filename: https://t.me/TQRM_N7
Name: {group}\{cm:UninstallProgram,{#ModName} {#ModVersion}}; Filename: {uninstallexe}
// [Messages]
// BeveledLabel=http://tqrm.zzz.com.ua
[code]
procedure RestoreFromBackup(const AFileName: string);
var
LFileName: string;
begin
LFileName := ChangeFileExt(AFileName, '');
if FileExists(LFileName) then
FileCopy(AFileName, ChangeFileExt(AFileName, ''), False);
end;
// DETECT PREVIOUS VERSION
function InitializeSetup(): Boolean;
begin
Result := True;
if RegKeyExists(HKEY_LOCAL_MACHINE,
'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{70653654-6624-42B4-B9A4-CAE370D75364}_is1') or
RegKeyExists(HKEY_CURRENT_USER,
'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{70653654-6624-42B4-B9A4-CAE370D75364}_is1') then
begin
Log('NEEED')
//MsgBox('Для переустановки или установки новой версии - необходимо удалить предыдущую', mbInformation, MB_OK);
//Result := False;
end;
end;
// CLICKABLE LINK TO TQ SITE
procedure BevelLabelClick(Sender: TObject);
var ErrorCode: Integer;
begin
ShellExec('open','http://tqrm.zzz.com.ua','', '', SW_SHOW, ewNoWait, ErrorCode)
end;
procedure InitializeWizard();
begin
with WizardForm do begin
with BeveledLabel do begin
OnClick:=@BevelLabelClick;
Font.Color:=clBlue;
Enabled:=True;
Cursor:=crHand;
end;
end;
end;
// PAGE WITH DESTINATION
procedure CurPageChanged(CurPageID: Integer);
begin
If CurPageID=wpSelectDir then
begin
WizardForm.DirEdit.Enabled := True;
WizardForm.DirBrowseButton.Enabled := True;
end
else
end;
// CREATE BACKUP BEFORE INSTALL
procedure CreateBackup;
var
srcFile, destFile: string;
begin
if RegKeyExists(HKEY_LOCAL_MACHINE,
'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{70653654-6624-42B4-B9A4-CAE370D75364}_is1') or
RegKeyExists(HKEY_CURRENT_USER,
'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{70653654-6624-42B4-B9A4-CAE370D75364}_is1') then
begin
// Do nothing
end
else
begin
srcFile:= ExpandConstant(CurrentFileName);
destFile:= srcFile + '.bak';
DeleteFile(destFile);
RenameFile(srcFile, destFile);
end
end;
procedure RestoreBackup(backupDir: string);
var
srcFile, destFile: string;
FSR, DSR: TFindRec;
FindResult: Boolean;
APath: string;
begin
APath := AddBackslash(backupDir);
FindResult := FindFirst(APath + '*.bak', FSR);
try
while FindResult do
begin
if FSR.Attributes and FILE_ATTRIBUTE_DIRECTORY = 0 then
begin
srcFile:= APath + FSR.Name;
destFile:= Copy(srcFile, 0, Length(srcFile)-4);
DeleteFile(destFile);
RenameFile(srcFile, destFile);
end;
FindResult := FindNext(FSR);
end;
FindResult := FindFirst(APath + '*.*', DSR);
while FindResult do
begin
if ((DSR.Attributes and FILE_ATTRIBUTE_DIRECTORY) = FILE_ATTRIBUTE_DIRECTORY) and
not ((DSR.Name = '.') or (DSR.Name = '..')) then
{Recursion} RestoreBackup(APath + DSR.Name);
FindResult := FindNext(DSR);
end;
finally
FindClose(FSR);
FindClose(DSR);
end;
end;
// RESTORE BACKUP AFTER UNINSTALL
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
begin
if CurUninstallStep = usPostUninstall then
begin
RestoreBackup(ExpandConstant('{app}'))
end;
begin
case CurUninstallStep of
usUninstall:
begin
RestoreFromBackup(ExpandConstant('{app}\Game.dll.bak'));
RestoreFromBackup(ExpandConstant('{app}\Game_DX11.dll.bak'));
end;
end;
end;
end;
// DETECT PATH OF INSTALLATION
var
InstallationPath: string;
function GetInstallationPath(Param: string): string;
begin
{ Detected path is cached, as this gets called multiple times }
if InstallationPath = '' then
begin
if RegQueryStringValue(
HKLM32, 'SOFTWARE\GOG.com\Games\1196955511',
'path', InstallationPath) then
begin
Log('Detected GOG installation: ' + InstallationPath);
end
else
if RegQueryStringValue(
HKLM64, 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Steam App 475150',
'InstallLocation', InstallationPath) then
begin
Log('Detected Steam installation: ' + InstallationPath);
end
else
begin
InstallationPath := ExpandConstant('{pf}');
MsgBox('Не удалось автоматически определить где установлена игра. В ходе установки укажите путь вручную', mbInformation, MB_OK);
Log('No installation detected, using the default path: ' + InstallationPath);
end;
end;
Result := InstallationPath;
end;