diff --git a/CUE4Parse b/CUE4Parse index c2143de8..9b7bb065 160000 --- a/CUE4Parse +++ b/CUE4Parse @@ -1 +1 @@ -Subproject commit c2143de8bda93c02f5b07657b9110c477ec1d5ff +Subproject commit 9b7bb06564cff6137dc17b6635d86b220f8a0a3b diff --git a/FModel/ViewModels/Commands/ImageCommand.cs b/FModel/ViewModels/Commands/ImageCommand.cs index 7cef0c8a..264255ac 100644 --- a/FModel/ViewModels/Commands/ImageCommand.cs +++ b/FModel/ViewModels/Commands/ImageCommand.cs @@ -41,8 +41,8 @@ public class ImageCommand : ViewModelCommand ClipboardExtensions.SetImage(contextViewModel.SelectedImage.ImageBuffer, $"{contextViewModel.SelectedImage.ExportName}.png"); break; case "Save": - contextViewModel.SaveImage(false); + contextViewModel.SaveImage(); break; } } -} \ No newline at end of file +} diff --git a/FModel/ViewModels/Commands/RightClickMenuCommand.cs b/FModel/ViewModels/Commands/RightClickMenuCommand.cs index 13e166cd..497cc518 100644 --- a/FModel/ViewModels/Commands/RightClickMenuCommand.cs +++ b/FModel/ViewModels/Commands/RightClickMenuCommand.cs @@ -43,30 +43,28 @@ public class RightClickMenuCommand : ViewModelCommand foreach (var asset in assetItems) { cancellationToken.ThrowIfCancellationRequested(); - contextViewModel.CUE4Parse.Extract(cancellationToken, asset.FullPath, false, EBulkType.Properties); - contextViewModel.CUE4Parse.TabControl.SelectedTab.SaveProperty(false); + contextViewModel.CUE4Parse.Extract(cancellationToken, asset.FullPath, false, EBulkType.Properties | EBulkType.Auto); } break; case "Assets_Save_Textures": foreach (var asset in assetItems) { cancellationToken.ThrowIfCancellationRequested(); - contextViewModel.CUE4Parse.Extract(cancellationToken, asset.FullPath, false, EBulkType.Textures); - contextViewModel.CUE4Parse.TabControl.SelectedTab.SaveImages(false); + contextViewModel.CUE4Parse.Extract(cancellationToken, asset.FullPath, false, EBulkType.Textures | EBulkType.Auto); } break; case "Assets_Save_Models": foreach (var asset in assetItems) { cancellationToken.ThrowIfCancellationRequested(); - contextViewModel.CUE4Parse.Extract(cancellationToken, asset.FullPath, false, EBulkType.Meshes); + contextViewModel.CUE4Parse.Extract(cancellationToken, asset.FullPath, false, EBulkType.Meshes | EBulkType.Auto); } break; case "Assets_Save_Animations": foreach (var asset in assetItems) { cancellationToken.ThrowIfCancellationRequested(); - contextViewModel.CUE4Parse.Extract(cancellationToken, asset.FullPath, false, EBulkType.Animations); + contextViewModel.CUE4Parse.Extract(cancellationToken, asset.FullPath, false, EBulkType.Animations | EBulkType.Auto); } break; } diff --git a/FModel/ViewModels/Commands/TabCommand.cs b/FModel/ViewModels/Commands/TabCommand.cs index 94a1feea..17152ed5 100644 --- a/FModel/ViewModels/Commands/TabCommand.cs +++ b/FModel/ViewModels/Commands/TabCommand.cs @@ -37,27 +37,25 @@ public class TabCommand : ViewModelCommand case "Asset_Save_Properties": await _threadWorkerView.Begin(cancellationToken => { - _applicationView.CUE4Parse.Extract(cancellationToken, contextViewModel.FullPath, false, EBulkType.Properties); - _applicationView.CUE4Parse.TabControl.SelectedTab.SaveProperty(false); + _applicationView.CUE4Parse.Extract(cancellationToken, contextViewModel.FullPath, false, EBulkType.Properties | EBulkType.Auto); }); break; case "Asset_Save_Textures": await _threadWorkerView.Begin(cancellationToken => { - _applicationView.CUE4Parse.Extract(cancellationToken, contextViewModel.FullPath, false, EBulkType.Textures); - _applicationView.CUE4Parse.TabControl.SelectedTab.SaveImages(false); + _applicationView.CUE4Parse.Extract(cancellationToken, contextViewModel.FullPath, false, EBulkType.Textures | EBulkType.Auto); }); break; case "Asset_Save_Models": await _threadWorkerView.Begin(cancellationToken => { - _applicationView.CUE4Parse.Extract(cancellationToken, contextViewModel.FullPath, false, EBulkType.Meshes); + _applicationView.CUE4Parse.Extract(cancellationToken, contextViewModel.FullPath, false, EBulkType.Meshes | EBulkType.Auto); }); break; case "Asset_Save_Animations": await _threadWorkerView.Begin(cancellationToken => { - _applicationView.CUE4Parse.Extract(cancellationToken, contextViewModel.FullPath, false, EBulkType.Animations); + _applicationView.CUE4Parse.Extract(cancellationToken, contextViewModel.FullPath, false, EBulkType.Animations | EBulkType.Auto); }); break; case "Open_Properties": diff --git a/FModel/ViewModels/TabControlViewModel.cs b/FModel/ViewModels/TabControlViewModel.cs index 440b42a4..c87b2381 100644 --- a/FModel/ViewModels/TabControlViewModel.cs +++ b/FModel/ViewModels/TabControlViewModel.cs @@ -244,7 +244,7 @@ public class TabItem : ViewModel { var t = new TabImage(name, rnn, img); if (bulkTexture) - SaveImage(t, true); + SaveImage(t); _images.Add(t); SelectedImage ??= t; @@ -264,7 +264,7 @@ public class TabItem : ViewModel Document.Text = text; if (bulkSave) - SaveProperty(true); + SaveProperty(); }); } @@ -277,25 +277,17 @@ public class TabItem : ViewModel }); } - public void SaveImages(bool bulkTexture) + public void SaveImages() { switch (_images.Count) { case 1: - SaveImage(bulkTexture); + SaveImage(); break; case > 1: var directory = Path.Combine(UserSettings.Default.TextureDirectory, UserSettings.Default.KeepDirectoryStructure ? Directory : "").Replace('\\', '/'); - - if (!bulkTexture) - { - var folderBrowser = new VistaFolderBrowserDialog(); - if (folderBrowser.ShowDialog() == true) - directory = folderBrowser.SelectedPath; - else return; - } - else System.IO.Directory.CreateDirectory(directory); + System.IO.Directory.CreateDirectory(directory); foreach (var image in _images) { @@ -307,28 +299,15 @@ public class TabItem : ViewModel } } - public void SaveImage(bool bulkTexture) => SaveImage(SelectedImage, bulkTexture); - private void SaveImage(TabImage image, bool bulkTexture) + public void SaveImage() => SaveImage(SelectedImage); + private void SaveImage(TabImage image) { if (image == null) return; var fileName = $"{image.ExportName}.png"; var path = Path.Combine(UserSettings.Default.TextureDirectory, UserSettings.Default.KeepDirectoryStructure ? Directory : "", fileName!).Replace('\\', '/'); - if (!bulkTexture) - { - var saveFileDialog = new SaveFileDialog - { - Title = "Save Texture", - FileName = fileName, - InitialDirectory = UserSettings.Default.TextureDirectory, - Filter = "PNG Files (*.png)|*.png|All Files (*.*)|*.*" - }; - var result = saveFileDialog.ShowDialog(); - if (!result.HasValue || !result.Value) return; - path = saveFileDialog.FileName; - } - else System.IO.Directory.CreateDirectory(path.SubstringBeforeLast('/')); + System.IO.Directory.CreateDirectory(path.SubstringBeforeLast('/')); SaveImage(image, path, fileName); } @@ -345,29 +324,13 @@ public class TabItem : ViewModel fs.Write(image.ImageBuffer, 0, image.ImageBuffer.Length); } - public void SaveProperty(bool autoSave) + public void SaveProperty() { var fileName = Path.ChangeExtension(Header, ".json"); var directory = Path.Combine(UserSettings.Default.PropertiesDirectory, UserSettings.Default.KeepDirectoryStructure ? Directory : "", fileName).Replace('\\', '/'); - if (!autoSave) - { - var saveFileDialog = new SaveFileDialog - { - Title = "Save Property", - FileName = fileName, - InitialDirectory = UserSettings.Default.PropertiesDirectory, - Filter = "JSON Files (*.json)|*.json|INI Files (*.ini)|*.ini|XML Files (*.xml)|*.xml|All Files (*.*)|*.*" - }; - var result = saveFileDialog.ShowDialog(); - if (!result.HasValue || !result.Value) return; - directory = saveFileDialog.FileName; - } - else - { - System.IO.Directory.CreateDirectory(directory.SubstringBeforeLast('/')); - } + System.IO.Directory.CreateDirectory(directory.SubstringBeforeLast('/')); Application.Current.Dispatcher.Invoke(() => File.WriteAllText(directory, Document.Text)); SaveCheck(directory, fileName); diff --git a/FModel/Views/Snooper/Lights/Light.cs b/FModel/Views/Snooper/Lights/Light.cs index 77c2bbff..8159f3b5 100644 --- a/FModel/Views/Snooper/Lights/Light.cs +++ b/FModel/Views/Snooper/Lights/Light.cs @@ -45,7 +45,7 @@ public abstract class Light : IDisposable Scale = light.GetOrDefault("RelativeScale3D", FVector.OneVector) }; - Model = Guid.NewGuid(); + Model = new FGuid((uint) light.GetFullName().GetHashCode()); Icon = icon; Color = light.GetOrDefault("LightColor", new FColor(0xFF, 0xFF, 0xFF, 0xFF)); diff --git a/FModel/Views/Snooper/Renderer.cs b/FModel/Views/Snooper/Renderer.cs index b6c128af..18348d0c 100644 --- a/FModel/Views/Snooper/Renderer.cs +++ b/FModel/Views/Snooper/Renderer.cs @@ -12,6 +12,7 @@ using CUE4Parse.UE4.Assets.Exports.SkeletalMesh; using CUE4Parse.UE4.Assets.Exports.StaticMesh; using CUE4Parse.UE4.Assets.Exports.Texture; using CUE4Parse.UE4.Objects.Core.Math; +using CUE4Parse.UE4.Objects.Core.Misc; using CUE4Parse.UE4.Objects.Engine; using CUE4Parse.UE4.Objects.UObject; using FModel.Creator; @@ -176,7 +177,7 @@ public class Renderer : IDisposable private void LoadSkeletalMesh(USkeletalMesh original) { - var guid = Guid.NewGuid(); + var guid = new FGuid((uint) original.GetFullName().GetHashCode()); if (Options.Models.ContainsKey(guid) || !original.TryConvert(out var mesh)) return; Options.Models[guid] = new Model(original, mesh);