reworked right click commands

This commit is contained in:
iAmAsval 2021-08-30 20:49:54 +02:00
parent 35a8e4c71d
commit 14cc7e20c1
9 changed files with 134 additions and 149 deletions

View File

@ -486,7 +486,13 @@
<ListBox Grid.Row="1" x:Name="AssetsListName" Style="{StaticResource AssetsListBox}" PreviewMouseDoubleClick="OnAssetsListMouseDoubleClick">
<ListBox.ContextMenu>
<ContextMenu DataContext="{Binding PlacementTarget, RelativeSource={RelativeSource Self}}">
<MenuItem Header="Extract in New Tab" Command="{Binding DataContext.ExtractNewTabCommand}" CommandParameter="{Binding SelectedItems}">
<MenuItem Header="Extract in New Tab" Command="{Binding DataContext.RightClickMenuCommand}">
<MenuItem.CommandParameter>
<MultiBinding Converter="{x:Static converters:MultiParameterConverter.Instance}">
<Binding Source="Assets_Extract_New_Tab" />
<Binding Path="SelectedItems" />
</MultiBinding>
</MenuItem.CommandParameter>
<MenuItem.Icon>
<Viewbox Width="16" Height="16">
<Canvas Width="24" Height="24">
@ -495,7 +501,13 @@
</Viewbox>
</MenuItem.Icon>
</MenuItem>
<MenuItem Header="Export Data" Command="{Binding DataContext.ExportDataCommand}" CommandParameter="{Binding SelectedItems}">
<MenuItem Header="Export Data" Command="{Binding DataContext.RightClickMenuCommand}">
<MenuItem.CommandParameter>
<MultiBinding Converter="{x:Static converters:MultiParameterConverter.Instance}">
<Binding Source="Assets_Export_Data" />
<Binding Path="SelectedItems" />
</MultiBinding>
</MenuItem.CommandParameter>
<MenuItem.Icon>
<Viewbox Width="16" Height="16">
<Canvas Width="24" Height="24">
@ -504,7 +516,13 @@
</Viewbox>
</MenuItem.Icon>
</MenuItem>
<MenuItem Header="Save Properties" Command="{Binding DataContext.SavePropertyCommand}" CommandParameter="{Binding SelectedItems}">
<MenuItem Header="Save Properties" Command="{Binding DataContext.RightClickMenuCommand}">
<MenuItem.CommandParameter>
<MultiBinding Converter="{x:Static converters:MultiParameterConverter.Instance}">
<Binding Source="Assets_Save_Properties" />
<Binding Path="SelectedItems" />
</MultiBinding>
</MenuItem.CommandParameter>
<MenuItem.Icon>
<Viewbox Width="16" Height="16">
<Canvas Width="24" Height="24">
@ -513,7 +531,13 @@
</Viewbox>
</MenuItem.Icon>
</MenuItem>
<MenuItem Header="Save Texture" Command="{Binding DataContext.SaveTextureCommand}" CommandParameter="{Binding SelectedItems}">
<MenuItem Header="Save Texture" Command="{Binding DataContext.RightClickMenuCommand}">
<MenuItem.CommandParameter>
<MultiBinding Converter="{x:Static converters:MultiParameterConverter.Instance}">
<Binding Source="Assets_Save_Texture" />
<Binding Path="SelectedItems" />
</MultiBinding>
</MenuItem.CommandParameter>
<MenuItem.Icon>
<Viewbox Width="16" Height="16">
<Canvas Width="24" Height="24">
@ -522,6 +546,36 @@
</Viewbox>
</MenuItem.Icon>
</MenuItem>
<!-- <MenuItem Header="Save Material" Command="{Binding DataContext.RightClickMenuCommand}"> -->
<!-- <MenuItem.CommandParameter> -->
<!-- <MultiBinding Converter="{x:Static converters:MultiParameterConverter.Instance}"> -->
<!-- <Binding Source="Assets_Save_Material" /> -->
<!-- <Binding Path="SelectedItems" /> -->
<!-- </MultiBinding> -->
<!-- </MenuItem.CommandParameter> -->
<!-- <MenuItem.Icon> -->
<!-- <Viewbox Width="16" Height="16"> -->
<!-- <Canvas Width="24" Height="24"> -->
<!-- <Path Fill="{DynamicResource {x:Static adonisUi:Brushes.ForegroundBrush}}" Data="{StaticResource MaterialIcon}" /> -->
<!-- </Canvas> -->
<!-- </Viewbox> -->
<!-- </MenuItem.Icon> -->
<!-- </MenuItem> -->
<!-- <MenuItem Header="Save Mesh" Command="{Binding DataContext.RightClickMenuCommand}"> -->
<!-- <MenuItem.CommandParameter> -->
<!-- <MultiBinding Converter="{x:Static converters:MultiParameterConverter.Instance}"> -->
<!-- <Binding Source="Assets_Save_Mesh" /> -->
<!-- <Binding Path="SelectedItems" /> -->
<!-- </MultiBinding> -->
<!-- </MenuItem.CommandParameter> -->
<!-- <MenuItem.Icon> -->
<!-- <Viewbox Width="16" Height="16"> -->
<!-- <Canvas Width="24" Height="24"> -->
<!-- <Path Fill="{DynamicResource {x:Static adonisUi:Brushes.ForegroundBrush}}" Data="{StaticResource MeshIcon}" /> -->
<!-- </Canvas> -->
<!-- </Viewbox> -->
<!-- </MenuItem.Icon> -->
<!-- </MenuItem> -->
<Separator />
<MenuItem Header="Copy">
<MenuItem.Icon>

