<UserControl x:Class="FModel.Views.Resources.Controls.ExportOptionsControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             mc:Ignorable="d" d:DesignWidth="512"
             d:DataContext="{d:DesignInstance Type=vm:ExportOptionsViewModel, IsDesignTimeCreatable=False}"

             xmlns:vm="clr-namespace:FModel.ViewModels"
             xmlns:adonisUi="clr-namespace:AdonisUI;assembly=AdonisUI"
             xmlns:converters="clr-namespace:FModel.Views.Resources.Converters"
             xmlns:c4pMeshes="clr-namespace:CUE4Parse_Conversion.Options;assembly=CUE4Parse-Conversion">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="10" />
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="5" />
            <ColumnDefinition Width="Auto" />
        </Grid.ColumnDefinitions>

        <TextBlock Grid.Row="0" Grid.Column="0" Text="Output Directory" VerticalAlignment="Center" />
        <TextBox Grid.Row="0" Grid.Column="2" IsReadOnly="True"
                 Text="{Binding OutputDirectory, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
        <Button Grid.Row="0" Grid.Column="4" Content="..." MinWidth="28" Click="OnBrowseOutputDirectory" />

        <TextBlock Grid.Row="1" Grid.Column="0" Text="Export Immediately" VerticalAlignment="Center" Margin="0 8 0 0"
                   Visibility="{Binding ShowExportImmediatelyOption, Converter={StaticResource BoolToVisibilityConverter}}"
                   ToolTip="Start exporting automatically after all selected assets have been queued." />
        <CheckBox Grid.Row="1" Grid.Column="2" Grid.ColumnSpan="3" Margin="0 8 0 0"
                  IsChecked="{Binding ExportImmediately, Mode=TwoWay}"
                  Content="{Binding IsChecked, RelativeSource={RelativeSource Self}, Converter={x:Static converters:BoolToToggleConverter.Instance}}"
                  Style="{DynamicResource {x:Static adonisUi:Styles.ToggleSwitch}}"
                  Visibility="{Binding ShowExportImmediatelyOption, Converter={StaticResource BoolToVisibilityConverter}}"
                  ToolTip="Start exporting automatically after all selected assets have been queued." />

        <Separator Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="5" Style="{StaticResource CustomSeparator}" Tag="MESH" Margin="0 10 0 10" />

        <TextBlock Grid.Row="3" Grid.Column="0" Text="Mesh Format" VerticalAlignment="Center" Margin="0 0 0 5" />
        <ComboBox Grid.Row="3" Grid.Column="2" Grid.ColumnSpan="3" Margin="0 0 0 5"
                  ItemsSource="{Binding MeshFormats}"
                  SelectedItem="{Binding SelectedMeshFormat, Mode=TwoWay}">
            <ComboBox.ItemTemplate>
                <DataTemplate>
                    <TextBlock Text="{Binding Converter={x:Static converters:EnumToStringConverter.Instance}}" />
                </DataTemplate>
            </ComboBox.ItemTemplate>
        </ComboBox>

        <ContentControl Grid.Row="4" Grid.Column="2" Grid.ColumnSpan="3" FontSize="10" Margin="0 0 0 5">
            <ContentControl.Style>
                <Style TargetType="{x:Type ContentControl}">
                    <Setter Property="Visibility" Value="Collapsed" />
                    <EventSetter Event="Hyperlink.Click" Handler="OnHyperlinkClick" />
                    <Style.Triggers>
                        <DataTrigger Binding="{Binding SelectedMeshFormat}" Value="{x:Static c4pMeshes:EMeshFormat.UEFormat}">
                            <Setter Property="ContentTemplate">
                                <Setter.Value>
                                    <DataTemplate>
                                        <TextBlock>
                                            <Run Text="Importer (Blender/UE): " />
                                            <Hyperlink NavigateUri="https://github.com/h4lfheart/UEFormat">github.com/h4lfheart/UEFormat</Hyperlink>
                                        </TextBlock>
                                    </DataTemplate>
                                </Setter.Value>
                            </Setter>
                            <Setter Property="Visibility" Value="Visible" />
                        </DataTrigger>
                        <DataTrigger Binding="{Binding SelectedMeshFormat}" Value="{x:Static c4pMeshes:EMeshFormat.ActorX}">
                            <Setter Property="ContentTemplate">
                                <Setter.Value>
                                    <DataTemplate>
                                        <TextBlock>
                                            <Run Text="Importers (Blender): " />
                                            <Hyperlink NavigateUri="https://github.com/DarklightGames/io_scene_psk_psa">github.com/DarklightGames/io_scene_psk_psa</Hyperlink>
                                        </TextBlock>
                                    </DataTemplate>
                                </Setter.Value>
                            </Setter>
                            <Setter Property="Visibility" Value="Visible" />
                        </DataTrigger>
                    </Style.Triggers>
                </Style>
            </ContentControl.Style>
        </ContentControl>

        <TextBlock Grid.Row="5" Grid.Column="0" Text="Mesh Quality" VerticalAlignment="Center" Margin="0 0 0 5" />
        <ComboBox Grid.Row="5" Grid.Column="2" Grid.ColumnSpan="3" Margin="0 0 0 5"
                  ItemsSource="{Binding MeshQualities}"
                  SelectedItem="{Binding SelectedMeshQuality, Mode=TwoWay}">
            <ComboBox.ItemTemplate>
                <DataTemplate>
                    <TextBlock Text="{Binding Converter={x:Static converters:EnumToStringConverter.Instance}}" />
                </DataTemplate>
            </ComboBox.ItemTemplate>
        </ComboBox>

        <TextBlock Grid.Row="6" Grid.Column="0" Text="Socket Format" VerticalAlignment="Center" Margin="0 0 0 5"
                   IsEnabled="{Binding SocketSettingsEnabled}" />
        <ComboBox Grid.Row="6" Grid.Column="2" Grid.ColumnSpan="3" Margin="0 0 0 5"
                  ItemsSource="{Binding SocketFormats}"
                  SelectedItem="{Binding SelectedSocketFormat, Mode=TwoWay}"
                  IsEnabled="{Binding SocketSettingsEnabled}">
            <ComboBox.ItemTemplate>
                <DataTemplate>
                    <TextBlock Text="{Binding Converter={x:Static converters:EnumToStringConverter.Instance}}" />
                </DataTemplate>
            </ComboBox.ItemTemplate>
        </ComboBox>

        <TextBlock Grid.Row="7" Grid.Column="0" Text="Compression Format" VerticalAlignment="Center" Margin="0 0 0 5"
                   IsEnabled="{Binding CompressionSettingsEnabled}" />
        <ComboBox Grid.Row="7" Grid.Column="2" Grid.ColumnSpan="3" Margin="0 0 0 5"
                  ItemsSource="{Binding CompressionFormats}"
                  SelectedItem="{Binding SelectedCompressionFormat, Mode=TwoWay}"
                  IsEnabled="{Binding CompressionSettingsEnabled}">
            <ComboBox.ItemTemplate>
                <DataTemplate>
                    <TextBlock Text="{Binding Converter={x:Static converters:EnumToStringConverter.Instance}}" />
                </DataTemplate>
            </ComboBox.ItemTemplate>
        </ComboBox>

        <TextBlock Grid.Row="8" Grid.Column="0" Text="Nanite Format" VerticalAlignment="Center" Margin="0 0 0 5" />
        <ComboBox Grid.Row="8" Grid.Column="2" Grid.ColumnSpan="3" Margin="0 0 0 5"
                  ItemsSource="{Binding NaniteMeshFormats}"
                  SelectedItem="{Binding SelectedNaniteMeshFormat, Mode=TwoWay}">
            <ComboBox.ItemTemplate>
                <DataTemplate>
                    <TextBlock Text="{Binding Converter={x:Static converters:EnumToStringConverter.Instance}}" />
                </DataTemplate>
            </ComboBox.ItemTemplate>
        </ComboBox>

        <Border Grid.Row="9" Grid.Column="0" Grid.ColumnSpan="5" Margin="0 10 0 5" CornerRadius="1"
                Background="#1AFFA726" BorderBrush="#FFA726" BorderThickness="1" Padding="10"
                Visibility="{Binding ShowNaniteWarning, Converter={StaticResource BoolToVisibilityConverter}}">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="Auto" />
                </Grid.ColumnDefinitions>

                <Viewbox Grid.Column="0" Height="{Binding Height, RelativeSource={RelativeSource AncestorType=Border}}"
                         Margin="0 0 10 0" VerticalAlignment="Center">
                    <Canvas Width="24" Height="24">
                        <Path Fill="#FFA726" Data="{StaticResource WarningIcon}" />
                    </Canvas>
                </Viewbox>
                <TextBlock Grid.Column="1" TextWrapping="Wrap" Foreground="#FFA726">
                    <Run FontWeight="Bold" Text="Nanite meshes are slower to export" />
                    <LineBreak />
                    <Run Text="It is not recommended for world exports, as this stacks up for every mesh in the level." />
                </TextBlock>
                <Viewbox Grid.Column="2" Height="{Binding Height, RelativeSource={RelativeSource AncestorType=Border}}"
                         Margin="10 0 0 0" VerticalAlignment="Center">
                    <Canvas Width="24" Height="24">
                        <Path Fill="#FFA726" Data="{StaticResource WarningIcon}" />
                    </Canvas>
                </Viewbox>
            </Grid>
        </Border>

        <Separator Grid.Row="10" Grid.Column="0" Grid.ColumnSpan="5" Style="{StaticResource CustomSeparator}" Tag="TEXTURE" Margin="0 10 0 10" />

        <TextBlock Grid.Row="11" Grid.Column="0" Text="Texture Format" VerticalAlignment="Center" Margin="0 0 0 5"
                   IsEnabled="{Binding TextureFormatsEnabled}" />
        <ComboBox Grid.Row="11" Grid.Column="2" Grid.ColumnSpan="3" Margin="0 0 0 5"
                  ItemsSource="{Binding TextureFormats}"
                  SelectedItem="{Binding SelectedTextureFormat, Mode=TwoWay}"
                  IsEnabled="{Binding TextureFormatsEnabled}">
            <ComboBox.ItemTemplate>
                <DataTemplate>
                    <TextBlock Text="{Binding Converter={x:Static converters:EnumToStringConverter.Instance}}" />
                </DataTemplate>
            </ComboBox.ItemTemplate>
        </ComboBox>

        <TextBlock Grid.Row="12" Grid.Column="0" Text="Texture Platform" VerticalAlignment="Center" Margin="0 0 0 10" />
        <ComboBox Grid.Row="12" Grid.Column="2" Grid.ColumnSpan="3" Margin="0 0 0 10"
                  ItemsSource="{Binding TexturePlatforms}"
                  SelectedItem="{Binding SelectedTexturePlatform, Mode=TwoWay}">
            <ComboBox.ItemTemplate>
                <DataTemplate>
                    <TextBlock Text="{Binding Converter={x:Static converters:EnumToStringConverter.Instance}}" />
                </DataTemplate>
            </ComboBox.ItemTemplate>
        </ComboBox>

        <TextBlock Grid.Row="13" Grid.Column="0" Text="Texture Quality" VerticalAlignment="Center" Margin="0 0 0 12" />
        <Slider Grid.Row="13" Grid.Column="2" Grid.ColumnSpan="3" Minimum="1" Maximum="100" TickPlacement="None"
                AutoToolTipPlacement="BottomRight" IsMoveToPointEnabled="True" IsSnapToTickEnabled="True" Margin="0 0 0 12"
                Value="{Binding TextureQuality, Mode=TwoWay}" />

        <TextBlock Grid.Row="14" Grid.Column="0" Text="Save HDR as .hdr" VerticalAlignment="Center" Margin="0 0 0 12" />
        <CheckBox Grid.Row="14" Grid.Column="2" Grid.ColumnSpan="3"
                  IsChecked="{Binding ExportHdrTexturesAsHdr, Mode=TwoWay}"
                  Content="{Binding IsChecked, RelativeSource={RelativeSource Self}, Converter={x:Static converters:BoolToToggleConverter.Instance}}"
                  Style="{DynamicResource {x:Static adonisUi:Styles.ToggleSwitch}}"
                  Margin="0 0 0 12" />

        <TextBlock Grid.Row="15"
                   Grid.Column="0"
                   Text="Export All Mips"
                   VerticalAlignment="Center" />
        <CheckBox Grid.Row="15"
                  Grid.Column="2"
                  Grid.ColumnSpan="3"
                  IsChecked="{Binding ExportAllTextureMips, Mode=TwoWay}"
                  Content="{Binding IsChecked, RelativeSource={RelativeSource Self}, Converter={x:Static converters:BoolToToggleConverter.Instance}}"
                  Style="{DynamicResource {x:Static adonisUi:Styles.ToggleSwitch}}" />

        <Separator Grid.Row="16" Grid.Column="0" Grid.ColumnSpan="5" Style="{StaticResource CustomSeparator}" Tag="MATERIAL &amp; MORPH" Margin="0 10 0 10" />

        <TextBlock Grid.Row="17" Grid.Column="0" Text="Material Depth" VerticalAlignment="Center" Margin="0 0 0 12" />
        <ComboBox Grid.Row="17" Grid.Column="2" Grid.ColumnSpan="3" Margin="0 0 0 12"
                  ItemsSource="{Binding MaterialDepths}"
                  SelectedItem="{Binding SelectedMaterialDepth, Mode=TwoWay}">
            <ComboBox.ItemTemplate>
                <DataTemplate>
                    <TextBlock Text="{Binding Converter={x:Static converters:EnumToStringConverter.Instance}}" />
                </DataTemplate>
            </ComboBox.ItemTemplate>
        </ComboBox>

        <TextBlock Grid.Row="18" Grid.Column="0" Text="Auto-Export Attached Materials" VerticalAlignment="Center" Margin="0 0 0 15"
                   ToolTip="When exporting a mesh, also find and export its attached materials." />
        <Grid Grid.Row="18" Grid.Column="2" Grid.ColumnSpan="3" Margin="0 0 0 15">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>

            <CheckBox Grid.Column="0"
                      IsChecked="{Binding ExportMaterials, Mode=TwoWay}"
                      Content="{Binding IsChecked, RelativeSource={RelativeSource Self}, Converter={x:Static converters:BoolToToggleConverter.Instance}}"
                      Style="{DynamicResource {x:Static adonisUi:Styles.ToggleSwitch}}" />
            <TextBlock Grid.Column="1" VerticalAlignment="Center" Margin="5 0 0 0" FontSize="11"
                       Foreground="{DynamicResource {x:Static adonisUi:Brushes.DisabledForegroundBrush}}"
                       Text="For geometry-only exports, it can be significantly faster to disable this option." />
        </Grid>

        <TextBlock Grid.Row="19" Grid.Column="0" Text="Export Morph Targets" VerticalAlignment="Center" Margin="0 0 0 15" />
        <CheckBox Grid.Row="19" Grid.Column="2" Grid.ColumnSpan="3" Margin="0 0 0 15"
                  IsChecked="{Binding ExportMorphTargets, Mode=TwoWay}"
                  Content="{Binding IsChecked, RelativeSource={RelativeSource Self}, Converter={x:Static converters:BoolToToggleConverter.Instance}}"
                  Style="{DynamicResource {x:Static adonisUi:Styles.ToggleSwitch}}" />
    </Grid>
</UserControl>

