<project>
    <shortName>PreMiD</shortName>
    <fullName>PreMiD</fullName>
    <version>VERSION</version>
    <installerFilename>upgrader.${platform_exec_suffix}</installerFilename>
    <debugLevel>0</debugLevel>
    <licenseFile>../LICENSE</licenseFile>
    <leftImage>leftSide.png</leftImage>
    <logoImage>logo.png</logoImage>
    <splashImage>logo.png</splashImage>
    <componentList>
        <component>
            <name>default</name>
            <description>Default Component</description>
            <canBeEdited>1</canBeEdited>
            <selected>1</selected>
            <show>1</show>
            <folderList>
                <folder>
                    <description>Program Files</description>
                    <destination>${installdir}</destination>
                    <name>programfiles</name>
                    <platforms>all</platforms>
                </folder>
                <folder>
                    <description>Program Files</description>
                    <destination>${installdir}</destination>
                    <name>programfileslinux</name>
                    <platforms>linux</platforms>
                </folder>
                <folder>
                    <description>Program Files</description>
                    <destination>${installdir}</destination>
                    <name>programfileslinux64</name>
                    <platforms>linux-x64</platforms>
                </folder>
                <folder>
                    <description>Program Files</description>
                    <destination>${installdir}</destination>
                    <name>programfileswindows</name>
                    <platforms>windows</platforms>
                </folder>
                <folder>
                    <description>Program Files</description>
                    <destination>${installdir}</destination>
                    <name>programfileswindows64</name>
                    <platforms>windows-x64</platforms>
                </folder>
                <folder>
                    <description>Program Files</description>
                    <destination>${installdir}</destination>
                    <name>programfilesosx</name>
                    <platforms>osx</platforms>
                </folder>
            </folderList>
            <startMenuShortcutList>
                <startMenuShortcut>
                    <comment>Uninstall ${product_fullname}</comment>
                    <name>Uninstall ${product_fullname}</name>
                    <runAsAdmin>0</runAsAdmin>
                    <runInTerminal>0</runInTerminal>
                    <windowsExec>${installdir}/${uninstallerName}.exe</windowsExec>
                    <windowsExecArgs></windowsExecArgs>
                    <windowsIcon></windowsIcon>
                    <windowsPath>${installdir}/</windowsPath>
                </startMenuShortcut>
                <startMenuShortcut>
                    <comment>Rich Presence for web services.</comment>
                    <name>PreMiD</name>
                    <runAsAdmin>0</runAsAdmin>
                    <runInTerminal>0</runInTerminal>
                    <windowsExec>${installdir}/PreMiD.${platform_exec_suffix}</windowsExec>
                    <windowsExecArgs></windowsExecArgs>
                    <windowsIcon></windowsIcon>
                    <windowsPath></windowsPath>
                </startMenuShortcut>
            </startMenuShortcutList>
        </component>
    </componentList>
    <initializationActionList>
        <setInstallerVariable>
            <name>installdir</name>
            <persist>1</persist>
            <value>${windows_folder_appdata}/PreMiD</value>
            <ruleList>
                <platformTest>
                    <type>windows</type>
                </platformTest>
            </ruleList>
        </setInstallerVariable>
        <setInstallerVariable>
            <name>installdir</name>
            <persist>1</persist>
            <value>${platform_install_prefix}/PreMiD</value>
            <ruleList>
                <platformTest>
                    <type>osx</type>
                </platformTest>
            </ruleList>
        </setInstallerVariable>
    </initializationActionList>
    <readyToInstallActionList>
        <actionGroup>
            <customErrorMessage>Couldn't download release... Try again later.</customErrorMessage>
            <progressText>Downloading latest release...</progressText>
            <actionList>
                <showProgressDialog>
                    <title>Downloading latest release...</title>
                    <width>450</width>
                    <actionList>
                        <httpGet>
                            <customErrorMessage>${platform_name}</customErrorMessage>
                            <filename>${system_temp_directory}/PreMiD-release.zip</filename>
                            <url>https://github.com/PreMiD/PreMiD/releases/latest/download/PreMiD-win32-x64.zip</url>
                        </httpGet>
                    </actionList>
                    <ruleList>
                        <platformTest>
                            <type>windows-x64</type>
                        </platformTest>
                    </ruleList>
                </showProgressDialog>
                <showProgressDialog>
                    <title>Downloading latest release...</title>
                    <actionList>
                        <httpGet>
                            <customErrorMessage>${platform_name}</customErrorMessage>
                            <filename>${system_temp_directory}/PreMiD-release.zip</filename>
                            <url>https://github.com/PreMiD/PreMiD/releases/latest/download/PreMiD-win32-ia32.zip</url>
                        </httpGet>
                    </actionList>
                    <ruleList>
                        <platformTest>
                            <type>windows-x86</type>
                        </platformTest>
                    </ruleList>
                </showProgressDialog>
                <showProgressDialog>
                    <title>Downloading latest release...</title>
                    <actionList>
                        <httpGet>
                            <customErrorMessage>${platform_name}</customErrorMessage>
                            <filename>${system_temp_directory}/PreMiD-release.zip</filename>
                            <url>https://github.com/PreMiD/PreMiD/releases/latest/download/PreMiD-darwin-x64.zip</url>
                        </httpGet>
                    </actionList>
                    <ruleList>
                        <platformTest>
                            <type>osx</type>
                        </platformTest>
                    </ruleList>
                </showProgressDialog>
            </actionList>
        </actionGroup>
        <actionGroup>
            <actionList>
                <!-- Remove the old ARP Entry
 Get the old version -->
                <registryGet>
                    <key>HKEY_LOCAL_MACHINE\Software\${project.windowsSoftwareRegistryPrefix}</key>
                    <name>Version</name>
                    <variable>oldVersion</variable>
                </registryGet>

                <!-- Delete the old ARP registry keys -->
                <registryDelete>
                    <key>HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${project.fullName} ${oldVersion}</key>
                    <name></name>
                </registryDelete>
                <registryDelete>
                    <key>HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Management\ARPCache\${project.fullName} ${oldVersion}</key>
                    <name></name>
                </registryDelete>
            </actionList>
            <ruleList>
                <platformTest type="windows"/>
                <isTrue value="${isUpgradeMode}"/>
            </ruleList>
        </actionGroup>
        <actionGroup>
            <progressText>Killing ${product_fullname}...</progressText>
            <actionList>
                <kill>
                    <abortOnError>0</abortOnError>
                    <name>${product_fullname}.exe</name>
                    <showMessageOnError>0</showMessageOnError>
                    <ruleList>
                        <platformTest>
                            <type>windows</type>
                        </platformTest>
                    </ruleList>
                </kill>
                <runProgram>
                    <program>pkill</program>
                    <programArguments>PreMiD</programArguments>
                    <runAs>${env(USER)}</runAs>
                    <useMSDOSPath>0</useMSDOSPath>
                    <workingDirectory>${installdir}/</workingDirectory>
                    <ruleList>
                        <platformTest>
                            <type>osx</type>
                        </platformTest>
                        <processTest>
                            <logic>is_running</logic>
                            <name>PreMiD</name>
                        </processTest>
                    </ruleList>
                </runProgram>
            </actionList>
        </actionGroup>
    </readyToInstallActionList>
    <postInstallationActionList>
        <unzip>
            <addToUninstaller>1</addToUninstaller>
            <destinationDirectory>${installdir}</destinationDirectory>
            <progressText>Extracting release...</progressText>
            <zipFile>${system_temp_directory}/PreMiD-release.zip</zipFile>
        </unzip>
        <addDirectoriesToUninstaller>
            <addContents>1</addContents>
            <files>${installdir}/</files>
        </addDirectoriesToUninstaller>
    </postInstallationActionList>
    <preUninstallationActionList>
        <actionGroup>
            <progressText>Killing ${product_fullname}...</progressText>
            <actionList>
                <kill>
                    <abortOnError>0</abortOnError>
                    <name>${product_fullname}.exe</name>
                    <showMessageOnError>0</showMessageOnError>
                    <ruleList>
                        <platformTest>
                            <type>windows</type>
                        </platformTest>
                    </ruleList>
                </kill>
                <runProgram>
                    <program>pkill</program>
                    <programArguments>PreMiD</programArguments>
                    <runAs>${env(USER)}</runAs>
                    <useMSDOSPath>0</useMSDOSPath>
                    <workingDirectory>${installdir}/</workingDirectory>
                    <ruleList>
                        <platformTest>
                            <type>osx</type>
                        </platformTest>
                        <processTest>
                            <logic>is_running</logic>
                            <name>PreMiD</name>
                        </processTest>
                    </ruleList>
                </runProgram>
            </actionList>
        </actionGroup>
    </preUninstallationActionList>
    <compressionAlgorithm>lzham-ultra</compressionAlgorithm>
    <createOsxBundleZip>1</createOsxBundleZip>
    <defaultInstallationMode>unattended</defaultInstallationMode>
    <deleteOnExit>1</deleteOnExit>
    <description>Rich Presence for web services.</description>
    <disableSplashScreen>1</disableSplashScreen>
    <enableRollback>0</enableRollback>
    <enableSslSupport>1</enableSslSupport>
    <enableTimestamp>1</enableTimestamp>
    <installationScope>user</installationScope>
    <installationType>upgrade</installationType>
    <licenseFileEncoding>utf-8</licenseFileEncoding>
    <osxApplicationBundleIcon>appIcon.icns</osxApplicationBundleIcon>
    <osxApplicationBundleIdentifier>eu.Timeraa.PreMiD</osxApplicationBundleIdentifier>
    <osxPlatforms>osx-intel osx-x86_64</osxPlatforms>
    <osxUninstallerApplicationBundleIcon>appIcon.icns</osxUninstallerApplicationBundleIcon>
    <outputDirectory>../dist/installer</outputDirectory>
    <overwritePolicy>onlyIfNewer</overwritePolicy>
    <productDisplayIcon>C:/Users/metzf/Documents/Development/PreMiD/PreMiD/installer_assets/appIcon.ico</productDisplayIcon>
    <productUrlHelpLink>https://discord.premid.app</productUrlHelpLink>
    <productUrlInfoAbout>https://premid.app</productUrlInfoAbout>
    <readmeFileEncoding>utf-8</readmeFileEncoding>
    <removeLogFile>1</removeLogFile>
    <removeUninstallationLogFile>1</removeUninstallationLogFile>
    <requestedExecutionLevel>asInvoker</requestedExecutionLevel>
    <saveRelativePaths>1</saveRelativePaths>
    <summary>Rich Presence for web services.</summary>
    <unattendedModeUI>minimalWithDialogs</unattendedModeUI>
    <vendor>Timeraa</vendor>
    <width>625</width>
    <windowsExecutableIcon>appIcon.ico</windowsExecutableIcon>
    <windowsResourceFileDescription>Rich Presence for web services.</windowsResourceFileDescription>
    <windowsResourceFileVersion>${product_version}</windowsResourceFileVersion>
    <windowsUninstallerExecutableIcon>appIcon.ico</windowsUninstallerExecutableIcon>
    <licenseFileList>
        <licenseFile>
            <code>en</code>
            <encoding>utf-8</encoding>
            <file>../LICENSE</file>
        </licenseFile>
    </licenseFileList>
    <parameterList>
        <parameterGroup>
            <name>post_install_page</name>
            <title>Installation Finished</title>
            <explanation></explanation>
            <value></value>
            <default></default>
            <insertAfter>installation</insertAfter>
            <parameterList>
                <labelParameter>
                    <name>general</name>
                    <description>General</description>
                    <explanation></explanation>
                    <image></image>
                </labelParameter>
                <booleanParameter>
                    <name>addDesktop</name>
                    <description>Create Desktop Icon</description>
                    <explanation></explanation>
                    <value>false</value>
                    <default>false</default>
                    <displayStyle>checkbox-left</displayStyle>
                </booleanParameter>
                <booleanParameter>
                    <name>launchApp</name>
                    <description>Launch App</description>
                    <explanation></explanation>
                    <value>true</value>
                    <default>true</default>
                    <displayStyle>checkbox-left</displayStyle>
                </booleanParameter>
                <labelParameter>
                    <name>extra</name>
                    <description>Extra</description>
                    <explanation></explanation>
                    <image></image>
                </labelParameter>
                <booleanParameter>
                    <name>openStore</name>
                    <description>Open Presence Store</description>
                    <explanation></explanation>
                    <value>true</value>
                    <default>true</default>
                    <displayStyle>checkbox-left</displayStyle>
                </booleanParameter>
            </parameterList>
            <postShowPageActionList>
                <createShortcuts>
                    <destination>${windows_folder_desktopdirectory}</destination>
                    <ruleList>
                        <isTrue>
                            <value>${addDesktop}</value>
                        </isTrue>
                    </ruleList>
                    <shortcutList>
                        <quickLaunchShortcut>
                            <comment>Rich Presence for web services.</comment>
                            <name>PreMiD</name>
                            <runAsAdmin>0</runAsAdmin>
                            <runInTerminal>0</runInTerminal>
                            <windowsExec>${installdir}/PreMiD.${platform_exec_suffix}</windowsExec>
                            <windowsExecArgs></windowsExecArgs>
                            <windowsIcon></windowsIcon>
                            <windowsPath></windowsPath>
                        </quickLaunchShortcut>
                    </shortcutList>
                </createShortcuts>
                <runProgram>
                    <abortOnError>0</abortOnError>
                    <program>PreMiD.exe</program>
                    <programArguments>&amp;</programArguments>
                    <progressText>Launching PreMiD...</progressText>
                    <showMessageOnError>0</showMessageOnError>
                    <workingDirectory>${installdir}</workingDirectory>
                    <ruleList>
                        <platformTest>
                            <type>windows</type>
                        </platformTest>
                        <isTrue>
                            <value>${launchApp}</value>
                        </isTrue>
                    </ruleList>
                </runProgram>
                <runProgram>
                    <abortOnError>0</abortOnError>
                    <program>open</program>
                    <programArguments>${installdir}/PreMiD.app</programArguments>
                    <progressText>Launching PreMiD...</progressText>
                    <runAs>${env(USER)}</runAs>
                    <showMessageOnError>0</showMessageOnError>
                    <useMSDOSPath>0</useMSDOSPath>
                    <ruleList>
                        <platformTest>
                            <type>osx</type>
                        </platformTest>
                        <isTrue>
                            <value>${launchApp}</value>
                        </isTrue>
                    </ruleList>
                </runProgram>
                <launchBrowser>
                    <url>https://premid.app/store</url>
                    <ruleList>
                        <isTrue>
                            <value>${openStore}</value>
                        </isTrue>
                    </ruleList>
                </launchBrowser>
                <exit/>
            </postShowPageActionList>
        </parameterGroup>
    </parameterList>
    <platformOptionsList>
        <platformOptions>
            <platform>windows</platform>
        </platformOptions>
    </platformOptionsList>
</project>