View File

@ -47,19 +47,13 @@ namespace FModel.ViewModels
IsReady = Status != EStatusKind.Loading && Status != EStatusKind.Stopping;
}
}
private MenuCommand _menuCommand;
public ExtractNewTabCommand ExtractNewTabCommand => _extractNewTabCommand ??= new ExtractNewTabCommand(this);
private ExtractNewTabCommand _extractNewTabCommand;
public RightClickMenuCommand RightClickMenuCommand => _rightClickMenuCommand ??= new RightClickMenuCommand(this);
private RightClickMenuCommand _rightClickMenuCommand;
public MenuCommand MenuCommand => _menuCommand ??= new MenuCommand(this);
private ExportDataCommand _exportDataCommand;
public ExportDataCommand ExportDataCommand => _exportDataCommand ??= new ExportDataCommand(this);
private SavePropertyCommand _savePropertyCommand;
public SavePropertyCommand SavePropertyCommand => _savePropertyCommand ??= new SavePropertyCommand(this);
private SaveTextureCommand _saveTextureCommand;
public SaveTextureCommand SaveTextureCommand => _saveTextureCommand ??= new SaveTextureCommand(this);
private CopyCommand _copyCommand;
private MenuCommand _menuCommand;
public CopyCommand CopyCommand => _copyCommand ??= new CopyCommand(this);
private CopyCommand _copyCommand;
public string TitleExtra => $"{CUE4Parse.Game.GetDescription()} ({UserSettings.Default.OverridedGame[CUE4Parse.Game]}){(Build != EBuildKind.Release ? $" ({Build})" : "")}";
public LoadingModesViewModel LoadingModes { get; }

View File

@ -1,32 +0,0 @@
using System.Collections;
using System.Linq;
using FModel.Framework;
using FModel.Services;
namespace FModel.ViewModels.Commands
{
public class ExportDataCommand : ViewModelCommand<ApplicationViewModel>
{
private ThreadWorkerViewModel _threadWorkerView => ApplicationService.ThreadWorkerView;
public ExportDataCommand(ApplicationViewModel contextViewModel) : base(contextViewModel)
{
}
public override async void Execute(ApplicationViewModel contextViewModel, object parameter)
{
if (parameter == null) return;
var assetItems = ((IList) parameter).Cast<AssetItem>().ToArray();
if (!assetItems.Any()) return;
await _threadWorkerView.Begin(_ =>
{
foreach (var asset in assetItems)
{
contextViewModel.CUE4Parse.ExportData(asset.FullPath);
}
});
}
}
}

