Open Metadorius opened 1 month ago
I installed it using an MSI, I don't think it asked me for association of the files at any point.
To allow the user to choose whether to associate file types with voxedit
during installation, you need to introduce a custom dialog in the WiX installer. This dialog will allow users to select the file associations they want to make. You can accomplish this by creating a custom user interface (UI) and using properties to conditionally set registry entries based on the user's choices.
Here’s how to update your WiX file:
You need to add a new dialog in the WiX installer to ask the user whether to associate the file types with your application.
First, define the dialog in your WiX project:
<UI>
<Dialog Id="DlgFileAssociations" Width="370" Height="270" Title="File Associations">
<Control Id="FileTypeLabel" Type="Text" X="20" Y="15" Width="330" Height="15" Text="Select the file types you want to associate with Vengi Voxel Editor:" />
<Control Id="VengiCheckBox" Type="CheckBox" X="40" Y="50" Width="200" Height="15" Text=".vengi files" Property="ASSOCIATE_VENGI" CheckBoxValue="1" />
<Control Id="AsepriteCheckBox" Type="CheckBox" X="40" Y="75" Width="200" Height="15" Text=".aseprite files" Property="ASSOCIATE_ASEPRITE" CheckBoxValue="1" />
<Control Id="OKButton" Type="PushButton" X="236" Y="243" Width="60" Height="17" Default="yes" Text="OK">
<Publish Event="EndDialog" Value="Return">1</Publish>
</Control>
</Dialog>
</UI>
The registry keys and ProgIds that associate the file extensions with voxedit
need to be created conditionally, based on whether the user has checked the corresponding checkbox.
For the .vengi
file association:
<RegistryValue Root="HKLM" Key="Software\vengi-voxedit\Capabilities\FileAssociations" Name=".vengi" Value="vengi-voxedit.vengi" Type="string" Condition="ASSOCIATE_VENGI=1" />
<RegistryValue Root="HKCR" Key="Applications\vengi_voxedit.exe\SupportedTypes" Name=".vengi" Value="" Type="string" Condition="ASSOCIATE_VENGI=1" />
<RegistryValue Root="HKCR" Key=".vengi\OpenWithProgids" Name="vengi-voxedit.vengi" Value="" Type="string" Condition="ASSOCIATE_VENGI=1" />
<ProgId Id="vengi-voxedit.vengi" Description="Vengi" Icon="CM_FP_voxedit.voxedit.vengi_voxedit.exe" Condition="ASSOCIATE_VENGI=1">
<Extension Id="vengi" ContentType="application/x-vengi">
<Verb Id="open" TargetFile="CM_FP_voxedit.voxedit.vengi_voxedit.exe" Argument=""%1"" />
</Extension>
</ProgId>
For the .aseprite
file association:
<RegistryValue Root="HKLM" Key="Software\vengi-voxedit\Capabilities\FileAssociations" Name=".aseprite" Value="vengi-voxedit.aseprite" Type="string" Condition="ASSOCIATE_ASEPRITE=1" />
<RegistryValue Root="HKCR" Key="Applications\vengi_voxedit.exe\SupportedTypes" Name=".aseprite" Value="" Type="string" Condition="ASSOCIATE_ASEPRITE=1" />
<RegistryValue Root="HKCR" Key=".aseprite\OpenWithProgids" Name="vengi-voxedit.aseprite" Value="" Type="string" Condition="ASSOCIATE_ASEPRITE=1" />
<ProgId Id="vengi-voxedit.aseprite" Description="aseprite" Icon="CM_FP_voxedit.voxedit.vengi_voxedit.exe" Condition="ASSOCIATE_ASEPRITE=1">
<Extension Id="aseprite" ContentType="application/x-aseprite">
<Verb Id="open" TargetFile="CM_FP_voxedit.voxedit.vengi_voxedit.exe" Argument=""%1"" />
</Extension>
</ProgId>
To display the file association dialog during installation, insert it into the sequence:
<InstallUISequence>
<Show Dialog="DlgFileAssociations" Before="ProgressDlg">NOT Installed</Show>
</InstallUISequence>
By default, the file associations will be enabled (i.e., checkboxes checked), but users can uncheck them if they don't want the associations:
<Property Id="ASSOCIATE_VENGI" Value="1" />
<Property Id="ASSOCIATE_ASEPRITE" Value="1" />
This example assumes you’ll modify your WiX patch XML accordingly. Ensure you generate the proper fragment or include it as part of the installation project so that the CPackWiX
tool can pick it up properly.
With these changes, during installation, users will be prompted with a dialog to accept or decline file type associations with voxedit
, and the registry entries will be created conditionally based on their choices.
<?xml version="1.0" encoding="UTF-8"?>
<CPackWiXPatch>
<!-- Your previous fragment entries here -->
<!-- Fragment to include a custom UI dialog -->
<CPackWiXFragment Id="CM_CP_CustomFileAssociationsDialog">
<!-- Define the custom dialog -->
<UI>
<Dialog Id="FileAssociationsDlg" Width="370" Height="270" Title="File Associations">
<Control Id="FileTypeLabel" Type="Text" X="20" Y="15" Width="330" Height="15" Text="Select the file types you want to associate with Vengi Voxel Editor:" />
<!-- Checkbox for file associations -->
<Control Id="VengiCheckBox" Type="CheckBox" X="40" Y="50" Width="200" Height="15" Text=".vengi files" Property="ASSOCIATE_VENGI" CheckBoxValue="1" />
<Control Id="AsepriteCheckBox" Type="CheckBox" X="40" Y="75" Width="200" Height="15" Text=".aseprite files" Property="ASSOCIATE_ASEPRITE" CheckBoxValue="1" />
<!-- OK button -->
<Control Id="OKButton" Type="PushButton" X="236" Y="243" Width="60" Height="17" Default="yes" Text="OK">
<Publish Event="EndDialog" Value="Return">1</Publish>
</Control>
</Dialog>
<!-- Integrate dialog into the UI flow -->
<InstallUISequence>
<!-- Show the file associations dialog before the install progress -->
<Show Dialog="FileAssociationsDlg" Before="ProgressDlg">NOT Installed</Show>
</InstallUISequence>
<!-- Default property values -->
<Property Id="ASSOCIATE_VENGI" Value="1" />
<Property Id="ASSOCIATE_ASEPRITE" Value="1" />
</UI>
</CPackWiXFragment>
</CPackWiXPatch>
This only happens if the user doesn't given an extension at all and selectedAll Formats
in the filter, no?EDIT: misunderstood - I thought this was about the file dialog - but this is about the MSI installer writing stuff into the registry.