mirror of
https://github.com/4sval/FModel.git
synced 2026-12-04 23:02:22 -06:00
Mesh Preview Feature (#727)
Some checks failed
FModel QA Builder / build (push) Has been cancelled
Some checks failed
FModel QA Builder / build (push) Has been cancelled
For lower end PCs it's recommended to use on-hover preview option Co-authored-by: Asval <asval.contactme@gmail.com>
This commit is contained in:
Submodule CUE4Parse updated: c95dd9b587...099b91b3b6
@@ -142,6 +142,7 @@ public enum EAssetCategory : uint
|
||||
MaterialFunction = Materials + 3,
|
||||
MaterialFunctionEditorData = Materials + 4,
|
||||
MaterialParameterCollection = Materials + 5,
|
||||
PhysicalMaterial = Materials + 6,
|
||||
Animation = AssetCategoryExtensions.CategoryBase + (5 << 16),
|
||||
Skeleton = Animation + 1,
|
||||
Rig = Animation + 2,
|
||||
@@ -155,8 +156,7 @@ public enum EAssetCategory : uint
|
||||
CurveBase = Data + 2,
|
||||
PhysicsAsset = Data + 3,
|
||||
ObjectRedirector = Data + 4,
|
||||
PhysicalMaterial = Data + 5,
|
||||
ByteCode = Data + 6,
|
||||
ByteCode = Data + 5,
|
||||
Media = AssetCategoryExtensions.CategoryBase + (8 << 16),
|
||||
Audio = Media + 1,
|
||||
Video = Media + 2,
|
||||
@@ -199,3 +199,10 @@ public enum EExplorerViewMode
|
||||
Grid,
|
||||
List
|
||||
}
|
||||
|
||||
public enum EExplorerPreviewMode
|
||||
{
|
||||
None,
|
||||
MeshesOnHover,
|
||||
All
|
||||
}
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using CUE4Parse.UE4.Assets.Exports;
|
||||
using Editor;
|
||||
using FModel.Views.Resources.Controls;
|
||||
using OpenTK.Windowing.Desktop;
|
||||
using Serilog;
|
||||
using Serilog.Context;
|
||||
using Snooper.Rendering;
|
||||
|
||||
namespace FModel.Framework;
|
||||
|
||||
@@ -17,13 +21,17 @@ namespace FModel.Framework;
|
||||
/// dying: GLFW and the GL driver keep per-thread state there. So the thread Snooper is created on never dies until
|
||||
/// FModel itself closes, it just loops back to waiting for the next window to build.
|
||||
/// </summary>
|
||||
public sealed class SnooperHost(Func<EditorWindow> build, Action<Exception> onStartupFailure) : IDisposable
|
||||
public sealed class SnooperHost(Func<EditorWindow> build, Action<Exception> onStartupFailure, int previewResolution) : IDisposable
|
||||
{
|
||||
private readonly Lock _lock = new();
|
||||
private readonly SemaphoreSlim _wanted = new(0);
|
||||
private readonly AutoResetEvent _wanted = new(false);
|
||||
private readonly ManualResetEventSlim _ready = new();
|
||||
private readonly ConcurrentQueue<Action> _renderRequests = new();
|
||||
private readonly MeshPreviewRenderer _meshPreviews = new(previewResolution);
|
||||
|
||||
private volatile EditorWindow? _window;
|
||||
private volatile bool _openRequested;
|
||||
private volatile bool _meshPreviewsUnavailable;
|
||||
private Exception? _failure;
|
||||
private Thread? _thread;
|
||||
|
||||
@@ -36,7 +44,8 @@ public sealed class SnooperHost(Func<EditorWindow> build, Action<Exception> onSt
|
||||
|
||||
_thread ??= StartThread();
|
||||
_ready.Reset();
|
||||
_wanted.Release();
|
||||
_openRequested = true;
|
||||
_wanted.Set();
|
||||
_ready.Wait();
|
||||
|
||||
if (_window is { } window) return window;
|
||||
@@ -48,6 +57,61 @@ public sealed class SnooperHost(Func<EditorWindow> build, Action<Exception> onSt
|
||||
return null;
|
||||
}
|
||||
|
||||
public byte[] RenderMeshPreview(UObject asset, float screenHeight)
|
||||
{
|
||||
if (!_meshPreviews.IsReady && !_meshPreviewsUnavailable)
|
||||
{
|
||||
var initialized = new TaskCompletionSource();
|
||||
QueueGraphicsWork(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
_meshPreviews.Initialize(loadBindings: _window == null);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
_meshPreviewsUnavailable = true;
|
||||
Log.Warning(exception, "Could not start the Snooper mesh preview context");
|
||||
}
|
||||
finally
|
||||
{
|
||||
initialized.SetResult();
|
||||
}
|
||||
});
|
||||
initialized.Task.Wait();
|
||||
}
|
||||
|
||||
return _meshPreviewsUnavailable ? null : _meshPreviews.Render(asset, screenHeight);
|
||||
}
|
||||
|
||||
public void CloseMeshPreviews()
|
||||
{
|
||||
_meshPreviewsUnavailable = true;
|
||||
if (_thread is not null)
|
||||
QueueGraphicsWork(_meshPreviews.Dispose);
|
||||
}
|
||||
|
||||
private void QueueGraphicsWork(Action action)
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
_thread ??= StartThread();
|
||||
_renderRequests.Enqueue(action);
|
||||
if (_window is { } window)
|
||||
window.Invoke(RunGraphicsWork);
|
||||
else
|
||||
_wanted.Set();
|
||||
}
|
||||
}
|
||||
|
||||
private void RunGraphicsWork()
|
||||
{
|
||||
if (_renderRequests.TryDequeue(out var action))
|
||||
action();
|
||||
if (!_renderRequests.IsEmpty && _window is { } window)
|
||||
window.Invoke(RunGraphicsWork);
|
||||
}
|
||||
|
||||
private Thread StartThread()
|
||||
{
|
||||
// this thread must never die until fmodel closes
|
||||
@@ -66,12 +130,22 @@ public sealed class SnooperHost(Func<EditorWindow> build, Action<Exception> onSt
|
||||
|
||||
while (true)
|
||||
{
|
||||
_wanted.Wait();
|
||||
if (!_openRequested && _renderRequests.IsEmpty)
|
||||
_wanted.WaitOne();
|
||||
|
||||
if (!_openRequested)
|
||||
{
|
||||
RunGraphicsWork();
|
||||
continue;
|
||||
}
|
||||
_openRequested = false;
|
||||
|
||||
try
|
||||
{
|
||||
_failure = null;
|
||||
_window = build();
|
||||
if (!_renderRequests.IsEmpty)
|
||||
_window.Invoke(RunGraphicsWork);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
||||
@@ -75,12 +75,7 @@
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Grid Grid.Row="0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Menu Grid.Column="0">
|
||||
<Menu>
|
||||
<MenuItem Header="Directory">
|
||||
<MenuItem Header="Selector" Command="{Binding MenuCommand}" CommandParameter="Directory_Selector">
|
||||
<MenuItem.Icon>
|
||||
@@ -234,18 +229,6 @@
|
||||
</MenuItem>
|
||||
</MenuItem>
|
||||
</Menu>
|
||||
|
||||
<Grid Grid.Column="1">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<TextBlock Grid.Column="0" Text="Preview New Explorer System" VerticalAlignment="Center" />
|
||||
<CheckBox Grid.Column="1" Margin="5 2 5 0" Unchecked="FeaturePreviewOnUnchecked" KeyboardNavigation.TabNavigation="None" KeyboardNavigation.ControlTabNavigation="None"
|
||||
IsChecked="{Binding FeaturePreviewNewAssetExplorer, Source={x:Static settings:UserSettings.Default}, Mode=TwoWay}"
|
||||
Style="{DynamicResource {x:Static adonisUi:Styles.ToggleSwitch}}"/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
||||
<Grid x:Name="RootGrid" Grid.Row="2">
|
||||
@@ -555,6 +538,59 @@
|
||||
Stretch="Uniform"
|
||||
Fill="{DynamicResource {x:Static adonisUi:Brushes.ForegroundBrush}}" />
|
||||
</ToggleButton>
|
||||
<ToggleButton Style="{StaticResource ExplorerViewToggleButton}"
|
||||
Margin="5,0,0,0"
|
||||
ToolTip="No Thumbnails"
|
||||
IsChecked="{Binding ExplorerPreviewMode,
|
||||
Source={x:Static local:Settings.UserSettings.Default},
|
||||
Converter={x:Static converters:EnumToBoolConverter.Instance},
|
||||
ConverterParameter={x:Static local:EExplorerPreviewMode.None},
|
||||
Mode=TwoWay}">
|
||||
<Path Data="{StaticResource AssetIcon}"
|
||||
Width="14"
|
||||
Height="14"
|
||||
Stretch="Uniform"
|
||||
Fill="{DynamicResource {x:Static adonisUi:Brushes.ForegroundBrush}}" />
|
||||
</ToggleButton>
|
||||
<ToggleButton Style="{StaticResource ExplorerViewToggleButton}"
|
||||
ToolTip="Mesh Thumbnails On Hover"
|
||||
IsChecked="{Binding ExplorerPreviewMode,
|
||||
Source={x:Static local:Settings.UserSettings.Default},
|
||||
Converter={x:Static converters:EnumToBoolConverter.Instance},
|
||||
ConverterParameter={x:Static local:EExplorerPreviewMode.MeshesOnHover},
|
||||
Mode=TwoWay}">
|
||||
<Path Data="{StaticResource CursorIcon}"
|
||||
Width="14"
|
||||
Height="14"
|
||||
Stretch="Uniform"
|
||||
Fill="{DynamicResource {x:Static adonisUi:Brushes.ForegroundBrush}}" />
|
||||
</ToggleButton>
|
||||
<ToggleButton Style="{StaticResource ExplorerViewToggleButton}"
|
||||
ToolTip="All Thumbnails"
|
||||
IsChecked="{Binding ExplorerPreviewMode,
|
||||
Source={x:Static local:Settings.UserSettings.Default},
|
||||
Converter={x:Static converters:EnumToBoolConverter.Instance},
|
||||
ConverterParameter={x:Static local:EExplorerPreviewMode.All},
|
||||
Mode=TwoWay}">
|
||||
<Path Data="{StaticResource TextureIconAlt}"
|
||||
Width="14"
|
||||
Height="14"
|
||||
Stretch="Uniform"
|
||||
Fill="{DynamicResource {x:Static adonisUi:Brushes.ForegroundBrush}}" />
|
||||
</ToggleButton>
|
||||
<ToggleButton Style="{StaticResource ExplorerViewToggleButton}"
|
||||
Margin="5,0,0,0"
|
||||
IsChecked="{Binding IsAssetsExplorerVisible, Converter={x:Static converters:InvertBooleanConverter.Instance}, Mode=TwoWay}">
|
||||
<ToggleButton.ToolTip>
|
||||
<ToolTip Content="{Binding SwitchAssetExplorer, Source={x:Static local:Settings.UserSettings.Default}}"
|
||||
ContentStringFormat="File Properties ({0})" />
|
||||
</ToggleButton.ToolTip>
|
||||
<Path Data="{StaticResource JsonIcon}"
|
||||
Width="14"
|
||||
Height="14"
|
||||
Stretch="Uniform"
|
||||
Fill="{DynamicResource {x:Static adonisUi:Brushes.ForegroundBrush}}" />
|
||||
</ToggleButton>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
|
||||
@@ -609,78 +645,6 @@
|
||||
Visibility="{Binding IsAssetsExplorerVisible, Converter={x:Static converters:InvertBoolToVisibilityConverter.Instance}, ConverterParameter=Hidden}" />
|
||||
</Grid>
|
||||
|
||||
<Border Grid.Row="0"
|
||||
VerticalAlignment="Bottom"
|
||||
HorizontalAlignment="Right"
|
||||
Margin="12,12,20,12"
|
||||
Opacity="0.5"
|
||||
Visibility="{Binding FeaturePreviewNewAssetExplorer, Source={x:Static settings:UserSettings.Default}, Converter={StaticResource BoolToVisibilityConverter}}"
|
||||
Background="{DynamicResource {x:Static adonisUi:Brushes.Layer2BackgroundBrush}}"
|
||||
CornerRadius="8"
|
||||
Padding="4"
|
||||
Effect="{DynamicResource ShadowEffect}">
|
||||
<Border.Triggers>
|
||||
<EventTrigger RoutedEvent="MouseEnter">
|
||||
<BeginStoryboard>
|
||||
<Storyboard>
|
||||
<DoubleAnimation Storyboard.TargetProperty="Opacity"
|
||||
To="1"
|
||||
Duration="0:0:0.2" />
|
||||
</Storyboard>
|
||||
</BeginStoryboard>
|
||||
</EventTrigger>
|
||||
<EventTrigger RoutedEvent="MouseLeave">
|
||||
<BeginStoryboard>
|
||||
<Storyboard>
|
||||
<DoubleAnimation Storyboard.TargetProperty="Opacity"
|
||||
To="0.5"
|
||||
Duration="0:0:0.2" />
|
||||
</Storyboard>
|
||||
</BeginStoryboard>
|
||||
</EventTrigger>
|
||||
</Border.Triggers>
|
||||
<StackPanel Orientation="Horizontal"
|
||||
HorizontalAlignment="Center">
|
||||
<ToggleButton Width="32"
|
||||
Height="32"
|
||||
Cursor="Hand"
|
||||
Margin="0,0,2,0"
|
||||
IsChecked="{Binding IsAssetsExplorerVisible, Mode=TwoWay}"
|
||||
Style="{StaticResource AssetsExplorerToggleButtonStyle}" />
|
||||
<ToggleButton Width="32"
|
||||
Height="32"
|
||||
Cursor="Hand"
|
||||
Checked="OnPreviewTexturesToggled"
|
||||
Focusable="False"
|
||||
IsChecked="{Binding PreviewTexturesAssetExplorer, Source={x:Static settings:UserSettings.Default}, Mode=TwoWay}">
|
||||
<ToggleButton.Style>
|
||||
<Style TargetType="ToggleButton"
|
||||
BasedOn="{StaticResource ModernToggleButtonStyle}">
|
||||
<Setter Property="ToolTip"
|
||||
Value="Preview Textures (OFF)" />
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsChecked"
|
||||
Value="True">
|
||||
<Setter Property="Background"
|
||||
Value="MediumPurple" />
|
||||
<Setter Property="ToolTip"
|
||||
Value="Preview Textures (ON)" />
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</ToggleButton.Style>
|
||||
<Viewbox Width="16"
|
||||
Height="16">
|
||||
<Canvas Width="24"
|
||||
Height="24">
|
||||
<Path Data="{StaticResource TextureIconAlt}"
|
||||
Fill="{DynamicResource {x:Static adonisUi:Brushes.ForegroundBrush}}" />
|
||||
</Canvas>
|
||||
</Viewbox>
|
||||
</ToggleButton>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
<Expander Grid.Row="1" Margin="0 5 0 5" ExpandDirection="Down"
|
||||
IsExpanded="{Binding IsLoggerExpanded, Source={x:Static settings:UserSettings.Default}}">
|
||||
<Grid>
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
@@ -27,6 +26,7 @@ public partial class MainWindow
|
||||
private ThreadWorkerViewModel _threadWorkerView => ApplicationService.ThreadWorkerView;
|
||||
private ApplicationViewModel _applicationView => ApplicationService.ApplicationView;
|
||||
private DiscordHandler _discordHandler => DiscordService.DiscordHandler;
|
||||
private readonly AssetExplorerPreviewResolver _previewResolver;
|
||||
|
||||
public MainWindow()
|
||||
{
|
||||
@@ -34,7 +34,7 @@ public partial class MainWindow
|
||||
CommandBindings.Add(new CommandBinding(ApplicationCommands.Find, (_, _) => OnOpenAvalonFinder()));
|
||||
CommandBindings.Add(new CommandBinding(NavigationCommands.BrowseBack, (_, _) =>
|
||||
{
|
||||
if (UserSettings.Default.FeaturePreviewNewAssetExplorer && !_applicationView.IsAssetsExplorerVisible)
|
||||
if (!_applicationView.IsAssetsExplorerVisible)
|
||||
{
|
||||
// back browsing the json view will reopen the assets explorer
|
||||
_applicationView.IsAssetsExplorerVisible = true;
|
||||
@@ -55,9 +55,8 @@ public partial class MainWindow
|
||||
DataContext = _applicationView;
|
||||
InitializeComponent();
|
||||
|
||||
AssetsExplorer.ItemContainerGenerator.StatusChanged += ItemContainerGenerator_StatusChanged;
|
||||
AssetsListExplorer.ItemContainerGenerator.StatusChanged += ItemContainerGenerator_StatusChanged;
|
||||
AssetsListName.ItemContainerGenerator.StatusChanged += ItemContainerGenerator_StatusChanged;
|
||||
_previewResolver = new AssetExplorerPreviewResolver(_applicationView, AssetsExplorer, AssetsListExplorer, AssetsListName);
|
||||
|
||||
AssetsExplorer.SelectionChanged += (_, e) => SyncSelection(AssetsListName, e);
|
||||
AssetsListExplorer.SelectionChanged += (_, e) => SyncSelection(AssetsListName, e);
|
||||
AssetsListName.SelectionChanged += (_, e) => SyncSelection(AssetsExplorer, e);
|
||||
@@ -83,6 +82,7 @@ public partial class MainWindow
|
||||
|
||||
private void OnClosing(object sender, CancelEventArgs e)
|
||||
{
|
||||
_previewResolver.Dispose();
|
||||
_discordHandler.Dispose();
|
||||
}
|
||||
|
||||
@@ -201,7 +201,7 @@ public partial class MainWindow
|
||||
OnExportHotkey("Save_Audio");
|
||||
else if (_applicationView.Status.IsReady && UserSettings.Default.ExportCode.IsTriggered(e.Key))
|
||||
OnExportHotkey("Save_Code");
|
||||
else if (_applicationView.Status.IsReady && UserSettings.Default.FeaturePreviewNewAssetExplorer && UserSettings.Default.SwitchAssetExplorer.IsTriggered(e.Key))
|
||||
else if (_applicationView.Status.IsReady && UserSettings.Default.SwitchAssetExplorer.IsTriggered(e.Key))
|
||||
_applicationView.IsAssetsExplorerVisible = !_applicationView.IsAssetsExplorerVisible;
|
||||
else if (UserSettings.Default.AssetAddTab.IsTriggered(e.Key))
|
||||
_applicationView.CUE4Parse.TabControl.AddTab();
|
||||
@@ -255,6 +255,7 @@ public partial class MainWindow
|
||||
private async void OnMappingsReload(object sender, ExecutedRoutedEventArgs e)
|
||||
{
|
||||
await _applicationView.CUE4Parse.InitMappings(true);
|
||||
_applicationView.RefreshAssetResolution();
|
||||
}
|
||||
|
||||
private void OnOpenAvalonFinder()
|
||||
@@ -274,28 +275,6 @@ public partial class MainWindow
|
||||
|
||||
private void OnFolderOpenAssets(object sender, EventArgs e) => _applicationView.SelectedLeftTabIndex = 2;
|
||||
|
||||
private void OnPreviewTexturesToggled(object sender, RoutedEventArgs e) => ItemContainerGenerator_StatusChanged(AssetsExplorer.ItemContainerGenerator, EventArgs.Empty);
|
||||
private void ItemContainerGenerator_StatusChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (sender is not ItemContainerGenerator { Status: GeneratorStatus.ContainersGenerated } generator)
|
||||
return;
|
||||
|
||||
var list = ReferenceEquals(generator, AssetsExplorer.ItemContainerGenerator) ? AssetsExplorer
|
||||
: ReferenceEquals(generator, AssetsListExplorer.ItemContainerGenerator) ? AssetsListExplorer
|
||||
: AssetsListName;
|
||||
|
||||
if (!list.IsVisible || list.FindVisualChild<VirtualizingPanel>() is not { } panel)
|
||||
return;
|
||||
|
||||
foreach (var container in panel.Children.OfType<ListBoxItem>())
|
||||
{
|
||||
if (container is FrameworkElement { IsVisible: true, DataContext: GameFileViewModel file })
|
||||
{
|
||||
file.OnIsVisible();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OnAssetsTreeSelectedItemChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
if (sender is not ListBox { SelectedItem: TreeItem })
|
||||
@@ -314,15 +293,10 @@ public partial class MainWindow
|
||||
|
||||
public void SelectAsset(GameFileViewModel asset)
|
||||
{
|
||||
var useExplorer = UserSettings.Default.FeaturePreviewNewAssetExplorer;
|
||||
_applicationView.SelectedLeftTabIndex = 1;
|
||||
_applicationView.IsAssetsExplorerVisible = true;
|
||||
|
||||
_applicationView.SelectedLeftTabIndex = useExplorer ? 1 : 2;
|
||||
if (useExplorer)
|
||||
{
|
||||
_applicationView.IsAssetsExplorerVisible = true;
|
||||
}
|
||||
|
||||
var list = useExplorer ? UserSettings.Default.ExplorerViewMode == EExplorerViewMode.List ? AssetsListExplorer : AssetsExplorer : AssetsListName;
|
||||
var list = UserSettings.Default.ExplorerViewMode == EExplorerViewMode.List ? AssetsListExplorer : AssetsExplorer;
|
||||
list.GetBindingExpression(ItemsControl.ItemsSourceProperty)?.UpdateTarget();
|
||||
list.UnselectAll();
|
||||
list.SelectedItem = asset;
|
||||
@@ -391,11 +365,6 @@ public partial class MainWindow
|
||||
}
|
||||
}
|
||||
|
||||
private void FeaturePreviewOnUnchecked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
_applicationView.IsAssetsExplorerVisible = false;
|
||||
}
|
||||
|
||||
private void OnExportHotkey(string trigger)
|
||||
{
|
||||
if (!_applicationView.Status.IsReady || Keyboard.FocusedElement is not DependencyObject focused)
|
||||
|
||||
341
FModel/Services/AssetExplorerPreviewResolver.cs
Normal file
341
FModel/Services/AssetExplorerPreviewResolver.cs
Normal file
@@ -0,0 +1,341 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Controls.Primitives;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Threading;
|
||||
using CUE4Parse.FileProvider;
|
||||
using FModel.Extensions;
|
||||
using FModel.Settings;
|
||||
using FModel.ViewModels;
|
||||
|
||||
namespace FModel.Services;
|
||||
|
||||
public sealed class AssetExplorerPreviewResolver : IDisposable
|
||||
{
|
||||
private readonly ApplicationViewModel _applicationView;
|
||||
private readonly (ListBox Grid, ListBox List, ListBox Packages) _views;
|
||||
private readonly UserSettings _settings = UserSettings.Default;
|
||||
|
||||
private ListBox Explorer => _views.Grid.IsVisible ? _views.Grid : _views.List;
|
||||
private readonly DispatcherTimer _resolutionTimer = new(DispatcherPriority.Background) { Interval = TimeSpan.FromMilliseconds(100) };
|
||||
private int _assetResolutionVersion;
|
||||
private int _startedAssetResolutionVersion;
|
||||
private bool _resolvingAssets;
|
||||
private volatile bool _closing;
|
||||
private volatile PreviewQueue _previews = new();
|
||||
private readonly ConcurrentDictionary<GameFileViewModel, byte> _activePreviews = new();
|
||||
private GameFileViewModel _hoveredPreview;
|
||||
|
||||
// Snooper rendering would block texture previews on a shared queue
|
||||
// therefore we need two separate queues for textures and rendered previews
|
||||
private readonly PreviewWorkers _textureWorkers;
|
||||
private readonly PreviewWorkers _renderWorkers;
|
||||
|
||||
public AssetExplorerPreviewResolver(ApplicationViewModel applicationView, ListBox grid, ListBox list, ListBox packages)
|
||||
{
|
||||
_applicationView = applicationView;
|
||||
_views = (grid, list, packages);
|
||||
_textureWorkers = new(this, rendered: false);
|
||||
_renderWorkers = new(this, rendered: true);
|
||||
|
||||
_resolutionTimer.Tick += OnResolutionTick;
|
||||
_settings.PropertyChanged += OnSettingsChanged;
|
||||
_applicationView.AssetResolutionRequested += OnAssetResolutionRequested;
|
||||
foreach (var view in new[] { grid, list, packages })
|
||||
{
|
||||
view.ItemContainerGenerator.StatusChanged += OnContainersGenerated;
|
||||
view.IsVisibleChanged += OnVisibilityChanged;
|
||||
view.AddHandler(ScrollViewer.ScrollChangedEvent, new ScrollChangedEventHandler(OnScrollChanged));
|
||||
}
|
||||
|
||||
grid.MouseMove += OnMouseMove;
|
||||
list.MouseMove += OnMouseMove;
|
||||
ScheduleAssetResolution();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (_closing)
|
||||
return;
|
||||
|
||||
_closing = true;
|
||||
Interlocked.Increment(ref _assetResolutionVersion);
|
||||
_resolutionTimer.Stop();
|
||||
_resolutionTimer.Tick -= OnResolutionTick;
|
||||
_settings.PropertyChanged -= OnSettingsChanged;
|
||||
_applicationView.AssetResolutionRequested -= OnAssetResolutionRequested;
|
||||
foreach (var view in new[] { _views.Grid, _views.List, _views.Packages })
|
||||
{
|
||||
view.ItemContainerGenerator.StatusChanged -= OnContainersGenerated;
|
||||
view.IsVisibleChanged -= OnVisibilityChanged;
|
||||
view.RemoveHandler(ScrollViewer.ScrollChangedEvent, new ScrollChangedEventHandler(OnScrollChanged));
|
||||
}
|
||||
|
||||
_views.Grid.MouseMove -= OnMouseMove;
|
||||
_views.List.MouseMove -= OnMouseMove;
|
||||
SnooperViewModel.Instance.CloseMeshPreviews();
|
||||
}
|
||||
|
||||
private void OnVisibilityChanged(object sender, DependencyPropertyChangedEventArgs e) => ScheduleAssetResolution();
|
||||
|
||||
private void OnContainersGenerated(object sender, EventArgs e)
|
||||
{
|
||||
if (sender is not ItemContainerGenerator { Status: GeneratorStatus.ContainersGenerated } generator)
|
||||
return;
|
||||
|
||||
var (grid, list, packages) = _views;
|
||||
var view = packages;
|
||||
if (ReferenceEquals(generator, grid.ItemContainerGenerator))
|
||||
{
|
||||
view = grid;
|
||||
}
|
||||
else if (ReferenceEquals(generator, list.ItemContainerGenerator))
|
||||
{
|
||||
view = list;
|
||||
}
|
||||
|
||||
if (view.IsVisible)
|
||||
ScheduleAssetResolution();
|
||||
}
|
||||
|
||||
private void OnAssetResolutionRequested(object sender, EventArgs e)
|
||||
{
|
||||
_previews = new();
|
||||
ScheduleAssetResolution();
|
||||
}
|
||||
|
||||
private void ScheduleAssetResolution()
|
||||
{
|
||||
if (_closing)
|
||||
return;
|
||||
|
||||
Interlocked.Increment(ref _assetResolutionVersion);
|
||||
RestartResolutionTimer();
|
||||
}
|
||||
|
||||
private void RestartResolutionTimer()
|
||||
{
|
||||
_resolutionTimer.Stop();
|
||||
_resolutionTimer.Start();
|
||||
}
|
||||
|
||||
private void OnResolutionTick(object sender, EventArgs e)
|
||||
{
|
||||
_resolutionTimer.Stop();
|
||||
if (_closing)
|
||||
return;
|
||||
|
||||
if (!_resolvingAssets && _startedAssetResolutionVersion != _assetResolutionVersion)
|
||||
ResolveVisibleAssets();
|
||||
}
|
||||
|
||||
private void ResolveVisibleAssets()
|
||||
{
|
||||
var version = _startedAssetResolutionVersion = _assetResolutionVersion;
|
||||
var explorer = Explorer;
|
||||
var withPreviews = explorer.IsVisible && _settings.ExplorerPreviewMode is not EExplorerPreviewMode.None;
|
||||
var provider = _applicationView.CUE4Parse?.Provider;
|
||||
|
||||
var previews = new PreviewQueue(provider);
|
||||
var uncategorized = new List<(GameFileViewModel File, bool Preview)>();
|
||||
foreach (var file in GetVisibleAssets(explorer, file => NeedsCategory(file) || (withPreviews && NeedsPreview(file))))
|
||||
{
|
||||
if (NeedsCategory(file))
|
||||
{
|
||||
uncategorized.Add((file, withPreviews));
|
||||
}
|
||||
else if (withPreviews && NeedsPreview(file))
|
||||
{
|
||||
GetPreviewWorkers(file).Enqueue(previews, file);
|
||||
}
|
||||
}
|
||||
|
||||
_previews = previews;
|
||||
_textureWorkers.Start();
|
||||
_renderWorkers.Start();
|
||||
|
||||
var visible = uncategorized
|
||||
.Concat(GetVisibleAssets(_views.Packages, NeedsCategory)
|
||||
.Select(file => (File: file, Preview: false)))
|
||||
.DistinctBy(request => request.File)
|
||||
.ToArray();
|
||||
|
||||
if (visible.Length == 0)
|
||||
return;
|
||||
|
||||
var dispatcher = explorer.Dispatcher;
|
||||
_resolvingAssets = true;
|
||||
_ = Task.Run(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
foreach (var (file, preview) in visible)
|
||||
{
|
||||
if (Volatile.Read(ref _assetResolutionVersion) != version)
|
||||
break;
|
||||
|
||||
var resolvePreview = file.ResolveCategory(provider, preview);
|
||||
if (!preview || !NeedsPreview(file))
|
||||
continue;
|
||||
|
||||
GetPreviewWorkers(file).Enqueue(previews, file, resolvePreview);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
dispatcher.InvokeAsync(() =>
|
||||
{
|
||||
_resolvingAssets = false;
|
||||
if (!_closing && version != _assetResolutionVersion && !_resolutionTimer.IsEnabled)
|
||||
_resolutionTimer.Start();
|
||||
}, DispatcherPriority.Background);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static IEnumerable<GameFileViewModel> GetVisibleAssets(ListBox list, Predicate<GameFileViewModel> include)
|
||||
{
|
||||
if (!list.IsVisible || list.FindVisualChild<ScrollContentPresenter>() is not { } viewport || viewport.FindVisualChild<VirtualizingPanel>() is not { } panel)
|
||||
yield break;
|
||||
|
||||
var viewportBounds = new Rect(viewport.RenderSize);
|
||||
foreach (var child in panel.Children)
|
||||
{
|
||||
if (child is not ListBoxItem { IsVisible: true, DataContext: GameFileViewModel file } container || !include(file))
|
||||
continue;
|
||||
|
||||
var bounds = container.TransformToAncestor(viewport).TransformBounds(new Rect(container.RenderSize));
|
||||
bounds.Intersect(viewportBounds);
|
||||
if (bounds.Width > 0 && bounds.Height > 0)
|
||||
yield return file;
|
||||
}
|
||||
}
|
||||
|
||||
private static bool NeedsCategory(GameFileViewModel file) => file.NeedsResolution(EResolveCompute.Category);
|
||||
|
||||
private bool NeedsPreview(GameFileViewModel file) => !NeedsCategory(file) && file.NeedsResolution(EResolveCompute.Preview) && !(file.RendersPreview && _settings.ExplorerPreviewMode is EExplorerPreviewMode.MeshesOnHover);
|
||||
|
||||
private PreviewWorkers GetPreviewWorkers(GameFileViewModel file) => file.RendersPreview ? _renderWorkers : _textureWorkers;
|
||||
|
||||
private void ProcessPreviews(bool rendered)
|
||||
{
|
||||
var provider = _applicationView.CUE4Parse?.Provider;
|
||||
while (!_closing && TryTakePreview(rendered, provider, out var preview))
|
||||
{
|
||||
if (!_activePreviews.TryAdd(preview.File, 0))
|
||||
continue;
|
||||
|
||||
try
|
||||
{
|
||||
preview.Resolve();
|
||||
}
|
||||
finally
|
||||
{
|
||||
_activePreviews.TryRemove(preview.File, out _);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool TryTakePreview(bool rendered, IFileProvider provider, out PreviewRequest preview)
|
||||
{
|
||||
if (rendered && Interlocked.Exchange(ref _hoveredPreview, null) is { } hovered && hovered.NeedsResolution(EResolveCompute.Preview))
|
||||
{
|
||||
preview = new PreviewRequest(hovered, () => hovered.Resolve(EResolveCompute.Preview, provider));
|
||||
return true;
|
||||
}
|
||||
|
||||
return _previews.GetQueue(rendered).TryDequeue(out preview);
|
||||
}
|
||||
|
||||
private readonly struct PreviewRequest(GameFileViewModel file, Action resolve)
|
||||
{
|
||||
public GameFileViewModel File { get; } = file;
|
||||
public Action Resolve { get; } = resolve;
|
||||
}
|
||||
|
||||
private sealed class PreviewQueue(IFileProvider provider = null)
|
||||
{
|
||||
private readonly ConcurrentQueue<PreviewRequest> _textures = new();
|
||||
private readonly ConcurrentQueue<PreviewRequest> _rendered = new();
|
||||
|
||||
public ConcurrentQueue<PreviewRequest> GetQueue(bool rendered) => rendered ? _rendered : _textures;
|
||||
|
||||
public void Enqueue(bool rendered, GameFileViewModel file, Action resolve)
|
||||
{
|
||||
resolve ??= () => file.Resolve(EResolveCompute.Preview, provider);
|
||||
GetQueue(rendered).Enqueue(new PreviewRequest(file, resolve));
|
||||
}
|
||||
}
|
||||
|
||||
private sealed class PreviewWorkers(AssetExplorerPreviewResolver resolver, bool rendered)
|
||||
{
|
||||
private int _active;
|
||||
|
||||
public void Enqueue(PreviewQueue previews, GameFileViewModel file, Action resolve = null)
|
||||
{
|
||||
previews.Enqueue(rendered, file, resolve);
|
||||
if (ReferenceEquals(previews, resolver._previews))
|
||||
Start();
|
||||
}
|
||||
|
||||
public void Start()
|
||||
{
|
||||
var limit = rendered && resolver._settings.ExplorerPreviewMode is EExplorerPreviewMode.All ? 2 : 1;
|
||||
while (!resolver._closing && HasWork())
|
||||
{
|
||||
var active = Volatile.Read(ref _active);
|
||||
if (active >= limit)
|
||||
return;
|
||||
|
||||
if (Interlocked.CompareExchange(ref _active, active + 1, active) == active)
|
||||
_ = Task.Run(Run);
|
||||
}
|
||||
|
||||
bool HasWork() => rendered && Volatile.Read(ref resolver._hoveredPreview) != null || !resolver._previews.GetQueue(rendered).IsEmpty;
|
||||
}
|
||||
|
||||
|
||||
private void Run()
|
||||
{
|
||||
try
|
||||
{
|
||||
resolver.ProcessPreviews(rendered);
|
||||
}
|
||||
finally
|
||||
{
|
||||
Interlocked.Decrement(ref _active);
|
||||
Start();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OnMouseMove(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (_settings.ExplorerPreviewMode is not EExplorerPreviewMode.MeshesOnHover || sender is not ListBox list || e.OriginalSource is not DependencyObject element ||
|
||||
ItemsControl.ContainerFromElement(list, element) is not ListBoxItem { DataContext: GameFileViewModel { RendersPreview: true } file } ||
|
||||
file.NeedsResolution(EResolveCompute.Category) || !file.NeedsResolution(EResolveCompute.Preview))
|
||||
return;
|
||||
|
||||
Volatile.Write(ref _hoveredPreview, file);
|
||||
_renderWorkers.Start();
|
||||
}
|
||||
|
||||
private void OnSettingsChanged(object sender, PropertyChangedEventArgs e)
|
||||
{
|
||||
if (e.PropertyName == nameof(UserSettings.ExplorerPreviewMode))
|
||||
ScheduleAssetResolution();
|
||||
}
|
||||
|
||||
private void OnScrollChanged(object sender, ScrollChangedEventArgs e)
|
||||
{
|
||||
if (sender is ListBox { IsVisible: true } && (e.VerticalChange != 0 || e.HorizontalChange != 0 || e.ViewportHeightChange != 0 || e.ViewportWidthChange != 0))
|
||||
ScheduleAssetResolution();
|
||||
}
|
||||
}
|
||||
@@ -684,18 +684,11 @@ public sealed class UserSettings : ViewModel
|
||||
set => SetProperty(ref _saveHdrTexturesAsHdr, value);
|
||||
}
|
||||
|
||||
private bool _featurePreviewNewAssetExplorer = true;
|
||||
public bool FeaturePreviewNewAssetExplorer
|
||||
private EExplorerPreviewMode _explorerPreviewMode = EExplorerPreviewMode.All;
|
||||
public EExplorerPreviewMode ExplorerPreviewMode
|
||||
{
|
||||
get => _featurePreviewNewAssetExplorer;
|
||||
set => SetProperty(ref _featurePreviewNewAssetExplorer, value);
|
||||
}
|
||||
|
||||
private bool _previewTexturesAssetExplorer = true;
|
||||
public bool PreviewTexturesAssetExplorer
|
||||
{
|
||||
get => _previewTexturesAssetExplorer;
|
||||
set => SetProperty(ref _previewTexturesAssetExplorer, value);
|
||||
get => _explorerPreviewMode;
|
||||
set => SetProperty(ref _explorerPreviewMode, value);
|
||||
}
|
||||
|
||||
private EExplorerViewMode _explorerViewMode = EExplorerViewMode.Grid;
|
||||
|
||||
@@ -52,13 +52,14 @@ public class ApplicationViewModel : ViewModel
|
||||
public bool IsAssetsExplorerVisible
|
||||
{
|
||||
get => _isAssetsExplorerVisible;
|
||||
set
|
||||
{
|
||||
if (value && !UserSettings.Default.FeaturePreviewNewAssetExplorer)
|
||||
return;
|
||||
set => SetProperty(ref _isAssetsExplorerVisible, value);
|
||||
}
|
||||
|
||||
SetProperty(ref _isAssetsExplorerVisible, value);
|
||||
}
|
||||
public event EventHandler AssetResolutionRequested;
|
||||
public void RefreshAssetResolution()
|
||||
{
|
||||
CUE4Parse.AssetsFolder.SelectedFolder?.ResolveCategoryFilter();
|
||||
AssetResolutionRequested?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
private bool _isUpdateAvailable;
|
||||
|
||||
@@ -88,7 +88,7 @@ public class TreeItem : ViewModel
|
||||
}
|
||||
else
|
||||
{
|
||||
_ = OnSelectedCategoryChanged();
|
||||
ResolveCategoryFilter();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -106,7 +106,7 @@ public class TreeItem : ViewModel
|
||||
// BulkPopulate sorts Folders before this view is created
|
||||
_filteredFoldersView ??= new ListCollectionView(Folders)
|
||||
{
|
||||
Filter = ItemFilter
|
||||
Filter = HasFilter ? ItemFilter : null
|
||||
};
|
||||
return _filteredFoldersView;
|
||||
}
|
||||
@@ -133,14 +133,27 @@ public class TreeItem : ViewModel
|
||||
Version = vfsEntry.Vfs.Ver;
|
||||
}
|
||||
PathAtThisPoint = pathHere;
|
||||
|
||||
AssetsList.AssetsView.Filter = ItemFilter;
|
||||
}
|
||||
|
||||
private bool HasFilter => SelectedCategory != EAssetCategory.All || _searchTerms.Length != 0;
|
||||
|
||||
private void RefreshFilters()
|
||||
{
|
||||
AssetsList.AssetsView.Refresh();
|
||||
FilteredFoldersView?.Refresh();
|
||||
Predicate<object> filter = HasFilter ? ItemFilter : null;
|
||||
UpdateFilter(AssetsList.AssetsView, filter);
|
||||
if (_filteredFoldersView != null) UpdateFilter(_filteredFoldersView, filter);
|
||||
}
|
||||
|
||||
private static void UpdateFilter(ICollectionView view, Predicate<object> filter)
|
||||
{
|
||||
if (view.Filter != filter)
|
||||
{
|
||||
view.Filter = filter;
|
||||
}
|
||||
else if (filter != null)
|
||||
{
|
||||
view.Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
private bool ItemFilter(object item) => item switch
|
||||
@@ -161,10 +174,51 @@ public class TreeItem : ViewModel
|
||||
return true;
|
||||
}
|
||||
|
||||
private async Task OnSelectedCategoryChanged()
|
||||
private bool _resolvingCategory;
|
||||
|
||||
public void ResolveCategoryFilter()
|
||||
{
|
||||
await Task.WhenAll(AssetsList.Assets.Select(asset => asset.ResolveAsync(EResolveCompute.Category)));
|
||||
RefreshFilters();
|
||||
if (_resolvingCategory || SelectedCategory is EAssetCategory.All)
|
||||
return;
|
||||
|
||||
var assets = AssetsList.Assets.Where(file => file.NeedsResolution(EResolveCompute.Category)).ToArray();
|
||||
if (assets.Length == 0)
|
||||
{
|
||||
RefreshFilters();
|
||||
return;
|
||||
}
|
||||
|
||||
_resolvingCategory = true;
|
||||
var provider = ApplicationService.ApplicationView.CUE4Parse?.Provider;
|
||||
_ = Task.Run(() =>
|
||||
{
|
||||
var interrupted = false;
|
||||
foreach (var asset in assets)
|
||||
{
|
||||
if (_selectedCategory is EAssetCategory.All)
|
||||
{
|
||||
interrupted = true;
|
||||
break;
|
||||
}
|
||||
asset.Resolve(EResolveCompute.Category, provider);
|
||||
}
|
||||
|
||||
Application.Current.Dispatcher.InvokeAsync(() =>
|
||||
{
|
||||
_resolvingCategory = false;
|
||||
if (SelectedCategory is EAssetCategory.All)
|
||||
return;
|
||||
|
||||
if (interrupted)
|
||||
{
|
||||
ResolveCategoryFilter();
|
||||
}
|
||||
else
|
||||
{
|
||||
RefreshFilters();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
public override string ToString() => $"{Header} | {Folders.Count} Folders | {AssetsList.Assets.Count} Files";
|
||||
|
||||
@@ -960,7 +960,7 @@ public class CUE4ParseViewModel : ViewModel
|
||||
|
||||
break;
|
||||
}
|
||||
case "ustbin" when Provider.Versions.Game is GAME_DeltaForce:
|
||||
case "ustbin" when Provider.Versions.Game is GAME_DeltaForce or GAME_DeltaForceMobile:
|
||||
{
|
||||
var archive = entry.CreateReader();
|
||||
var ustbin = new FDeltaStringTable(archive);
|
||||
|
||||
@@ -39,6 +39,9 @@ public class MenuCommand : ViewModelCommand<ApplicationViewModel>
|
||||
case "Views_3dViewer":
|
||||
SnooperViewModel.Instance.Load(null);
|
||||
break;
|
||||
case "Views_AssetsExplorer":
|
||||
contextViewModel.IsAssetsExplorerVisible = true;
|
||||
break;
|
||||
case "Views_ExportSession":
|
||||
Helper.OpenWindow<AdonisWindow>("Export Session", () => new ExportSessionWindow().Show());
|
||||
break;
|
||||
|
||||
@@ -6,9 +6,11 @@ using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Threading;
|
||||
using CUE4Parse_Conversion.Textures;
|
||||
using CUE4Parse_Conversion.Textures.Paper2D;
|
||||
using CUE4Parse_Conversion.Dto;
|
||||
using CUE4Parse.FileProvider;
|
||||
using CUE4Parse.FileProvider.Objects;
|
||||
using CUE4Parse.GameTypes.Borderlands3.Assets.Exports;
|
||||
using CUE4Parse.GameTypes.Borderlands4.Assets.Exports;
|
||||
@@ -64,6 +66,7 @@ using CUE4Parse.UE4.Objects.UObject.Editor;
|
||||
using CUE4Parse.UE4.Versions;
|
||||
using CUE4Parse.Utils;
|
||||
using FModel.Framework;
|
||||
using FModel.Extensions;
|
||||
using FModel.Services;
|
||||
using FModel.Settings;
|
||||
using FModel.Views.Resources.Controls;
|
||||
@@ -75,12 +78,17 @@ namespace FModel.ViewModels;
|
||||
|
||||
public class GameFileViewModel(GameFile asset) : ViewModel
|
||||
{
|
||||
private const int MaxPreviewSize = 128;
|
||||
public const int MaxPreviewSize = 128;
|
||||
|
||||
private ApplicationViewModel _applicationView => ApplicationService.ApplicationView;
|
||||
private EGame? GameVersion => _applicationView.CUE4Parse?.Provider.Versions.Game;
|
||||
|
||||
public EResolveCompute Resolved { get; private set; } = EResolveCompute.None;
|
||||
private volatile EResolveCompute _resolved;
|
||||
public EResolveCompute Resolved
|
||||
{
|
||||
get => _resolved;
|
||||
private set => _resolved = value;
|
||||
}
|
||||
public GameFile Asset { get; } = asset;
|
||||
|
||||
private string _resolvedAssetType = asset.Extension;
|
||||
@@ -143,15 +151,18 @@ public class GameFileViewModel(GameFile asset) : ViewModel
|
||||
public ImageSource PreviewImage
|
||||
{
|
||||
get => _previewImage;
|
||||
private set
|
||||
{
|
||||
if (SetProperty(ref _previewImage, value))
|
||||
{
|
||||
Resolved |= EResolveCompute.Preview;
|
||||
}
|
||||
}
|
||||
private set => SetProperty(ref _previewImage, value);
|
||||
}
|
||||
|
||||
private bool _isRenderedPreview;
|
||||
public bool IsRenderedPreview
|
||||
{
|
||||
get => _isRenderedPreview;
|
||||
private set => SetProperty(ref _isRenderedPreview, value);
|
||||
}
|
||||
|
||||
public bool RendersPreview => AssetCategory is EAssetCategory.Material or EAssetCategory.Nascar || AssetCategory.IsOfCategory(EAssetCategory.Mesh);
|
||||
|
||||
private int _numTextures = 0;
|
||||
public int NumTextures
|
||||
{
|
||||
@@ -159,43 +170,60 @@ public class GameFileViewModel(GameFile asset) : ViewModel
|
||||
private set => SetProperty(ref _numTextures, value);
|
||||
}
|
||||
|
||||
public Task ExtractAsync()
|
||||
=> ApplicationService.ThreadWorkerView.Begin(cancellationToken =>
|
||||
_applicationView.CUE4Parse.ExtractSelected(cancellationToken, [Asset]));
|
||||
public Task ExtractAsync() => ApplicationService.ThreadWorkerView.Begin(cancellationToken => _applicationView.CUE4Parse.ExtractSelected(cancellationToken, [Asset]));
|
||||
|
||||
public Task ResolveAsync(EResolveCompute resolve)
|
||||
private Lock _resolveLock;
|
||||
|
||||
public bool NeedsResolution(EResolveCompute resolve) => (resolve & ~Resolved) != EResolveCompute.None;
|
||||
|
||||
public void Resolve(EResolveCompute resolve, IFileProvider provider) => ResolveCore(resolve, provider);
|
||||
|
||||
public Action ResolveCategory(IFileProvider provider, bool withPreview)
|
||||
{
|
||||
try
|
||||
{
|
||||
return ResolveInternalAsync(resolve);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.Error(e, "Failed to resolve asset {AssetName} ({Resolver})", Asset.Path, resolve.ToStringBitfield());
|
||||
var export = ResolveCore(EResolveCompute.Category, provider);
|
||||
return withPreview && export != null ? () => ResolveCore(EResolveCompute.Preview, provider, export) : null;
|
||||
}
|
||||
|
||||
Resolved = EResolveCompute.All;
|
||||
return Task.CompletedTask;
|
||||
private Lazy<UObject> ResolveCore(EResolveCompute resolve, IFileProvider provider, Lazy<UObject> previewExport = null)
|
||||
{
|
||||
if (!NeedsResolution(resolve))
|
||||
return null;
|
||||
|
||||
lock (LazyInitializer.EnsureInitialized(ref _resolveLock))
|
||||
{
|
||||
resolve &= ~Resolved;
|
||||
if (resolve is EResolveCompute.None)
|
||||
return null;
|
||||
|
||||
try
|
||||
{
|
||||
Lazy<UObject> export = null;
|
||||
if (previewExport != null)
|
||||
{
|
||||
ResolvePackagePreview(previewExport.Value);
|
||||
}
|
||||
else if (!Asset.IsUePackage || provider is null)
|
||||
{
|
||||
ResolveByExtension(resolve, provider);
|
||||
}
|
||||
else
|
||||
{
|
||||
export = ResolveByPackage(resolve, provider);
|
||||
}
|
||||
|
||||
Resolved |= resolve;
|
||||
return export;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Resolved &= ~resolve;
|
||||
Log.Error(e, "Failed to resolve asset {AssetName} ({Resolver})", Asset.Path, resolve.ToStringBitfield());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Task ResolveInternalAsync(EResolveCompute resolve)
|
||||
{
|
||||
if (!_applicationView.IsAssetsExplorerVisible || !UserSettings.Default.PreviewTexturesAssetExplorer)
|
||||
{
|
||||
resolve &= ~EResolveCompute.Preview;
|
||||
}
|
||||
|
||||
resolve &= ~Resolved;
|
||||
if (resolve == EResolveCompute.None)
|
||||
return Task.CompletedTask;
|
||||
|
||||
if (!Asset.IsUePackage || _applicationView.CUE4Parse is null)
|
||||
return ResolveByExtensionAsync(resolve);
|
||||
|
||||
return ResolveByPackageAsync(resolve);
|
||||
}
|
||||
|
||||
private Task ResolveByPackageAsync(EResolveCompute resolve)
|
||||
private Lazy<UObject> ResolveByPackage(EResolveCompute resolve, IFileProvider provider)
|
||||
{
|
||||
if (Asset.Extension is "umap")
|
||||
{
|
||||
@@ -203,7 +231,7 @@ public class GameFileViewModel(GameFile asset) : ViewModel
|
||||
AssetActions = EBulkType.Worlds | EBulkType.Textures | EBulkType.Audio | EBulkType.Code;
|
||||
ResolvedAssetType = "World";
|
||||
Resolved |= EResolveCompute.Preview;
|
||||
return Task.CompletedTask;
|
||||
return null;
|
||||
}
|
||||
|
||||
if (Asset.NameWithoutExtension.EndsWith("_BuiltData"))
|
||||
@@ -212,231 +240,241 @@ public class GameFileViewModel(GameFile asset) : ViewModel
|
||||
AssetActions = EBulkType.Textures;
|
||||
ResolvedAssetType = "MapBuildDataRegistry";
|
||||
Resolved |= EResolveCompute.Preview;
|
||||
return Task.CompletedTask;
|
||||
return null;
|
||||
}
|
||||
|
||||
return Task.Run(() =>
|
||||
var pkg = provider.LoadPackage(Asset);
|
||||
|
||||
var pointer = FindMainExport(pkg);
|
||||
if (pointer?.Object is not { } export)
|
||||
return null;
|
||||
|
||||
if ((resolve & EResolveCompute.Category) != 0)
|
||||
ResolveCategory((AbstractUePackage) pkg, pointer, export);
|
||||
|
||||
if (AssetCategory is not (EAssetCategory.Texture or EAssetCategory.AnimatedTexture or EAssetCategory.ItemDefinitionBase) && !RendersPreview)
|
||||
{
|
||||
// TODO: cache and reuse packages
|
||||
var pkg = _applicationView.CUE4Parse?.Provider.LoadPackage(Asset);
|
||||
if (pkg is null)
|
||||
throw new InvalidOperationException($"Failed to load {Asset.Path} as UE package.");
|
||||
Resolved |= EResolveCompute.Preview;
|
||||
return null;
|
||||
}
|
||||
|
||||
var mainIndex = pkg.GetExportIndex(Asset.NameWithoutExtension, StringComparison.OrdinalIgnoreCase);
|
||||
if (mainIndex < 0) mainIndex = pkg.GetExportIndex($"{Asset.NameWithoutExtension}_C", StringComparison.OrdinalIgnoreCase);
|
||||
if (mainIndex < 0) mainIndex = 0;
|
||||
if ((resolve & EResolveCompute.Preview) == 0)
|
||||
return NeedsResolution(EResolveCompute.Preview) ? export : null;
|
||||
|
||||
var pointer = new FPackageIndex(pkg, mainIndex + 1).ResolvedObject;
|
||||
if (pointer?.Object is null)
|
||||
return;
|
||||
|
||||
var dummy = ((AbstractUePackage) pkg).ConstructObject(pointer.Class, pkg);
|
||||
ResolvedAssetType = dummy.ExportType;
|
||||
|
||||
AssetFamily = dummy switch
|
||||
{
|
||||
UAtomSoundBase or UAtomSoundBank or USoundAtomCue or USoundAtomCueSheet
|
||||
or USoundAtomConfig or UAtomDspBusSetting or UAtomRackBase => EAssetFamily.Criware,
|
||||
|
||||
UAkAudioType or UAkAssetData or UAkAssetPlatformData or UAkMediaAssetData
|
||||
or UAkMediaAsset or UWwiseAssetLibrary or UWwiseAssetLibraryGroup or UExternalSource or UExternalSourceBank => EAssetFamily.Wwise,
|
||||
|
||||
UFMODEvent or UFMODBank or UFMODBankLookup or UFMODBus
|
||||
or UFMODSnapshot or UFMODSnapshotReverb or UFMODVCA => EAssetFamily.FMod,
|
||||
|
||||
UHoudiniAsset or UHoudiniStaticMesh => EAssetFamily.Houdini,
|
||||
|
||||
UPaperTileMap or UPaperTileLayer or UPaperTileSet or UPaperSprite or UPaperFlipbook => EAssetFamily.Paper2D,
|
||||
|
||||
_ => EAssetFamily.None,
|
||||
};
|
||||
|
||||
(AssetCategory, AssetActions) = dummy switch
|
||||
{
|
||||
URigVMBlueprintGeneratedClass => (EAssetCategory.RigVMBlueprintGeneratedClass, EBulkType.Code),
|
||||
UAnimBlueprintGeneratedClass => (EAssetCategory.AnimBlueprintGeneratedClass, EBulkType.Code),
|
||||
UWidgetBlueprintGeneratedClass => (EAssetCategory.WidgetBlueprintGeneratedClass, EBulkType.Code),
|
||||
UFunction => (EAssetCategory.BlueprintGeneratedClass, EBulkType.Code),
|
||||
UBlueprintGeneratedClass => (EAssetCategory.BlueprintGeneratedClass, EBulkType.Code | EBulkType.Worlds),
|
||||
|
||||
UUserDefinedEnum => (EAssetCategory.UserDefinedEnum, EBulkType.None),
|
||||
UUserDefinedStruct => (EAssetCategory.UserDefinedStruct, EBulkType.Code),
|
||||
UBlueprintCore => (EAssetCategory.Blueprint, EBulkType.Code),
|
||||
UClassCookedMetaData or UStructCookedMetaData or UEnumCookedMetaData => (EAssetCategory.CookedMetaData, EBulkType.None),
|
||||
|
||||
UStaticMesh => (EAssetCategory.StaticMesh, EBulkType.Meshes),
|
||||
UHoudiniStaticMesh => (EAssetCategory.StaticMesh, EBulkType.Meshes),
|
||||
USkeletalMesh => (EAssetCategory.SkeletalMesh, EBulkType.Meshes),
|
||||
UChaosClothAsset => (EAssetCategory.ChaosClothAsset, EBulkType.Meshes),
|
||||
UCustomizableObject => (EAssetCategory.CustomizableObject, EBulkType.None), // TODO: Add support
|
||||
UNaniteDisplacedMesh => (EAssetCategory.NaniteDisplacedMesh, EBulkType.None),
|
||||
UGeometryCollection => (EAssetCategory.GeometryCollection, EBulkType.Meshes),
|
||||
UGroomAsset => (EAssetCategory.GroomAsset, EBulkType.Meshes), // TODO: Add full support
|
||||
UGroomBindingAsset => (EAssetCategory.GroomAsset, EBulkType.None), // TODO: Add support
|
||||
|
||||
UHoudiniAsset => (EAssetCategory.Data, EBulkType.None),
|
||||
|
||||
UTexture or UPaperSprite => (EAssetCategory.Texture, EBulkType.Textures),
|
||||
UPaperFlipbook => (EAssetCategory.AnimatedTexture, EBulkType.Textures),
|
||||
|
||||
UMaterialInterface => (EAssetCategory.Material, EBulkType.None),
|
||||
UMaterialInterfaceEditorOnlyData => (EAssetCategory.MaterialEditorData, EBulkType.None),
|
||||
UMaterialFunction => (EAssetCategory.MaterialFunction, EBulkType.None),
|
||||
UMaterialFunctionEditorOnlyData => (EAssetCategory.MaterialFunctionEditorData, EBulkType.None),
|
||||
UMaterialParameterCollection => (EAssetCategory.MaterialParameterCollection, EBulkType.None),
|
||||
|
||||
UAnimationAsset => (EAssetCategory.Animation, EBulkType.Animations),
|
||||
USkeleton => (EAssetCategory.Skeleton, EBulkType.Meshes),
|
||||
URig => (EAssetCategory.Rig, EBulkType.None),
|
||||
|
||||
UWorld => (EAssetCategory.World, EBulkType.Meshes | EBulkType.Textures | EBulkType.Audio | EBulkType.Code),
|
||||
UMapBuildDataRegistry => (EAssetCategory.BuildData, EBulkType.Textures),
|
||||
ULevelSequence => (EAssetCategory.LevelSequence, EBulkType.Code),
|
||||
UFoliageType => (EAssetCategory.Foliage, EBulkType.None),
|
||||
|
||||
UItemDefinitionBase => (EAssetCategory.ItemDefinitionBase, EBulkType.Textures),
|
||||
UDataAsset or UDataTable or UCurveTable or UStringTable => (EAssetCategory.Data, EBulkType.None),
|
||||
UCurveBase => (EAssetCategory.CurveBase, EBulkType.None),
|
||||
UPhysicsAsset => (EAssetCategory.PhysicsAsset, EBulkType.None),
|
||||
UObjectRedirector => (EAssetCategory.ObjectRedirector, EBulkType.None),
|
||||
UPhysicalMaterial => (EAssetCategory.PhysicalMaterial, EBulkType.None),
|
||||
|
||||
USoundAtomCue or UAtomSoundCue or UAkAudioEvent or USoundCue or UFMODEvent
|
||||
or UAkAssetData or UAkAssetPlatformData => (EAssetCategory.AudioEvent, EBulkType.Audio),
|
||||
|
||||
UFileManaMovie => (EAssetCategory.Video, EBulkType.None),
|
||||
|
||||
UFMODBankLookup or USoundAtomConfig or UFMODSnapshotReverb or UFMODBus or UFMODSnapshot
|
||||
or UFMODVCA or UAtomDspBusSetting => (EAssetCategory.Data, EBulkType.None),
|
||||
|
||||
USQEXSEADSoundAttenuation => (EAssetCategory.Audio, EBulkType.None),
|
||||
|
||||
UFMODBank or UAkAudioBank or UAtomSoundBank or USoundAtomCueSheet
|
||||
or UAkInitBank or USQEXSEADSoundBank => (EAssetCategory.SoundBank, EBulkType.Audio),
|
||||
|
||||
UWwiseAssetLibrary or UWwiseAssetLibraryGroup or UAtomSoundBase or USoundBase or UAkMediaAssetData
|
||||
or UExternalSource or UExternalSourceBank or UAkMediaAsset => (EAssetCategory.Audio, EBulkType.Audio),
|
||||
|
||||
UAkAudioType => (EAssetCategory.Data, EBulkType.None),
|
||||
|
||||
UFileMediaSource => (EAssetCategory.Video, EBulkType.None),
|
||||
UFont or UFontFace or USMGLocaleFontUMG => (EAssetCategory.Font, EBulkType.None),
|
||||
|
||||
UNiagaraSystem or UNiagaraScriptBase or UParticleSystem => (EAssetCategory.Particle, EBulkType.None),
|
||||
|
||||
USwfMovie => (EAssetCategory.Flash, EBulkType.None),
|
||||
|
||||
// Game specific assets below
|
||||
UBorderlandsDialogObject when GameVersion is EGame.GAME_Borderlands3 => (EAssetCategory.Borderlands, EBulkType.None), // Borderlands 3;
|
||||
UGbxGraphAsset or UDialogScriptData or UDialogPerformanceData when GameVersion is EGame.GAME_Borderlands4 or EGame.GAME_Borderlands3 => (EAssetCategory.Borderlands, EBulkType.Audio), // Borderlands 4; Borderlands 3;
|
||||
UFaceFXAnimSet when GameVersion is EGame.GAME_Borderlands4 => (EAssetCategory.Borderlands, EBulkType.Audio), // Borderlands 4;
|
||||
UWubAudioEvent or UWubDialogueEvent when GameVersion is EGame.GAME_LEGOBatmanLegacyoftheDarkKnight => (EAssetCategory.LegoBatman, EBulkType.Audio), // Lego Batman: Legacy of the Dark Knight;
|
||||
UREDBinaryObject => (EAssetCategory.ArcSys, EBulkType.None), // Arc System Works games;
|
||||
UOrpheusBank or UOrpheusEvent => (EAssetCategory.GothamKnights, EBulkType.Audio), // Gotham Knights;
|
||||
UIRMesh => (EAssetCategory.Nascar, EBulkType.Meshes), // iRacing games;
|
||||
UPaperTileMap when GameVersion is EGame.GAME_DeadByDaylight => (EAssetCategory.DeadByDaylight, EBulkType.Worlds), // DBD; UPaperTileMap isn't game specific, its use is just non typical
|
||||
|
||||
_ => (EAssetCategory.All, EBulkType.None),
|
||||
};
|
||||
|
||||
var obj = pointer.Object.Value;
|
||||
IconStyle = obj switch
|
||||
{
|
||||
UGroomBindingAsset => (null, "GroomBindingAssetBrush"),
|
||||
USkeletalMesh mesh when mesh.AssetUserData?.Any(data => data?.ResolvedObject is { } reference &&
|
||||
(reference.IsA<UDNAAsset>() || reference.Class?.Name.Text == "DNAAssetUserData")) == true => ("MetaHumanIcon", null), // Way to detect MetaHumans, for >UE 5.8 DNAAssetUserData is needed since DNAAsset can be standalone asset
|
||||
_ => default
|
||||
};
|
||||
|
||||
if (EmbeddedFilesDto.Supports(dummy))
|
||||
{
|
||||
var files = new EmbeddedFilesDto(obj).Files;
|
||||
EmbeddedFileExtensions = string.Join(", ", files.Select(file => "." + file.Extension).Distinct(StringComparer.OrdinalIgnoreCase).OrderBy(extension => extension, StringComparer.OrdinalIgnoreCase));
|
||||
if (files.Count > 0)
|
||||
AssetActions |= EBulkType.EmbeddedFiles;
|
||||
}
|
||||
|
||||
switch (AssetCategory)
|
||||
{
|
||||
case EAssetCategory.Texture:
|
||||
{
|
||||
if (!resolve.HasFlag(EResolveCompute.Preview))
|
||||
break;
|
||||
|
||||
if (obj is UTexture2DArray textureArray && textureArray.GetFirstMip() is { SizeZ: > 1 } firstMip)
|
||||
NumTextures = firstMip.SizeZ;
|
||||
|
||||
var options = UserSettings.GetExportOptions();
|
||||
var img = obj switch
|
||||
{
|
||||
UTexture texture => texture.Decode(MaxPreviewSize, options),
|
||||
UPaperSprite sprite => sprite.Decode(options),
|
||||
_ => null
|
||||
};
|
||||
if (img != null)
|
||||
{
|
||||
using var bitmap = img.ToSkBitmap();
|
||||
using var image = bitmap.Encode(SKEncodedImageFormat.Png, 100);
|
||||
SetPreviewImage(image);
|
||||
}
|
||||
else
|
||||
{
|
||||
Resolved |= EResolveCompute.Preview;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case EAssetCategory.AnimatedTexture when obj is UPaperFlipbook flipbook:
|
||||
{
|
||||
if (!resolve.HasFlag(EResolveCompute.Preview))
|
||||
break;
|
||||
|
||||
var preview = ImageAnimation.CreateThumbnail(flipbook, UserSettings.GetExportOptions(), MaxPreviewSize);
|
||||
Application.Current.Dispatcher.InvokeAsync(() => PreviewImage = preview);
|
||||
if (preview == null) Resolved |= EResolveCompute.Preview;
|
||||
break;
|
||||
}
|
||||
case EAssetCategory.ItemDefinitionBase:
|
||||
if (!resolve.HasFlag(EResolveCompute.Preview))
|
||||
break;
|
||||
|
||||
if (obj is UItemDefinitionBase itemDef)
|
||||
{
|
||||
if (LookupPreview(itemDef.DataList)) break;
|
||||
|
||||
if (itemDef is UAthenaPickaxeItemDefinition pickaxe && pickaxe.WeaponDefinition.TryLoad(out UItemDefinitionBase weaponDef))
|
||||
{
|
||||
LookupPreview(weaponDef.DataList);
|
||||
}
|
||||
|
||||
bool LookupPreview(FInstancedStruct[] dataList)
|
||||
{
|
||||
foreach (var data in dataList)
|
||||
{
|
||||
if (!data.NonConstStruct.TryGetValue(out FSoftObjectPath icon, "Icon", "LargeIcon") ||
|
||||
!icon.TryLoad<UTexture2D>(out var texture))
|
||||
continue;
|
||||
|
||||
var img = texture.Decode(MaxPreviewSize, UserSettings.GetExportOptions());
|
||||
if (img == null) return false;
|
||||
|
||||
using var bitmap = img.ToSkBitmap();
|
||||
using var image = bitmap.Encode(SKEncodedImageFormat.Png, 100);
|
||||
SetPreviewImage(image);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
Resolved |= EResolveCompute.Preview;
|
||||
break;
|
||||
}
|
||||
});
|
||||
ResolvePackagePreview(export.Value);
|
||||
return null;
|
||||
}
|
||||
|
||||
private Task ResolveByExtensionAsync(EResolveCompute resolve)
|
||||
private void ResolveCategory(AbstractUePackage pkg, ResolvedObject pointer, Lazy<UObject> export)
|
||||
{
|
||||
var dummy = pkg.ConstructObject(pointer.Class, pkg);
|
||||
ResolvedAssetType = dummy.ExportType;
|
||||
|
||||
AssetFamily = dummy switch
|
||||
{
|
||||
UAtomSoundBase or UAtomSoundBank or USoundAtomCue or USoundAtomCueSheet
|
||||
or USoundAtomConfig or UAtomDspBusSetting or UAtomRackBase => EAssetFamily.Criware,
|
||||
|
||||
UAkAudioType or UAkAssetData or UAkAssetPlatformData or UAkMediaAssetData
|
||||
or UAkMediaAsset or UWwiseAssetLibrary or UWwiseAssetLibraryGroup or UExternalSource or UExternalSourceBank => EAssetFamily.Wwise,
|
||||
|
||||
UFMODEvent or UFMODBank or UFMODBankLookup or UFMODBus
|
||||
or UFMODSnapshot or UFMODSnapshotReverb or UFMODVCA => EAssetFamily.FMod,
|
||||
|
||||
UHoudiniAsset or UHoudiniStaticMesh => EAssetFamily.Houdini,
|
||||
|
||||
UPaperTileMap or UPaperTileLayer or UPaperTileSet or UPaperSprite or UPaperFlipbook => EAssetFamily.Paper2D,
|
||||
|
||||
_ => EAssetFamily.None,
|
||||
};
|
||||
|
||||
var (category, actions) = dummy switch
|
||||
{
|
||||
URigVMBlueprintGeneratedClass => (EAssetCategory.RigVMBlueprintGeneratedClass, EBulkType.Code),
|
||||
UAnimBlueprintGeneratedClass => (EAssetCategory.AnimBlueprintGeneratedClass, EBulkType.Code),
|
||||
UWidgetBlueprintGeneratedClass => (EAssetCategory.WidgetBlueprintGeneratedClass, EBulkType.Code),
|
||||
UFunction => (EAssetCategory.BlueprintGeneratedClass, EBulkType.Code),
|
||||
UBlueprintGeneratedClass => (EAssetCategory.BlueprintGeneratedClass, EBulkType.Code | EBulkType.Worlds),
|
||||
|
||||
UUserDefinedEnum => (EAssetCategory.UserDefinedEnum, EBulkType.None),
|
||||
UUserDefinedStruct => (EAssetCategory.UserDefinedStruct, EBulkType.Code),
|
||||
UBlueprintCore => (EAssetCategory.Blueprint, EBulkType.Code),
|
||||
UClassCookedMetaData or UStructCookedMetaData or UEnumCookedMetaData => (EAssetCategory.CookedMetaData, EBulkType.None),
|
||||
|
||||
UStaticMesh => (EAssetCategory.StaticMesh, EBulkType.Meshes),
|
||||
UHoudiniStaticMesh => (EAssetCategory.StaticMesh, EBulkType.Meshes),
|
||||
USkeletalMesh => (EAssetCategory.SkeletalMesh, EBulkType.Meshes),
|
||||
UChaosClothAsset => (EAssetCategory.ChaosClothAsset, EBulkType.Meshes),
|
||||
UCustomizableObject => (EAssetCategory.CustomizableObject, EBulkType.None), // TODO: Add support
|
||||
UNaniteDisplacedMesh => (EAssetCategory.NaniteDisplacedMesh, EBulkType.None),
|
||||
UGeometryCollection => (EAssetCategory.GeometryCollection, EBulkType.Meshes),
|
||||
UGroomAsset => (EAssetCategory.GroomAsset, EBulkType.Meshes), // TODO: Add full support
|
||||
UGroomBindingAsset => (EAssetCategory.GroomAsset, EBulkType.None), // TODO: Add support
|
||||
|
||||
UHoudiniAsset => (EAssetCategory.Data, EBulkType.None),
|
||||
|
||||
UTexture or UPaperSprite => (EAssetCategory.Texture, EBulkType.Textures),
|
||||
UPaperFlipbook => (EAssetCategory.AnimatedTexture, EBulkType.Textures),
|
||||
|
||||
UMaterialInterface => (EAssetCategory.Material, EBulkType.None),
|
||||
UMaterialInterfaceEditorOnlyData => (EAssetCategory.MaterialEditorData, EBulkType.None),
|
||||
UMaterialFunction => (EAssetCategory.MaterialFunction, EBulkType.None),
|
||||
UMaterialFunctionEditorOnlyData => (EAssetCategory.MaterialFunctionEditorData, EBulkType.None),
|
||||
UMaterialParameterCollection => (EAssetCategory.MaterialParameterCollection, EBulkType.None),
|
||||
UPhysicalMaterial => (EAssetCategory.PhysicalMaterial, EBulkType.None),
|
||||
|
||||
UAnimationAsset => (EAssetCategory.Animation, EBulkType.Animations),
|
||||
USkeleton => (EAssetCategory.Skeleton, EBulkType.Meshes),
|
||||
URig => (EAssetCategory.Rig, EBulkType.None),
|
||||
|
||||
UWorld => (EAssetCategory.World, EBulkType.Meshes | EBulkType.Textures | EBulkType.Audio | EBulkType.Code),
|
||||
UMapBuildDataRegistry => (EAssetCategory.BuildData, EBulkType.Textures),
|
||||
ULevelSequence => (EAssetCategory.LevelSequence, EBulkType.Code),
|
||||
UFoliageType => (EAssetCategory.Foliage, EBulkType.None),
|
||||
|
||||
UItemDefinitionBase => (EAssetCategory.ItemDefinitionBase, EBulkType.Textures),
|
||||
UDataAsset or UDataTable or UCurveTable or UStringTable => (EAssetCategory.Data, EBulkType.None),
|
||||
UCurveBase => (EAssetCategory.CurveBase, EBulkType.None),
|
||||
UPhysicsAsset => (EAssetCategory.PhysicsAsset, EBulkType.None),
|
||||
UObjectRedirector => (EAssetCategory.ObjectRedirector, EBulkType.None),
|
||||
|
||||
USoundAtomCue or UAtomSoundCue or UAkAudioEvent or USoundCue or UFMODEvent
|
||||
or UAkAssetData or UAkAssetPlatformData => (EAssetCategory.AudioEvent, EBulkType.Audio),
|
||||
|
||||
UFileManaMovie => (EAssetCategory.Video, EBulkType.None),
|
||||
|
||||
UFMODBankLookup or USoundAtomConfig or UFMODSnapshotReverb or UFMODBus or UFMODSnapshot
|
||||
or UFMODVCA or UAtomDspBusSetting => (EAssetCategory.Data, EBulkType.None),
|
||||
|
||||
USQEXSEADSoundAttenuation => (EAssetCategory.Audio, EBulkType.None),
|
||||
|
||||
UFMODBank or UAkAudioBank or UAtomSoundBank or USoundAtomCueSheet
|
||||
or UAkInitBank or USQEXSEADSoundBank => (EAssetCategory.SoundBank, EBulkType.Audio),
|
||||
|
||||
UWwiseAssetLibrary or UWwiseAssetLibraryGroup or UAtomSoundBase or USoundBase or UAkMediaAssetData
|
||||
or UExternalSource or UExternalSourceBank or UAkMediaAsset => (EAssetCategory.Audio, EBulkType.Audio),
|
||||
|
||||
UAkAudioType => (EAssetCategory.Data, EBulkType.None),
|
||||
|
||||
UFileMediaSource => (EAssetCategory.Video, EBulkType.None),
|
||||
UFont or UFontFace or USMGLocaleFontUMG => (EAssetCategory.Font, EBulkType.None),
|
||||
|
||||
UNiagaraSystem or UNiagaraScriptBase or UParticleSystem => (EAssetCategory.Particle, EBulkType.None),
|
||||
|
||||
USwfMovie => (EAssetCategory.Flash, EBulkType.None),
|
||||
|
||||
// Game specific assets below
|
||||
UBorderlandsDialogObject when GameVersion is EGame.GAME_Borderlands3 => (EAssetCategory.Borderlands, EBulkType.None), // Borderlands 3;
|
||||
UGbxGraphAsset or UDialogScriptData or UDialogPerformanceData when GameVersion is EGame.GAME_Borderlands4 or EGame.GAME_Borderlands3 => (EAssetCategory.Borderlands, EBulkType.Audio), // Borderlands 4; Borderlands 3;
|
||||
UFaceFXAnimSet when GameVersion is EGame.GAME_Borderlands4 => (EAssetCategory.Borderlands, EBulkType.Audio), // Borderlands 4;
|
||||
UWubAudioEvent or UWubDialogueEvent when GameVersion is EGame.GAME_LEGOBatmanLegacyoftheDarkKnight => (EAssetCategory.LegoBatman, EBulkType.Audio), // Lego Batman: Legacy of the Dark Knight;
|
||||
UREDBinaryObject => (EAssetCategory.ArcSys, EBulkType.None), // Arc System Works games;
|
||||
UOrpheusBank or UOrpheusEvent => (EAssetCategory.GothamKnights, EBulkType.Audio), // Gotham Knights;
|
||||
UIRMesh => (EAssetCategory.Nascar, EBulkType.Meshes), // iRacing games;
|
||||
UPaperTileMap when GameVersion is EGame.GAME_DeadByDaylight => (EAssetCategory.DeadByDaylight, EBulkType.Worlds), // DBD; UPaperTileMap isn't game specific, its use is just non typical
|
||||
|
||||
_ => (EAssetCategory.All, EBulkType.None),
|
||||
};
|
||||
|
||||
(AssetCategory, AssetActions) = (category, actions);
|
||||
|
||||
IconStyle = dummy switch
|
||||
{
|
||||
UGroomBindingAsset => (null, "GroomBindingAssetBrush"),
|
||||
USkeletalMesh when export.Value is USkeletalMesh mesh && mesh.AssetUserData?.Any(data => data?.ResolvedObject is { } reference && (reference.IsA<UDNAAsset>() || reference.Class?.Name.Text == "DNAAssetUserData")) == true => ("MetaHumanIcon", null), // Way to detect MetaHumans, for >UE 5.8 DNAAssetUserData is needed since DNAAsset can be standalone asset
|
||||
_ => default
|
||||
};
|
||||
|
||||
if (EmbeddedFilesDto.Supports(dummy))
|
||||
{
|
||||
var files = new EmbeddedFilesDto(export.Value).Files;
|
||||
EmbeddedFileExtensions = string.Join(", ", files.Select(file => "." + file.Extension).Distinct(StringComparer.OrdinalIgnoreCase).OrderBy(extension => extension, StringComparer.OrdinalIgnoreCase));
|
||||
if (files.Count > 0)
|
||||
AssetActions |= EBulkType.EmbeddedFiles;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void ResolvePackagePreview(UObject export)
|
||||
{
|
||||
var options = UserSettings.GetExportOptions();
|
||||
switch (export)
|
||||
{
|
||||
case UTexture or UPaperSprite:
|
||||
{
|
||||
if (export is UTexture2DArray textureArray && textureArray.GetFirstMip() is { SizeZ: > 1 } firstMip)
|
||||
NumTextures = firstMip.SizeZ;
|
||||
|
||||
var img = export switch
|
||||
{
|
||||
UTexture texture => texture.Decode(MaxPreviewSize, options),
|
||||
UPaperSprite sprite => sprite.Decode(options),
|
||||
_ => null
|
||||
};
|
||||
if (img != null)
|
||||
{
|
||||
using var bitmap = img.ToSkBitmap();
|
||||
SetPreviewImage(bitmap);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case UPaperFlipbook flipbook:
|
||||
{
|
||||
var preview = ImageAnimation.CreateThumbnail(flipbook, options, MaxPreviewSize);
|
||||
if (preview != null)
|
||||
PublishPreview(preview);
|
||||
|
||||
break;
|
||||
}
|
||||
case UStaticMesh or USkinnedAsset or UGeometryCollection or UHoudiniStaticMesh or UIRMesh or UMaterialInterface:
|
||||
{
|
||||
var pixels = SnooperViewModel.Instance.RenderMeshPreview(export);
|
||||
if (pixels == null)
|
||||
break;
|
||||
|
||||
var image = BitmapSource.Create(MaxPreviewSize, MaxPreviewSize, 96, 96, PixelFormats.Pbgra32, null, pixels, MaxPreviewSize * 4);
|
||||
image.Freeze();
|
||||
PublishPreview(image, true);
|
||||
break;
|
||||
}
|
||||
case UItemDefinitionBase itemDef:
|
||||
{
|
||||
if (LookupPreview(itemDef.DataList))
|
||||
break;
|
||||
|
||||
if (itemDef is UAthenaPickaxeItemDefinition pickaxe && pickaxe.WeaponDefinition.TryLoad(out UItemDefinitionBase weaponDef))
|
||||
LookupPreview(weaponDef.DataList);
|
||||
|
||||
break;
|
||||
|
||||
bool LookupPreview(FInstancedStruct[] dataList)
|
||||
{
|
||||
foreach (var data in dataList)
|
||||
{
|
||||
if (!data.NonConstStruct.TryGetValue(out FSoftObjectPath icon, "Icon", "LargeIcon") || !icon.TryLoad<UTexture2D>(out var texture))
|
||||
continue;
|
||||
|
||||
var img = texture.Decode(MaxPreviewSize, options);
|
||||
if (img == null) return false;
|
||||
|
||||
using var bitmap = img.ToSkBitmap();
|
||||
SetPreviewImage(bitmap);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private ResolvedObject FindMainExport(IPackage package)
|
||||
{
|
||||
var index = package.GetExportIndex(Asset.NameWithoutExtension, StringComparison.OrdinalIgnoreCase);
|
||||
if (index < 0) index = package.GetExportIndex($"{Asset.NameWithoutExtension}_C", StringComparison.OrdinalIgnoreCase);
|
||||
return new FPackageIndex(package, Math.Max(0, index) + 1).ResolvedObject;
|
||||
}
|
||||
|
||||
private void ResolveByExtension(EResolveCompute resolve, IFileProvider provider)
|
||||
{
|
||||
var lowercaseExtension = Asset.Extension.ToLowerInvariant();
|
||||
|
||||
@@ -525,41 +563,41 @@ public class GameFileViewModel(GameFile asset) : ViewModel
|
||||
AssetCategory = EAssetCategory.Texture;
|
||||
AssetActions = EBulkType.Textures;
|
||||
if (!resolve.HasFlag(EResolveCompute.Preview))
|
||||
return Task.CompletedTask;
|
||||
return;
|
||||
|
||||
return Task.Run(() =>
|
||||
if (provider == null) return;
|
||||
var data = provider.SaveAsset(Asset);
|
||||
using var stream = new MemoryStream(data);
|
||||
stream.Position = 0;
|
||||
|
||||
SKBitmap bitmap;
|
||||
if (lowercaseExtension == "svg")
|
||||
{
|
||||
var data = _applicationView.CUE4Parse.Provider.SaveAsset(Asset);
|
||||
using var stream = new MemoryStream(data);
|
||||
stream.Position = 0;
|
||||
var svg = new SKSvg();
|
||||
svg.Load(stream);
|
||||
if (svg.Picture == null)
|
||||
return;
|
||||
|
||||
SKBitmap bitmap;
|
||||
if (lowercaseExtension == "svg")
|
||||
{
|
||||
var svg = new SKSvg();
|
||||
svg.Load(stream);
|
||||
if (svg.Picture == null)
|
||||
return;
|
||||
bitmap = new SKBitmap(MaxPreviewSize, MaxPreviewSize);
|
||||
using var canvas = new SKCanvas(bitmap);
|
||||
canvas.Clear(SKColors.Transparent);
|
||||
|
||||
bitmap = new SKBitmap(MaxPreviewSize, MaxPreviewSize);
|
||||
using var canvas = new SKCanvas(bitmap);
|
||||
canvas.Clear(SKColors.Transparent);
|
||||
var bounds = svg.Picture.CullRect;
|
||||
float scale = Math.Min(MaxPreviewSize / bounds.Width, MaxPreviewSize / bounds.Height);
|
||||
canvas.Scale(scale);
|
||||
canvas.Translate(-bounds.Left, -bounds.Top);
|
||||
canvas.DrawPicture(svg.Picture);
|
||||
}
|
||||
else
|
||||
{
|
||||
bitmap = SKBitmap.Decode(stream);
|
||||
}
|
||||
|
||||
var bounds = svg.Picture.CullRect;
|
||||
float scale = Math.Min(MaxPreviewSize / bounds.Width, MaxPreviewSize / bounds.Height);
|
||||
canvas.Scale(scale);
|
||||
canvas.Translate(-bounds.Left, -bounds.Top);
|
||||
canvas.DrawPicture(svg.Picture);
|
||||
}
|
||||
else
|
||||
{
|
||||
bitmap = SKBitmap.Decode(stream);
|
||||
}
|
||||
|
||||
using var image = bitmap.Encode(lowercaseExtension == "jpg" ? SKEncodedImageFormat.Jpeg : SKEncodedImageFormat.Png, 100);
|
||||
SetPreviewImage(image);
|
||||
bitmap.Dispose();
|
||||
});
|
||||
using (bitmap)
|
||||
{
|
||||
if (bitmap != null) SetPreviewImage(bitmap);
|
||||
}
|
||||
return;
|
||||
}
|
||||
case "swf":
|
||||
AssetCategory = EAssetCategory.Flash;
|
||||
@@ -577,7 +615,7 @@ public class GameFileViewModel(GameFile asset) : ViewModel
|
||||
case "cam" when GameVersion is EGame.GAME_RocoKingdomWorld:
|
||||
AssetCategory = EAssetCategory.RocoKingdomWorld;
|
||||
break;
|
||||
case "ustbin" when GameVersion is EGame.GAME_DeltaForce:
|
||||
case "ustbin" when GameVersion is EGame.GAME_DeltaForce or EGame.GAME_DeltaForceMobile:
|
||||
AssetCategory = EAssetCategory.DeltaForce;
|
||||
break;
|
||||
default:
|
||||
@@ -586,37 +624,29 @@ public class GameFileViewModel(GameFile asset) : ViewModel
|
||||
}
|
||||
|
||||
Resolved |= EResolveCompute.Preview;
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private void SetPreviewImage(SKData data)
|
||||
private void SetPreviewImage(SKBitmap bitmap)
|
||||
{
|
||||
using var ms = new MemoryStream(data.ToArray());
|
||||
ms.Position = 0;
|
||||
var bitmap = new BitmapImage();
|
||||
bitmap.BeginInit();
|
||||
bitmap.CacheOption = BitmapCacheOption.OnLoad;
|
||||
bitmap.StreamSource = ms;
|
||||
bitmap.EndInit();
|
||||
bitmap.Freeze();
|
||||
Application.Current.Dispatcher.InvokeAsync(() => PreviewImage = bitmap);
|
||||
}
|
||||
|
||||
private CancellationTokenSource _previewCts;
|
||||
public void OnIsVisible()
|
||||
{
|
||||
if (Resolved == EResolveCompute.All)
|
||||
if (bitmap.Width <= 0 || bitmap.Height <= 0)
|
||||
return;
|
||||
|
||||
_previewCts?.Cancel();
|
||||
_previewCts = new CancellationTokenSource();
|
||||
var token = _previewCts.Token;
|
||||
Task.Delay(100, token).ContinueWith(t =>
|
||||
{
|
||||
if (t.IsCanceled) return;
|
||||
ResolveAsync(EResolveCompute.All);
|
||||
}, TaskScheduler.FromCurrentSynchronizationContext());
|
||||
var scale = Math.Min(1, (double) MaxPreviewSize / Math.Max(bitmap.Width, bitmap.Height));
|
||||
using var pixels = new SKBitmap(new SKImageInfo(Math.Max(1, (int) (bitmap.Width * scale)), Math.Max(1, (int) (bitmap.Height * scale)), SKColorType.Bgra8888, SKAlphaType.Premul));
|
||||
|
||||
if (!bitmap.ScalePixels(pixels, SKFilterQuality.Low))
|
||||
return;
|
||||
|
||||
var image = BitmapSource.Create(pixels.Width, pixels.Height, 96, 96, PixelFormats.Pbgra32, null, pixels.GetPixels(), pixels.ByteCount, pixels.RowBytes);
|
||||
image.Freeze();
|
||||
PublishPreview(image);
|
||||
}
|
||||
|
||||
private void PublishPreview(ImageSource image, bool rendered = false) => Application.Current.Dispatcher.InvokeAsync(() =>
|
||||
{
|
||||
IsRenderedPreview = rendered;
|
||||
PreviewImage = image;
|
||||
}, DispatcherPriority.Background);
|
||||
}
|
||||
|
||||
[Flags]
|
||||
|
||||
@@ -70,11 +70,15 @@ public class SnooperViewModel : ViewModel, IDisposable
|
||||
Bridge.Host = new FModelBridgeHost();
|
||||
Bridge.PendingRequestChanged += request => PendingRequest = request;
|
||||
|
||||
_host = new SnooperHost(() => new EditorWindow(htz, width, height, ApplicationService.ApplicationView.CUE4Parse.Provider, startVisible: false, closeHides: true), OnStartupFailure);
|
||||
_host = new SnooperHost(() => new EditorWindow(htz, width, height, ApplicationService.ApplicationView.CUE4Parse.Provider, startVisible: false, closeHides: true), OnStartupFailure, GameFileViewModel.MaxPreviewSize);
|
||||
_sun = new SunActor();
|
||||
_environment = new EnvironmentActor();
|
||||
}
|
||||
|
||||
public byte[] RenderMeshPreview(UObject asset) => _host.RenderMeshPreview(asset, (float) SystemParameters.PrimaryScreenHeight);
|
||||
|
||||
public void CloseMeshPreviews() => _host.CloseMeshPreviews();
|
||||
|
||||
public void Load(UObject obj, CancellationToken ct = default)
|
||||
{
|
||||
if (!CanOpenSnooper)
|
||||
@@ -88,6 +92,7 @@ public class SnooperViewModel : ViewModel, IDisposable
|
||||
UIRMesh ir => new MeshActor(ir),
|
||||
UHoudiniStaticMesh hsm => new MeshActor(hsm),
|
||||
USkinnedAsset sa => new MeshActor(sa),
|
||||
USkeleton sk => new MeshActor(sk),
|
||||
UGeometryCollection gc => new MeshActor(gc),
|
||||
UAnimationAsset anim => new MeshActor(anim),
|
||||
UMaterialInterface mat => new MaterialActor(mat),
|
||||
|
||||
@@ -17,7 +17,9 @@
|
||||
<SolidColorBrush x:Key="CustomizableObjectBrush" Color="DarkRed" />
|
||||
<SolidColorBrush x:Key="NaniteDisplacedMeshBrush" Color="ForestGreen" />
|
||||
|
||||
<SolidColorBrush x:Key="MaterialBrush" Color="BurlyWood" />
|
||||
<SolidColorBrush x:Key="MaterialBrush" Color="#40c040" />
|
||||
<SolidColorBrush x:Key="MaterialFunctionBrush" Color="#659f9c"/>
|
||||
<SolidColorBrush x:Key="MaterialParameterBrush" Color="#008000"/>
|
||||
<SolidColorBrush x:Key="MaterialEditorBrush" Color="Yellow" />
|
||||
|
||||
<SolidColorBrush x:Key="RigBrush" Color="YellowGreen" />
|
||||
|
||||
@@ -99,6 +99,7 @@ public partial class DropOverlay : UserControl
|
||||
try
|
||||
{
|
||||
_applicationView.CUE4Parse.ApplyMappingFile(_path);
|
||||
_applicationView.RefreshAssetResolution();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
@@ -24,21 +24,27 @@
|
||||
<Grid Width="20"
|
||||
Height="20"
|
||||
Margin="0 0 8 0">
|
||||
<Image Stretch="Uniform"
|
||||
controls:ImageAnimation.Frames="{Binding PreviewImage.(controls:ImageAnimation.Frames)}"
|
||||
Source="{Binding PreviewImage}" />
|
||||
<Image x:Name="Preview" Stretch="Uniform" Source="{Binding PreviewImage}"
|
||||
controls:ImageAnimation.Frames="{Binding PreviewImage.(controls:ImageAnimation.Frames)}" />
|
||||
<Path x:Name="FallbackIcon"
|
||||
Stretch="Uniform">
|
||||
Stretch="Uniform" IsHitTestVisible="False">
|
||||
<Path.Style>
|
||||
<Style TargetType="{x:Type Path}">
|
||||
<Setter Property="Visibility"
|
||||
Value="Collapsed" />
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding PreviewImage}"
|
||||
<DataTrigger Binding="{Binding Source, ElementName=Preview}"
|
||||
Value="{x:Null}">
|
||||
<Setter Property="Visibility"
|
||||
Value="Visible" />
|
||||
</DataTrigger>
|
||||
<DataTrigger Binding="{Binding IsRenderedPreview}" Value="True">
|
||||
<Setter Property="Visibility" Value="Visible" />
|
||||
<Setter Property="Width" Value="8" />
|
||||
<Setter Property="Height" Value="8" />
|
||||
<Setter Property="HorizontalAlignment" Value="Right" />
|
||||
<Setter Property="VerticalAlignment" Value="Bottom" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</Path.Style>
|
||||
|
||||
@@ -20,15 +20,25 @@
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Grid Grid.Row="0" Height="128" Background="{DynamicResource {x:Static adonisUi:Brushes.Layer3BorderBrush}}">
|
||||
<Image Stretch="Uniform" Source="{Binding PreviewImage}" controls:ImageAnimation.Frames="{Binding PreviewImage.(controls:ImageAnimation.Frames)}" />
|
||||
<Path x:Name="FallbackIcon" Width="64" Stretch="Uniform">
|
||||
<Image x:Name="Preview" Stretch="Uniform" Source="{Binding PreviewImage}"
|
||||
controls:ImageAnimation.Frames="{Binding PreviewImage.(controls:ImageAnimation.Frames)}" />
|
||||
<Path x:Name="FallbackIcon" Stretch="Uniform" IsHitTestVisible="False">
|
||||
<Path.Style>
|
||||
<Style TargetType="{x:Type Path}">
|
||||
<Setter Property="Width" Value="64" />
|
||||
<Setter Property="Visibility" Value="Collapsed" />
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding PreviewImage}" Value="{x:Null}">
|
||||
<DataTrigger Binding="{Binding Source, ElementName=Preview}" Value="{x:Null}">
|
||||
<Setter Property="Visibility" Value="Visible" />
|
||||
</DataTrigger>
|
||||
<DataTrigger Binding="{Binding IsRenderedPreview}" Value="True">
|
||||
<Setter Property="Visibility" Value="Visible" />
|
||||
<Setter Property="Width" Value="16" />
|
||||
<Setter Property="Height" Value="16" />
|
||||
<Setter Property="HorizontalAlignment" Value="Right" />
|
||||
<Setter Property="VerticalAlignment" Value="Bottom" />
|
||||
<Setter Property="Margin" Value="0 0 5 5" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</Path.Style>
|
||||
|
||||
@@ -40,9 +40,10 @@ public class FileToGeometryConverter : IMultiValueConverter
|
||||
|
||||
EAssetCategory.Material => ("MaterialIcon", "MaterialBrush"),
|
||||
EAssetCategory.MaterialEditorData => ("MaterialIcon", "MaterialEditorBrush"),
|
||||
EAssetCategory.MaterialParameterCollection => ("MaterialParameterCollectionIcon", "MaterialBrush"),
|
||||
EAssetCategory.MaterialFunction => ("MaterialFunctionIcon", "MaterialBrush"),
|
||||
EAssetCategory.MaterialParameterCollection => ("MaterialParameterCollectionIcon", "MaterialParameterBrush"),
|
||||
EAssetCategory.MaterialFunction => ("MaterialFunctionIcon", "MaterialFunctionBrush"),
|
||||
EAssetCategory.MaterialFunctionEditorData => ("MaterialFunctionIcon", "MaterialEditorBrush"),
|
||||
EAssetCategory.PhysicalMaterial => ("PhysicalMaterialIcon", "NeutralBrush"),
|
||||
|
||||
EAssetCategory.Animation => ("AnimationIconAlt", "AnimationBrush"),
|
||||
EAssetCategory.Skeleton => ("SkeletonIcon", "NeutralBrush"),
|
||||
@@ -57,7 +58,6 @@ public class FileToGeometryConverter : IMultiValueConverter
|
||||
EAssetCategory.CurveBase => ("CurveIcon", "CurveBrush"),
|
||||
EAssetCategory.PhysicsAsset => ("PhysicsIcon", "NeutralBrush"),
|
||||
EAssetCategory.ObjectRedirector => ("RedirectorIcon", "ConfigBrush"),
|
||||
EAssetCategory.PhysicalMaterial => ("MaterialIcon", "NeutralBrush"),
|
||||
|
||||
EAssetCategory.Audio => ("AudioIconAlt", "AudioBrush"),
|
||||
EAssetCategory.SoundBank => ("AudioIconAlt", "SoundBankBrush"),
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -824,6 +824,21 @@
|
||||
|
||||
<Menu Background="{DynamicResource {x:Static adonisUi:Brushes.Layer3BackgroundBrush}}"
|
||||
HorizontalAlignment="Right" VerticalAlignment="Bottom" Grid.Column="1">
|
||||
<MenuItem Command="{Binding MenuCommand}" CommandParameter="Views_AssetsExplorer" Width="30">
|
||||
<MenuItem.ToolTip>
|
||||
<ToolTip Content="{Binding SwitchAssetExplorer, Source={x:Static settings:UserSettings.Default}}"
|
||||
ContentStringFormat="Assets Explorer ({0})" />
|
||||
</MenuItem.ToolTip>
|
||||
<MenuItem.Header>
|
||||
<Viewbox Width="16" Height="16" HorizontalAlignment="Center">
|
||||
<Canvas Width="24" Height="24">
|
||||
<Path Stroke="{DynamicResource {x:Static adonisUi:Brushes.ForegroundBrush}}" StrokeThickness="1.75" Data="M11 19h-6a2 2 0 0 1 -2 -2v-11a2 2 0 0 1 2 -2h4l3 3h7a2 2 0 0 1 2 2v2.5" />
|
||||
<Path Stroke="{DynamicResource {x:Static adonisUi:Brushes.ForegroundBrush}}" StrokeThickness="1.75" Data="M15 18a3 3 0 1 0 6 0a3 3 0 1 0 -6 0" />
|
||||
<Path Stroke="{DynamicResource {x:Static adonisUi:Brushes.ForegroundBrush}}" StrokeThickness="1.75" Data="M20.2 20.2l1.8 1.8" />
|
||||
</Canvas>
|
||||
</Viewbox>
|
||||
</MenuItem.Header>
|
||||
</MenuItem>
|
||||
<MenuItem Command="{Binding CUE4Parse.TabControl.AddTabCommand}" ToolTip="Add New Tab" Width="30">
|
||||
<MenuItem.Header>
|
||||
<Viewbox Width="16" Height="16" HorizontalAlignment="Center">
|
||||
@@ -2173,125 +2188,6 @@
|
||||
<Setter Property="SelectedFoldingMarkerBackgroundBrush" Value="#2A2B34" />
|
||||
</Style>
|
||||
|
||||
<DropShadowEffect x:Key="ShadowEffect"
|
||||
Color="Black"
|
||||
BlurRadius="6"
|
||||
ShadowDepth="0"
|
||||
Opacity="0.3" />
|
||||
|
||||
<Style x:Key="ModernToggleButtonStyle"
|
||||
TargetType="ToggleButton">
|
||||
<Setter Property="Background"
|
||||
Value="{DynamicResource {x:Static adonisUi:Brushes.Layer1BackgroundBrush}}" />
|
||||
<Setter Property="BorderBrush"
|
||||
Value="{DynamicResource {x:Static adonisUi:Brushes.Layer3BackgroundBrush}}" />
|
||||
<Setter Property="BorderThickness"
|
||||
Value="1" />
|
||||
<Setter Property="Padding"
|
||||
Value="4" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="ToggleButton">
|
||||
<Border Background="{TemplateBinding Background}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
CornerRadius="8"
|
||||
Padding="{TemplateBinding Padding}">
|
||||
<ContentPresenter HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center" />
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsChecked"
|
||||
Value="True">
|
||||
<Setter Property="Background"
|
||||
Value="{DynamicResource {x:Static adonisUi:Brushes.AccentBrush}}" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsMouseOver"
|
||||
Value="True">
|
||||
<Setter Property="Background"
|
||||
Value="{DynamicResource {x:Static adonisUi:Brushes.Layer3BackgroundBrush}}" />
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="AssetsExplorerToggleButtonStyle"
|
||||
TargetType="ToggleButton">
|
||||
<Setter Property="Background"
|
||||
Value="{DynamicResource {x:Static adonisUi:Brushes.Layer1BackgroundBrush}}" />
|
||||
<Setter Property="BorderBrush"
|
||||
Value="{DynamicResource {x:Static adonisUi:Brushes.Layer3BackgroundBrush}}" />
|
||||
<Setter Property="BorderThickness"
|
||||
Value="1" />
|
||||
<Setter Property="Padding"
|
||||
Value="4" />
|
||||
<Setter Property="ToolTip">
|
||||
<Setter.Value>
|
||||
<ToolTip Content="{Binding SwitchAssetExplorer, Source={x:Static settings:UserSettings.Default}}"
|
||||
ContentStringFormat="Assets Explorer ({0})" />
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="ToggleButton">
|
||||
<Border Background="{TemplateBinding Background}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
CornerRadius="8">
|
||||
<Viewbox Width="18"
|
||||
Height="18">
|
||||
<Canvas Width="24"
|
||||
Height="24">
|
||||
<Path x:Name="IconPath"
|
||||
Data="{StaticResource FolderIconAlt}"
|
||||
Fill="{DynamicResource {x:Static adonisUi:Brushes.ForegroundBrush}}" />
|
||||
</Canvas>
|
||||
</Viewbox>
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsChecked"
|
||||
Value="True">
|
||||
<Setter TargetName="IconPath"
|
||||
Property="Data"
|
||||
Value="{StaticResource FolderIconAlt}" />
|
||||
<Setter Property="Background"
|
||||
Value="{DynamicResource {x:Static adonisUi:Brushes.AccentBrush}}" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsChecked"
|
||||
Value="False">
|
||||
<Setter TargetName="IconPath"
|
||||
Property="Data"
|
||||
Value="{StaticResource AssetIcon}" />
|
||||
<Setter Property="Background"
|
||||
Value="{DynamicResource {x:Static adonisUi:Brushes.Layer1BackgroundBrush}}" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsChecked"
|
||||
Value="False">
|
||||
<Setter TargetName="IconPath"
|
||||
Property="Data"
|
||||
Value="{StaticResource AssetIcon}" />
|
||||
<Setter Property="Background"
|
||||
Value="{DynamicResource {x:Static adonisUi:Brushes.Layer1BackgroundBrush}}" />
|
||||
<Setter Property="ToolTip">
|
||||
<Setter.Value>
|
||||
<ToolTip Content="{Binding SwitchAssetExplorer, Source={x:Static settings:UserSettings.Default}}"
|
||||
ContentStringFormat="File Properties ({0})" />
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Trigger>
|
||||
<Trigger Property="IsMouseOver"
|
||||
Value="True">
|
||||
<Setter Property="Background"
|
||||
Value="{DynamicResource {x:Static adonisUi:Brushes.Layer3BackgroundBrush}}" />
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<!-- Just to keep border color during toggle -->
|
||||
<Style x:Key="ExplorerViewToggleButton"
|
||||
TargetType="{x:Type ToggleButton}"
|
||||
|
||||
@@ -433,49 +433,59 @@
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="10" />
|
||||
<ColumnDefinition Width="16" />
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="5" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<TextBlock Grid.Row="0" Grid.Column="0" Text="Preview Max Texture Size" VerticalAlignment="Center" Margin="0 0 0 5" />
|
||||
<Slider Grid.Row="0" Grid.Column="2" Grid.ColumnSpan="3" TickPlacement="None" Minimum="4" Maximum="4096" Ticks="4,8,16,32,64,128,256,512,1024,2048,4096"
|
||||
AutoToolTipPlacement="BottomRight" IsMoveToPointEnabled="True" IsSnapToTickEnabled="True" Margin="0 5 0 5"
|
||||
Value="{Binding PreviewMaxTextureSize, Source={x:Static local:Settings.UserSettings.Default}, Mode=TwoWay}"/>
|
||||
<Separator Grid.Row="0" Grid.ColumnSpan="3" Style="{StaticResource CustomSeparator}" Tag="3D VIEWER" />
|
||||
|
||||
<TextBlock Grid.Row="1" Grid.Column="0" Text="Preview Static Meshes" VerticalAlignment="Center" Margin="0 0 0 5" />
|
||||
<CheckBox Grid.Row="1" Grid.Column="2" Grid.ColumnSpan="3" Content="{Binding IsChecked, RelativeSource={RelativeSource Self}, Converter={x:Static converters:BoolToToggleConverter.Instance}}"
|
||||
<TextBlock Grid.Row="1" Text="Preview Max Texture Size" VerticalAlignment="Center" />
|
||||
<Grid Grid.Row="1" Grid.Column="2" Margin="0 5">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="10" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Slider x:Name="PreviewTextureSize" Minimum="4" Maximum="4096" Ticks="4,8,16,32,64,128,256,512,1024,2048,4096"
|
||||
AutoToolTipPlacement="BottomRight" IsMoveToPointEnabled="True" IsSnapToTickEnabled="True" VerticalAlignment="Center"
|
||||
Value="{Binding PreviewMaxTextureSize, Source={x:Static local:Settings.UserSettings.Default}, Mode=TwoWay}" />
|
||||
<TextBlock Grid.Column="2" VerticalAlignment="Center"
|
||||
Text="{Binding Value, ElementName=PreviewTextureSize, StringFormat={}{0:0} px}" />
|
||||
</Grid>
|
||||
|
||||
<TextBlock Grid.Row="2" Text="Preview Static Meshes" VerticalAlignment="Center" />
|
||||
<CheckBox Grid.Row="2" Grid.Column="2" Content="{Binding IsChecked, RelativeSource={RelativeSource Self}, Converter={x:Static converters:BoolToToggleConverter.Instance}}"
|
||||
IsChecked="{Binding PreviewStaticMeshes, Source={x:Static local:Settings.UserSettings.Default}, Mode=TwoWay}"
|
||||
Style="{DynamicResource {x:Static adonisUi:Styles.ToggleSwitch}}" Margin="0 5 0 5"/>
|
||||
Style="{DynamicResource {x:Static adonisUi:Styles.ToggleSwitch}}" Margin="0 5 0 10" />
|
||||
|
||||
<TextBlock Grid.Row="2" Grid.Column="0" Text="Preview Skeletal Meshes" VerticalAlignment="Center" Margin="0 0 0 5" />
|
||||
<CheckBox Grid.Row="2" Grid.Column="2" Grid.ColumnSpan="3" Content="{Binding IsChecked, RelativeSource={RelativeSource Self}, Converter={x:Static converters:BoolToToggleConverter.Instance}}"
|
||||
<TextBlock Grid.Row="3" Text="Preview Skeletal Meshes" VerticalAlignment="Center" TextWrapping="Wrap" />
|
||||
<CheckBox Grid.Row="3" Grid.Column="2" Content="{Binding IsChecked, RelativeSource={RelativeSource Self}, Converter={x:Static converters:BoolToToggleConverter.Instance}}"
|
||||
IsChecked="{Binding PreviewSkeletalMeshes, Source={x:Static local:Settings.UserSettings.Default}, Mode=TwoWay}"
|
||||
Style="{DynamicResource {x:Static adonisUi:Styles.ToggleSwitch}}" Margin="0 5 0 5"/>
|
||||
Style="{DynamicResource {x:Static adonisUi:Styles.ToggleSwitch}}" Margin="0 5 0 10" />
|
||||
|
||||
<TextBlock Grid.Row="3" Grid.Column="0" Text="Preview Animations" VerticalAlignment="Center" Margin="0 0 0 5" />
|
||||
<CheckBox Grid.Row="3" Grid.Column="2" Grid.ColumnSpan="3" Content="{Binding IsChecked, RelativeSource={RelativeSource Self}, Converter={x:Static converters:BoolToToggleConverter.Instance}}"
|
||||
<TextBlock Grid.Row="4" Text="Preview Animations" VerticalAlignment="Center" />
|
||||
<CheckBox Grid.Row="4" Grid.Column="2" Content="{Binding IsChecked, RelativeSource={RelativeSource Self}, Converter={x:Static converters:BoolToToggleConverter.Instance}}"
|
||||
IsChecked="{Binding PreviewAnimations, Source={x:Static local:Settings.UserSettings.Default}, Mode=TwoWay}"
|
||||
Style="{DynamicResource {x:Static adonisUi:Styles.ToggleSwitch}}" Margin="0 5 0 5"/>
|
||||
Style="{DynamicResource {x:Static adonisUi:Styles.ToggleSwitch}}" Margin="0 5 0 10" />
|
||||
|
||||
<TextBlock Grid.Row="4" Grid.Column="0" Text="Preview Materials" VerticalAlignment="Center" Margin="0 0 0 5" />
|
||||
<CheckBox Grid.Row="4" Grid.Column="2" Grid.ColumnSpan="3" Content="{Binding IsChecked, RelativeSource={RelativeSource Self}, Converter={x:Static converters:BoolToToggleConverter.Instance}}"
|
||||
<TextBlock Grid.Row="5" Text="Preview Materials" VerticalAlignment="Center" />
|
||||
<CheckBox Grid.Row="5" Grid.Column="2" Content="{Binding IsChecked, RelativeSource={RelativeSource Self}, Converter={x:Static converters:BoolToToggleConverter.Instance}}"
|
||||
IsChecked="{Binding PreviewMaterials, Source={x:Static local:Settings.UserSettings.Default}, Mode=TwoWay}"
|
||||
Style="{DynamicResource {x:Static adonisUi:Styles.ToggleSwitch}}" Margin="0 5 0 5"/>
|
||||
Style="{DynamicResource {x:Static adonisUi:Styles.ToggleSwitch}}" Margin="0 5 0 10" />
|
||||
|
||||
<TextBlock Grid.Row="5" Grid.Column="0" Text="Preview Worlds (.umap)" VerticalAlignment="Center" Margin="0 0 0 5" />
|
||||
<CheckBox Grid.Row="5" Grid.Column="2" Grid.ColumnSpan="3" Content="{Binding IsChecked, RelativeSource={RelativeSource Self}, Converter={x:Static converters:BoolToToggleConverter.Instance}}"
|
||||
<TextBlock Grid.Row="6" Text="Preview Worlds (.umap)" VerticalAlignment="Center" TextWrapping="Wrap" />
|
||||
<CheckBox Grid.Row="6" Grid.Column="2" Content="{Binding IsChecked, RelativeSource={RelativeSource Self}, Converter={x:Static converters:BoolToToggleConverter.Instance}}"
|
||||
IsChecked="{Binding PreviewWorlds, Source={x:Static local:Settings.UserSettings.Default}, Mode=TwoWay}"
|
||||
Style="{DynamicResource {x:Static adonisUi:Styles.ToggleSwitch}}" Margin="0 5 0 5"/>
|
||||
Style="{DynamicResource {x:Static adonisUi:Styles.ToggleSwitch}}" Margin="0 5 0 10" />
|
||||
|
||||
<TextBlock Grid.Row="6" Grid.Column="0" Text="Handle Skeletons as Empty Meshes" VerticalAlignment="Center" />
|
||||
<CheckBox Grid.Row="6" Grid.Column="2" Grid.ColumnSpan="3" Content="{Binding IsChecked, RelativeSource={RelativeSource Self}, Converter={x:Static converters:BoolToToggleConverter.Instance}}"
|
||||
<TextBlock Grid.Row="7" Text="Treat Skeletons as Empty Meshes" VerticalAlignment="Center" TextWrapping="Wrap" />
|
||||
<CheckBox Grid.Row="7" Grid.Column="2" Content="{Binding IsChecked, RelativeSource={RelativeSource Self}, Converter={x:Static converters:BoolToToggleConverter.Instance}}"
|
||||
IsChecked="{Binding SaveSkeletonAsMesh, Source={x:Static local:Settings.UserSettings.Default}, Mode=TwoWay}"
|
||||
Style="{DynamicResource {x:Static adonisUi:Styles.ToggleSwitch}}" Margin="0 5 0 0"/>
|
||||
Style="{DynamicResource {x:Static adonisUi:Styles.ToggleSwitch}}" Margin="0 5 0 10" />
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
<DataTemplate x:Key="KeybindingsTemplate">
|
||||
|
||||
@@ -77,6 +77,7 @@ public partial class SettingsView
|
||||
|
||||
UserSettings.Save();
|
||||
ExportSessionViewModel.Instance.Options.ResetToUserDefaults();
|
||||
_applicationView.RefreshAssetResolution();
|
||||
}
|
||||
|
||||
private void OnClosing(object sender, CancelEventArgs e)
|
||||
|
||||
2
Snooper
2
Snooper
Submodule Snooper updated: d3d4ce01f3...a58b7f2379
Reference in New Issue
Block a user