View File

@ -1,33 +0,0 @@
using System.Collections;
using System.Linq;
using FModel.Framework;
using FModel.Services;
namespace FModel.ViewModels.Commands
{
public class ExtractNewTabCommand : ViewModelCommand<ApplicationViewModel>
{
private ThreadWorkerViewModel _threadWorkerView => ApplicationService.ThreadWorkerView;
public ExtractNewTabCommand(ApplicationViewModel contextViewModel) : base(contextViewModel)
{
}
public override async void Execute(ApplicationViewModel contextViewModel, object parameter)
{
if (parameter == null) return;
var assetItems = ((IList) parameter).Cast<AssetItem>().ToArray();
if (!assetItems.Any()) return;
await _threadWorkerView.Begin(cancellationToken =>
{
foreach (var asset in assetItems)
{
cancellationToken.ThrowIfCancellationRequested();
contextViewModel.CUE4Parse.Extract(asset.FullPath, true);
}
});
}
}
}

View File

@ -0,0 +1,66 @@
using System.Collections;
using System.Linq;
using FModel.Framework;
using FModel.Services;
namespace FModel.ViewModels.Commands
{
public class RightClickMenuCommand : ViewModelCommand<ApplicationViewModel>
{
private ThreadWorkerViewModel _threadWorkerView => ApplicationService.ThreadWorkerView;
public RightClickMenuCommand(ApplicationViewModel contextViewModel) : base(contextViewModel)
{
}
public override async void Execute(ApplicationViewModel contextViewModel, object parameter)
{
if (parameter is not object[] parameters || parameters[0] is not string trigger)
return;
var assetItems = ((IList) parameters[1]).Cast<AssetItem>().ToArray();
if (!assetItems.Any()) return;
await _threadWorkerView.Begin(cancellationToken =>
{
switch (trigger)
{
case "Assets_Extract_New_Tab":
foreach (var asset in assetItems)
{
cancellationToken.ThrowIfCancellationRequested();
contextViewModel.CUE4Parse.Extract(asset.FullPath, true);
}
break;
case "Assets_Export_Data":
foreach (var asset in assetItems)
{
cancellationToken.ThrowIfCancellationRequested();
contextViewModel.CUE4Parse.ExportData(asset.FullPath);
}
break;
case "Assets_Save_Properties":
foreach (var asset in assetItems)
{
cancellationToken.ThrowIfCancellationRequested();
contextViewModel.CUE4Parse.Extract(asset.FullPath);
contextViewModel.CUE4Parse.TabControl.SelectedTab.SaveProperty(false);
}
break;
case "Assets_Save_Texture":
foreach (var asset in assetItems)
{
cancellationToken.ThrowIfCancellationRequested();
contextViewModel.CUE4Parse.Extract(asset.FullPath);
contextViewModel.CUE4Parse.TabControl.SelectedTab.SaveImage(false);
}
break;
// case "Assets_Save_Material":
// break;
// case "Assets_Save_Mesh":
// break;
}
});
}
}
}

View File

@ -1,33 +0,0 @@
using System.Collections;
using System.Linq;
using FModel.Framework;
using FModel.Services;
namespace FModel.ViewModels.Commands
{
public class SavePropertyCommand : ViewModelCommand<ApplicationViewModel>
{
private ThreadWorkerViewModel _threadWorkerView => ApplicationService.ThreadWorkerView;
public SavePropertyCommand(ApplicationViewModel contextViewModel) : base(contextViewModel)
{
}
public override async void Execute(ApplicationViewModel contextViewModel, object parameter)
{
if (parameter == null) return;
var assetItems = ((IList) parameter).Cast<AssetItem>().ToArray();
if (!assetItems.Any()) return;
await _threadWorkerView.Begin(_ =>
{
foreach (var asset in assetItems)
{
contextViewModel.CUE4Parse.Extract(asset.FullPath);
contextViewModel.CUE4Parse.TabControl.SelectedTab.SaveProperty(false);
}
});
}
}
}

