mirror of
https://github.com/4sval/FModel.git
synced 2026-12-04 23:02:22 -06:00
This commit is contained in:
Submodule CUE4Parse updated: 858ecc7dae...c95dd9b587
@@ -27,6 +27,8 @@ namespace FModel;
|
||||
/// </summary>
|
||||
public partial class App
|
||||
{
|
||||
public string LogFilePath { get; private set; }
|
||||
|
||||
[DllImport("kernel32.dll")]
|
||||
private static extern bool AttachConsole(int dwProcessId);
|
||||
|
||||
@@ -74,47 +76,48 @@ public partial class App
|
||||
if (!Directory.Exists(UserSettings.Default.RawDataDirectory))
|
||||
{
|
||||
createMe = true;
|
||||
UserSettings.Default.RawDataDirectory = Path.Combine(UserSettings.Default.OutputDirectory, "Exports");
|
||||
UserSettings.Default.RawDataDirectory = UserSettings.Default.ExportsDirectory;
|
||||
}
|
||||
|
||||
if (!Directory.Exists(UserSettings.Default.PropertiesDirectory))
|
||||
{
|
||||
createMe = true;
|
||||
UserSettings.Default.PropertiesDirectory = Path.Combine(UserSettings.Default.OutputDirectory, "Exports");
|
||||
UserSettings.Default.PropertiesDirectory = UserSettings.Default.ExportsDirectory;
|
||||
}
|
||||
|
||||
if (!Directory.Exists(UserSettings.Default.TextureDirectory))
|
||||
{
|
||||
createMe = true;
|
||||
UserSettings.Default.TextureDirectory = Path.Combine(UserSettings.Default.OutputDirectory, "Exports");
|
||||
UserSettings.Default.TextureDirectory = UserSettings.Default.ExportsDirectory;
|
||||
}
|
||||
|
||||
if (!Directory.Exists(UserSettings.Default.AudioDirectory))
|
||||
{
|
||||
createMe = true;
|
||||
UserSettings.Default.AudioDirectory = Path.Combine(UserSettings.Default.OutputDirectory, "Exports");
|
||||
UserSettings.Default.AudioDirectory = UserSettings.Default.ExportsDirectory;
|
||||
}
|
||||
|
||||
if (!Directory.Exists(UserSettings.Default.CodeDirectory))
|
||||
{
|
||||
createMe = true;
|
||||
UserSettings.Default.CodeDirectory = Path.Combine(UserSettings.Default.OutputDirectory, "Exports");
|
||||
UserSettings.Default.CodeDirectory = UserSettings.Default.ExportsDirectory;
|
||||
}
|
||||
|
||||
if (!Directory.Exists(UserSettings.Default.ModelDirectory))
|
||||
{
|
||||
createMe = true;
|
||||
UserSettings.Default.ModelDirectory = Path.Combine(UserSettings.Default.OutputDirectory, "Exports");
|
||||
UserSettings.Default.ModelDirectory = UserSettings.Default.ExportsDirectory;
|
||||
}
|
||||
|
||||
Directory.CreateDirectory(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "FModel"));
|
||||
Directory.CreateDirectory(Path.Combine(UserSettings.Default.OutputDirectory, "Backups"));
|
||||
if (createMe) Directory.CreateDirectory(Path.Combine(UserSettings.Default.OutputDirectory, "Exports"));
|
||||
Directory.CreateDirectory(Path.Combine(UserSettings.Default.OutputDirectory, "Logs"));
|
||||
Directory.CreateDirectory(UserSettings.Default.BackupsDirectory);
|
||||
if (createMe) Directory.CreateDirectory(UserSettings.Default.ExportsDirectory);
|
||||
Directory.CreateDirectory(UserSettings.Default.LogsDirectory);
|
||||
Directory.CreateDirectory(UserSettings.Default.MappingsDirectory);
|
||||
CacheManager.EnsureDirectories();
|
||||
|
||||
#if DEBUG
|
||||
var filePath = Path.Combine(UserSettings.Default.OutputDirectory, "Logs", $"FModel-Debug-Log-{DateTime.Now:yyyy-MM-dd}.log");
|
||||
LogFilePath = Path.Combine(UserSettings.Default.LogsDirectory, $"FModel-Debug-Log-{DateTime.Now:yyyy-MM-dd}.log");
|
||||
|
||||
var viewerContexts = typeof(Snooper.Hosting.Bridge).Assembly.GetTypes()
|
||||
.Concat(typeof(EditorWindow).Assembly.GetTypes())
|
||||
@@ -122,7 +125,7 @@ public partial class App
|
||||
.Append("Snooper")
|
||||
.ToHashSet(StringComparer.Ordinal);
|
||||
#else
|
||||
var filePath = Path.Combine(UserSettings.Default.OutputDirectory, "Logs", $"FModel-Log-{DateTime.Now:yyyy-MM-dd}.log");
|
||||
LogFilePath = Path.Combine(UserSettings.Default.LogsDirectory, $"FModel-Log-{DateTime.Now:yyyy-MM-dd}.log");
|
||||
#endif
|
||||
const string template1 = "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] {SourceContext}: {Message:lj}{NewLine}{Exception}";
|
||||
const string template2 = "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{ClassName}] {ObjectPath}: {Message:lj}{NewLine}{Exception}";
|
||||
@@ -142,14 +145,15 @@ public partial class App
|
||||
.WriteTo.Logger(lc => lc
|
||||
.Filter.ByExcluding(IsConversionLibrary)
|
||||
.WriteTo.Console(outputTemplate: template1, theme: AnsiConsoleTheme.Literate)
|
||||
.WriteTo.File(outputTemplate: template1, path: filePath, shared: true))
|
||||
.WriteTo.File(outputTemplate: template1, path: LogFilePath, shared: true))
|
||||
.WriteTo.Logger(lc => lc
|
||||
.Filter.ByIncludingOnly(IsConversionLibrary)
|
||||
.WriteTo.Console(outputTemplate: template2, theme: AnsiConsoleTheme.Literate)
|
||||
.WriteTo.File(outputTemplate: template2, path: filePath, shared: true))
|
||||
.WriteTo.File(outputTemplate: template2, path: LogFilePath, shared: true))
|
||||
.MinimumLevel.Override("CUE4Parse_Conversion", LogEventLevel.Verbose)
|
||||
.WriteTo.Sink(ImGuiSink.Instance)
|
||||
.CreateLogger();
|
||||
CUE4Parse.CUE4ParseLog.UseLogger(Log.Logger);
|
||||
|
||||
CacheManager.MigrateLegacyFiles();
|
||||
Log.Information("Version {Version} ({CommitId})", Constants.APP_VERSION, Constants.APP_COMMIT_ID);
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace FModel.Framework;
|
||||
public static class CacheManager
|
||||
{
|
||||
public static string DataDirectory =>
|
||||
Directory.CreateDirectory(Path.Combine(UserSettings.Default.OutputDirectory, ".data")).FullName;
|
||||
Directory.CreateDirectory(UserSettings.Default.CacheDirectory).FullName;
|
||||
|
||||
public static string ChunksDirectory =>
|
||||
Directory.CreateDirectory(Path.Combine(DataDirectory, "chunks")).FullName;
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace FModel.Framework;
|
||||
public sealed class FModelBridgeHost : IBridgeHost
|
||||
{
|
||||
public string Name => "FModel";
|
||||
public string ImGuiIniPath => Path.Combine(UserSettings.Default.OutputDirectory, ".data", "snooper.ini");
|
||||
public string ImGuiIniPath => Path.Combine(UserSettings.Default.CacheDirectory, "snooper.ini");
|
||||
|
||||
public bool CanBrowseAssets => true;
|
||||
|
||||
|
||||
124
FModel/Framework/StaticMappingGenerator.cs
Normal file
124
FModel/Framework/StaticMappingGenerator.cs
Normal file
@@ -0,0 +1,124 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using CUE4Parse.MappingsProvider.Usmap;
|
||||
using CUE4Parse.UE4.Versions;
|
||||
using Serilog;
|
||||
|
||||
namespace FModel.Framework;
|
||||
|
||||
public static class StaticMappingGenerator
|
||||
{
|
||||
public static string Generate(string executable, string mappingsDirectory, EGame game, EUsmapCompressionMethod compression, string gameDisplayName = null)
|
||||
{
|
||||
if (game < EGame.GAME_UE4_18)
|
||||
throw new NotSupportedException("Static mapping generation requires Unreal Engine 4.18 or later.");
|
||||
|
||||
var directory = Directory.CreateDirectory(mappingsDirectory).FullName;
|
||||
var pendingOutput = Path.Combine(directory, $"{Guid.NewGuid():N}.usmap");
|
||||
|
||||
try
|
||||
{
|
||||
if (!UsmapGenerator.Generate(executable, pendingOutput, compression))
|
||||
throw new InvalidOperationException("UsmapGen could not create the mapping.");
|
||||
|
||||
using var stream = File.OpenRead(pendingOutput);
|
||||
var engineVersion = new UsmapParser(stream, comparer: StringComparer.Ordinal).EngineVersion;
|
||||
|
||||
var major = engineVersion?.Major ?? ((int) game >> 24);
|
||||
var minor = engineVersion?.Minor ?? (((int) game >> 16) & 0xFF);
|
||||
var suffix = compression == EUsmapCompressionMethod.None ? "" : $"_{compression}";
|
||||
var name = gameDisplayName == null ? null : string.Join("_", gameDisplayName.Split(Path.GetInvalidFileNameChars(), StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries));
|
||||
if (string.IsNullOrEmpty(name) || string.Equals(name, "Unknown", StringComparison.OrdinalIgnoreCase))
|
||||
name = Path.GetFileNameWithoutExtension(executable);
|
||||
|
||||
// Example: 501_GameName_22-11-2026_ZStandard.usmap (Engine version without using "." is intentional)
|
||||
var fileName = FormattableString.Invariant($"{major}{minor:D2}_{name}_{DateTime.Today:dd-MM-yyyy}{suffix}.usmap");
|
||||
var output = Path.Combine(directory, fileName);
|
||||
File.Move(pendingOutput, output, overwrite: true);
|
||||
return output;
|
||||
}
|
||||
finally
|
||||
{
|
||||
try
|
||||
{
|
||||
File.Delete(pendingOutput);
|
||||
}
|
||||
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException)
|
||||
{
|
||||
Log.Warning(ex, "Could not remove temporary mapping {Path}", pendingOutput);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static string FindShippingExe(string archiveDirectory)
|
||||
{
|
||||
if (!Directory.Exists(archiveDirectory))
|
||||
throw new DirectoryNotFoundException("Static mapping generation requires a local archive directory.");
|
||||
|
||||
var archive = new DirectoryInfo(archiveDirectory);
|
||||
for (var directory = archive; directory.Parent != null; directory = directory.Parent)
|
||||
{
|
||||
if (Search(directory) is { } executable)
|
||||
return executable;
|
||||
}
|
||||
|
||||
var options = new EnumerationOptions { AttributesToSkip = FileAttributes.ReparsePoint };
|
||||
string match = null;
|
||||
foreach (var project in FindProjects(archive))
|
||||
{
|
||||
if (Search(project) is not { } executable)
|
||||
continue;
|
||||
|
||||
if (match != null)
|
||||
throw new FileNotFoundException($"Found multiple Win64 shipping executables under '{archiveDirectory}'.");
|
||||
|
||||
match = executable;
|
||||
}
|
||||
|
||||
return match ?? throw new FileNotFoundException($"No Win64 shipping executable was found near '{archiveDirectory}'.");
|
||||
|
||||
IEnumerable<DirectoryInfo> FindProjects(DirectoryInfo directory)
|
||||
{
|
||||
foreach (var child in directory.EnumerateDirectories("*", options))
|
||||
{
|
||||
if (child.Name.Equals("Engine", StringComparison.OrdinalIgnoreCase))
|
||||
continue;
|
||||
|
||||
if (Directory.Exists(Path.Combine(child.FullName, "Content", "Paks")))
|
||||
{
|
||||
yield return child;
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach (var project in FindProjects(child))
|
||||
yield return project;
|
||||
}
|
||||
}
|
||||
|
||||
static string Search(DirectoryInfo project)
|
||||
{
|
||||
var binaries = Path.Combine(project.FullName, "Binaries", "Win64");
|
||||
if (!Directory.Exists(binaries))
|
||||
return null;
|
||||
|
||||
var preferred = Path.Combine(binaries, $"{project.Name}-Win64-Shipping.exe");
|
||||
if (File.Exists(preferred))
|
||||
return preferred;
|
||||
|
||||
var projectExecutable = Path.Combine(binaries, $"{project.Name}.exe");
|
||||
if (File.Exists(projectExecutable))
|
||||
return projectExecutable;
|
||||
|
||||
using var candidates = Directory.EnumerateFiles(binaries, "*-Shipping.exe").GetEnumerator();
|
||||
if (!candidates.MoveNext())
|
||||
return null;
|
||||
|
||||
var executable = candidates.Current;
|
||||
if (candidates.MoveNext())
|
||||
throw new FileNotFoundException($"Found multiple shipping executables in '{binaries}'.");
|
||||
|
||||
return executable;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -692,6 +692,24 @@
|
||||
|
||||
<controls:CustomRichTextBox Grid.Column="0" Grid.ColumnSpan="3" x:Name="LogRtbName" Style="{StaticResource CustomRichTextBox}" />
|
||||
<StackPanel Grid.Column="2" Orientation="Vertical" VerticalAlignment="Bottom" Margin="-5 -5 5 5">
|
||||
<Button Style="{DynamicResource {x:Static adonisUi:Styles.ToolbarButton}}"
|
||||
ToolTip="Open Log"
|
||||
Padding="0,4,0,4"
|
||||
Command="{Binding MenuCommand}"
|
||||
CommandParameter="ToolBox_Open_Log"
|
||||
Focusable="False">
|
||||
<Viewbox Width="16"
|
||||
Height="16"
|
||||
HorizontalAlignment="Center">
|
||||
<Canvas Width="24"
|
||||
Height="24">
|
||||
<Path StrokeThickness="2"
|
||||
Stroke="{DynamicResource {x:Static adonisUi:Brushes.ForegroundBrush}}"
|
||||
StrokeLineJoin="Round"
|
||||
Data="M5 3h9l5 5v13H5z M14 3v5h5 M8 12h8 M8 16h8" />
|
||||
</Canvas>
|
||||
</Viewbox>
|
||||
</Button>
|
||||
<Button Style="{DynamicResource {x:Static adonisUi:Styles.ToolbarButton}}" ToolTip="Open Output Folder" Padding="0,4,0,4"
|
||||
Command="{Binding MenuCommand}" CommandParameter="ToolBox_Open_Output_Directory" Focusable="False">
|
||||
<Viewbox Width="16" Height="16" HorizontalAlignment="Center">
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using CUE4Parse.MappingsProvider.Usmap;
|
||||
using CUE4Parse.UE4.Assets.Exports.Material;
|
||||
using CUE4Parse.UE4.Versions;
|
||||
using CUE4Parse_Conversion.Options;
|
||||
@@ -92,6 +93,12 @@ public sealed class UserSettings : ViewModel
|
||||
set => SetProperty(ref _outputDirectory, value);
|
||||
}
|
||||
|
||||
[JsonIgnore] public string ExportsDirectory => Path.Combine(OutputDirectory, "Exports");
|
||||
[JsonIgnore] public string BackupsDirectory => Path.Combine(OutputDirectory, "Backups");
|
||||
[JsonIgnore] public string LogsDirectory => Path.Combine(OutputDirectory, "Logs");
|
||||
[JsonIgnore] public string MappingsDirectory => Path.Combine(OutputDirectory, "Mappings");
|
||||
[JsonIgnore] public string CacheDirectory => Path.Combine(OutputDirectory, ".data");
|
||||
|
||||
private string _rawDataDirectory;
|
||||
public string RawDataDirectory
|
||||
{
|
||||
@@ -148,6 +155,16 @@ public sealed class UserSettings : ViewModel
|
||||
set => SetProperty(ref _lastOpenedSettingTab, value);
|
||||
}
|
||||
|
||||
// Without Oodle
|
||||
private EUsmapCompressionMethod _mappingCompression = EUsmapCompressionMethod.ZStandard;
|
||||
public EUsmapCompressionMethod MappingCompression
|
||||
{
|
||||
get => _mappingCompression;
|
||||
set => SetProperty(ref _mappingCompression, value is not (EUsmapCompressionMethod.Oodle or EUsmapCompressionMethod.Unknown) && Enum.IsDefined(value)
|
||||
? value
|
||||
: EUsmapCompressionMethod.ZStandard);
|
||||
}
|
||||
|
||||
private bool _isLoggerExpanded = true;
|
||||
public bool IsLoggerExpanded
|
||||
{
|
||||
|
||||
@@ -261,7 +261,7 @@ public class ApplicationViewModel : ViewModel
|
||||
|
||||
public static async Task InitVgmStream()
|
||||
{
|
||||
var vgmZipFilePath = Path.Combine(UserSettings.Default.OutputDirectory, ".data", "vgmstream-win.zip");
|
||||
var vgmZipFilePath = Path.Combine(UserSettings.Default.CacheDirectory, "vgmstream-win.zip");
|
||||
var vgmFileInfo = new FileInfo(vgmZipFilePath);
|
||||
|
||||
if (!vgmFileInfo.Exists || vgmFileInfo.LastWriteTimeUtc < DateTime.UtcNow.AddMonths(-4))
|
||||
@@ -288,10 +288,10 @@ public class ApplicationViewModel : ViewModel
|
||||
if (!Avx2.IsSupported)
|
||||
return;
|
||||
|
||||
var oodlePath = Path.Combine(UserSettings.Default.OutputDirectory, ".data", OodleHelper.OODLE_NAME_OLD);
|
||||
var oodlePath = Path.Combine(UserSettings.Default.CacheDirectory, OodleHelper.OODLE_NAME_OLD);
|
||||
if (!File.Exists(oodlePath))
|
||||
{
|
||||
oodlePath = Path.Combine(UserSettings.Default.OutputDirectory, ".data", OodleHelper.OODLE_NAME_CURRENT);
|
||||
oodlePath = Path.Combine(UserSettings.Default.CacheDirectory, OodleHelper.OODLE_NAME_CURRENT);
|
||||
}
|
||||
|
||||
await OodleHelper.InitializeAsync(oodlePath);
|
||||
@@ -299,7 +299,7 @@ public class ApplicationViewModel : ViewModel
|
||||
|
||||
public static async Task InitZlib()
|
||||
{
|
||||
var zlibPath = Path.Combine(UserSettings.Default.OutputDirectory, ".data", ZlibHelper.DLL_NAME);
|
||||
var zlibPath = Path.Combine(UserSettings.Default.CacheDirectory, ZlibHelper.DLL_NAME);
|
||||
var zlibFileInfo = new FileInfo(zlibPath);
|
||||
|
||||
if (!zlibFileInfo.Exists || zlibFileInfo.LastWriteTimeUtc < DateTime.UtcNow.AddMonths(-4))
|
||||
@@ -316,7 +316,7 @@ public class ApplicationViewModel : ViewModel
|
||||
|
||||
public static async Task InitUnluac()
|
||||
{
|
||||
var unluacPath = Path.Combine(UserSettings.Default.OutputDirectory, ".data", UnluacHelper.DllName);
|
||||
var unluacPath = Path.Combine(UserSettings.Default.CacheDirectory, UnluacHelper.DllName);
|
||||
await UnluacHelper.InitializeAsync(unluacPath).ConfigureAwait(false);
|
||||
if (UnluacHelper.Instance is null)
|
||||
FLogger.Append(ELog.Error, () => FLogger.Text("Failed to download unluac", Constants.WHITE, true));
|
||||
|
||||
@@ -710,7 +710,7 @@ public class AudioPlayerViewModel : ViewModel, ISource, IDisposable
|
||||
private static bool TryConvertRada(string inputFilePath, byte[] inputFileData, string extension, out string rawFilePath, bool updateUi = false)
|
||||
{
|
||||
rawFilePath = string.Empty;
|
||||
var decoderPath = Path.Combine(UserSettings.Default.OutputDirectory, ".data", $"{extension}dec.exe");
|
||||
var decoderPath = Path.Combine(UserSettings.Default.CacheDirectory, $"{extension}dec.exe");
|
||||
if (!File.Exists(decoderPath))
|
||||
{
|
||||
Log.Error("Failed to convert {FilePath}, {Extension} decoder is missing", inputFilePath, extension);
|
||||
@@ -763,10 +763,10 @@ public class AudioPlayerViewModel : ViewModel, ISource, IDisposable
|
||||
|
||||
private static string TryGetVgmstreamPath()
|
||||
{
|
||||
var vgmFilePath = Path.Combine(UserSettings.Default.OutputDirectory, ".data", "test.exe");
|
||||
var vgmFilePath = Path.Combine(UserSettings.Default.CacheDirectory, "test.exe");
|
||||
if (!File.Exists(vgmFilePath))
|
||||
{
|
||||
vgmFilePath = Path.Combine(UserSettings.Default.OutputDirectory, ".data", "vgmstream-cli.exe");
|
||||
vgmFilePath = Path.Combine(UserSettings.Default.CacheDirectory, "vgmstream-cli.exe");
|
||||
if (!File.Exists(vgmFilePath))
|
||||
{
|
||||
Log.Error("Failed to convert audio, vgmstream is missing");
|
||||
|
||||
@@ -63,7 +63,7 @@ public class BackupManagerViewModel : ViewModel
|
||||
{
|
||||
await _threadWorkerView.Begin(_ =>
|
||||
{
|
||||
var backupFolder = Path.Combine(UserSettings.Default.OutputDirectory, "Backups");
|
||||
var backupFolder = UserSettings.Default.BackupsDirectory;
|
||||
var fileName = $"{_gameName}_{DateTime.Now:MM'_'dd'_'yyyy}.fbkp";
|
||||
var fullPath = Path.Combine(backupFolder, fileName);
|
||||
var func = new Func<GameFile, bool>(x => !x.IsUePackagePayload);
|
||||
@@ -92,7 +92,7 @@ public class BackupManagerViewModel : ViewModel
|
||||
if (SelectedBackup == null) return;
|
||||
await _threadWorkerView.Begin(_ =>
|
||||
{
|
||||
var fullPath = Path.Combine(Path.Combine(UserSettings.Default.OutputDirectory, "Backups"), SelectedBackup.FileName);
|
||||
var fullPath = Path.Combine(UserSettings.Default.BackupsDirectory, SelectedBackup.FileName);
|
||||
_apiEndpointView.DownloadFile(SelectedBackup.Url, fullPath);
|
||||
SaveCheck(fullPath, SelectedBackup.FileName, "downloaded", "download");
|
||||
});
|
||||
|
||||
@@ -108,6 +108,7 @@ public class CUE4ParseViewModel : ViewModel
|
||||
RegexOptions.Compiled | RegexOptions.Singleline | RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);
|
||||
|
||||
private static readonly HttpClient _chunkClient = ManifestParseOptions.CreateDefaultClient();
|
||||
private string _appliedLocalMappingPath;
|
||||
|
||||
public AbstractVfsFileProvider Provider { get; }
|
||||
public GameDirectoryViewModel GameDirectory { get; }
|
||||
@@ -406,69 +407,101 @@ public class CUE4ParseViewModel : ViewModel
|
||||
return new FileUsmapTypeMappingsProvider(path, StringComparer.Ordinal);
|
||||
}
|
||||
|
||||
public void ApplyMappingFile(string path)
|
||||
{
|
||||
var mappings = SelectMappingsProvider(path);
|
||||
var endpoint = UserSettings.Default.CurrentDir.Endpoints[(int) EEndpointType.Mapping];
|
||||
Provider.MappingsContainer = mappings;
|
||||
endpoint.FilePath = path;
|
||||
endpoint.Overwrite = true;
|
||||
_appliedLocalMappingPath = path;
|
||||
LogLoadedMappings(ELog.Information);
|
||||
}
|
||||
|
||||
public bool HasMappingSettingsChanged()
|
||||
{
|
||||
var endpoint = UserSettings.Default.CurrentDir.Endpoints[(int) EEndpointType.Mapping];
|
||||
return !string.Equals(_appliedLocalMappingPath, GetLocalMappingPath(endpoint), StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
private static string GetLocalMappingPath(EndpointSettings endpoint) => endpoint.Overwrite && File.Exists(endpoint.FilePath) ? endpoint.FilePath : null;
|
||||
|
||||
public Task InitMappings(bool force = false)
|
||||
{
|
||||
if (!UserSettings.IsEndpointValid(EEndpointType.Mapping, out var endpoint))
|
||||
var endpoint = UserSettings.Default.CurrentDir.Endpoints[(int) EEndpointType.Mapping];
|
||||
if (GetLocalMappingPath(endpoint) is { } path)
|
||||
{
|
||||
ApplyMappingFile(path);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
if (!endpoint.IsValid)
|
||||
{
|
||||
Provider.MappingsContainer = null;
|
||||
_appliedLocalMappingPath = null;
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
return Task.Run(() =>
|
||||
{
|
||||
var l = ELog.Information;
|
||||
if (endpoint.Overwrite && File.Exists(endpoint.FilePath))
|
||||
var mappingsProvider = _appliedLocalMappingPath == null ? Provider.MappingsContainer : null;
|
||||
|
||||
// deprecated values
|
||||
if (endpoint.Path == "$.[?(@.meta.compressionMethod=='Oodle')].['url','fileName']") endpoint.Path = "$.[0].['url','fileName']";
|
||||
if (endpoint.Url == "https://fortnitecentral.genxgames.gg/api/v1/mappings")
|
||||
{
|
||||
Provider.MappingsContainer = SelectMappingsProvider(endpoint.FilePath);
|
||||
endpoint.Url = "https://uedb.dev/svc/api/v1/fortnite/mappings";
|
||||
endpoint.Path = "$.mappings.ZStandard";
|
||||
}
|
||||
else if (endpoint.IsValid)
|
||||
|
||||
var mappingsFolder = CacheManager.MappingsDirectory;
|
||||
var mappings = _apiEndpointView.DynamicApi.GetMappings(CancellationToken.None, endpoint.Url, endpoint.Path);
|
||||
if (mappings is { Length: > 0 })
|
||||
{
|
||||
// deprecated values
|
||||
if (endpoint.Path == "$.[?(@.meta.compressionMethod=='Oodle')].['url','fileName']") endpoint.Path = "$.[0].['url','fileName']";
|
||||
if (endpoint.Url == "https://fortnitecentral.genxgames.gg/api/v1/mappings")
|
||||
foreach (var mapping in mappings)
|
||||
{
|
||||
endpoint.Url = "https://uedb.dev/svc/api/v1/fortnite/mappings";
|
||||
endpoint.Path = "$.mappings.ZStandard";
|
||||
}
|
||||
if (!mapping.IsValid) continue;
|
||||
|
||||
var mappingsFolder = CacheManager.MappingsDirectory;
|
||||
var mappings = _apiEndpointView.DynamicApi.GetMappings(CancellationToken.None, endpoint.Url, endpoint.Path);
|
||||
if (mappings is { Length: > 0 })
|
||||
{
|
||||
foreach (var mapping in mappings)
|
||||
var mappingPath = Path.Combine(mappingsFolder, mapping.FileName);
|
||||
if (force || !File.Exists(mappingPath) || new FileInfo(mappingPath).Length == 0)
|
||||
{
|
||||
if (!mapping.IsValid) continue;
|
||||
|
||||
var mappingPath = Path.Combine(mappingsFolder, mapping.FileName);
|
||||
if (force || !File.Exists(mappingPath) || new FileInfo(mappingPath).Length == 0)
|
||||
{
|
||||
_apiEndpointView.DownloadFile(mapping.Url, mappingPath);
|
||||
}
|
||||
|
||||
Provider.MappingsContainer = SelectMappingsProvider(mappingPath);
|
||||
break;
|
||||
_apiEndpointView.DownloadFile(mapping.Url, mappingPath);
|
||||
}
|
||||
|
||||
mappingsProvider = SelectMappingsProvider(mappingPath);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (Provider.MappingsContainer == null)
|
||||
if (mappingsProvider == null)
|
||||
{
|
||||
var latestUsmaps = new DirectoryInfo(mappingsFolder).GetFiles("*_oo.usmap");
|
||||
if (latestUsmaps.Length > 0)
|
||||
{
|
||||
var latestUsmaps = new DirectoryInfo(mappingsFolder).GetFiles("*_oo.usmap");
|
||||
if (latestUsmaps.Length <= 0) return;
|
||||
|
||||
var latestUsmapInfo = latestUsmaps.OrderBy(f => f.LastWriteTime).Last();
|
||||
Provider.MappingsContainer = new FileUsmapTypeMappingsProvider(latestUsmapInfo.FullName, StringComparer.Ordinal);
|
||||
mappingsProvider = new FileUsmapTypeMappingsProvider(latestUsmapInfo.FullName, StringComparer.Ordinal);
|
||||
l = ELog.Warning;
|
||||
}
|
||||
}
|
||||
|
||||
if (Provider.MappingsContainer is FileUsmapTypeMappingsProvider m)
|
||||
{
|
||||
Log.Information($"Mappings pulled from '{m.FileName}'");
|
||||
FLogger.Append(l, () => FLogger.Text($"Mappings pulled from '{m.FileName}'", Constants.WHITE, true));
|
||||
}
|
||||
if (GetLocalMappingPath(endpoint) != null) return;
|
||||
|
||||
Provider.MappingsContainer = mappingsProvider;
|
||||
_appliedLocalMappingPath = null;
|
||||
LogLoadedMappings(l);
|
||||
});
|
||||
}
|
||||
|
||||
private void LogLoadedMappings(ELog level)
|
||||
{
|
||||
if (Provider.MappingsContainer is FileUsmapTypeMappingsProvider m)
|
||||
{
|
||||
Log.Information($"Mappings pulled from '{m.FileName}'");
|
||||
FLogger.Append(level, () => FLogger.Text($"Mappings pulled from '{m.FileName}'", Constants.WHITE, true));
|
||||
}
|
||||
}
|
||||
|
||||
public Task VerifyConsoleVariables()
|
||||
{
|
||||
if (Provider.Versions["StripAdditiveRefPose"])
|
||||
|
||||
@@ -168,7 +168,7 @@ public class LoadCommand : ViewModelCommand<LoadingModesViewModel>
|
||||
var openFileDialog = new OpenFileDialog
|
||||
{
|
||||
Title = "Select a backup file older than your current game version",
|
||||
InitialDirectory = Path.Combine(UserSettings.Default.OutputDirectory, "Backups"),
|
||||
InitialDirectory = UserSettings.Default.BackupsDirectory,
|
||||
Filter = "FBKP Files (*.fbkp)|*.fbkp|All Files (*.*)|*.*",
|
||||
Multiselect = false
|
||||
};
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using AdonisUI.Controls;
|
||||
using FModel.Extensions;
|
||||
using FModel.Framework;
|
||||
@@ -68,6 +69,10 @@ public class MenuCommand : ViewModelCommand<ApplicationViewModel>
|
||||
case "ToolBox_Clear_Logs":
|
||||
FLogger.ClearLogs();
|
||||
break;
|
||||
case "ToolBox_Open_Log":
|
||||
if (App.Current is App app && File.Exists(app.LogFilePath))
|
||||
Process.Start(new ProcessStartInfo { FileName = app.LogFilePath, UseShellExecute = true });
|
||||
break;
|
||||
case "ToolBox_Open_Output_Directory":
|
||||
Process.Start(new ProcessStartInfo { FileName = UserSettings.Default.OutputDirectory, UseShellExecute = true });
|
||||
break;
|
||||
|
||||
@@ -2,6 +2,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using CUE4Parse.MappingsProvider.Usmap;
|
||||
using CUE4Parse.UE4.Assets.Exports.Texture;
|
||||
using CUE4Parse.UE4.Objects.Core.Serialization;
|
||||
using CUE4Parse.UE4.Versions;
|
||||
@@ -33,6 +34,8 @@ public class SettingsViewModel : ViewModel
|
||||
set => SetProperty(ref _selectedUeGame, value);
|
||||
}
|
||||
|
||||
public bool CanGenerateMapping => UserSettings.Default.CurrentDir?.UeVersion >= EGame.GAME_UE4_18;
|
||||
|
||||
private IList<FCustomVersion> _selectedCustomVersions;
|
||||
public IList<FCustomVersion> SelectedCustomVersions
|
||||
{
|
||||
@@ -68,6 +71,20 @@ public class SettingsViewModel : ViewModel
|
||||
set => SetProperty(ref _mappingEndpoint, value);
|
||||
}
|
||||
|
||||
private EUsmapCompressionMethod _selectedMappingCompression;
|
||||
public EUsmapCompressionMethod SelectedMappingCompression
|
||||
{
|
||||
get => _selectedMappingCompression;
|
||||
set => SetProperty(ref _selectedMappingCompression, value);
|
||||
}
|
||||
|
||||
private bool _isGeneratingMapping;
|
||||
public bool IsGeneratingMapping
|
||||
{
|
||||
get => _isGeneratingMapping;
|
||||
set => SetProperty(ref _isGeneratingMapping, value);
|
||||
}
|
||||
|
||||
private ELanguage _selectedAssetLanguage;
|
||||
public ELanguage SelectedAssetLanguage
|
||||
{
|
||||
@@ -131,27 +148,16 @@ public class SettingsViewModel : ViewModel
|
||||
public ReadOnlyObservableCollection<EAesReload> AesReloads { get; private set; }
|
||||
public ReadOnlyObservableCollection<EDiscordRpc> DiscordRpcs { get; private set; }
|
||||
public ReadOnlyObservableCollection<ECompressedAudio> CompressedAudios { get; private set; }
|
||||
public ReadOnlyObservableCollection<EUsmapCompressionMethod> MappingCompressions { get; private set; }
|
||||
public ReadOnlyObservableCollection<EIconStyle> CosmeticStyles { get; private set; }
|
||||
public ReadOnlyObservableCollection<EJsonHighlightTheme> JsonHighlightThemes { get; private set; }
|
||||
|
||||
private string _outputSnapshot;
|
||||
private string _rawDataSnapshot;
|
||||
private string _propertiesSnapshot;
|
||||
private string _textureSnapshot;
|
||||
private string _audioSnapshot;
|
||||
private string _codeSnapshot;
|
||||
private string _modelSnapshot;
|
||||
private string _gameSnapshot;
|
||||
private EGame _ueGameSnapshot;
|
||||
private IList<FCustomVersion> _customVersionsSnapshot;
|
||||
private IDictionary<string, bool> _optionsSnapshot;
|
||||
private IDictionary<string, KeyValuePair<string, string>> _mapStructTypesSnapshot;
|
||||
private ELanguage _assetLanguageSnapshot;
|
||||
private ECompressedAudio _compressedAudioSnapshot;
|
||||
private EIconStyle _cosmeticStyleSnapshot;
|
||||
private EJsonHighlightTheme _jsonHighlightThemeSnapshot;
|
||||
|
||||
private bool _mappingsUpdate = false;
|
||||
|
||||
public SettingsViewModel()
|
||||
{
|
||||
@@ -160,44 +166,28 @@ public class SettingsViewModel : ViewModel
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
_outputSnapshot = UserSettings.Default.OutputDirectory;
|
||||
_rawDataSnapshot = UserSettings.Default.RawDataDirectory;
|
||||
_propertiesSnapshot = UserSettings.Default.PropertiesDirectory;
|
||||
_textureSnapshot = UserSettings.Default.TextureDirectory;
|
||||
_audioSnapshot = UserSettings.Default.AudioDirectory;
|
||||
_codeSnapshot = UserSettings.Default.CodeDirectory;
|
||||
_modelSnapshot = UserSettings.Default.ModelDirectory;
|
||||
_gameSnapshot = UserSettings.Default.GameDirectory;
|
||||
_ueGameSnapshot = UserSettings.Default.CurrentDir.UeVersion;
|
||||
_customVersionsSnapshot = UserSettings.Default.CurrentDir.Versioning.CustomVersions;
|
||||
_optionsSnapshot = UserSettings.Default.CurrentDir.Versioning.Options;
|
||||
_mapStructTypesSnapshot = UserSettings.Default.CurrentDir.Versioning.MapStructTypes;
|
||||
_criwareDecryptionKey = UserSettings.Default.CurrentDir.CriwareDecryptionKey;
|
||||
_unluacOpcodeMap = UserSettings.Default.CurrentDir.UnluacOpCodeMap;
|
||||
|
||||
AesEndpoint = UserSettings.Default.CurrentDir.Endpoints[0];
|
||||
MappingEndpoint = UserSettings.Default.CurrentDir.Endpoints[1];
|
||||
MappingEndpoint.PropertyChanged += (_, args) =>
|
||||
{
|
||||
if (!_mappingsUpdate)
|
||||
_mappingsUpdate = args.PropertyName is "Overwrite" or "FilePath";
|
||||
};
|
||||
|
||||
_assetLanguageSnapshot = UserSettings.Default.AssetLanguage;
|
||||
_compressedAudioSnapshot = UserSettings.Default.CompressedAudioMode;
|
||||
_cosmeticStyleSnapshot = UserSettings.Default.CosmeticStyle;
|
||||
_jsonHighlightThemeSnapshot = UserSettings.Default.JsonHighlightTheme;
|
||||
|
||||
SelectedUeGame = _ueGameSnapshot;
|
||||
SelectedCustomVersions = _customVersionsSnapshot;
|
||||
SelectedOptions = _optionsSnapshot;
|
||||
SelectedMapStructTypes = _mapStructTypesSnapshot;
|
||||
SelectedAssetLanguage = _assetLanguageSnapshot;
|
||||
SelectedCompressedAudio = _compressedAudioSnapshot;
|
||||
SelectedCosmeticStyle = _cosmeticStyleSnapshot;
|
||||
CriwareDecryptionKey = _criwareDecryptionKey;
|
||||
UnluacOpcodeMap = _unluacOpcodeMap;
|
||||
SelectedJsonHighlightTheme = _jsonHighlightThemeSnapshot;
|
||||
SelectedCompressedAudio = UserSettings.Default.CompressedAudioMode;
|
||||
SelectedMappingCompression = UserSettings.Default.MappingCompression;
|
||||
SelectedCosmeticStyle = UserSettings.Default.CosmeticStyle;
|
||||
CriwareDecryptionKey = UserSettings.Default.CurrentDir.CriwareDecryptionKey;
|
||||
UnluacOpcodeMap = UserSettings.Default.CurrentDir.UnluacOpCodeMap;
|
||||
SelectedJsonHighlightTheme = UserSettings.Default.JsonHighlightTheme;
|
||||
SelectedAesReload = UserSettings.Default.AesReload;
|
||||
SelectedDiscordRpc = UserSettings.Default.DiscordRpc;
|
||||
|
||||
@@ -206,6 +196,7 @@ public class SettingsViewModel : ViewModel
|
||||
AesReloads = new ReadOnlyObservableCollection<EAesReload>(new ObservableCollection<EAesReload>(EnumerateAesReloads()));
|
||||
DiscordRpcs = new ReadOnlyObservableCollection<EDiscordRpc>(new ObservableCollection<EDiscordRpc>(EnumerateDiscordRpcs()));
|
||||
CompressedAudios = new ReadOnlyObservableCollection<ECompressedAudio>(new ObservableCollection<ECompressedAudio>(EnumerateCompressedAudios()));
|
||||
MappingCompressions = new ReadOnlyObservableCollection<EUsmapCompressionMethod>(new ObservableCollection<EUsmapCompressionMethod>(EnumerateMappingCompressions()));
|
||||
CosmeticStyles = new ReadOnlyObservableCollection<EIconStyle>(new ObservableCollection<EIconStyle>(EnumerateCosmeticStyles()));
|
||||
JsonHighlightThemes = new ReadOnlyObservableCollection<EJsonHighlightTheme>(new ObservableCollection<EJsonHighlightTheme>(EnumerateJsonHighlightThemes()));
|
||||
}
|
||||
@@ -217,8 +208,6 @@ public class SettingsViewModel : ViewModel
|
||||
|
||||
if (_assetLanguageSnapshot != SelectedAssetLanguage)
|
||||
whatShouldIDo.Add(SettingsOut.ReloadLocres);
|
||||
if (_mappingsUpdate)
|
||||
whatShouldIDo.Add(SettingsOut.ReloadMappings);
|
||||
|
||||
if (_ueGameSnapshot != SelectedUeGame || _customVersionsSnapshot != SelectedCustomVersions ||
|
||||
_optionsSnapshot != SelectedOptions || // combobox
|
||||
@@ -234,6 +223,7 @@ public class SettingsViewModel : ViewModel
|
||||
UserSettings.Default.CurrentDir.UnluacOpCodeMap = UnluacOpcodeMap;
|
||||
|
||||
UserSettings.Default.AssetLanguage = SelectedAssetLanguage;
|
||||
UserSettings.Default.MappingCompression = SelectedMappingCompression;
|
||||
UserSettings.Default.CompressedAudioMode = SelectedCompressedAudio;
|
||||
UserSettings.Default.CosmeticStyle = SelectedCosmeticStyle;
|
||||
UserSettings.Default.AesReload = SelectedAesReload;
|
||||
@@ -257,6 +247,9 @@ public class SettingsViewModel : ViewModel
|
||||
private IEnumerable<EAesReload> EnumerateAesReloads() => Enum.GetValues<EAesReload>();
|
||||
private IEnumerable<EDiscordRpc> EnumerateDiscordRpcs() => Enum.GetValues<EDiscordRpc>();
|
||||
private IEnumerable<ECompressedAudio> EnumerateCompressedAudios() => Enum.GetValues<ECompressedAudio>();
|
||||
private IEnumerable<EUsmapCompressionMethod> EnumerateMappingCompressions() => Enum.GetValues<EUsmapCompressionMethod>()
|
||||
.Where(value => value is not (EUsmapCompressionMethod.Oodle or EUsmapCompressionMethod.Unknown))
|
||||
.Reverse();
|
||||
private IEnumerable<EIconStyle> EnumerateCosmeticStyles() => Enum.GetValues<EIconStyle>();
|
||||
private IEnumerable<EJsonHighlightTheme> EnumerateJsonHighlightThemes() => Enum.GetValues<EJsonHighlightTheme>();
|
||||
}
|
||||
|
||||
@@ -142,7 +142,7 @@ public partial class ImageMerger
|
||||
var fileBrowser = new OpenFileDialog
|
||||
{
|
||||
Title = "Add image(s)",
|
||||
InitialDirectory = Path.Combine(UserSettings.Default.OutputDirectory, "Exports"),
|
||||
InitialDirectory = UserSettings.Default.ExportsDirectory,
|
||||
Multiselect = true,
|
||||
Filter = "Image Files (*.png,*.bmp,*.jpg,*.jpeg,*.jfif,*.jpe,*.tiff,*.tif)|*.png;*.bmp;*.jpg;*.jpeg;*.jfif;*.jpe;*.tiff;*.tif|All Files (*.*)|*.*"
|
||||
};
|
||||
|
||||
@@ -6,7 +6,6 @@ using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Threading;
|
||||
using FModel.Services;
|
||||
using FModel.Settings;
|
||||
using FModel.ViewModels;
|
||||
|
||||
namespace FModel.Views.Resources.Controls;
|
||||
@@ -97,17 +96,12 @@ public partial class DropOverlay : UserControl
|
||||
await Dispatcher.InvokeAsync(() => _applicationView.AddGameDirectory(_path));
|
||||
break;
|
||||
case DragStatus.File:
|
||||
UserSettings.IsEndpointValid(EEndpointType.Mapping, out var oldMappingsEndpoint);
|
||||
try
|
||||
{
|
||||
var newMappingsEndpoint = new EndpointSettings() { Overwrite = true, FilePath = _path };
|
||||
UserSettings.Default.CurrentDir.Endpoints[(int) EEndpointType.Mapping] = newMappingsEndpoint;
|
||||
await _applicationView.CUE4Parse.InitMappings();
|
||||
_applicationView.SettingsView.MappingEndpoint = newMappingsEndpoint;
|
||||
_applicationView.CUE4Parse.ApplyMappingFile(_path);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
UserSettings.Default.CurrentDir.Endpoints[(int) EEndpointType.Mapping] = oldMappingsEndpoint;
|
||||
FLogger.Append(ELog.Error, () =>
|
||||
{
|
||||
FLogger.Text($"Failed to load mapping file: {ex.Message}", Constants.WHITE, true);
|
||||
|
||||
@@ -12,10 +12,16 @@
|
||||
WindowStartupLocation="CenterScreen" ResizeMode="NoResize" IconVisibility="Collapsed" SizeToContent="Height"
|
||||
MinHeight="{Binding Source={x:Static SystemParameters.MaximizedPrimaryScreenHeight}, Converter={converters:RatioConverter}, ConverterParameter='0.10'}"
|
||||
Width="{Binding Source={x:Static SystemParameters.MaximizedPrimaryScreenWidth}, Converter={converters:RatioConverter}, ConverterParameter='0.45'}"
|
||||
AllowDrop="True">
|
||||
Closing="OnClosing">
|
||||
<adonisControls:AdonisWindow.Style>
|
||||
<Style TargetType="adonisControls:AdonisWindow" BasedOn="{StaticResource {x:Type adonisControls:AdonisWindow}}" >
|
||||
<Setter Property="Title" Value="Settings" />
|
||||
<Setter Property="AllowDrop" Value="True" />
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding SettingsView.IsGeneratingMapping}" Value="True">
|
||||
<Setter Property="AllowDrop" Value="False" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</adonisControls:AdonisWindow.Style>
|
||||
<adonisControls:AdonisWindow.Resources>
|
||||
@@ -158,7 +164,6 @@
|
||||
Content="{Binding IsChecked, RelativeSource={RelativeSource Self}, Converter={x:Static converters:BoolToToggleConverter.Instance}}"
|
||||
IsChecked="{Binding SettingsView.MappingEndpoint.Overwrite, Mode=TwoWay}"
|
||||
Style="{DynamicResource {x:Static adonisUi:Styles.ToggleSwitch}}" />
|
||||
|
||||
<TextBlock Grid.Row="10" Grid.Column="0" Text="Mapping File Path" VerticalAlignment="Center" Margin="0 10 0 0"
|
||||
DataContext="{Binding DataContext, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:Views.SettingsView}}}"
|
||||
Visibility="{Binding SettingsView.MappingEndpoint.Overwrite, Converter={StaticResource BoolToVisibilityConverter}}" />
|
||||
@@ -169,10 +174,93 @@
|
||||
DataContext="{Binding DataContext, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:Views.SettingsView}}}"
|
||||
Visibility="{Binding SettingsView.MappingEndpoint.Overwrite, Converter={StaticResource BoolToVisibilityConverter}}" />
|
||||
|
||||
<Separator Grid.Row="11" Grid.Column="0" Grid.ColumnSpan="7" Style="{StaticResource CustomSeparator}" Tag="ADVANCED"></Separator>
|
||||
<TextBlock Grid.Row="11"
|
||||
Grid.Column="0"
|
||||
Text="Mapping Generation Compression"
|
||||
VerticalAlignment="Center"
|
||||
Margin="0 5 0 0"
|
||||
Visibility="{Binding Visibility, ElementName=MappingGenerationControls}" />
|
||||
<Grid x:Name="MappingGenerationControls"
|
||||
Grid.Row="11"
|
||||
Grid.Column="2"
|
||||
Grid.ColumnSpan="5"
|
||||
Margin="0 5 0 0"
|
||||
DataContext="{Binding DataContext, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:Views.SettingsView}}}">
|
||||
<Grid.Style>
|
||||
<Style TargetType="Grid">
|
||||
<Setter Property="Visibility" Value="Collapsed" />
|
||||
<Style.Triggers>
|
||||
<MultiDataTrigger>
|
||||
<MultiDataTrigger.Conditions>
|
||||
<Condition Binding="{Binding SettingsView.CanGenerateMapping}" Value="True" />
|
||||
<Condition Binding="{Binding SettingsView.MappingEndpoint.Overwrite}" Value="True" />
|
||||
</MultiDataTrigger.Conditions>
|
||||
<Setter Property="Visibility" Value="Visible" />
|
||||
</MultiDataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</Grid.Style>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="5" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<TextBlock Grid.Row="12" Grid.Column="0" Text="Versioning Configuration *" VerticalAlignment="Center" Margin="0 0 0 5" />
|
||||
<Grid Grid.Row="12" Grid.Column="2" Grid.ColumnSpan="5" Margin="0 0 0 5">
|
||||
<ComboBox Grid.Column="0"
|
||||
ItemsSource="{Binding SettingsView.MappingCompressions}"
|
||||
SelectedItem="{Binding SettingsView.SelectedMappingCompression, Mode=TwoWay}" />
|
||||
<Button Grid.Column="2"
|
||||
Click="OnGenerateMapping"
|
||||
Cursor="Hand">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Path Width="12"
|
||||
Height="12"
|
||||
Margin="0 0 5 0"
|
||||
VerticalAlignment="Center"
|
||||
Stroke="{Binding Foreground, RelativeSource={RelativeSource AncestorType=Button}}"
|
||||
StrokeThickness="2"
|
||||
Data="M 6,1 A 5,5 0 1 1 1,6"
|
||||
RenderTransformOrigin="0.5,0.5">
|
||||
<Path.RenderTransform>
|
||||
<RotateTransform />
|
||||
</Path.RenderTransform>
|
||||
<Path.Style>
|
||||
<Style TargetType="Path">
|
||||
<Setter Property="Visibility"
|
||||
Value="Collapsed" />
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding SettingsView.IsGeneratingMapping}"
|
||||
Value="True">
|
||||
<Setter Property="Visibility"
|
||||
Value="Visible" />
|
||||
<DataTrigger.EnterActions>
|
||||
<BeginStoryboard Name="MappingSpinner">
|
||||
<Storyboard>
|
||||
<DoubleAnimation Storyboard.TargetProperty="RenderTransform.Angle"
|
||||
From="0"
|
||||
To="360"
|
||||
Duration="0:0:0.8"
|
||||
RepeatBehavior="Forever" />
|
||||
</Storyboard>
|
||||
</BeginStoryboard>
|
||||
</DataTrigger.EnterActions>
|
||||
<DataTrigger.ExitActions>
|
||||
<RemoveStoryboard BeginStoryboardName="MappingSpinner" />
|
||||
</DataTrigger.ExitActions>
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</Path.Style>
|
||||
</Path>
|
||||
<TextBlock Text="Generate Mapping" />
|
||||
</StackPanel>
|
||||
</Button>
|
||||
</Grid>
|
||||
|
||||
<Separator Grid.Row="12" Grid.Column="0" Grid.ColumnSpan="7" Style="{StaticResource CustomSeparator}" Tag="ADVANCED"></Separator>
|
||||
|
||||
<TextBlock Grid.Row="13" Grid.Column="0" Text="Versioning Configuration *" VerticalAlignment="Center" Margin="0 0 0 5" />
|
||||
<Grid Grid.Row="13" Grid.Column="2" Grid.ColumnSpan="5" Margin="0 0 0 5">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="5" />
|
||||
@@ -186,10 +274,10 @@
|
||||
<Button Grid.Column="4" Content="MapStructTypes" Click="OpenMapStructTypes" />
|
||||
</Grid>
|
||||
|
||||
<TextBlock Grid.Row="13" Grid.Column="0" Text="AES Reload at Launch" VerticalAlignment="Center" Margin="0 0 0 5"
|
||||
<TextBlock Grid.Row="14" Grid.Column="0" Text="AES Reload at Launch" VerticalAlignment="Center" Margin="0 0 0 5"
|
||||
DataContext="{Binding DataContext, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:Views.SettingsView}}}"
|
||||
Visibility="{Binding SettingsView.AesEndpoint.IsValid, Converter={StaticResource BoolToVisibilityConverter}}" />
|
||||
<ComboBox Grid.Row="13" Grid.Column="2" Grid.ColumnSpan="5" Margin="0 0 0 5"
|
||||
<ComboBox Grid.Row="14" Grid.Column="2" Grid.ColumnSpan="5" Margin="0 0 0 5"
|
||||
DataContext="{Binding DataContext, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:Views.SettingsView}}}"
|
||||
ItemsSource="{Binding SettingsView.AesReloads}" SelectedItem="{Binding SettingsView.SelectedAesReload, Mode=TwoWay}"
|
||||
Visibility="{Binding SettingsView.AesEndpoint.IsValid, Converter={StaticResource BoolToVisibilityConverter}}">
|
||||
@@ -200,8 +288,8 @@
|
||||
</ComboBox.ItemTemplate>
|
||||
</ComboBox>
|
||||
|
||||
<TextBlock Grid.Row="14" Grid.Column="0" Text="Endpoint Configuration" VerticalAlignment="Center" Margin="0 0 0 5" />
|
||||
<Grid Grid.Row="14" Grid.Column="2" Grid.ColumnSpan="5" Margin="0 0 0 5"
|
||||
<TextBlock Grid.Row="15" Grid.Column="0" Text="Endpoint Configuration" VerticalAlignment="Center" Margin="0 0 0 5" />
|
||||
<Grid Grid.Row="15" Grid.Column="2" Grid.ColumnSpan="5" Margin="0 0 0 5"
|
||||
DataContext="{Binding DataContext, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:Views.SettingsView}}}">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
@@ -213,33 +301,33 @@
|
||||
<Button Grid.Column="2" Content="Mapping" Click="OpenMappingEndpoint" />
|
||||
</Grid>
|
||||
|
||||
<TextBlock Grid.Row="15" Grid.Column="0" Text="Serialize Script Bytecode" VerticalAlignment="Center" Margin="0 0 0 5" />
|
||||
<CheckBox Grid.Row="15" Grid.Column="2" Content="{Binding IsChecked, RelativeSource={RelativeSource Self}, Converter={x:Static converters:BoolToToggleConverter.Instance}}"
|
||||
<TextBlock Grid.Row="16" Grid.Column="0" Text="Serialize Script Bytecode" VerticalAlignment="Center" Margin="0 0 0 5" />
|
||||
<CheckBox Grid.Row="16" Grid.Column="2" Content="{Binding IsChecked, RelativeSource={RelativeSource Self}, Converter={x:Static converters:BoolToToggleConverter.Instance}}"
|
||||
IsChecked="{Binding ReadScriptData, Source={x:Static local:Settings.UserSettings.Default}, Mode=TwoWay}" Margin="0 5 0 10"
|
||||
Style="{DynamicResource {x:Static adonisUi:Styles.ToggleSwitch}}" />
|
||||
|
||||
<TextBlock Grid.Row="16" Grid.Column="0" Text="Serialize Inlined Shader Maps" VerticalAlignment="Center" Margin="0 0 0 5" />
|
||||
<CheckBox Grid.Row="16" Grid.Column="2" Content="{Binding IsChecked, RelativeSource={RelativeSource Self}, Converter={x:Static converters:BoolToToggleConverter.Instance}}"
|
||||
<TextBlock Grid.Row="17" Grid.Column="0" Text="Serialize Inlined Shader Maps" VerticalAlignment="Center" Margin="0 0 0 5" />
|
||||
<CheckBox Grid.Row="17" Grid.Column="2" Content="{Binding IsChecked, RelativeSource={RelativeSource Self}, Converter={x:Static converters:BoolToToggleConverter.Instance}}"
|
||||
IsChecked="{Binding ReadShaderMaps, Source={x:Static local:Settings.UserSettings.Default}, Mode=TwoWay}" Margin="0 5 0 10"
|
||||
Style="{DynamicResource {x:Static adonisUi:Styles.ToggleSwitch}}" />
|
||||
|
||||
<TextBlock Grid.Row="17" Grid.Column="0" Text="Decompile Blueprint to Pseudo C++" VerticalAlignment="Center" Margin="0 0 0 5" ToolTip="Adds a right click option to decompile UClass packages into a pseudo C++ friendly format" />
|
||||
<CheckBox Grid.Row="17" Grid.Column="2" Content="{Binding IsChecked, RelativeSource={RelativeSource Self}, Converter={x:Static converters:BoolToToggleConverter.Instance}}"
|
||||
<TextBlock Grid.Row="18" Grid.Column="0" Text="Decompile Blueprint to Pseudo C++" VerticalAlignment="Center" Margin="0 0 0 5" ToolTip="Adds a right click option to decompile UClass packages into a pseudo C++ friendly format" />
|
||||
<CheckBox Grid.Row="18" Grid.Column="2" Content="{Binding IsChecked, RelativeSource={RelativeSource Self}, Converter={x:Static converters:BoolToToggleConverter.Instance}}"
|
||||
IsChecked="{Binding ShowDecompileOption, Source={x:Static local:Settings.UserSettings.Default}, Mode=TwoWay}" Margin="0 5 0 10"
|
||||
Style="{DynamicResource {x:Static adonisUi:Styles.ToggleSwitch}}" />
|
||||
|
||||
<TextBlock Grid.Row="18" Grid.Column="0" Text="Decompile Lua" VerticalAlignment="Center" Margin="0 0 0 5" ToolTip="Decompile/Disassemble compiled lua files with an unluac." />
|
||||
<CheckBox Grid.Row="18" Grid.Column="2" Content="{Binding IsChecked, RelativeSource={RelativeSource Self}, Converter={x:Static converters:BoolToToggleConverter.Instance}}"
|
||||
<TextBlock Grid.Row="19" Grid.Column="0" Text="Decompile Lua" VerticalAlignment="Center" Margin="0 0 0 5" ToolTip="Decompile/Disassemble compiled lua files with an unluac." />
|
||||
<CheckBox Grid.Row="19" Grid.Column="2" Content="{Binding IsChecked, RelativeSource={RelativeSource Self}, Converter={x:Static converters:BoolToToggleConverter.Instance}}"
|
||||
IsChecked="{Binding DecompileLua, Source={x:Static local:Settings.UserSettings.Default}, Mode=TwoWay}" Margin="0 5 0 10"
|
||||
Style="{DynamicResource {x:Static adonisUi:Styles.ToggleSwitch}}"
|
||||
Checked="OnDecompileLuaChanged" />
|
||||
|
||||
<TextBlock Grid.Row="19"
|
||||
<TextBlock Grid.Row="20"
|
||||
Grid.Column="0"
|
||||
Text="Convert Audio During Export (.wav)"
|
||||
VerticalAlignment="Center"
|
||||
Margin="0 0 0 5" />
|
||||
<CheckBox Grid.Row="19"
|
||||
<CheckBox Grid.Row="20"
|
||||
Grid.Column="2"
|
||||
Content="{Binding IsChecked, RelativeSource={RelativeSource Self}, Converter={x:Static converters:BoolToToggleConverter.Instance}}"
|
||||
IsChecked="{Binding ConvertAudioOnBulkExport, Source={x:Static local:Settings.UserSettings.Default}, Mode=TwoWay}"
|
||||
@@ -645,6 +733,15 @@
|
||||
</ResourceDictionary>
|
||||
</adonisControls:AdonisWindow.Resources>
|
||||
<Grid>
|
||||
<Grid.Style>
|
||||
<Style TargetType="Grid">
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding SettingsView.IsGeneratingMapping}" Value="True">
|
||||
<Setter Property="IsEnabled" Value="False" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</Grid.Style>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="Auto" />
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Documents;
|
||||
using CUE4Parse.MappingsProvider.Usmap;
|
||||
using CUE4Parse.UE4.Lua.unluac;
|
||||
using FModel.Extensions;
|
||||
using FModel.Extensions.Themes;
|
||||
@@ -17,6 +20,7 @@ using FModel.Views.Resources.Controls;
|
||||
using ICSharpCode.AvalonEdit;
|
||||
using Microsoft.Win32;
|
||||
using Ookii.Dialogs.Wpf;
|
||||
using Serilog;
|
||||
|
||||
namespace FModel.Views;
|
||||
|
||||
@@ -44,6 +48,8 @@ public partial class SettingsView
|
||||
private async void OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var restart = _applicationView.SettingsView.Save(out var whatShouldIDo);
|
||||
if (_applicationView.CUE4Parse.HasMappingSettingsChanged())
|
||||
whatShouldIDo.Add(SettingsOut.ReloadMappings);
|
||||
if (restart)
|
||||
_applicationView.RestartWithWarning();
|
||||
|
||||
@@ -73,13 +79,19 @@ public partial class SettingsView
|
||||
ExportSessionViewModel.Instance.Options.ResetToUserDefaults();
|
||||
}
|
||||
|
||||
private void OnClosing(object sender, CancelEventArgs e)
|
||||
{
|
||||
if (_settingsView.IsGeneratingMapping)
|
||||
e.Cancel = true;
|
||||
}
|
||||
|
||||
private void OnBrowseOutput(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (!TryBrowse(out var path)) return;
|
||||
UserSettings.Default.OutputDirectory = path;
|
||||
if (_applicationView.SettingsView.UseCustomOutputFolders) return;
|
||||
|
||||
path = Path.Combine(path, "Exports");
|
||||
path = UserSettings.Default.ExportsDirectory;
|
||||
UserSettings.Default.RawDataDirectory = path;
|
||||
UserSettings.Default.PropertiesDirectory = path;
|
||||
UserSettings.Default.TextureDirectory = path;
|
||||
@@ -119,17 +131,90 @@ public partial class SettingsView
|
||||
|
||||
private void OnBrowseMappings(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var mappingsDirectory = UserSettings.Default.MappingsDirectory;
|
||||
var openFileDialog = new OpenFileDialog
|
||||
{
|
||||
Title = "Select a mapping file",
|
||||
InitialDirectory = CacheManager.MappingsDirectory,
|
||||
InitialDirectory = Directory.Exists(mappingsDirectory) ? mappingsDirectory : CacheManager.MappingsDirectory,
|
||||
Filter = "USMAP Files (*.usmap, *.jmap, *.jmap.gz)|*.usmap;*.jmap;*.jmap.gz|All Files (*.*)|*.*"
|
||||
};
|
||||
|
||||
if (!openFileDialog.ShowDialog().GetValueOrDefault())
|
||||
return;
|
||||
|
||||
_applicationView.SettingsView.MappingEndpoint.FilePath = openFileDialog.FileName;
|
||||
try
|
||||
{
|
||||
_applicationView.CUE4Parse.ApplyMappingFile(openFileDialog.FileName);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, "Failed to load mapping file {Path}", openFileDialog.FileName);
|
||||
FLogger.Append(ELog.Error, () => FLogger.Text($"Failed to load mapping file: {ex.Message}", Constants.WHITE, true));
|
||||
}
|
||||
}
|
||||
|
||||
private async void OnGenerateMapping(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (_settingsView.IsGeneratingMapping || !_settingsView.CanGenerateMapping || _settingsView.MappingEndpoint?.Overwrite != true)
|
||||
return;
|
||||
|
||||
var directory = UserSettings.Default.CurrentDir;
|
||||
var archiveDirectory = directory.GameDirectory;
|
||||
var mappingsDirectory = UserSettings.Default.MappingsDirectory;
|
||||
var game = directory.UeVersion;
|
||||
var compression = _settingsView.SelectedMappingCompression;
|
||||
_settingsView.IsGeneratingMapping = true;
|
||||
|
||||
try
|
||||
{
|
||||
string executable;
|
||||
try
|
||||
{
|
||||
executable = await Task.Run(() => StaticMappingGenerator.FindShippingExe(archiveDirectory));
|
||||
}
|
||||
catch (IOException ex) when (ex is FileNotFoundException or DirectoryNotFoundException)
|
||||
{
|
||||
Log.Warning("Could not locate the shipping executable automatically. {Reason}", ex.Message);
|
||||
var openFileDialog = new OpenFileDialog
|
||||
{
|
||||
Title = "Select Unreal Engine shipping executable (.exe)",
|
||||
InitialDirectory = Directory.Exists(archiveDirectory) ? archiveDirectory : string.Empty,
|
||||
Filter = "Executables (*.exe)|*.exe"
|
||||
};
|
||||
|
||||
if (openFileDialog.ShowDialog(this) != true)
|
||||
return;
|
||||
|
||||
executable = openFileDialog.FileName;
|
||||
}
|
||||
|
||||
var gameDisplayName = _applicationView.CUE4Parse.Provider.GameDisplayName;
|
||||
var path = await Task.Run(() => StaticMappingGenerator.Generate(executable, mappingsDirectory, game, compression, gameDisplayName));
|
||||
|
||||
if (ReferenceEquals(directory, UserSettings.Default.CurrentDir))
|
||||
_applicationView.CUE4Parse.ApplyMappingFile(path);
|
||||
|
||||
var mappingType = compression == EUsmapCompressionMethod.None ? "mapping" : $"{compression} mapping";
|
||||
Log.Information("Generated {MappingType} from {Executable} at {Path}", mappingType, executable, path);
|
||||
FLogger.Append(ELog.Information, () =>
|
||||
{
|
||||
FLogger.Text($"Generated {mappingType} ", Constants.WHITE);
|
||||
FLogger.Link(Path.GetFileName(path), path, true);
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, "Failed to generate a static mapping for {ArchiveDirectory}", archiveDirectory);
|
||||
FLogger.Append(ELog.Error, () =>
|
||||
{
|
||||
FLogger.Text("Failed to generate mapping. See: ", Constants.WHITE);
|
||||
FLogger.Link("→ link ←", Constants.MAPPING_ISSUE_LINK, true);
|
||||
});
|
||||
}
|
||||
finally
|
||||
{
|
||||
_settingsView.IsGeneratingMapping = false;
|
||||
}
|
||||
}
|
||||
|
||||
private bool TryBrowse(out string path)
|
||||
|
||||
Reference in New Issue
Block a user