<Wix
  xmlns="http://wixtoolset.org/schemas/v4/wxs"
  xmlns:ui="http://wixtoolset.org/schemas/v4/wxs/ui"
  >

  <Package
    Name="Stacked Git"
    Version="$(StGitVersion)"
    Manufacturer="Stacked Git Project"
    Scope="perMachine"
    UpgradeCode="8816B18C-9578-48C0-8604-39785D99654D"
    >

    <Media Id="1" Cabinet="stgit" EmbedCab="yes" />

    <Feature Id="StGitBase" Title="Stacked Git" Level="1">
      <Component Id="StGitExe" Directory="APPBINDIR">
        <File Source="target\release\stg.exe" KeyPath="yes" Checksum="yes" />
      </Component>
      <Component
        Id="RequiredDocs"
        Directory="APPLICATIONFOLDER"
        Guid="77FFFA6A-C4EA-4AB6-9C43-C1943A357581"
        >
        <File Source="README.md" />
        <File Source="COPYING" />
      </Component>
    </Feature>

    <Feature Id="SetPath" Title="Add StGit to PATH" Level="1">
      <Component
        Id="SetStGitPath"
        Directory="APPBINDIR"
        Guid="D136C879-F475-4934-B912-B0B968D205EB"
        >
        <Environment
          Name="PATH"
          Action="set"
          Part="last"
          Permanent="no"
          System="yes"
          Value="[APPBINDIR]"
          />
      </Component>
    </Feature>

    <Feature Id="ShellCompletions" Title="Shell Completions" Level="1">
      <Component
        Id="CompletionScripts"
        Directory="COMPLETIONSDIR"
        Guid="D76DCCB1-59F9-47AB-B9A3-21EE6373E8C7"
        >
        <File Source="completion\stg.fish" />
        <File Source="completion\stgit.bash" />
        <File Source="completion\stgit.zsh" />
      </Component>
    </Feature>

    <ui:WixUI Id="FeatureTree_ViewLicense" />

    <!-- <WixVariable Id="WixUILicenseRtf" Value="contrib\wix\gpl-2.0.rtf" /> -->
    <WixVariable Id="WixUIDialogBmp" Value="contrib\wix\dialog.bmp" />
    <WixVariable Id="WixUIBannerBmp" Value="contrib\wix\banner.bmp" />

  </Package>

  <Fragment>
    <StandardDirectory Id="ProgramFiles64Folder">
      <Directory Id="APPLICATIONFOLDER" Name="StGit">
        <Directory Id="APPBINDIR" Name="bin" />
        <Directory Id="COMPLETIONSDIR" Name="completion" />
      </Directory>
    </StandardDirectory>
  </Fragment>

  <?foreach WIXUIARCH in X86;X64;A64 ?>
  <Fragment>
    <UI Id="FeatureTree_ViewLicense_$(WIXUIARCH)">
      <Publish Dialog="ViewLicenseDlg" Control="Print" Event="DoAction" Value="WixUIPrintEula_$(WIXUIARCH)" />
    </UI>

    <UIRef Id="FeatureTree_ViewLicense" />
  </Fragment>
  <?endforeach?>

  <!-- Like WixUI_FeatureTree, but the license text is shown without the agreement checkbox. -->
  <Fragment>
    <UI Id="file FeatureTree_ViewLicense">
      <TextStyle Id="WixUI_Font_Normal" FaceName="Tahoma" Size="8" />
      <TextStyle Id="WixUI_Font_Bigger" FaceName="Tahoma" Size="12" />
      <TextStyle Id="WixUI_Font_Title" FaceName="Tahoma" Size="9" Bold="yes" />

      <Property Id="DefaultUIFont" Value="WixUI_Font_Normal" />

      <DialogRef Id="ErrorDlg" />
      <DialogRef Id="FatalError" />
      <DialogRef Id="FilesInUse" />
      <DialogRef Id="MsiRMFilesInUse" />
      <DialogRef Id="PrepareDlg" />
      <DialogRef Id="ProgressDlg" />
      <DialogRef Id="ResumeDlg" />
      <DialogRef Id="UserExit" />

      <Publish Dialog="ExitDialog" Control="Finish" Event="EndDialog" Value="Return" Order="999" />
      <Publish Dialog="WelcomeDlg" Control="Next" Event="NewDialog" Value="ViewLicenseDlg" Condition="NOT Installed" />
      <Publish Dialog="WelcomeDlg" Control="Next" Event="NewDialog" Value="VerifyReadyDlg" Condition="Installed AND PATCH" />
      <Publish Dialog="ViewLicenseDlg" Control="Back" Event="NewDialog" Value="WelcomeDlg" />
      <Publish Dialog="ViewLicenseDlg" Control="Next" Event="NewDialog" Value="CustomizeDlg" />
      <Publish Dialog="CustomizeDlg" Control="Back" Event="NewDialog" Value="MaintenanceTypeDlg" Order="1" Condition="Installed" />
      <Publish Dialog="CustomizeDlg" Control="Back" Event="NewDialog" Value="ViewLicenseDlg" Order="2" Condition="NOT Installed" />
      <Publish Dialog="CustomizeDlg" Control="Next" Event="NewDialog" Value="VerifyReadyDlg" />
      <Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="CustomizeDlg" Order="1" Condition="NOT Installed OR WixUI_InstallMode = &quot;Change&quot;" />
      <Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="MaintenanceTypeDlg" Order="2" Condition="Installed AND NOT PATCH" />
      <Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="WelcomeDlg" Order="3" Condition="Installed AND PATCH" />
      <Publish Dialog="MaintenanceWelcomeDlg" Control="Next" Event="NewDialog" Value="MaintenanceTypeDlg" />
      <Publish Dialog="MaintenanceTypeDlg" Control="ChangeButton" Event="NewDialog" Value="CustomizeDlg" />
      <Publish Dialog="MaintenanceTypeDlg" Control="RepairButton" Event="NewDialog" Value="VerifyReadyDlg" />
      <Publish Dialog="MaintenanceTypeDlg" Control="RemoveButton" Event="NewDialog" Value="VerifyReadyDlg" />
      <Publish Dialog="MaintenanceTypeDlg" Control="Back" Event="NewDialog" Value="MaintenanceWelcomeDlg" />
    </UI>

    <UIRef Id="WixUI_Common" />
  </Fragment>

  <!-- License dialog that just shows the license file w/o agreement checkbox. -->
  <Fragment>
    <UI>
      <Dialog Id="ViewLicenseDlg" Width="370" Height="270" Title="!(loc.LicenseAgreementDlg_Title)">
        <Control Id="BannerBitmap" Type="Bitmap" X="0" Y="0" Width="370" Height="44" TabSkip="no" Text="!(loc.LicenseAgreementDlgBannerBitmap)" />
        <Control Id="BannerLine" Type="Line" X="0" Y="44" Width="370" Height="0" />
        <Control Id="BottomLine" Type="Line" X="0" Y="234" Width="370" Height="0" />
        <Control Id="Description" Type="Text" X="25" Y="23" Width="340" Height="15" Transparent="yes" NoPrefix="yes" Text="!(loc.LicenseAgreementDlgDescription)" />
        <Control Id="Title" Type="Text" X="15" Y="6" Width="200" Height="15" Transparent="yes" NoPrefix="yes" Text="!(loc.LicenseAgreementDlgTitle)" />
        <Control Id="Print" Type="PushButton" X="112" Y="243" Width="56" Height="17" Text="!(loc.WixUIPrint)" />
        <Control Id="Back" Type="PushButton" X="180" Y="243" Width="56" Height="17" Text="!(loc.WixUIBack)" />
        <Control Id="Next" Type="PushButton" X="236" Y="243" Width="56" Height="17" Default="yes" Text="!(loc.WixUINext)">
          <Publish Event="SpawnWaitDialog" Value="WaitForCostingDlg" Condition="!(wix.WixUICostingPopupOptOut) OR CostingComplete = 1" />
        </Control>
        <Control Id="Cancel" Type="PushButton" X="304" Y="243" Width="56" Height="17" Cancel="yes" Text="!(loc.WixUICancel)">
          <Publish Event="SpawnDialog" Value="CancelDlg" />
        </Control>
        <Control Id="LicenseText" Type="ScrollableText" X="20" Y="60" Width="330" Height="158" Sunken="yes" TabSkip="no">
          <Text SourceFile="contrib\wix\gpl-2.0.rtf" />
        </Control>
      </Dialog>
    </UI>
  </Fragment>

</Wix>