View File

@ -1,33 +0,0 @@
using System.Collections;
using System.Linq;
using FModel.Framework;
using FModel.Services;
namespace FModel.ViewModels.Commands
{
public class SaveTextureCommand : ViewModelCommand<ApplicationViewModel>
{
private ThreadWorkerViewModel _threadWorkerView => ApplicationService.ThreadWorkerView;
public SaveTextureCommand(ApplicationViewModel contextViewModel) : base(contextViewModel)
{
}
public override async void Execute(ApplicationViewModel contextViewModel, object parameter)
{
if (parameter == null) return;
var assetItems = ((IList) parameter).Cast<AssetItem>().ToArray();
if (!assetItems.Any()) return;
await _threadWorkerView.Begin(_ =>
{
foreach (var asset in assetItems)
{
contextViewModel.CUE4Parse.Extract(asset.FullPath);
contextViewModel.CUE4Parse.TabControl.SelectedTab.SaveImage(false);
}
});
}
}
}

View File

@ -63,6 +63,8 @@
<Geometry x:Key="FoldIcon">M8.12 19.3c.39.39 1.02.39 1.41 0L12 16.83l2.47 2.47c.39.39 1.02.39 1.41 0 .39-.39.39-1.02 0-1.41l-3.17-3.17c-.39-.39-1.02-.39-1.41 0l-3.17 3.17c-.4.38-.4 1.02-.01 1.41zm7.76-14.6c-.39-.39-1.02-.39-1.41 0L12 7.17 9.53 4.7c-.39-.39-1.02-.39-1.41 0-.39.39-.39 1.03 0 1.42l3.17 3.17c.39.39 1.02.39 1.41 0l3.17-3.17c.4-.39.4-1.03.01-1.42z</Geometry>
<Geometry x:Key="UnfoldIcon">M12 5.83l2.46 2.46c.39.39 1.02.39 1.41 0 .39-.39.39-1.02 0-1.41L12.7 3.7c-.39-.39-1.02-.39-1.41 0L8.12 6.88c-.39.39-.39 1.02 0 1.41.39.39 1.02.39 1.41 0L12 5.83zm0 12.34l-2.46-2.46c-.39-.39-1.02-.39-1.41 0-.39.39-.39 1.02 0 1.41l3.17 3.18c.39.39 1.02.39 1.41 0l3.17-3.17c.39-.39.39-1.02 0-1.41-.39-.39-1.02-.39-1.41 0L12 18.17z</Geometry>
<Geometry x:Key="LocateMeIcon">M11.71,17.99C8.53,17.84,6,15.22,6,12c0-3.31,2.69-6,6-6c3.22,0,5.84,2.53,5.99,5.71l-2.1-0.63C15.48,9.31,13.89,8,12,8 c-2.21,0-4,1.79-4,4c0,1.89,1.31,3.48,3.08,3.89L11.71,17.99z M22,12c0,0.3-0.01,0.6-0.04,0.9l-1.97-0.59C20,12.21,20,12.1,20,12 c0-4.42-3.58-8-8-8s-8,3.58-8,8s3.58,8,8,8c0.1,0,0.21,0,0.31-0.01l0.59,1.97C12.6,21.99,12.3,22,12,22C6.48,22,2,17.52,2,12 C2,6.48,6.48,2,12,2S22,6.48,22,12z M18.23,16.26l2.27-0.76c0.46-0.15,0.45-0.81-0.01-0.95l-7.6-2.28 c-0.38-0.11-0.74,0.24-0.62,0.62l2.28,7.6c0.14,0.47,0.8,0.48,0.95,0.01l0.76-2.27l3.91,3.91c0.2,0.2,0.51,0.2,0.71,0l1.27-1.27 c0.2-0.2,0.2-0.51,0-0.71L18.23,16.26z</Geometry>
<Geometry x:Key="MeshIcon">M12 2c1.1 0 2 .9 2 2s-.9 2-2 2-2-.9-2-2 .9-2 2-2zm8 7h-5v12c0 .55-.45 1-1 1s-1-.45-1-1v-5h-2v5c0 .55-.45 1-1 1s-1-.45-1-1V9H4c-.55 0-1-.45-1-1s.45-1 1-1h16c.55 0 1 .45 1 1s-.45 1-1 1z</Geometry>
<Geometry x:Key="MaterialIcon">M11 9h2v2h-2V9zm-2 2h2v2H9v-2zm4 0h2v2h-2v-2zm2-2h2v2h-2V9zM7 9h2v2H7V9zm12-6H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM9 18H7v-2h2v2zm4 0h-2v-2h2v2zm4 0h-2v-2h2v2zm2-7h-2v2h2v2h-2v-2h-2v2h-2v-2h-2v2H9v-2H7v2H5v-2h2v-2H5V6c0-.55.45-1 1-1h12c.55 0 1 .45 1 1v5z</Geometry>
<Style x:Key="TabItemFillSpace" TargetType="TabItem" BasedOn="{StaticResource {x:Type TabItem}}">
<Setter Property="Width">

