; Script generated by the Inno Setup Script Wizard. 
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
                       
#define MyAppName "TTW_Bot"  
#define MyAppExeName "TTW_Bot_app.exe" 
#define MyAppDir "C:\Delphi\d12\ttw_fmx_v10"
#define MyAppExePath MyAppDir + "\Win32\Release\" + MyAppExeName         
#define MyAppVersion GetFileVersion(MyAppExePath)
#define MyAppPublisher "PTyTb, Inc."
#define MyAppURL "https://ptytb.ru/ttw_bot"
#define MyAppAssocName MyAppName + "_Files"
#define MyAppAssocExt ".myp"
#define MyAppAssocKey StringChange(MyAppAssocName, " ", "") + MyAppAssocExt


[Setup]
; NOTE: The value of AppId uniquely identifies this application. Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
LicenseFile={#MyAppDir}\license.rtf
DisableWelcomePage=no
AppId={{81A4FB77-4AE5-4FAC-A889-CA3CA7B8C687}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={autopf}\{#MyAppName}
ChangesAssociations=yes
DisableDirPage=auto
DisableProgramGroupPage=auto
; Uncomment the following line to run in non administrative install mode (install for current user only.)
;PrivilegesRequired=lowest
OutputDir={#MyAppDir}\Win32\installer
OutputBaseFilename=TTW_Bot_setup
SetupIconFile={#MyAppDir}\install.ico
Compression=lzma2/ultra
SolidCompression=yes
WizardStyle=modern

[Languages]
Name: "russian"; MessagesFile: "compiler:Languages\Russian.isl"; LicenseFile: "{#MyAppDir}\license.rtf"

[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked

[Files]
Source: "{#MyAppDir}\Win32\Release\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion
Source: "{#MyAppDir}\Win32\Release\bass.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "{#MyAppDir}\Win32\Release\botapp.cfg"; DestDir: "{app}"; Flags: ignoreversion
;Source: "{#MyAppDir}\Win32\Release\ffmpeg.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "{#MyAppDir}\Win32\Release\libcrypto-1_1.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "{#MyAppDir}\Win32\Release\libeay32.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "{#MyAppDir}\Win32\Release\libssl-1_1.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "{#MyAppDir}\Win32\Release\libssl32.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "{#MyAppDir}\Win32\Release\SilentPlayer.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "{#MyAppDir}\Win32\Release\ssleay32.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "{#MyAppDir}\Win32\Release\yt-dlp.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "{#MyAppDir}\Win32\Release\zlib1.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "{#MyAppDir}\Win32\Release\stl\*"; DestDir: "{userappdata}\TTW_Bot\stl"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: "{#MyAppDir}\Win32\Release\piper\*"; DestDir: "{app}\piper"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: "{#MyAppDir}\Win32\Release\games\*"; DestDir: "{app}\games"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: "{#MyAppDir}\license.rtf"; DestDir: "{app}"; Flags: ignoreversion
; NOTE: Don't use "Flags: ignoreversion" on any shared system files

[Registry]
Root: HKA; Subkey: "Software\Classes\{#MyAppAssocExt}\OpenWithProgids"; ValueType: string; ValueName: "{#MyAppAssocKey}"; ValueData: ""; Flags: uninsdeletevalue
Root: HKA; Subkey: "Software\Classes\{#MyAppAssocKey}"; ValueType: string; ValueName: ""; ValueData: "{#MyAppAssocName}"; Flags: uninsdeletekey
Root: HKA; Subkey: "Software\Classes\{#MyAppAssocKey}\DefaultIcon"; ValueType: string; ValueName: ""; ValueData: "{app}\{#MyAppExeName},0"
Root: HKA; Subkey: "Software\Classes\{#MyAppAssocKey}\shell\open\command"; ValueType: string; ValueName: ""; ValueData: """{app}\{#MyAppExeName}"" ""%1"""
Root: HKA; Subkey: "Software\Classes\Applications\{#MyAppExeName}\SupportedTypes"; ValueType: string; ValueName: ".myp"; ValueData: ""

[Icons]
Name: "{autoprograms}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon

[Run]
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent

[Code]
function NextButtonClick(CurPageID: Integer): Boolean;
begin
  if CurPageID = wpLicense then
  begin
    Result := WizardForm.LicenseAcceptedRadio.Checked;
    if not Result then
      MsgBox('Вы должны принять условия лицензионного соглашения!', mbError, MB_OK);
  end
  else
    Result := True;
end;