mirror of
https://github.com/4sval/FModel.git
synced 2026-12-04 23:02:22 -06:00
Monster Hunter Outlanders, Ghostwire: Tokyo, animated textures, various fixes
Some checks failed
FModel QA Builder / build (push) Has been cancelled
Some checks failed
FModel QA Builder / build (push) Has been cancelled
- Roco Kingdom: World fix - Paper2D support, with animated flipbook preview/export - texture inspector - export disabled mesh sections - texture decoding and orphaned component fixes Co-authored-by: Masusder <59669685+Masusder@users.noreply.github.com> Co-authored-by: LongerWarrior <37636768+LongerWarrior@users.noreply.github.com> Co-authored-by: DRayX <7531689+DRayX@users.noreply.github.com> Co-authored-by: FudgeRookie <30218389+FudgeRK@users.noreply.github.com> Co-authored-by: Luke <17146677+LukeFZ@users.noreply.github.com>
This commit is contained in:
Submodule CUE4Parse updated: 85495b5e12...18d2b8bce7
@@ -170,7 +170,7 @@ public class BaseIcon : UCreator
|
||||
{
|
||||
if (uObject is UTexture2D texture2D)
|
||||
{
|
||||
SeriesBackground = texture2D.Decode().ToSkBitmap();
|
||||
SeriesBackground = texture2D.Decode(UserSettings.GetExportOptions()).ToSkBitmap();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -124,7 +124,7 @@ public static class Utils
|
||||
|
||||
public static SKBitmap GetB64Bitmap(string b64) => SKBitmap.Decode(new MemoryStream(Convert.FromBase64String(b64)) { Position = 0 });
|
||||
public static SKBitmap GetBitmap(string fullPath) => TryLoadObject(fullPath, out UTexture2D texture) ? GetBitmap(texture) : null;
|
||||
public static SKBitmap GetBitmap(UTexture2D texture) => texture.Decode(UserSettings.Default.CurrentDir.TexturePlatform).ToSkBitmap();
|
||||
public static SKBitmap GetBitmap(UTexture2D texture) => texture.Decode(UserSettings.GetExportOptions()).ToSkBitmap();
|
||||
public static SKBitmap GetBitmap(byte[] data) => SKBitmap.Decode(data);
|
||||
|
||||
public static SKBitmap ResizeWithRatio(this SKBitmap me, double width, double height)
|
||||
|
||||
@@ -133,7 +133,9 @@ public enum EAssetCategory : uint
|
||||
NaniteDisplacedMesh = Mesh + 4,
|
||||
GeometryCollection = Mesh + 5,
|
||||
ChaosClothAsset = Mesh + 6,
|
||||
GroomAsset = Mesh + 7,
|
||||
Texture = AssetCategoryExtensions.CategoryBase + (3 << 16),
|
||||
AnimatedTexture = Texture + 1,
|
||||
Materials = AssetCategoryExtensions.CategoryBase + (4 << 16),
|
||||
Material = Materials + 1,
|
||||
MaterialEditorData = Materials + 2,
|
||||
|
||||
@@ -6,11 +6,21 @@ using System.IO;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Media.Imaging;
|
||||
|
||||
namespace FModel.Extensions;
|
||||
|
||||
public static class ClipboardExtensions
|
||||
{
|
||||
public static void SetImage(BitmapSource image, string fileName = null)
|
||||
{
|
||||
var encoder = new PngBitmapEncoder();
|
||||
encoder.Frames.Add(BitmapFrame.Create(image));
|
||||
using var stream = new MemoryStream();
|
||||
encoder.Save(stream);
|
||||
SetImage(stream.ToArray(), fileName);
|
||||
}
|
||||
|
||||
public static void SetImage(byte[] pngBytes, string fileName = null)
|
||||
{
|
||||
Clipboard.Clear();
|
||||
@@ -195,4 +205,4 @@ public static class ClipboardExtensions
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<Solution>
|
||||
<Project Path="../CUE4Parse/CUE4Parse-Conversion/CUE4Parse-Conversion.csproj" />
|
||||
<Project Path="../CUE4Parse/CUE4Parse.Tests/CUE4Parse.Tests.csproj" />
|
||||
<Project Path="../CUE4Parse/CUE4Parse/CUE4Parse.csproj" />
|
||||
<Project Path="../Snooper/Editor/Editor.csproj" />
|
||||
<Project Path="../Snooper/Snooper/Snooper.csproj" />
|
||||
|
||||
@@ -17,7 +17,7 @@ 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) : IDisposable
|
||||
public sealed class SnooperHost(Func<EditorWindow> build, Action<Exception> onStartupFailure) : IDisposable
|
||||
{
|
||||
private readonly Lock _lock = new();
|
||||
private readonly SemaphoreSlim _wanted = new(0);
|
||||
@@ -27,22 +27,25 @@ public sealed class SnooperHost(Func<EditorWindow> build) : IDisposable
|
||||
private Exception? _failure;
|
||||
private Thread? _thread;
|
||||
|
||||
public EditorWindow Window
|
||||
public EditorWindow? GetWindow()
|
||||
{
|
||||
get
|
||||
Exception? failure;
|
||||
lock (_lock)
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
if (_window is { } current) return current;
|
||||
if (_window is { } current) return current;
|
||||
|
||||
_thread ??= StartThread();
|
||||
_ready.Reset();
|
||||
_wanted.Release();
|
||||
_ready.Wait();
|
||||
_thread ??= StartThread();
|
||||
_ready.Reset();
|
||||
_wanted.Release();
|
||||
_ready.Wait();
|
||||
|
||||
return _window ?? throw new InvalidOperationException("Snooper failed to start", _failure);
|
||||
}
|
||||
if (_window is { } window) return window;
|
||||
|
||||
failure = _failure;
|
||||
}
|
||||
|
||||
onStartupFailure(new InvalidOperationException("Snooper failed to start", failure));
|
||||
return null;
|
||||
}
|
||||
|
||||
private Thread StartThread()
|
||||
|
||||
@@ -149,7 +149,8 @@
|
||||
</MenuItem>
|
||||
</MenuItem>
|
||||
<MenuItem Header="Views">
|
||||
<MenuItem Header="3D Viewer" Command="{Binding MenuCommand}" CommandParameter="Views_3dViewer">
|
||||
<MenuItem Header="3D Viewer" Command="{Binding MenuCommand}" CommandParameter="Views_3dViewer"
|
||||
IsEnabled="{Binding CanOpenSnooper, Source={x:Static viewModels:SnooperViewModel.Instance}}">
|
||||
<MenuItem.Icon>
|
||||
<Viewbox Width="16" Height="16">
|
||||
<Canvas Width="24" Height="24">
|
||||
@@ -423,6 +424,7 @@
|
||||
<DockPanel>
|
||||
|
||||
<inputs:SearchTextBox DockPanel.Dock="Top" x:Name="AssetsSearchTextBox"
|
||||
Watermark="Filter assets in current folder..."
|
||||
Text="{Binding CUE4Parse.AssetsFolder.SelectedFolder.SearchText, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
|
||||
ClearButtonClick="OnClearFilterClick" />
|
||||
|
||||
@@ -510,6 +512,7 @@
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<inputs:SearchTextBox x:Name="AssetsExplorerSearch" Grid.Column="0"
|
||||
Watermark="Filter assets in current folder..."
|
||||
Text="{Binding CUE4Parse.AssetsFolder.SelectedFolder.SearchText, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
|
||||
ClearButtonClick="OnClearFilterClick" />
|
||||
|
||||
|
||||
@@ -120,7 +120,6 @@ public partial class MainWindow
|
||||
_applicationView.CUE4Parse.VerifyConsoleVariables(),
|
||||
_applicationView.CUE4Parse.VerifyOnDemandArchives(),
|
||||
_applicationView.CUE4Parse.InitMappings(),
|
||||
ApplicationViewModel.InitDetex(),
|
||||
ApplicationViewModel.InitVgmStream(),
|
||||
Task.Run(() =>
|
||||
{
|
||||
|
||||
@@ -72,7 +72,9 @@ public sealed class UserSettings : ViewModel
|
||||
Default.SocketExportFormat,
|
||||
Default.CompressionFormat,
|
||||
Default.PngCompressionLevel,
|
||||
Default.TgaRleCompression
|
||||
Default.TgaRleCompression,
|
||||
Default.IncludeDisabledMeshSections,
|
||||
Default.AnimatedTextureExportFormat
|
||||
);
|
||||
}
|
||||
|
||||
@@ -504,6 +506,13 @@ public sealed class UserSettings : ViewModel
|
||||
set => SetProperty(ref _naniteMeshExportFormat, value);
|
||||
}
|
||||
|
||||
private bool _includeDisabledMeshSections;
|
||||
public bool IncludeDisabledMeshSections
|
||||
{
|
||||
get => _includeDisabledMeshSections;
|
||||
set => SetProperty(ref _includeDisabledMeshSections, value);
|
||||
}
|
||||
|
||||
private EMeshQuality _meshQuality = EMeshQuality.Highest;
|
||||
public EMeshQuality MeshQuality
|
||||
{
|
||||
@@ -511,7 +520,7 @@ public sealed class UserSettings : ViewModel
|
||||
set => SetProperty(ref _meshQuality, value);
|
||||
}
|
||||
|
||||
private EMaterialDepth _materialExportFormat = EMaterialDepth.TopLayerOnly;
|
||||
private EMaterialDepth _materialExportFormat = EMaterialDepth.AllLayers;
|
||||
public EMaterialDepth MaterialExportFormat
|
||||
{
|
||||
get => _materialExportFormat;
|
||||
@@ -525,6 +534,13 @@ public sealed class UserSettings : ViewModel
|
||||
set => SetProperty(ref _textureExportFormat, value);
|
||||
}
|
||||
|
||||
private EAnimatedTextureFormat _animatedTextureExportFormat = EAnimatedTextureFormat.Png;
|
||||
public EAnimatedTextureFormat AnimatedTextureExportFormat
|
||||
{
|
||||
get => _animatedTextureExportFormat;
|
||||
set => SetProperty(ref _animatedTextureExportFormat, value);
|
||||
}
|
||||
|
||||
private int _textureQuality = 100;
|
||||
public int TextureQuality
|
||||
{
|
||||
|
||||
@@ -314,21 +314,6 @@ public class ApplicationViewModel : ViewModel
|
||||
await ZlibHelper.InitializeAsync(zlibPath);
|
||||
}
|
||||
|
||||
public static async Task InitDetex()
|
||||
{
|
||||
var detexPath = Path.Combine(UserSettings.Default.OutputDirectory, ".data", DetexHelper.DLL_NAME);
|
||||
if (File.Exists(DetexHelper.DLL_NAME))
|
||||
{
|
||||
File.Move(DetexHelper.DLL_NAME, detexPath, true);
|
||||
}
|
||||
else if (!File.Exists(detexPath))
|
||||
{
|
||||
await DetexHelper.LoadDllAsync(detexPath);
|
||||
}
|
||||
|
||||
DetexHelper.Initialize(detexPath);
|
||||
}
|
||||
|
||||
public static async Task InitUnluac()
|
||||
{
|
||||
var unluacPath = Path.Combine(UserSettings.Default.OutputDirectory, ".data", UnluacHelper.DllName);
|
||||
|
||||
@@ -60,6 +60,7 @@ public class TreeItem : ViewModel
|
||||
}
|
||||
|
||||
private string _searchText = string.Empty;
|
||||
private string[] _searchTerms = [];
|
||||
public string SearchText
|
||||
{
|
||||
get => _searchText;
|
||||
@@ -67,6 +68,7 @@ public class TreeItem : ViewModel
|
||||
{
|
||||
if (SetProperty(ref _searchText, value))
|
||||
{
|
||||
_searchTerms = value.Trim().Split(' ', StringSplitOptions.RemoveEmptyEntries);
|
||||
RefreshFilters();
|
||||
}
|
||||
}
|
||||
@@ -104,7 +106,7 @@ public class TreeItem : ViewModel
|
||||
// BulkPopulate sorts Folders before this view is created
|
||||
_filteredFoldersView ??= new ListCollectionView(Folders)
|
||||
{
|
||||
Filter = e => ItemFilter(e, SearchText.Trim().Split(' ', StringSplitOptions.RemoveEmptyEntries))
|
||||
Filter = ItemFilter
|
||||
};
|
||||
return _filteredFoldersView;
|
||||
}
|
||||
@@ -132,7 +134,7 @@ public class TreeItem : ViewModel
|
||||
}
|
||||
PathAtThisPoint = pathHere;
|
||||
|
||||
AssetsList.AssetsView.Filter = o => ItemFilter(o, SearchText.Trim().Split(' ', StringSplitOptions.RemoveEmptyEntries));
|
||||
AssetsList.AssetsView.Filter = ItemFilter;
|
||||
}
|
||||
|
||||
private void RefreshFilters()
|
||||
@@ -141,27 +143,22 @@ public class TreeItem : ViewModel
|
||||
FilteredFoldersView?.Refresh();
|
||||
}
|
||||
|
||||
private bool ItemFilter(object item, IEnumerable<string> filters)
|
||||
private bool ItemFilter(object item) => item switch
|
||||
{
|
||||
var f = filters.ToArray();
|
||||
switch (item)
|
||||
GameFileViewModel entry => (SelectedCategory == EAssetCategory.All || entry.AssetCategory.IsOfCategory(SelectedCategory)) && MatchesSearch(entry.Asset.Name),
|
||||
TreeItem folder => SelectedCategory == EAssetCategory.All && MatchesSearch(folder.Header),
|
||||
_ => false
|
||||
};
|
||||
|
||||
private bool MatchesSearch(string name)
|
||||
{
|
||||
foreach (var term in _searchTerms)
|
||||
{
|
||||
case GameFileViewModel entry:
|
||||
{
|
||||
bool matchesSearch = f.Length == 0 || f.All(x => entry.Asset.Name.Contains(x, StringComparison.OrdinalIgnoreCase));
|
||||
bool matchesCategory = SelectedCategory == EAssetCategory.All || entry.AssetCategory.IsOfCategory(SelectedCategory);
|
||||
|
||||
return matchesSearch && matchesCategory;
|
||||
}
|
||||
case TreeItem folder:
|
||||
{
|
||||
bool matchesSearch = f.Length == 0 || f.All(x => folder.Header.Contains(x, StringComparison.OrdinalIgnoreCase));
|
||||
bool matchesCategory = SelectedCategory == EAssetCategory.All;
|
||||
|
||||
return matchesSearch && matchesCategory;
|
||||
}
|
||||
if (!name.Contains(term, StringComparison.OrdinalIgnoreCase))
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private async Task OnSelectedCategoryChanged()
|
||||
@@ -333,7 +330,7 @@ public class AssetsFolderViewModel : ViewModel
|
||||
}
|
||||
}
|
||||
|
||||
private static void SortFolders(RangeObservableCollection<TreeItem> folders)
|
||||
private static void SortEntries(RangeObservableCollection<TreeItem> folders)
|
||||
{
|
||||
if (folders.Count > 1)
|
||||
{
|
||||
@@ -342,7 +339,13 @@ public class AssetsFolderViewModel : ViewModel
|
||||
|
||||
foreach (var folder in folders)
|
||||
{
|
||||
SortFolders(folder.Folders);
|
||||
// Keep the source ordered so filtering does not sort the same assets on every edit
|
||||
if (folder.AssetsList.Assets.Count > 1)
|
||||
{
|
||||
folder.AssetsList.Assets.ReplaceRange([.. folder.AssetsList.Assets.OrderBy(x => x.Asset.Path, StringComparer.CurrentCulture)]);
|
||||
}
|
||||
|
||||
SortEntries(folder.Folders);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -420,7 +423,7 @@ public class AssetsFolderViewModel : ViewModel
|
||||
lastNode?.AssetsList.Add(entry);
|
||||
}
|
||||
|
||||
SortFolders(treeItems);
|
||||
SortEntries(treeItems);
|
||||
|
||||
Folders.AddRange(treeItems);
|
||||
VisibleFolders.AddRange(treeItems);
|
||||
|
||||
@@ -14,10 +14,7 @@ public class AssetsListViewModel
|
||||
{
|
||||
get
|
||||
{
|
||||
_assetsView ??= new ListCollectionView(Assets)
|
||||
{
|
||||
SortDescriptions = { new SortDescription("Asset.Path", ListSortDirection.Ascending) }
|
||||
};
|
||||
_assetsView ??= new ListCollectionView(Assets);
|
||||
return _assetsView;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -402,7 +402,7 @@ public class CUE4ParseViewModel : ViewModel
|
||||
return new JmapTypeMappingsProvider(path);
|
||||
}
|
||||
|
||||
return new FileUsmapTypeMappingsProvider(path);
|
||||
return new FileUsmapTypeMappingsProvider(path, StringComparer.Ordinal);
|
||||
}
|
||||
|
||||
public Task InitMappings(bool force = false)
|
||||
@@ -455,7 +455,7 @@ public class CUE4ParseViewModel : ViewModel
|
||||
if (latestUsmaps.Length <= 0) return;
|
||||
|
||||
var latestUsmapInfo = latestUsmaps.OrderBy(f => f.LastWriteTime).Last();
|
||||
Provider.MappingsContainer = new FileUsmapTypeMappingsProvider(latestUsmapInfo.FullName);
|
||||
Provider.MappingsContainer = new FileUsmapTypeMappingsProvider(latestUsmapInfo.FullName, StringComparer.Ordinal);
|
||||
l = ELog.Warning;
|
||||
}
|
||||
}
|
||||
@@ -964,7 +964,7 @@ public class CUE4ParseViewModel : ViewModel
|
||||
canvas.Translate(-bounds.Left, -bounds.Top);
|
||||
canvas.DrawPicture(svg.Picture);
|
||||
|
||||
TabControl.SelectedTab.AddImage(entry.NameWithoutExtension, false, bitmap, saveTextures, updateUi);
|
||||
TabControl.SelectedTab.AddImage(entry.Name, data, bitmap, saveTextures, updateUi);
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -1277,6 +1277,34 @@ public class CUE4ParseViewModel : ViewModel
|
||||
TabControl.SelectedTab.SetDocumentText(luaScript.Code, false, false);
|
||||
return true;
|
||||
}
|
||||
case UPaperSprite when (isNone || saveTextures) && pointer.Object.Value is UPaperSprite paperSprite:
|
||||
{
|
||||
if (saveTextures)
|
||||
{
|
||||
SaveExport(paperSprite);
|
||||
}
|
||||
|
||||
if (updateUi)
|
||||
{
|
||||
TabControl.SelectedTab.AddImage(paperSprite, false, true);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
case UPaperFlipbook when (isNone || saveTextures) && pointer.Object.Value is UPaperFlipbook paperFlipbook:
|
||||
{
|
||||
if (saveTextures)
|
||||
{
|
||||
SaveExport(paperFlipbook);
|
||||
}
|
||||
|
||||
if (updateUi)
|
||||
{
|
||||
TabControl.SelectedTab.AddImage(paperFlipbook, false, true);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
case UTexture when (isNone || saveTextures) && pointer.Object.Value is UTexture texture:
|
||||
{
|
||||
if (saveTextures)
|
||||
@@ -1345,7 +1373,7 @@ public class CUE4ParseViewModel : ViewModel
|
||||
}
|
||||
}
|
||||
|
||||
TabControl.SelectedTab.AddImage(sourceFile.SubstringAfterLast('/'), false, bitmap, false, updateUi);
|
||||
TabControl.SelectedTab.AddImage(Path.GetFileName(sourceFile) ?? svgasset.Name + ".svg", data, bitmap, false, updateUi);
|
||||
return false;
|
||||
}
|
||||
case UBiomesMaskTextureData when (isNone || saveTextures) && pointer.Object.Value is UBiomesMaskTextureData biomes && biomes.MaskData is { } maskData:
|
||||
@@ -1616,7 +1644,7 @@ public class CUE4ParseViewModel : ViewModel
|
||||
case UPaperTileMap when HasFlag(bulk, EBulkType.Worlds) && Provider.Versions.Game is GAME_DeadByDaylight:
|
||||
{
|
||||
SaveExport(pointer.Object.Value);
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
default:
|
||||
{
|
||||
|
||||
@@ -4,19 +4,18 @@ using FModel.Framework;
|
||||
using FModel.Views.Resources.Controls;
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.IO;
|
||||
using FModel.Views.Resources.Converters;
|
||||
|
||||
namespace FModel.ViewModels.Commands;
|
||||
|
||||
public class ImageCommand : ViewModelCommand<TabItem>
|
||||
public class ImageCommand(TabItem contextViewModel) : ViewModelCommand<TabItem>(contextViewModel)
|
||||
{
|
||||
public ImageCommand(TabItem contextViewModel) : base(contextViewModel)
|
||||
{
|
||||
}
|
||||
|
||||
public override void Execute(TabItem tabViewModel, object parameter)
|
||||
{
|
||||
if (parameter == null || !tabViewModel.HasImage) return;
|
||||
if (parameter == null || tabViewModel?.SelectedImage is not { } image)
|
||||
return;
|
||||
|
||||
switch (parameter)
|
||||
{
|
||||
@@ -33,12 +32,23 @@ public class ImageCommand : ViewModelCommand<TabItem>
|
||||
ImageCtrl = { Source = tabViewModel.SelectedImage.Image }
|
||||
};
|
||||
RenderOptions.SetBitmapScalingMode(popout.ImageCtrl, BoolToRenderModeConverter.Instance.Convert(tabViewModel.SelectedImage.RenderNearestNeighbor));
|
||||
ImageAnimation.SetFrames(popout.ImageCtrl, tabViewModel.SelectedImage.AnimationFrames);
|
||||
popout.Show();
|
||||
});
|
||||
break;
|
||||
}
|
||||
case "InspectTexture" when image.InspectorTexture is { } texture:
|
||||
SnooperViewModel.Instance.InspectTexture(texture, image.Name, image.RenderNearestNeighbor);
|
||||
break;
|
||||
case "PreviousImage":
|
||||
tabViewModel.GoPreviousImage();
|
||||
break;
|
||||
case "NextImage":
|
||||
tabViewModel.GoNextImage();
|
||||
break;
|
||||
case "Copy":
|
||||
ClipboardExtensions.SetImage(tabViewModel.SelectedImage.ImageBuffer, $"{tabViewModel.SelectedImage.ExportName}.png");
|
||||
case BitmapSource:
|
||||
ClipboardExtensions.SetImage(parameter as BitmapSource ?? tabViewModel.SelectedImage.Image, Path.ChangeExtension(tabViewModel.SelectedImage.ExportName, "png"));
|
||||
break;
|
||||
case "Save":
|
||||
tabViewModel.SaveImage();
|
||||
|
||||
@@ -90,6 +90,12 @@ public class ExportOptionsViewModel : ViewModel
|
||||
|
||||
public bool ShowNaniteWarning => SelectedNaniteMeshFormat != ENaniteMeshFormat.NoNanite;
|
||||
|
||||
public bool IncludeDisabledMeshSections
|
||||
{
|
||||
get;
|
||||
set => SetProperty(ref field, value);
|
||||
}
|
||||
|
||||
public IEnumerable<EMeshQuality> MeshQualities { get; } = Enum.GetValues<EMeshQuality>();
|
||||
public EMeshQuality SelectedMeshQuality
|
||||
{
|
||||
@@ -145,6 +151,13 @@ public class ExportOptionsViewModel : ViewModel
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<EAnimatedTextureFormat> AnimatedTextureFormats { get; } = Enum.GetValues<EAnimatedTextureFormat>();
|
||||
public EAnimatedTextureFormat SelectedAnimatedTextureFormat
|
||||
{
|
||||
get;
|
||||
set => SetProperty(ref field, value);
|
||||
}
|
||||
|
||||
public bool ShowTextureQuality => SelectedTextureFormat is ETextureFormat.Jpeg or ETextureFormat.Webp;
|
||||
public bool ShowPngCompression => SelectedTextureFormat is ETextureFormat.Png;
|
||||
public bool ShowTgaCompression => SelectedTextureFormat is ETextureFormat.Tga;
|
||||
@@ -199,6 +212,7 @@ public class ExportOptionsViewModel : ViewModel
|
||||
OutputDirectory = UserSettings.Default.ModelDirectory;
|
||||
SelectedMeshFormat = UserSettings.Default.MeshExportFormat;
|
||||
SelectedNaniteMeshFormat = UserSettings.Default.NaniteMeshExportFormat;
|
||||
IncludeDisabledMeshSections = UserSettings.Default.IncludeDisabledMeshSections;
|
||||
SelectedMeshQuality = UserSettings.Default.MeshQuality;
|
||||
SelectedSocketFormat = UserSettings.Default.SocketExportFormat;
|
||||
SelectedCompressionFormat = UserSettings.Default.CompressionFormat;
|
||||
@@ -206,6 +220,7 @@ public class ExportOptionsViewModel : ViewModel
|
||||
ExportMaterials = UserSettings.Default.SaveEmbeddedMaterials;
|
||||
SelectedTexturePlatform = UserSettings.Default.CurrentDir.TexturePlatform;
|
||||
SelectedTextureFormat = UserSettings.Default.TextureExportFormat;
|
||||
SelectedAnimatedTextureFormat = UserSettings.Default.AnimatedTextureExportFormat;
|
||||
if (SelectedMeshFormat is EMeshFormat.USD)
|
||||
{
|
||||
_preUsdTextureFormat = SelectedTextureFormat;
|
||||
@@ -228,6 +243,7 @@ public class ExportOptionsViewModel : ViewModel
|
||||
UserSettings.Default.ModelDirectory = OutputDirectory;
|
||||
UserSettings.Default.MeshExportFormat = SelectedMeshFormat;
|
||||
UserSettings.Default.NaniteMeshExportFormat = SelectedNaniteMeshFormat;
|
||||
UserSettings.Default.IncludeDisabledMeshSections = IncludeDisabledMeshSections;
|
||||
UserSettings.Default.MeshQuality = SelectedMeshQuality;
|
||||
UserSettings.Default.SocketExportFormat = SelectedSocketFormat;
|
||||
UserSettings.Default.CompressionFormat = SelectedCompressionFormat;
|
||||
@@ -235,6 +251,7 @@ public class ExportOptionsViewModel : ViewModel
|
||||
UserSettings.Default.SaveEmbeddedMaterials = ExportMaterials;
|
||||
UserSettings.Default.CurrentDir.TexturePlatform = SelectedTexturePlatform;
|
||||
UserSettings.Default.TextureExportFormat = SelectedTextureFormat;
|
||||
UserSettings.Default.AnimatedTextureExportFormat = SelectedAnimatedTextureFormat;
|
||||
UserSettings.Default.SaveHdrTexturesAsHdr = ExportHdrTexturesAsHdr;
|
||||
UserSettings.Default.SaveMorphTargets = ExportMorphTargets;
|
||||
UserSettings.Default.TextureQuality = TextureQuality;
|
||||
@@ -244,6 +261,8 @@ public class ExportOptionsViewModel : ViewModel
|
||||
UserSettings.Default.ExportImmediately = ExportImmediately;
|
||||
UserSettings.Save();
|
||||
|
||||
SnooperViewModel.Instance.Dispose();
|
||||
|
||||
OverrideOptions = false;
|
||||
FeedbackMessage = "Saved as default";
|
||||
}
|
||||
@@ -263,6 +282,8 @@ public class ExportOptionsViewModel : ViewModel
|
||||
SelectedSocketFormat,
|
||||
SelectedCompressionFormat,
|
||||
PngCompressionLevel,
|
||||
TgaRleCompression
|
||||
TgaRleCompression,
|
||||
IncludeDisabledMeshSections,
|
||||
SelectedAnimatedTextureFormat
|
||||
);
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ using System.Windows;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using CUE4Parse_Conversion.Textures;
|
||||
using CUE4Parse_Conversion.Textures.Paper2D;
|
||||
using CUE4Parse_Conversion.Dto;
|
||||
using CUE4Parse.FileProvider.Objects;
|
||||
using CUE4Parse.GameTypes.Borderlands3.Assets.Exports;
|
||||
@@ -35,6 +36,7 @@ using CUE4Parse.UE4.Assets.Exports.Fmod;
|
||||
using CUE4Parse.UE4.Assets.Exports.FMod;
|
||||
using CUE4Parse.UE4.Assets.Exports.Foliage;
|
||||
using CUE4Parse.UE4.Assets.Exports.GeometryCollection;
|
||||
using CUE4Parse.UE4.Assets.Exports.HairStrands;
|
||||
using CUE4Parse.UE4.Assets.Exports.Houdini;
|
||||
using CUE4Parse.UE4.Assets.Exports.Internationalization;
|
||||
using CUE4Parse.UE4.Assets.Exports.Paper2D;
|
||||
@@ -63,6 +65,7 @@ using CUE4Parse.Utils;
|
||||
using FModel.Framework;
|
||||
using FModel.Services;
|
||||
using FModel.Settings;
|
||||
using FModel.Views.Resources.Controls;
|
||||
using Serilog;
|
||||
using SkiaSharp;
|
||||
using Svg.Skia;
|
||||
@@ -194,6 +197,7 @@ public class GameFileViewModel(GameFile asset) : ViewModel
|
||||
Resolved |= EResolveCompute.Preview;
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
if (Asset.NameWithoutExtension.EndsWith("_BuiltData"))
|
||||
{
|
||||
AssetCategory = EAssetCategory.BuildData;
|
||||
@@ -234,7 +238,7 @@ public class GameFileViewModel(GameFile asset) : ViewModel
|
||||
|
||||
UHoudiniAsset or UHoudiniStaticMesh => EAssetFamily.Houdini,
|
||||
|
||||
UPaperTileMap or UPaperTileLayer or UPaperTileSet or UPaperSprite => EAssetFamily.Paper2D,
|
||||
UPaperTileMap or UPaperTileLayer or UPaperTileSet or UPaperSprite or UPaperFlipbook => EAssetFamily.Paper2D,
|
||||
|
||||
_ => EAssetFamily.None,
|
||||
};
|
||||
@@ -259,10 +263,12 @@ public class GameFileViewModel(GameFile asset) : ViewModel
|
||||
UCustomizableObject => (EAssetCategory.CustomizableObject, EBulkType.None),
|
||||
UNaniteDisplacedMesh => (EAssetCategory.NaniteDisplacedMesh, EBulkType.None),
|
||||
UGeometryCollection => (EAssetCategory.GeometryCollection, EBulkType.Meshes),
|
||||
UGroomAsset or UGroomBindingAsset => (EAssetCategory.GroomAsset, EBulkType.None),
|
||||
|
||||
UHoudiniAsset => (EAssetCategory.Data, EBulkType.None),
|
||||
|
||||
UTexture => (EAssetCategory.Texture, EBulkType.Textures),
|
||||
UTexture or UPaperSprite => (EAssetCategory.Texture, EBulkType.Textures),
|
||||
UPaperFlipbook => (EAssetCategory.AnimatedTexture, EBulkType.Textures),
|
||||
|
||||
UMaterialInterface => (EAssetCategory.Material, EBulkType.None),
|
||||
UMaterialInterfaceEditorOnlyData => (EAssetCategory.MaterialEditorData, EBulkType.None),
|
||||
@@ -324,9 +330,10 @@ public class GameFileViewModel(GameFile asset) : ViewModel
|
||||
_ => (EAssetCategory.All, EBulkType.None),
|
||||
};
|
||||
|
||||
var obj = pointer.Object.Value;
|
||||
if (EmbeddedFilesDto.Supports(dummy))
|
||||
{
|
||||
var files = new EmbeddedFilesDto(pointer.Object.Value).Files;
|
||||
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;
|
||||
@@ -334,28 +341,49 @@ public class GameFileViewModel(GameFile asset) : ViewModel
|
||||
|
||||
switch (AssetCategory)
|
||||
{
|
||||
case EAssetCategory.Texture when pointer.Object.Value is UTexture texture:
|
||||
case EAssetCategory.Texture:
|
||||
{
|
||||
if (!resolve.HasFlag(EResolveCompute.Preview))
|
||||
break;
|
||||
|
||||
if (pointer.Object.Value is UTexture2DArray textureArray && textureArray.GetFirstMip() is { SizeZ: > 1 } firstMip)
|
||||
if (obj is UTexture2DArray textureArray && textureArray.GetFirstMip() is { SizeZ: > 1 } firstMip)
|
||||
NumTextures = firstMip.SizeZ;
|
||||
|
||||
var img = texture.Decode(MaxPreviewSize, UserSettings.Default.CurrentDir.TexturePlatform);
|
||||
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 (pointer.Object.Value is UItemDefinitionBase itemDef)
|
||||
if (obj is UItemDefinitionBase itemDef)
|
||||
{
|
||||
if (LookupPreview(itemDef.DataList)) break;
|
||||
|
||||
@@ -372,7 +400,7 @@ public class GameFileViewModel(GameFile asset) : ViewModel
|
||||
!icon.TryLoad<UTexture2D>(out var texture))
|
||||
continue;
|
||||
|
||||
var img = texture.Decode(MaxPreviewSize, UserSettings.Default.CurrentDir.TexturePlatform);
|
||||
var img = texture.Decode(MaxPreviewSize, UserSettings.GetExportOptions());
|
||||
if (img == null) return false;
|
||||
|
||||
using var bitmap = img.ToSkBitmap();
|
||||
@@ -393,7 +421,6 @@ public class GameFileViewModel(GameFile asset) : ViewModel
|
||||
|
||||
private Task ResolveByExtensionAsync(EResolveCompute resolve)
|
||||
{
|
||||
Resolved |= EResolveCompute.Preview;
|
||||
var lowercaseExtension = Asset.Extension.ToLowerInvariant();
|
||||
|
||||
AssetFamily = lowercaseExtension switch
|
||||
@@ -478,11 +505,10 @@ public class GameFileViewModel(GameFile asset) : ViewModel
|
||||
case "bmp":
|
||||
case "svg":
|
||||
{
|
||||
Resolved |= ~EResolveCompute.Preview;
|
||||
AssetCategory = EAssetCategory.Texture;
|
||||
AssetActions = EBulkType.Textures;
|
||||
if (!resolve.HasFlag(EResolveCompute.Preview))
|
||||
break;
|
||||
return Task.CompletedTask;
|
||||
|
||||
return Task.Run(() =>
|
||||
{
|
||||
@@ -515,7 +541,6 @@ public class GameFileViewModel(GameFile asset) : ViewModel
|
||||
|
||||
using var image = bitmap.Encode(lowercaseExtension == "jpg" ? SKEncodedImageFormat.Jpeg : SKEncodedImageFormat.Png, 100);
|
||||
SetPreviewImage(image);
|
||||
|
||||
bitmap.Dispose();
|
||||
});
|
||||
}
|
||||
@@ -543,6 +568,7 @@ public class GameFileViewModel(GameFile asset) : ViewModel
|
||||
break;
|
||||
}
|
||||
|
||||
Resolved |= EResolveCompute.Preview;
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
@@ -550,14 +576,12 @@ public class GameFileViewModel(GameFile asset) : ViewModel
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -570,7 +594,6 @@ public class GameFileViewModel(GameFile asset) : ViewModel
|
||||
_previewCts?.Cancel();
|
||||
_previewCts = new CancellationTokenSource();
|
||||
var token = _previewCts.Token;
|
||||
|
||||
Task.Delay(100, token).ContinueWith(t =>
|
||||
{
|
||||
if (t.IsCanceled) return;
|
||||
|
||||
@@ -16,11 +16,14 @@ using CUE4Parse.UE4.Assets.Exports.StaticMesh;
|
||||
using CUE4Parse.UE4.Objects.Engine;
|
||||
using CUE4Parse.UE4.Versions;
|
||||
using CUE4Parse_Conversion.Options;
|
||||
using CUE4Parse_Conversion.Textures;
|
||||
using Editor;
|
||||
using Editor.Managers;
|
||||
using FModel.Framework;
|
||||
using FModel.Services;
|
||||
using FModel.Settings;
|
||||
using FModel.Views.Resources.Controls;
|
||||
using OpenTK.Windowing.GraphicsLibraryFramework;
|
||||
using Snooper.Hosting;
|
||||
using Snooper.Rendering.Actors;
|
||||
using Snooper.Rendering.Components.Camera;
|
||||
@@ -29,6 +32,8 @@ using Snooper.Rendering.Components.Primitive;
|
||||
using Snooper.Rendering.Components.Transforms;
|
||||
using Snooper.Rendering.Systems;
|
||||
using Snooper.Rendering.Actors.Custom;
|
||||
using Snooper.UI;
|
||||
using GlfwErrorCode = OpenTK.Windowing.GraphicsLibraryFramework.ErrorCode;
|
||||
|
||||
namespace FModel.ViewModels;
|
||||
|
||||
@@ -40,6 +45,12 @@ public class SnooperViewModel : ViewModel, IDisposable
|
||||
private readonly SunActor _sun;
|
||||
private readonly EnvironmentActor _environment;
|
||||
|
||||
public bool CanOpenSnooper
|
||||
{
|
||||
get;
|
||||
private set => SetProperty(ref field, value);
|
||||
} = true;
|
||||
|
||||
/// <summary>
|
||||
/// Mirrors <see cref="Bridge.PendingRequest"/> for bindings.
|
||||
/// </summary>
|
||||
@@ -59,13 +70,16 @@ 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, false, true));
|
||||
_host = new SnooperHost(() => new EditorWindow(htz, width, height, ApplicationService.ApplicationView.CUE4Parse.Provider, startVisible: false, closeHides: true), OnStartupFailure);
|
||||
_sun = new SunActor();
|
||||
_environment = new EnvironmentActor();
|
||||
}
|
||||
|
||||
public void Load(UObject obj, CancellationToken ct = default)
|
||||
{
|
||||
if (!CanOpenSnooper)
|
||||
return;
|
||||
|
||||
SetOptions(obj);
|
||||
|
||||
Actor actor = obj switch
|
||||
@@ -89,7 +103,9 @@ public class SnooperViewModel : ViewModel, IDisposable
|
||||
return;
|
||||
}
|
||||
|
||||
var editor = _host.Window;
|
||||
if (_host.GetWindow() is not { } editor)
|
||||
return;
|
||||
|
||||
editor.Invoke(() =>
|
||||
{
|
||||
if (editor.Manager.RootActor == null)
|
||||
@@ -109,6 +125,7 @@ public class SnooperViewModel : ViewModel, IDisposable
|
||||
}));
|
||||
}
|
||||
|
||||
WindowRequests.Request(actor is MaterialActor ? Snooper.Settings.MaterialInspectorWindow : Snooper.Settings.ViewportWindow);
|
||||
if (actor != null)
|
||||
editor.Manager.LoadScene(actor);
|
||||
|
||||
@@ -145,23 +162,43 @@ public class SnooperViewModel : ViewModel, IDisposable
|
||||
|
||||
public bool TryDeliver(UObject obj)
|
||||
{
|
||||
if (!Bridge.TryDeliver(obj)) return false;
|
||||
if (!CanOpenSnooper || !Bridge.TryDeliver(obj) || _host.GetWindow() is not { } editor)
|
||||
return false;
|
||||
|
||||
var editor = _host.Window;
|
||||
editor.Invoke(editor.Show);
|
||||
return true;
|
||||
}
|
||||
|
||||
public void InspectTexture(CTexture texture, string name, bool nearestNeighbor)
|
||||
{
|
||||
if (CanOpenSnooper)
|
||||
{
|
||||
_host.GetWindow()?.InspectTexture(texture, name, nearestNeighbor);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnStartupFailure(Exception e)
|
||||
{
|
||||
if (e.InnerException is GLFWException { ErrorCode: GlfwErrorCode.ApiUnavailable or GlfwErrorCode.VersionUnavailable })
|
||||
CanOpenSnooper = false;
|
||||
|
||||
FLogger.Append(e);
|
||||
}
|
||||
|
||||
private void SetOptions(UObject obj)
|
||||
{
|
||||
var settings = UserSettings.Default;
|
||||
var options = Bridge.Options;
|
||||
|
||||
options.NaniteMeshFormat = obj is UWorld or UPaperTileMap { Game: EGame.GAME_DeadByDaylight } ? ENaniteMeshFormat.NoNanite : settings.NaniteMeshExportFormat;
|
||||
options.MaterialDepth = settings.MaterialExportFormat;
|
||||
options.TexturePlatform = settings.CurrentDir.TexturePlatform;
|
||||
options.LoadMorphTargets = settings.SaveMorphTargets;
|
||||
options.MaxTextureMipSize = settings.PreviewMaxTextureSize;
|
||||
Bridge.Options = new SnooperOptions(
|
||||
obj is UWorld or UPaperTileMap { Game: EGame.GAME_DeadByDaylight }
|
||||
? ENaniteMeshFormat.NoNanite
|
||||
: settings.NaniteMeshExportFormat,
|
||||
settings.MaterialExportFormat,
|
||||
settings.CurrentDir.TexturePlatform,
|
||||
settings.SaveMorphTargets,
|
||||
settings.SocketExportFormat,
|
||||
settings.IncludeDisabledMeshSections,
|
||||
settings.PreviewMaxTextureSize
|
||||
);
|
||||
}
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
|
||||
@@ -7,9 +7,11 @@ using System.Windows;
|
||||
using System.Windows.Media.Imaging;
|
||||
using CUE4Parse_Conversion.Options;
|
||||
using CUE4Parse.FileProvider.Objects;
|
||||
using CUE4Parse.UE4.Assets.Exports.Paper2D;
|
||||
using CUE4Parse.UE4.Assets.Exports.Texture;
|
||||
using CUE4Parse.Utils;
|
||||
using CUE4Parse_Conversion.Textures;
|
||||
using CUE4Parse_Conversion.Textures.Paper2D;
|
||||
using FModel.Extensions;
|
||||
using FModel.Framework;
|
||||
using FModel.Services;
|
||||
@@ -25,31 +27,80 @@ namespace FModel.ViewModels;
|
||||
|
||||
public class TabImage : ViewModel
|
||||
{
|
||||
private readonly string _name;
|
||||
private readonly object _source;
|
||||
|
||||
public string Name => _name;
|
||||
public string ExportName { get; set; }
|
||||
|
||||
public byte[] ImageBuffer { get; set; }
|
||||
|
||||
public ImageAnimation.Frame[] AnimationFrames { get; }
|
||||
public bool CanDisableAlpha => AnimationFrames == null;
|
||||
|
||||
public EPixelFormat? TextureFormat { get; }
|
||||
public int? MipCount { get; }
|
||||
public CTexture InspectorTexture => TextureFormat.HasValue ? _source as CTexture : null;
|
||||
public bool HasTexture => InspectorTexture != null;
|
||||
|
||||
public TabImage(string name, CFlipbook flipbook)
|
||||
{
|
||||
_name = name;
|
||||
_source = flipbook;
|
||||
RenderNearestNeighbor = true;
|
||||
Encode(UserSettings.GetExportOptions());
|
||||
AnimationFrames = ImageAnimation.CreateFrames(flipbook);
|
||||
Image = ImageAnimation.CreateSource(AnimationFrames);
|
||||
}
|
||||
|
||||
public TabImage(string name, bool rnn, SKBitmap img)
|
||||
{
|
||||
ExportName = name;
|
||||
_name = name;
|
||||
_source = img;
|
||||
RenderNearestNeighbor = rnn;
|
||||
SetImage(img);
|
||||
Encode(UserSettings.GetExportOptions());
|
||||
}
|
||||
|
||||
public TabImage(string name, bool rnn, CTexture img)
|
||||
public TabImage(string name, bool rnn, CTexture img, UTexture sourceTexture = null)
|
||||
{
|
||||
ExportName = name;
|
||||
_name = name;
|
||||
_source = img;
|
||||
if (img != null && sourceTexture != null)
|
||||
{
|
||||
TextureFormat = sourceTexture.Format == EPixelFormat.PF_Unknown ? img.PixelFormat : sourceTexture.Format;
|
||||
|
||||
var platformData = sourceTexture.PlatformData;
|
||||
var mipCount = platformData.Mips.Length;
|
||||
if (platformData is { FirstMipToSerialize: >= 0, VTData: { } virtualTexture } && virtualTexture.IsInitialized())
|
||||
mipCount = (int) virtualTexture.NumMips;
|
||||
|
||||
if (mipCount > 1)
|
||||
MipCount = mipCount;
|
||||
}
|
||||
RenderNearestNeighbor = rnn;
|
||||
SetImage(img);
|
||||
SetImage(img?.ToSkBitmap());
|
||||
Encode(UserSettings.GetExportOptions());
|
||||
}
|
||||
|
||||
private BitmapImage _image;
|
||||
public BitmapImage Image
|
||||
public TabImage(string exportName, byte[] data, SKBitmap preview)
|
||||
{
|
||||
_name = Path.GetFileNameWithoutExtension(exportName);
|
||||
_source = data;
|
||||
ExportName = exportName;
|
||||
ImageBuffer = data;
|
||||
SetImage(preview);
|
||||
}
|
||||
|
||||
private BitmapSource _image;
|
||||
public BitmapSource Image
|
||||
{
|
||||
get => _image;
|
||||
set
|
||||
{
|
||||
if (_image == value) return;
|
||||
if (_image == value)
|
||||
return;
|
||||
|
||||
SetProperty(ref _image, value);
|
||||
}
|
||||
}
|
||||
@@ -67,6 +118,9 @@ public class TabImage : ViewModel
|
||||
get => _noAlpha;
|
||||
set
|
||||
{
|
||||
if (!CanDisableAlpha)
|
||||
return;
|
||||
|
||||
SetProperty(ref _noAlpha, value);
|
||||
ResetImage();
|
||||
}
|
||||
@@ -82,49 +136,54 @@ public class TabImage : ViewModel
|
||||
}
|
||||
|
||||
_bmp = bitmap;
|
||||
ExportName += "." + (NoAlpha ? "jpg" : "png");
|
||||
using var data = _bmp.Encode(NoAlpha ? SKEncodedImageFormat.Jpeg : SKEncodedImageFormat.Png, 100);
|
||||
using var stream = new MemoryStream(ImageBuffer = data.ToArray(), false);
|
||||
var image = new BitmapImage();
|
||||
image.BeginInit();
|
||||
image.CacheOption = BitmapCacheOption.OnLoad;
|
||||
image.StreamSource = stream;
|
||||
image.EndInit();
|
||||
image.Freeze();
|
||||
Image = image;
|
||||
using var opaque = NoAlpha ? _bmp.Copy(SKColorType.Rgb888x) : null;
|
||||
using var data = (opaque ?? _bmp).Encode(SKEncodedImageFormat.Png, 100);
|
||||
using var stream = new MemoryStream(data.ToArray(), false);
|
||||
Image = CreateImage(stream);
|
||||
}
|
||||
|
||||
private void SetImage(CTexture bitmap)
|
||||
public void Encode(ExportOptions options)
|
||||
{
|
||||
if (bitmap is null)
|
||||
string ext;
|
||||
switch (_source)
|
||||
{
|
||||
ImageBuffer = null;
|
||||
Image = null;
|
||||
return;
|
||||
case byte[] data:
|
||||
ImageBuffer = data;
|
||||
return;
|
||||
case CFlipbook flipbook:
|
||||
ImageBuffer = flipbook.Encode(options, out ext);
|
||||
break;
|
||||
case CTexture texture:
|
||||
ImageBuffer = texture.Encode(options, out ext);
|
||||
break;
|
||||
case SKBitmap source:
|
||||
{
|
||||
using var bitmap = new SKBitmap(new SKImageInfo(source.Width, source.Height, SKColorType.Rgba8888, SKAlphaType.Unpremul));
|
||||
using var pixels = source.PeekPixels();
|
||||
if (!pixels.ReadPixels(bitmap.Info, bitmap.GetPixels(), bitmap.RowBytes))
|
||||
throw new InvalidOperationException("Failed to read image pixels for export.");
|
||||
|
||||
var converted = new CTexture(bitmap.Width, bitmap.Height, EPixelFormat.PF_R8G8B8A8, bitmap.Bytes);
|
||||
ImageBuffer = converted.Encode(options, out ext);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
_bmp = bitmap.ToSkBitmap();
|
||||
byte[] imageData = _bmp.Encode(NoAlpha ? SKEncodedImageFormat.Jpeg : SKEncodedImageFormat.Png, 100).ToArray();
|
||||
ExportName = _name + "." + ext;
|
||||
}
|
||||
|
||||
if (PixelFormatUtils.IsHDR(bitmap.PixelFormat) || (UserSettings.Default.TextureExportFormat != ETextureFormat.Jpeg && UserSettings.Default.TextureExportFormat != ETextureFormat.Png))
|
||||
{
|
||||
ImageBuffer = bitmap.Encode(UserSettings.Default.TextureExportFormat, UserSettings.Default.SaveHdrTexturesAsHdr, out var ext);
|
||||
ExportName += "." + ext;
|
||||
}
|
||||
else
|
||||
{
|
||||
ImageBuffer = imageData;
|
||||
ExportName += "." + (NoAlpha || UserSettings.Default.TextureExportFormat == ETextureFormat.Jpeg ? "jpg" : "png");
|
||||
}
|
||||
|
||||
using var stream = new MemoryStream(imageData);
|
||||
private static BitmapImage CreateImage(Stream stream)
|
||||
{
|
||||
stream.Position = 0;
|
||||
var image = new BitmapImage();
|
||||
image.BeginInit();
|
||||
image.CacheOption = BitmapCacheOption.OnLoad;
|
||||
image.StreamSource = stream;
|
||||
image.EndInit();
|
||||
image.Freeze();
|
||||
Image = image;
|
||||
return image;
|
||||
}
|
||||
|
||||
private SKBitmap _bmp;
|
||||
@@ -231,7 +290,9 @@ public class TabItem : ViewModel
|
||||
get => _highlighter;
|
||||
set
|
||||
{
|
||||
if (_highlighter == value) return;
|
||||
if (_highlighter == value)
|
||||
return;
|
||||
|
||||
SetProperty(ref _highlighter, value);
|
||||
}
|
||||
}
|
||||
@@ -242,10 +303,12 @@ public class TabItem : ViewModel
|
||||
get => _selectedImage;
|
||||
set
|
||||
{
|
||||
if (_selectedImage == value) return;
|
||||
if (_selectedImage == value)
|
||||
return;
|
||||
|
||||
SetProperty(ref _selectedImage, value);
|
||||
RaisePropertyChanged("HasImage");
|
||||
RaisePropertyChanged("Page");
|
||||
RaisePropertyChanged(nameof(HasImage));
|
||||
RaisePropertyChanged(nameof(Page));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -269,7 +332,7 @@ public class TabItem : ViewModel
|
||||
public TabItem(GameFile entry)
|
||||
{
|
||||
Entry = entry;
|
||||
_images = new ObservableCollection<TabImage>();
|
||||
_images = [];
|
||||
}
|
||||
|
||||
public void SoftReset(GameFile entry)
|
||||
@@ -281,32 +344,50 @@ public class TabItem : ViewModel
|
||||
{
|
||||
_images.Clear();
|
||||
SelectedImage = null;
|
||||
RaisePropertyChanged("HasMultipleImages");
|
||||
RaisePropertyChanged(nameof(HasMultipleImages));
|
||||
|
||||
Document ??= new TextDocument();
|
||||
Document.Text = string.Empty;
|
||||
});
|
||||
}
|
||||
|
||||
public void AddImage(UPaperSprite sprite, bool save, bool updateUi)
|
||||
{
|
||||
var decoded = sprite.Decode(UserSettings.GetExportOptions());
|
||||
if (decoded == null)
|
||||
return;
|
||||
|
||||
AddImage(sprite.Name, true, decoded, save, updateUi);
|
||||
}
|
||||
|
||||
public void AddImage(UPaperFlipbook flipbook, bool save, bool updateUi)
|
||||
{
|
||||
var decoded = flipbook.Decode(UserSettings.GetExportOptions());
|
||||
if (decoded == null)
|
||||
return;
|
||||
|
||||
AddImage(new TabImage(flipbook.Name, decoded), save, updateUi);
|
||||
}
|
||||
|
||||
public void AddImage(UTexture texture, bool save, bool updateUi)
|
||||
{
|
||||
var appendLayerNumber = false;
|
||||
var img = new CTexture[1];
|
||||
if (texture is UTexture2DArray textureArray)
|
||||
{
|
||||
img = textureArray.DecodeTextureArray(UserSettings.Default.CurrentDir.TexturePlatform);
|
||||
img = textureArray.DecodeTextureArray(UserSettings.GetExportOptions());
|
||||
appendLayerNumber = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
img[0] = texture.Decode(UserSettings.Default.CurrentDir.TexturePlatform);
|
||||
img[0] = texture.Decode(UserSettings.GetExportOptions());
|
||||
if (texture is UTextureCube)
|
||||
{
|
||||
img[0] = img[0].ToPanorama();
|
||||
}
|
||||
}
|
||||
|
||||
AddImage(texture.Name, texture.RenderNearestNeighbor, img, save, updateUi, appendLayerNumber);
|
||||
AddImage(texture.Name, texture.RenderNearestNeighbor, img, save, updateUi, appendLayerNumber, texture);
|
||||
}
|
||||
|
||||
public void AddImage(string name, bool rnn, SKBitmap[] img, bool save, bool updateUi, bool appendLayerNumber = false)
|
||||
@@ -317,41 +398,37 @@ public class TabItem : ViewModel
|
||||
}
|
||||
}
|
||||
|
||||
public void AddImage(string name, bool rnn, CTexture[] img, bool save, bool updateUi, bool appendLayerNumber = false)
|
||||
public void AddImage(string name, bool rnn, CTexture[] img, bool save, bool updateUi, bool appendLayerNumber = false, UTexture sourceTexture = null)
|
||||
{
|
||||
for (var i = 0; i < img.Length; i++)
|
||||
{
|
||||
AddImage($"{name}{(appendLayerNumber ? $"_{i}" : "")}", rnn, img[i], save, updateUi);
|
||||
var layerName = appendLayerNumber ? $"{name}_{i}" : name;
|
||||
AddImage(new TabImage(layerName, rnn, img[i], sourceTexture), save, updateUi);
|
||||
}
|
||||
}
|
||||
|
||||
public void AddImage(string name, bool rnn, CTexture img, bool save, bool updateUi)
|
||||
{
|
||||
Application.Current.Dispatcher.Invoke(() =>
|
||||
{
|
||||
var t = new TabImage(name, rnn, img);
|
||||
if (save) SaveImage(t, updateUi);
|
||||
if (!updateUi) return;
|
||||
|
||||
_images.Add(t);
|
||||
SelectedImage ??= t;
|
||||
RaisePropertyChanged("Page");
|
||||
RaisePropertyChanged("HasMultipleImages");
|
||||
});
|
||||
}
|
||||
=> AddImage(new TabImage(name, rnn, img), save, updateUi);
|
||||
|
||||
public void AddImage(string name, bool rnn, SKBitmap img, bool save, bool updateUi)
|
||||
=> AddImage(new TabImage(name, rnn, img), save, updateUi);
|
||||
|
||||
public void AddImage(string exportName, byte[] data, SKBitmap preview, bool save, bool updateUi)
|
||||
=> AddImage(new TabImage(exportName, data, preview), save, updateUi);
|
||||
|
||||
private void AddImage(TabImage image, bool save, bool updateUi)
|
||||
{
|
||||
Application.Current.Dispatcher.Invoke(() =>
|
||||
{
|
||||
var t = new TabImage(name, rnn, img);
|
||||
if (save) SaveImage(t, updateUi);
|
||||
if (!updateUi) return;
|
||||
if (save)
|
||||
SaveImage(image, updateUi);
|
||||
if (!updateUi)
|
||||
return;
|
||||
|
||||
_images.Add(t);
|
||||
SelectedImage ??= t;
|
||||
RaisePropertyChanged("Page");
|
||||
RaisePropertyChanged("HasMultipleImages");
|
||||
_images.Add(image);
|
||||
SelectedImage ??= image;
|
||||
RaisePropertyChanged(nameof(Page));
|
||||
RaisePropertyChanged(nameof(HasMultipleImages));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -366,15 +443,18 @@ public class TabItem : ViewModel
|
||||
Document.Text = text;
|
||||
Document.UndoStack.ClearAll();
|
||||
|
||||
if (save) SaveProperty(updateUi);
|
||||
if (save)
|
||||
SaveProperty(updateUi);
|
||||
});
|
||||
}
|
||||
|
||||
public void SaveImage() => SaveImage(SelectedImage, true);
|
||||
private void SaveImage(TabImage image, bool updateUi)
|
||||
{
|
||||
if (image is null) return;
|
||||
if (image is null)
|
||||
return;
|
||||
|
||||
image.Encode(UserSettings.GetExportOptions());
|
||||
var path = Path.Combine(UserSettings.Default.TextureDirectory, UserSettings.Default.KeepDirectoryStructure ? Entry.Directory : "", image.ExportName).Replace('\\', '/');
|
||||
|
||||
Directory.CreateDirectory(path.SubstringBeforeLast('/'));
|
||||
@@ -390,7 +470,9 @@ public class TabItem : ViewModel
|
||||
|
||||
private void SaveImage(TabImage image, string path)
|
||||
{
|
||||
if (image.ImageBuffer is null) return;
|
||||
if (image.ImageBuffer is null)
|
||||
return;
|
||||
|
||||
using var fs = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.Read);
|
||||
fs.Write(image.ImageBuffer, 0, image.ImageBuffer.Length);
|
||||
}
|
||||
@@ -477,7 +559,9 @@ public class TabControlViewModel : ViewModel
|
||||
return;
|
||||
}
|
||||
|
||||
if (!CanAddTabs) return;
|
||||
if (!CanAddTabs)
|
||||
return;
|
||||
|
||||
Application.Current.Dispatcher.Invoke(() =>
|
||||
{
|
||||
_tabItems.Add(new TabItem(entry));
|
||||
|
||||
@@ -1,20 +1,21 @@
|
||||
using System.Collections;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Controls.Primitives;
|
||||
using FModel.Extensions;
|
||||
|
||||
namespace FModel.Views.Resources.Controls.Explorer;
|
||||
|
||||
public class AssetExplorerListBox : ListBox
|
||||
{
|
||||
protected override void OnItemsSourceChanged(IEnumerable oldValue, IEnumerable newValue)
|
||||
public AssetExplorerListBox()
|
||||
{
|
||||
base.OnItemsSourceChanged(oldValue, newValue);
|
||||
AddHandler(ScrollViewer.ScrollChangedEvent, new ScrollChangedEventHandler(OnScrollChanged));
|
||||
}
|
||||
|
||||
// Always start at the top, otherwise inherited offset can cause items not to be visible when we change folder
|
||||
if (this.FindVisualChild<VirtualizingPanel>() is IScrollInfo scroll)
|
||||
// This is important, when we scroll and then change folder, scroll offset won't be adjusted and we will end up with missing items
|
||||
// Same applies to filtering assets as that also changes scroll offset
|
||||
private void OnScrollChanged(object sender, ScrollChangedEventArgs e)
|
||||
{
|
||||
if (e.OriginalSource is ScrollViewer scroll && scroll.VerticalOffset > scroll.ScrollableHeight)
|
||||
{
|
||||
scroll.SetVerticalOffset(0);
|
||||
scroll.ScrollToVerticalOffset(scroll.ScrollableHeight);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:vm="clr-namespace:FModel.ViewModels"
|
||||
xmlns:controls="clr-namespace:FModel.Views.Resources.Controls"
|
||||
xmlns:converters="clr-namespace:FModel.Views.Resources.Converters"
|
||||
xmlns:adonisUi="clr-namespace:AdonisUI;assembly=AdonisUI"
|
||||
mc:Ignorable="d"
|
||||
@@ -24,6 +25,7 @@
|
||||
Height="20"
|
||||
Margin="0 0 8 0">
|
||||
<Image Stretch="Uniform"
|
||||
controls:ImageAnimation.Frames="{Binding PreviewImage.(controls:ImageAnimation.Frames)}"
|
||||
Source="{Binding PreviewImage}" />
|
||||
<Path x:Name="FallbackIcon"
|
||||
Stretch="Uniform">
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
d:DataContext="{d:DesignInstance Type=vm:GameFileViewModel, IsDesignTimeCreatable=False}"
|
||||
|
||||
xmlns:vm="clr-namespace:FModel.ViewModels"
|
||||
xmlns:controls="clr-namespace:FModel.Views.Resources.Controls"
|
||||
xmlns:converters="clr-namespace:FModel.Views.Resources.Converters"
|
||||
xmlns:adonisUi="clr-namespace:AdonisUI;assembly=AdonisUI"
|
||||
Width="128" Height="192"
|
||||
@@ -19,7 +20,7 @@
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Grid Grid.Row="0" Height="128" Background="{DynamicResource {x:Static adonisUi:Brushes.Layer3BorderBrush}}">
|
||||
<Image Stretch="Uniform" Source="{Binding PreviewImage}" />
|
||||
<Image Stretch="Uniform" Source="{Binding PreviewImage}" controls:ImageAnimation.Frames="{Binding PreviewImage.(controls:ImageAnimation.Frames)}" />
|
||||
<Path x:Name="FallbackIcon" Width="64" Stretch="Uniform">
|
||||
<Path.Style>
|
||||
<Style TargetType="{x:Type Path}">
|
||||
|
||||
@@ -32,6 +32,8 @@
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
@@ -160,7 +162,33 @@
|
||||
</ComboBox.ItemTemplate>
|
||||
</ComboBox>
|
||||
|
||||
<Border Grid.Row="9" Grid.Column="0" Grid.ColumnSpan="5" Margin="0 10 0 5" CornerRadius="1"
|
||||
<TextBlock Grid.Row="9"
|
||||
Grid.Column="0"
|
||||
Text="Include Disabled Sections"
|
||||
VerticalAlignment="Center"
|
||||
Margin="0 8 0 0" />
|
||||
<Grid Grid.Row="9"
|
||||
Grid.Column="2"
|
||||
Grid.ColumnSpan="3"
|
||||
Margin="0 8 0 0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<CheckBox Grid.Column="0"
|
||||
IsChecked="{Binding IncludeDisabledMeshSections, Mode=TwoWay}"
|
||||
Content="{Binding IsChecked, RelativeSource={RelativeSource Self}, Converter={x:Static converters:BoolToToggleConverter.Instance}}"
|
||||
Style="{DynamicResource {x:Static adonisUi:Styles.ToggleSwitch}}" />
|
||||
<TextBlock Grid.Column="1"
|
||||
VerticalAlignment="Center"
|
||||
Margin="5 0 0 0"
|
||||
FontSize="11"
|
||||
Foreground="{DynamicResource {x:Static adonisUi:Brushes.DisabledForegroundBrush}}"
|
||||
Text="It is not recommended to enable this option, unless you need sections not rendered in-game." />
|
||||
</Grid>
|
||||
|
||||
<Border Grid.Row="10" Grid.Column="0" Grid.ColumnSpan="5" Margin="0 10 0 5" CornerRadius="1"
|
||||
Background="#1AFFA726" BorderBrush="#FFA726" BorderThickness="1" Padding="10"
|
||||
Visibility="{Binding ShowNaniteWarning, Converter={StaticResource BoolToVisibilityConverter}}">
|
||||
<Grid>
|
||||
@@ -190,11 +218,11 @@
|
||||
</Grid>
|
||||
</Border>
|
||||
|
||||
<Separator Grid.Row="10" Grid.Column="0" Grid.ColumnSpan="5" Style="{StaticResource CustomSeparator}" Tag="TEXTURE" Margin="0 10 0 10" />
|
||||
<Separator Grid.Row="11" Grid.Column="0" Grid.ColumnSpan="5" Style="{StaticResource CustomSeparator}" Tag="TEXTURE" Margin="0 10 0 10" />
|
||||
|
||||
<TextBlock Grid.Row="11" Grid.Column="0" Text="Texture Format" VerticalAlignment="Center" Margin="0 0 0 5"
|
||||
<TextBlock Grid.Row="12" Grid.Column="0" Text="Texture Format" VerticalAlignment="Center" Margin="0 0 0 5"
|
||||
IsEnabled="{Binding TextureFormatsEnabled}" />
|
||||
<ComboBox Grid.Row="11" Grid.Column="2" Grid.ColumnSpan="3" Margin="0 0 0 5"
|
||||
<ComboBox Grid.Row="12" Grid.Column="2" Grid.ColumnSpan="3" Margin="0 0 0 5"
|
||||
ItemsSource="{Binding TextureFormats}"
|
||||
SelectedItem="{Binding SelectedTextureFormat, Mode=TwoWay}"
|
||||
IsEnabled="{Binding TextureFormatsEnabled}">
|
||||
@@ -205,8 +233,28 @@
|
||||
</ComboBox.ItemTemplate>
|
||||
</ComboBox>
|
||||
|
||||
<TextBlock Grid.Row="12" Grid.Column="0" Text="Texture Platform" VerticalAlignment="Center" Margin="0 0 0 10" />
|
||||
<ComboBox Grid.Row="12" Grid.Column="2" Grid.ColumnSpan="3" Margin="0 0 0 10"
|
||||
<TextBlock Grid.Row="13" Grid.Column="0" Text="Animated Texture Format" VerticalAlignment="Center" Margin="0 0 0 5" />
|
||||
<ComboBox Grid.Row="13" Grid.Column="2" Grid.ColumnSpan="3" Margin="0 0 0 5"
|
||||
ItemsSource="{Binding AnimatedTextureFormats}"
|
||||
SelectedItem="{Binding SelectedAnimatedTextureFormat, Mode=TwoWay}">
|
||||
<ComboBox.Style>
|
||||
<Style TargetType="{x:Type ComboBox}" BasedOn="{StaticResource {x:Type ComboBox}}">
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding SelectedAnimatedTextureFormat}" Value="{x:Static c4pMeshes:EAnimatedTextureFormat.Auto}">
|
||||
<Setter Property="ToolTip" Value="Uses the same format you have selected for normal textures (if given format supports animation)." />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</ComboBox.Style>
|
||||
<ComboBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding Converter={x:Static converters:EnumToStringConverter.Instance}}" />
|
||||
</DataTemplate>
|
||||
</ComboBox.ItemTemplate>
|
||||
</ComboBox>
|
||||
|
||||
<TextBlock Grid.Row="14" Grid.Column="0" Text="Texture Platform" VerticalAlignment="Center" Margin="0 0 0 10" />
|
||||
<ComboBox Grid.Row="14" Grid.Column="2" Grid.ColumnSpan="3" Margin="0 0 0 10"
|
||||
ItemsSource="{Binding TexturePlatforms}"
|
||||
SelectedItem="{Binding SelectedTexturePlatform, Mode=TwoWay}">
|
||||
<ComboBox.ItemTemplate>
|
||||
@@ -216,17 +264,17 @@
|
||||
</ComboBox.ItemTemplate>
|
||||
</ComboBox>
|
||||
|
||||
<TextBlock Grid.Row="13" Grid.Column="0" Text="Texture Quality" VerticalAlignment="Center" Margin="0 0 0 12"
|
||||
<TextBlock Grid.Row="15" Grid.Column="0" Text="Texture Quality" VerticalAlignment="Center" Margin="0 0 0 12"
|
||||
Visibility="{Binding ShowTextureQuality, Converter={StaticResource BoolToVisibilityConverter}}" />
|
||||
<Slider Grid.Row="13" Grid.Column="2" Grid.ColumnSpan="3" Minimum="1" Maximum="100" TickPlacement="None"
|
||||
<Slider Grid.Row="15" Grid.Column="2" Grid.ColumnSpan="3" Minimum="1" Maximum="100" TickPlacement="None"
|
||||
AutoToolTipPlacement="BottomRight" IsMoveToPointEnabled="True" IsSnapToTickEnabled="True" Margin="0 0 0 12"
|
||||
Value="{Binding TextureQuality, Mode=TwoWay}"
|
||||
Visibility="{Binding ShowTextureQuality, Converter={StaticResource BoolToVisibilityConverter}}" />
|
||||
|
||||
<TextBlock x:Name="PngCompressionText" Grid.Row="13" Grid.Column="0" Text="PNG Compression" VerticalAlignment="Center" Margin="0 0 0 12"
|
||||
<TextBlock x:Name="PngCompressionText" Grid.Row="15" Grid.Column="0" Text="PNG Compression" VerticalAlignment="Center" Margin="0 0 0 12"
|
||||
ToolTip="Lossless compression. Level 3 is recommended for speed."
|
||||
Visibility="{Binding ShowPngCompression, Converter={StaticResource BoolToVisibilityConverter}}" />
|
||||
<Grid Grid.Row="13" Grid.Column="2" Grid.ColumnSpan="3" Margin="0 0 0 12"
|
||||
<Grid Grid.Row="15" Grid.Column="2" Grid.ColumnSpan="3" Margin="0 0 0 12"
|
||||
ToolTip="{Binding ToolTip, ElementName=PngCompressionText}"
|
||||
Visibility="{Binding ShowPngCompression, Converter={StaticResource BoolToVisibilityConverter}}">
|
||||
<Grid.ColumnDefinitions>
|
||||
@@ -239,37 +287,37 @@
|
||||
<TextBlock Grid.Column="1" Text="{Binding PngCompressionLevel}" VerticalAlignment="Center" Margin="8 0 0 0" />
|
||||
</Grid>
|
||||
|
||||
<TextBlock Grid.Row="13" Grid.Column="0" Text="TGA RLE Compression" VerticalAlignment="Center" Margin="0 0 0 12"
|
||||
<TextBlock Grid.Row="15" Grid.Column="0" Text="TGA RLE Compression" VerticalAlignment="Center" Margin="0 0 0 12"
|
||||
ToolTip="Lossless compression of repeated pixels. File size depends on the image."
|
||||
Visibility="{Binding ShowTgaCompression, Converter={StaticResource BoolToVisibilityConverter}}" />
|
||||
<CheckBox Grid.Row="13" Grid.Column="2" Grid.ColumnSpan="3" Margin="0 0 0 12"
|
||||
<CheckBox Grid.Row="15" Grid.Column="2" Grid.ColumnSpan="3" Margin="0 0 0 12"
|
||||
IsChecked="{Binding TgaRleCompression, Mode=TwoWay}"
|
||||
Content="{Binding IsChecked, RelativeSource={RelativeSource Self}, Converter={x:Static converters:BoolToToggleConverter.Instance}}"
|
||||
Style="{DynamicResource {x:Static adonisUi:Styles.ToggleSwitch}}"
|
||||
Visibility="{Binding ShowTgaCompression, Converter={StaticResource BoolToVisibilityConverter}}" />
|
||||
|
||||
<TextBlock Grid.Row="14" Grid.Column="0" Text="Save HDR as .hdr" VerticalAlignment="Center" Margin="0 0 0 12" />
|
||||
<CheckBox Grid.Row="14" Grid.Column="2" Grid.ColumnSpan="3"
|
||||
<TextBlock Grid.Row="16" Grid.Column="0" Text="Save HDR as .hdr" VerticalAlignment="Center" Margin="0 0 0 12" />
|
||||
<CheckBox Grid.Row="16" Grid.Column="2" Grid.ColumnSpan="3"
|
||||
IsChecked="{Binding ExportHdrTexturesAsHdr, Mode=TwoWay}"
|
||||
Content="{Binding IsChecked, RelativeSource={RelativeSource Self}, Converter={x:Static converters:BoolToToggleConverter.Instance}}"
|
||||
Style="{DynamicResource {x:Static adonisUi:Styles.ToggleSwitch}}"
|
||||
Margin="0 0 0 12" />
|
||||
|
||||
<TextBlock Grid.Row="15"
|
||||
<TextBlock Grid.Row="17"
|
||||
Grid.Column="0"
|
||||
Text="Export All Mips"
|
||||
VerticalAlignment="Center" />
|
||||
<CheckBox Grid.Row="15"
|
||||
<CheckBox Grid.Row="17"
|
||||
Grid.Column="2"
|
||||
Grid.ColumnSpan="3"
|
||||
IsChecked="{Binding ExportAllTextureMips, Mode=TwoWay}"
|
||||
Content="{Binding IsChecked, RelativeSource={RelativeSource Self}, Converter={x:Static converters:BoolToToggleConverter.Instance}}"
|
||||
Style="{DynamicResource {x:Static adonisUi:Styles.ToggleSwitch}}" />
|
||||
|
||||
<Separator Grid.Row="16" Grid.Column="0" Grid.ColumnSpan="5" Style="{StaticResource CustomSeparator}" Tag="MATERIAL & MORPH" Margin="0 10 0 10" />
|
||||
<Separator Grid.Row="18" Grid.Column="0" Grid.ColumnSpan="5" Style="{StaticResource CustomSeparator}" Tag="MATERIAL & MORPH" Margin="0 10 0 10" />
|
||||
|
||||
<TextBlock Grid.Row="17" Grid.Column="0" Text="Material Depth" VerticalAlignment="Center" Margin="0 0 0 12" />
|
||||
<ComboBox Grid.Row="17" Grid.Column="2" Grid.ColumnSpan="3" Margin="0 0 0 12"
|
||||
<TextBlock Grid.Row="19" Grid.Column="0" Text="Material Depth" VerticalAlignment="Center" Margin="0 0 0 12" />
|
||||
<ComboBox Grid.Row="19" Grid.Column="2" Grid.ColumnSpan="3" Margin="0 0 0 12"
|
||||
ItemsSource="{Binding MaterialDepths}"
|
||||
SelectedItem="{Binding SelectedMaterialDepth, Mode=TwoWay}">
|
||||
<ComboBox.ItemTemplate>
|
||||
@@ -279,9 +327,9 @@
|
||||
</ComboBox.ItemTemplate>
|
||||
</ComboBox>
|
||||
|
||||
<TextBlock Grid.Row="18" Grid.Column="0" Text="Auto-Export Attached Materials" VerticalAlignment="Center" Margin="0 0 0 15"
|
||||
<TextBlock Grid.Row="20" Grid.Column="0" Text="Auto-Export Attached Materials" VerticalAlignment="Center" Margin="0 0 0 15"
|
||||
ToolTip="When exporting a mesh, also find and export its attached materials." />
|
||||
<Grid Grid.Row="18" Grid.Column="2" Grid.ColumnSpan="3" Margin="0 0 0 15">
|
||||
<Grid Grid.Row="20" Grid.Column="2" Grid.ColumnSpan="3" Margin="0 0 0 15">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
@@ -296,8 +344,8 @@
|
||||
Text="For geometry-only exports, it can be significantly faster to disable this option." />
|
||||
</Grid>
|
||||
|
||||
<TextBlock Grid.Row="19" Grid.Column="0" Text="Export Morph Targets" VerticalAlignment="Center" Margin="0 0 0 15" />
|
||||
<CheckBox Grid.Row="19" Grid.Column="2" Grid.ColumnSpan="3" Margin="0 0 0 15"
|
||||
<TextBlock Grid.Row="21" Grid.Column="0" Text="Export Morph Targets" VerticalAlignment="Center" Margin="0 0 0 15" />
|
||||
<CheckBox Grid.Row="21" Grid.Column="2" Grid.ColumnSpan="3" Margin="0 0 0 15"
|
||||
IsChecked="{Binding ExportMorphTargets, Mode=TwoWay}"
|
||||
Content="{Binding IsChecked, RelativeSource={RelativeSource Self}, Converter={x:Static converters:BoolToToggleConverter.Instance}}"
|
||||
Style="{DynamicResource {x:Static adonisUi:Styles.ToggleSwitch}}" />
|
||||
|
||||
164
FModel/Views/Resources/Controls/ImageAnimation.cs
Normal file
164
FModel/Views/Resources/Controls/ImageAnimation.cs
Normal file
@@ -0,0 +1,164 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Threading;
|
||||
using CUE4Parse.UE4.Assets.Exports.Paper2D;
|
||||
using CUE4Parse_Conversion.Options;
|
||||
using CUE4Parse_Conversion.Textures;
|
||||
using CUE4Parse_Conversion.Textures.Paper2D;
|
||||
|
||||
namespace FModel.Views.Resources.Controls;
|
||||
|
||||
public static class ImageAnimation
|
||||
{
|
||||
public sealed record Frame(BitmapSource Image, TimeSpan Duration);
|
||||
|
||||
public static readonly DependencyProperty FramesProperty = DependencyProperty.RegisterAttached("Frames", typeof(IReadOnlyList<Frame>), typeof(ImageAnimation), new PropertyMetadata(null, OnFramesChanged));
|
||||
|
||||
private static readonly DependencyProperty _playbackProperty = DependencyProperty.RegisterAttached("Playback", typeof(Playback), typeof(ImageAnimation));
|
||||
|
||||
public static IReadOnlyList<Frame> GetFrames(DependencyObject image) => (IReadOnlyList<Frame>) image.GetValue(FramesProperty);
|
||||
public static void SetFrames(DependencyObject image, IReadOnlyList<Frame> frames) => image.SetValue(FramesProperty, frames);
|
||||
|
||||
public static BitmapSource CreateSource(IReadOnlyList<Frame> frames)
|
||||
{
|
||||
if (frames is not { Count: > 0 })
|
||||
return null;
|
||||
if (frames.Count == 1)
|
||||
return frames[0].Image;
|
||||
|
||||
var source = frames[0].Image.Clone();
|
||||
SetFrames(source, frames);
|
||||
source.Freeze();
|
||||
return source;
|
||||
}
|
||||
|
||||
internal static Frame[] CreateFrames(CFlipbook flipbook, int maxSize = 0, CancellationToken cancellationToken = default)
|
||||
{
|
||||
using var animation = flipbook.ToImage(new ExportOptions(), maxSize: maxSize, cancellationToken: cancellationToken);
|
||||
var frames = new Frame[animation.Frames.Count];
|
||||
var minimumDuration = maxSize > 0 ? 1.0 / 15 : 0.001;
|
||||
for (var i = 0; i < frames.Length; i++)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
var frame = animation.Frames[i];
|
||||
var pixels = new byte[frame.Width * frame.Height * 4];
|
||||
frame.CopyPixelDataTo(pixels);
|
||||
for (var pixel = 0; pixel < pixels.Length; pixel += 4)
|
||||
{
|
||||
(pixels[pixel], pixels[pixel + 2]) = (pixels[pixel + 2], pixels[pixel]);
|
||||
}
|
||||
|
||||
var image = BitmapSource.Create(frame.Width, frame.Height, 96, 96, PixelFormats.Bgra32, null, pixels, frame.Width * 4);
|
||||
image.Freeze();
|
||||
|
||||
var seconds = flipbook.FramesPerSecond > 0 ? flipbook.Frames[i].FrameRun / (double) flipbook.FramesPerSecond : 0;
|
||||
frames[i] = new Frame(image, TimeSpan.FromSeconds(Math.Max(minimumDuration, seconds)));
|
||||
}
|
||||
|
||||
return frames;
|
||||
}
|
||||
|
||||
// Only light animations, otherwise use the first frame as a thumbnail
|
||||
internal static BitmapSource CreateThumbnail(UPaperFlipbook flipbook, ExportOptions options, int maxSize)
|
||||
{
|
||||
var cache = new Dictionary<string, CTexture>();
|
||||
if (flipbook.FramesPerSecond > 0 && flipbook.KeyFrames.Length is > 1 and <= 64)
|
||||
{
|
||||
var pixels = flipbook.KeyFrames.Where(frame => frame.FrameRun > 0).Select(frame => frame.LoadSprite()).OfType<UPaperSprite>().Distinct()
|
||||
.Sum(sprite => (double) sprite.BakedSourceDimension.X * sprite.BakedSourceDimension.Y);
|
||||
if (pixels <= 16 * 1024 * 1024 && flipbook.Decode(options, cache) is { } decoded)
|
||||
{
|
||||
var minimumRun = Math.Max(1, (int) Math.Ceiling(decoded.FramesPerSecond / 15));
|
||||
var frames = new List<CFlipbookFrame>();
|
||||
foreach (var frame in decoded.Frames)
|
||||
{
|
||||
if (frames.Count > 0 && frames[^1].FrameRun < minimumRun)
|
||||
{
|
||||
var previous = frames[^1];
|
||||
frames[^1] = new CFlipbookFrame(previous.Texture, previous.FrameRun + frame.FrameRun, previous.Offset);
|
||||
}
|
||||
else
|
||||
{
|
||||
frames.Add(frame);
|
||||
}
|
||||
}
|
||||
|
||||
return CreateSource(CreateFrames(new CFlipbook(frames, decoded.FramesPerSecond), maxSize));
|
||||
}
|
||||
}
|
||||
|
||||
var first = flipbook.KeyFrames.Where(frame => frame.FrameRun > 0).Select(frame => frame.LoadSprite()?.Decode(options, cache)).FirstOrDefault(texture => texture != null);
|
||||
return first == null ? null : CreateSource(CreateFrames(new CFlipbook([new CFlipbookFrame(first)], 1), maxSize));
|
||||
}
|
||||
|
||||
private static void OnFramesChanged(DependencyObject element, DependencyPropertyChangedEventArgs args)
|
||||
{
|
||||
if (element is not Image image)
|
||||
return;
|
||||
|
||||
(image.GetValue(_playbackProperty) as Playback)?.Dispose();
|
||||
image.ClearValue(_playbackProperty);
|
||||
if (args.NewValue is not IReadOnlyList<Frame> { Count: > 0 } frames)
|
||||
return;
|
||||
|
||||
image.SetCurrentValue(Image.SourceProperty, frames[0].Image);
|
||||
if (frames.Count > 1)
|
||||
{
|
||||
image.SetValue(_playbackProperty, new Playback(image, frames));
|
||||
}
|
||||
}
|
||||
|
||||
private sealed class Playback : IDisposable
|
||||
{
|
||||
private readonly Image _image;
|
||||
private readonly IReadOnlyList<Frame> _frames;
|
||||
private readonly DispatcherTimer _timer;
|
||||
private int _index;
|
||||
|
||||
public Playback(Image image, IReadOnlyList<Frame> frames)
|
||||
{
|
||||
_image = image;
|
||||
_frames = frames;
|
||||
_timer = new DispatcherTimer(DispatcherPriority.Render, image.Dispatcher) { Interval = frames[0].Duration };
|
||||
_timer.Tick += (_, _) =>
|
||||
{
|
||||
_index = (_index + 1) % _frames.Count;
|
||||
_image.SetCurrentValue(Image.SourceProperty, _frames[_index].Image);
|
||||
_timer.Interval = _frames[_index].Duration;
|
||||
};
|
||||
image.Loaded += UpdatePlayback;
|
||||
image.Unloaded += OnUnloaded;
|
||||
image.IsVisibleChanged += OnIsVisibleChanged;
|
||||
UpdatePlayback(image, null);
|
||||
}
|
||||
|
||||
private void UpdatePlayback(object sender, RoutedEventArgs args)
|
||||
{
|
||||
if (_image.IsLoaded && _image.IsVisible)
|
||||
{
|
||||
_timer.Start();
|
||||
}
|
||||
else
|
||||
{
|
||||
_timer.Stop();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnUnloaded(object sender, RoutedEventArgs args) => _timer.Stop();
|
||||
private void OnIsVisibleChanged(object sender, DependencyPropertyChangedEventArgs args) => UpdatePlayback(sender, null);
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_timer.Stop();
|
||||
_image.Loaded -= UpdatePlayback;
|
||||
_image.Unloaded -= OnUnloaded;
|
||||
_image.IsVisibleChanged -= OnIsVisibleChanged;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -28,7 +28,7 @@ public class FileToGeometryConverter : IMultiValueConverter
|
||||
EAssetCategory.UserDefinedStruct => ("BlueprintIcon", "UserDefinedStructBrush"),
|
||||
EAssetCategory.CookedMetaData => ("BlueprintIcon", "CookedMetaDataBrush"),
|
||||
|
||||
EAssetCategory.Texture => ("TextureIconAlt", "TextureBrush"),
|
||||
EAssetCategory.Texture or EAssetCategory.AnimatedTexture => ("TextureIconAlt", "TextureBrush"),
|
||||
|
||||
EAssetCategory.StaticMesh => ("StaticMeshIconAlt", "NeutralBrush"),
|
||||
EAssetCategory.SkeletalMesh => ("SkeletalMeshIconAlt", "NeutralBrush"),
|
||||
@@ -36,6 +36,7 @@ public class FileToGeometryConverter : IMultiValueConverter
|
||||
EAssetCategory.CustomizableObject => ("StaticMeshIconAlt", "CustomizableObjectBrush"),
|
||||
EAssetCategory.NaniteDisplacedMesh => ("StaticMeshIconAlt", "NaniteDisplacedMeshBrush"),
|
||||
EAssetCategory.GeometryCollection => ("GeometryCollectionIcon", "NeutralBrush"),
|
||||
EAssetCategory.GroomAsset => ("GroomAssetIcon", "GroomAssetBrush"),
|
||||
|
||||
EAssetCategory.Material => ("MaterialIcon", "MaterialBrush"),
|
||||
EAssetCategory.MaterialEditorData => ("MaterialIcon", "MaterialEditorBrush"),
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -7,6 +7,7 @@
|
||||
xmlns:audioControls="clr-namespace:FModel.Views.Resources.Controls.Aup"
|
||||
xmlns:converters="clr-namespace:FModel.Views.Resources.Converters"
|
||||
xmlns:settings="clr-namespace:FModel.Settings"
|
||||
xmlns:viewModels="clr-namespace:FModel.ViewModels"
|
||||
xmlns:avalonedit="http://icsharpcode.net/sharpdevelop/avalonedit"
|
||||
xmlns:folding="clr-namespace:ICSharpCode.AvalonEdit.Folding;assembly=ICSharpCode.AvalonEdit"
|
||||
xmlns:adonisUi="clr-namespace:AdonisUI;assembly=AdonisUI"
|
||||
@@ -521,13 +522,223 @@
|
||||
<ColumnDefinition Width="{Binding AvalonImageSize, Source={x:Static settings:UserSettings.Default}, Mode=TwoWay}" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<controls:AvalonEditor x:Name="DynamicArea" Grid.Column="0" DataContext="{Binding SelectedItem, ElementName=TabControlName}" />
|
||||
<GridSplitter Grid.Column="1" Width="4" VerticalAlignment="Stretch" ResizeDirection="Columns" KeyboardIncrement="0"
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<controls:AvalonEditor x:Name="DynamicArea" Grid.Column="0" Grid.RowSpan="2" DataContext="{Binding SelectedItem, ElementName=TabControlName}" />
|
||||
<GridSplitter Grid.Column="1" Grid.RowSpan="2" Width="4" VerticalAlignment="Stretch" ResizeDirection="Columns" KeyboardIncrement="0"
|
||||
Visibility="{Binding SelectedItem.HasImage, ElementName=TabControlName, Converter={StaticResource BoolToVisibilityConverter}}"
|
||||
Background="{DynamicResource {x:Static adonisUi:Brushes.Layer3BackgroundBrush}}" />
|
||||
<Border Grid.Column="2" BorderBrush="#3b3d4a" BorderThickness="1" HorizontalAlignment="Center" VerticalAlignment="Center"
|
||||
<Border Grid.Column="2"
|
||||
Padding="10 6 8 8"
|
||||
BorderThickness="0 0 0 1"
|
||||
DataContext="{Binding SelectedItem, ElementName=TabControlName}"
|
||||
BorderBrush="{DynamicResource {x:Static adonisUi:Brushes.Layer1BorderBrush}}"
|
||||
TextElement.Foreground="{DynamicResource {x:Static adonisUi:Brushes.ForegroundBrush}}"
|
||||
Visibility="{Binding HasImage, Converter={StaticResource BoolToVisibilityConverter}}">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<TextBlock Margin="0 0 4 0"
|
||||
Text="{Binding SelectedImage.Name}"
|
||||
VerticalAlignment="Center"
|
||||
ToolTip="{Binding Text, RelativeSource={RelativeSource Self}}"
|
||||
FontSize="12"
|
||||
FontWeight="Bold"
|
||||
TextTrimming="CharacterEllipsis" />
|
||||
<Button Grid.Column="1"
|
||||
Margin="0 2"
|
||||
Cursor="Hand"
|
||||
VerticalAlignment="Center"
|
||||
ToolTip="Open in Texture Inspector"
|
||||
Command="{Binding ImageCommand}"
|
||||
CommandParameter="InspectTexture"
|
||||
IsEnabled="{Binding CanOpenSnooper, Source={x:Static viewModels:SnooperViewModel.Instance}}"
|
||||
Visibility="{Binding SelectedImage.HasTexture, Converter={StaticResource BoolToVisibilityConverter}, FallbackValue=Collapsed}">
|
||||
<Button.Style>
|
||||
<Style TargetType="Button"
|
||||
BasedOn="{StaticResource {x:Type Button}}">
|
||||
<Setter Property="Width"
|
||||
Value="24" />
|
||||
<Setter Property="Height"
|
||||
Value="24" />
|
||||
<Setter Property="Padding"
|
||||
Value="5" />
|
||||
<Setter Property="Background"
|
||||
Value="Transparent" />
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding HasMultipleImages}"
|
||||
Value="True">
|
||||
<Setter Property="Width"
|
||||
Value="18" />
|
||||
<Setter Property="Height"
|
||||
Value="18" />
|
||||
<Setter Property="Padding"
|
||||
Value="4" />
|
||||
<Setter Property="Background"
|
||||
Value="{DynamicResource {x:Static adonisUi:Brushes.Layer1BackgroundBrush}}" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</Button.Style>
|
||||
<Button.Template>
|
||||
<ControlTemplate TargetType="Button">
|
||||
<Border Background="{TemplateBinding Background}"
|
||||
Padding="{TemplateBinding Padding}"
|
||||
CornerRadius="3">
|
||||
<Path x:Name="InspectorIcon"
|
||||
Stretch="Uniform"
|
||||
Fill="{TemplateBinding Foreground}"
|
||||
Data="{StaticResource TextureInspectorIcon}">
|
||||
<Path.Effect>
|
||||
<DropShadowEffect Color="Black"
|
||||
BlurRadius="2"
|
||||
ShadowDepth="1"
|
||||
Opacity="0.35" />
|
||||
</Path.Effect>
|
||||
</Path>
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsMouseOver"
|
||||
Value="True">
|
||||
<Setter TargetName="InspectorIcon"
|
||||
Property="Fill"
|
||||
Value="#B79AF4" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsEnabled"
|
||||
Value="False">
|
||||
<Setter TargetName="InspectorIcon"
|
||||
Property="Fill"
|
||||
Value="{DynamicResource {x:Static adonisUi:Brushes.DisabledForegroundBrush}}" />
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Button.Template>
|
||||
</Button>
|
||||
<DockPanel Grid.Row="1"
|
||||
Grid.ColumnSpan="2"
|
||||
Margin="0 1 0 0"
|
||||
TextElement.Foreground="{DynamicResource {x:Static adonisUi:Brushes.DisabledForegroundBrush}}">
|
||||
<StackPanel DockPanel.Dock="Right"
|
||||
Orientation="Horizontal"
|
||||
Margin="6 0 0 0"
|
||||
VerticalAlignment="Center"
|
||||
Visibility="{Binding HasMultipleImages, Converter={StaticResource BoolToVisibilityConverter}}">
|
||||
<StackPanel.Resources>
|
||||
<Style TargetType="RepeatButton">
|
||||
<Setter Property="Width"
|
||||
Value="18" />
|
||||
<Setter Property="Height"
|
||||
Value="18" />
|
||||
<Setter Property="Cursor"
|
||||
Value="Hand" />
|
||||
<Setter Property="Background"
|
||||
Value="{DynamicResource {x:Static adonisUi:Brushes.Layer2BackgroundBrush}}" />
|
||||
<Setter Property="Foreground"
|
||||
Value="{DynamicResource {x:Static adonisUi:Brushes.ForegroundBrush}}" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="RepeatButton">
|
||||
<Border Background="{TemplateBinding Background}"
|
||||
CornerRadius="3">
|
||||
<ContentPresenter HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center" />
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsMouseOver"
|
||||
Value="True">
|
||||
<Setter Property="Background"
|
||||
Value="{DynamicResource {x:Static adonisUi:Brushes.Layer2HighlightBrush}}" />
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</StackPanel.Resources>
|
||||
<RepeatButton ToolTip="Previous image"
|
||||
Command="{Binding ImageCommand}"
|
||||
CommandParameter="PreviousImage">
|
||||
<Path Data="M4,0 L0,4 4,8"
|
||||
Width="6"
|
||||
Height="9"
|
||||
Stretch="Uniform"
|
||||
StrokeThickness="1.3"
|
||||
Stroke="{Binding Foreground, RelativeSource={RelativeSource AncestorType=RepeatButton}}" />
|
||||
</RepeatButton>
|
||||
<Border Height="18"
|
||||
Margin="1 0"
|
||||
Padding="5 0"
|
||||
CornerRadius="3"
|
||||
Background="{DynamicResource {x:Static adonisUi:Brushes.Layer1BackgroundBrush}}">
|
||||
<TextBlock FontSize="11"
|
||||
VerticalAlignment="Center"
|
||||
Text="{Binding Page}"
|
||||
Foreground="{DynamicResource {x:Static adonisUi:Brushes.ForegroundBrush}}" />
|
||||
</Border>
|
||||
<RepeatButton ToolTip="Next image"
|
||||
Command="{Binding ImageCommand}"
|
||||
CommandParameter="NextImage">
|
||||
<Path Data="M0,0 L4,4 0,8"
|
||||
Width="6"
|
||||
Height="9"
|
||||
Stretch="Uniform"
|
||||
StrokeThickness="1.3"
|
||||
Stroke="{Binding Foreground, RelativeSource={RelativeSource AncestorType=RepeatButton}}" />
|
||||
</RepeatButton>
|
||||
</StackPanel>
|
||||
<TextBlock DockPanel.Dock="Left"
|
||||
FontSize="11"
|
||||
VerticalAlignment="Center"
|
||||
Visibility="{Binding SelectedImage.HasTexture, Converter={StaticResource BoolToVisibilityConverter}, FallbackValue=Collapsed}">
|
||||
<Run Text="{Binding SelectedImage.TextureFormat, Mode=OneWay}"
|
||||
Foreground="{DynamicResource {x:Static adonisUi:Brushes.AlertBrush}}" />
|
||||
<Run Text=" / "
|
||||
Foreground="{DynamicResource {x:Static adonisUi:Brushes.DisabledForegroundBrush}}" />
|
||||
<Run Text="{Binding SelectedImage.InspectorTexture.Data.Length, Mode=OneWay, Converter={x:Static converters:SizeToStringConverter.Instance}}" />
|
||||
<Run Text=" / "
|
||||
Foreground="{DynamicResource {x:Static adonisUi:Brushes.DisabledForegroundBrush}}" />
|
||||
</TextBlock>
|
||||
<TextBlock FontSize="11"
|
||||
VerticalAlignment="Center"
|
||||
TextTrimming="CharacterEllipsis">
|
||||
<Run>
|
||||
<Run.Text>
|
||||
<MultiBinding Mode="OneWay"
|
||||
StringFormat="{}{0} × {1}px"
|
||||
FallbackValue="">
|
||||
<Binding Path="SelectedImage.Image.PixelWidth" />
|
||||
<Binding Path="SelectedImage.Image.PixelHeight" />
|
||||
</MultiBinding>
|
||||
</Run.Text>
|
||||
</Run>
|
||||
<Run>
|
||||
<Run.Text>
|
||||
<Binding Path="SelectedImage.MipCount"
|
||||
Mode="OneWay"
|
||||
StringFormat="{} / {0} mips"
|
||||
TargetNullValue=""
|
||||
FallbackValue="" />
|
||||
</Run.Text>
|
||||
</Run>
|
||||
</TextBlock>
|
||||
</DockPanel>
|
||||
</Grid>
|
||||
</Border>
|
||||
<Border Grid.Column="2" Grid.Row="1" Margin="8" BorderThickness="1" HorizontalAlignment="Center" VerticalAlignment="Center"
|
||||
BorderBrush="{DynamicResource {x:Static adonisUi:Brushes.Layer2BorderBrush}}"
|
||||
Visibility="{Binding SelectedItem.HasImage, ElementName=TabControlName, Converter={StaticResource BoolToVisibilityConverter}}">
|
||||
<Image VerticalAlignment="Center" HorizontalAlignment="Center" Stretch="Uniform"
|
||||
controls:ImageAnimation.Frames="{Binding SelectedItem.SelectedImage.AnimationFrames, ElementName=TabControlName}"
|
||||
Visibility="{Binding SelectedItem.HasImage, ElementName=TabControlName, Converter={StaticResource BoolToVisibilityConverter}}"
|
||||
Source="{Binding SelectedItem.SelectedImage.Image, ElementName=TabControlName}" RenderOptions.BitmapScalingMode="{Binding SelectedItem.SelectedImage.RenderNearestNeighbor, ElementName=TabControlName, Converter={x:Static converters:BoolToRenderModeConverter.Instance}}">
|
||||
<Image.InputBindings>
|
||||
@@ -535,8 +746,20 @@
|
||||
</Image.InputBindings>
|
||||
<Image.ContextMenu>
|
||||
<ContextMenu DataContext="{Binding PlacementTarget, RelativeSource={RelativeSource Self}}">
|
||||
<MenuItem Header="Disable Alpha Channel" IsCheckable="True" IsChecked="{Binding DataContext.SelectedImage.NoAlpha}" />
|
||||
<MenuItem Header="Open Image" Command="{Binding DataContext.ImageCommand}" CommandParameter="Open">
|
||||
<MenuItem Header="Open in Texture Inspector"
|
||||
Command="{Binding DataContext.ImageCommand}"
|
||||
CommandParameter="InspectTexture"
|
||||
IsEnabled="{Binding CanOpenSnooper, Source={x:Static viewModels:SnooperViewModel.Instance}}"
|
||||
Visibility="{Binding DataContext.SelectedImage.HasTexture, Converter={StaticResource BoolToVisibilityConverter}, FallbackValue=Collapsed}">
|
||||
<MenuItem.Icon>
|
||||
<Path Width="12"
|
||||
Height="12"
|
||||
Stretch="Uniform"
|
||||
Fill="{DynamicResource {x:Static adonisUi:Brushes.ForegroundBrush}}"
|
||||
Data="{StaticResource TextureInspectorIcon}" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<MenuItem Header="Open in New Window" Command="{Binding DataContext.ImageCommand}" CommandParameter="Open">
|
||||
<MenuItem.Icon>
|
||||
<Viewbox Width="16" Height="16">
|
||||
<Canvas Width="24" Height="24">
|
||||
@@ -547,7 +770,7 @@
|
||||
</Viewbox>
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<MenuItem Header="Copy Image" Command="{Binding DataContext.ImageCommand}" CommandParameter="Copy">
|
||||
<MenuItem Header="Copy Image" Command="{Binding DataContext.ImageCommand}" CommandParameter="{Binding Source}">
|
||||
<MenuItem.Icon>
|
||||
<Viewbox Width="16" Height="16">
|
||||
<Canvas Width="24" Height="24">
|
||||
@@ -556,7 +779,7 @@
|
||||
</Viewbox>
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<MenuItem Header="Save Image" Command="{Binding DataContext.ImageCommand}" CommandParameter="Save">
|
||||
<MenuItem Header="Export Image" Command="{Binding DataContext.ImageCommand}" CommandParameter="Save">
|
||||
<MenuItem.Icon>
|
||||
<Viewbox Width="16" Height="16">
|
||||
<Canvas Width="24" Height="24">
|
||||
@@ -565,19 +788,13 @@
|
||||
</Viewbox>
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<Separator />
|
||||
<MenuItem Header="Ignore Alpha in Preview" IsCheckable="True" IsChecked="{Binding DataContext.SelectedImage.NoAlpha}"
|
||||
IsEnabled="{Binding DataContext.SelectedImage.CanDisableAlpha}" />
|
||||
</ContextMenu>
|
||||
</Image.ContextMenu>
|
||||
</Image>
|
||||
</Border>
|
||||
<StackPanel Grid.Column="2" VerticalAlignment="Bottom" HorizontalAlignment="Center">
|
||||
<TextBlock HorizontalAlignment="Center"
|
||||
Text="{Binding SelectedItem.SelectedImage.ExportName, Converter={x:Static converters:FileNameWithoutExtensionConverter.Instance}, ElementName=TabControlName}"
|
||||
FontSize="10" FontWeight="SemiBold"
|
||||
Visibility="{Binding SelectedItem.HasImage, ElementName=TabControlName, Converter={StaticResource BoolToVisibilityConverter}}" />
|
||||
<TextBlock HorizontalAlignment="Center"
|
||||
Visibility="{Binding SelectedItem.HasMultipleImages, ElementName=TabControlName, Converter={StaticResource BoolToVisibilityConverter}}"
|
||||
Text="{Binding SelectedItem.Page, ElementName=TabControlName}" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
<DataTemplate.Triggers>
|
||||
<DataTrigger Binding="{Binding SelectedItem.HasImage, ElementName=TabControlName}" Value="False">
|
||||
|
||||
2
Snooper
2
Snooper
Submodule Snooper updated: 9d44219c9f...230f204aed
Reference in New Issue
Block a user