View File

@ -270,7 +270,7 @@
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<TextBlock Grid.Row="0" Grid.Column="0" Text="Mesh Export Format" VerticalAlignment="Center" Margin="0 0 0 5" />
<TextBlock Grid.Row="0" Grid.Column="0" Text="Mesh Format" VerticalAlignment="Center" Margin="0 0 0 5" />
<ComboBox Grid.Row="0" Grid.Column="2" ItemsSource="{Binding SettingsView.MeshExportFormats}" SelectedItem="{Binding SettingsView.SelectedMeshExportFormat, Mode=TwoWay}"
DataContext="{Binding DataContext, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:Views.SettingsView}}}" Margin="0 0 0 5">
<ComboBox.ItemTemplate>
@ -280,7 +280,7 @@
</ComboBox.ItemTemplate>
</ComboBox>
<TextBlock Grid.Row="1" Grid.Column="0" Text="Level Of Detail Export Format" VerticalAlignment="Center" Margin="0 0 0 5" />
<TextBlock Grid.Row="1" Grid.Column="0" Text="Level Of Detail Format" VerticalAlignment="Center" Margin="0 0 0 5" />
<ComboBox Grid.Row="1" Grid.Column="2" ItemsSource="{Binding SettingsView.LodExportFormats}" SelectedItem="{Binding SettingsView.SelectedLodExportFormat, Mode=TwoWay}"
DataContext="{Binding DataContext, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:Views.SettingsView}}}" Margin="0 0 0 5">
<ComboBox.ItemTemplate>
@ -290,7 +290,7 @@
</ComboBox.ItemTemplate>
</ComboBox>
<TextBlock Grid.Row="2" Grid.Column="0" Text="Texture Export Format" VerticalAlignment="Center" Margin="0 0 0 5" />
<TextBlock Grid.Row="2" Grid.Column="0" Text="Texture Format" VerticalAlignment="Center" Margin="0 0 0 5" />
<ComboBox Grid.Row="2" Grid.Column="2" ItemsSource="{Binding SettingsView.TextureExportFormats}" SelectedItem="{Binding SettingsView.SelectedTextureExportFormat, Mode=TwoWay}"
DataContext="{Binding DataContext, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:Views.SettingsView}}}" Margin="0 0 0 5">
<ComboBox.ItemTemplate>