removed any kind of popup asking for a directory

it was more annoying than useful now that you can just click to open the file location
This commit is contained in:
4sval 2023-02-07 21:14:00 +01:00
parent 0b7ed2cf7f
commit af2fceb9e5
7 changed files with 24 additions and 64 deletions

@ -1 +1 @@
Subproject commit c2143de8bda93c02f5b07657b9110c477ec1d5ff
Subproject commit 9b7bb06564cff6137dc17b6635d86b220f8a0a3b

View File

@ -41,8 +41,8 @@ public class ImageCommand : ViewModelCommand<TabItem>
ClipboardExtensions.SetImage(contextViewModel.SelectedImage.ImageBuffer, $"{contextViewModel.SelectedImage.ExportName}.png");
break;
case "Save":
contextViewModel.SaveImage(false);
contextViewModel.SaveImage();
break;
}
}
}
}

View File

@ -43,30 +43,28 @@ public class RightClickMenuCommand : ViewModelCommand<ApplicationViewModel>
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;
}

View File

@ -37,27 +37,25 @@ public class TabCommand : ViewModelCommand<TabItem>
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":

View File

@ -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);

View File

@ -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));

View File

@ -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);