; Dragonflight Premiere Pro CEP panel — Windows installer
; Build:  iscc installer.iss /DMyAppVersion=1.0.0
;         (build-installer.ps1 parses CSXS/manifest.xml and passes the version)

#ifndef MyAppVersion
  #define MyAppVersion "0.0.0-dev"
#endif

#define MyAppName       "Dragonflight Premiere Panel"
#define MyAppPublisher  "Wild Dragon LLC"
#define MyAppURL        "https://forge.wilddragon.net/zgaetano/dragonflight"
#define BundleId        "net.wilddragon.dragonflight.panel"
#define LegacyBundleId  "com.wilddragon.mam.panel"
#define PanelSrcDir     "..\"
#define OutDir          "dist"

[Setup]
AppId={{8E2C1F6D-1B9A-4D7E-9C3F-9F2E5A4C7B11}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}/issues
AppUpdatesURL={#MyAppURL}/releases
DefaultDirName={userappdata}\Adobe\CEP\extensions\{#BundleId}
DefaultGroupName={#MyAppName}
DisableProgramGroupPage=yes
DisableDirPage=yes
PrivilegesRequired=lowest
PrivilegesRequiredOverridesAllowed=
OutputDir={#OutDir}
OutputBaseFilename=dragonflight-premiere-panel-{#MyAppVersion}-windows-setup
Compression=lzma
SolidCompression=yes
WizardStyle=modern
UninstallDisplayName={#MyAppName} {#MyAppVersion}
UninstallDisplayIcon={app}\index.html
SetupLogging=yes

[Languages]
Name: "en"; MessagesFile: "compiler:Default.isl"

[Tasks]
Name: "removelegacy"; Description: "Remove legacy {#LegacyBundleId} install if present"; GroupDescription: "Migration:"; Check: LegacyPanelExists

[Files]
; Copy the entire panel bundle, minus the build/ pipeline and the
; deprecated install-windows.ps1 (this installer supersedes it).
Source: "{#PanelSrcDir}*"; DestDir: "{app}"; Excludes: "build,install-windows.ps1,*.log"; \
    Flags: ignoreversion recursesubdirs createallsubdirs

[Registry]
; Enable PlayerDebugMode for every CEP version Premiere Pro might use.
; Adobe stores this as REG_SZ "1" (a STRING, not a DWORD). Intentionally
; no uninsdeletevalue flag — other CEP panels need this key too.
Root: HKCU; Subkey: "Software\Adobe\CSXS.8";  ValueType: string; ValueName: "PlayerDebugMode"; ValueData: "1"
Root: HKCU; Subkey: "Software\Adobe\CSXS.9";  ValueType: string; ValueName: "PlayerDebugMode"; ValueData: "1"
Root: HKCU; Subkey: "Software\Adobe\CSXS.10"; ValueType: string; ValueName: "PlayerDebugMode"; ValueData: "1"
Root: HKCU; Subkey: "Software\Adobe\CSXS.11"; ValueType: string; ValueName: "PlayerDebugMode"; ValueData: "1"
Root: HKCU; Subkey: "Software\Adobe\CSXS.12"; ValueType: string; ValueName: "PlayerDebugMode"; ValueData: "1"
Root: HKCU; Subkey: "Software\Adobe\CSXS.13"; ValueType: string; ValueName: "PlayerDebugMode"; ValueData: "1"

[InstallDelete]
; Wipe the legacy folder before installing the new one (only if user opted in).
Type: filesandordirs; Name: "{userappdata}\Adobe\CEP\extensions\{#LegacyBundleId}"; Tasks: removelegacy

[UninstallDelete]
; Strip the install dir clean on uninstall. App lives entirely in {app}.
Type: filesandordirs; Name: "{app}"

[Code]
function LegacyPanelExists: Boolean;
begin
  Result := DirExists(ExpandConstant('{userappdata}\Adobe\CEP\extensions\{#LegacyBundleId}'));
end;

[Run]
Filename: "{app}\README.md"; Description: "Open README"; Flags: shellexec postinstall skipifsilent unchecked
