From 25cb46525a65e5527cea44f4c48ad5a1ec7f1626 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Thu, 20 Apr 2023 09:35:23 +0200 Subject: [PATCH] Fix bug with shpk editing. --- Penumbra/UI/AdvancedWindow/FileEditor.cs | 7 ++----- Penumbra/UI/AdvancedWindow/ModEditWindow.cs | 4 ++-- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/Penumbra/UI/AdvancedWindow/FileEditor.cs b/Penumbra/UI/AdvancedWindow/FileEditor.cs index 2da62772..401d96a6 100644 --- a/Penumbra/UI/AdvancedWindow/FileEditor.cs +++ b/Penumbra/UI/AdvancedWindow/FileEditor.cs @@ -26,7 +26,7 @@ public class FileEditor where T : class, IWritable public FileEditor(ModEditWindow owner, DataManager gameData, Configuration config, FileDialogService fileDialog, string tabName, string fileType, Func> getFiles, Func drawEdit, Func getInitialPath, - Func? parseFile) + Func parseFile) { _owner = owner; _gameData = gameData; @@ -35,7 +35,7 @@ public class FileEditor where T : class, IWritable _fileType = fileType; _drawEdit = drawEdit; _getInitialPath = getInitialPath; - _parseFile = parseFile ?? DefaultParseFile; + _parseFile = parseFile; _combo = new Combo(config, getFiles); } @@ -170,9 +170,6 @@ public class FileEditor where T : class, IWritable UpdateCurrentFile(_combo.CurrentSelection); } - private static T? DefaultParseFile(byte[] bytes) - => Activator.CreateInstance(typeof(T), bytes) as T; - private void UpdateCurrentFile(FileRegistry path) { if (ReferenceEquals(_currentPath, path)) diff --git a/Penumbra/UI/AdvancedWindow/ModEditWindow.cs b/Penumbra/UI/AdvancedWindow/ModEditWindow.cs index 4edb2701..a922c477 100644 --- a/Penumbra/UI/AdvancedWindow/ModEditWindow.cs +++ b/Penumbra/UI/AdvancedWindow/ModEditWindow.cs @@ -513,9 +513,9 @@ public partial class ModEditWindow : Window, IDisposable () => _editor.Files.Mtrl, DrawMaterialPanel, () => _mod?.ModPath.FullName ?? string.Empty, bytes => new MtrlTab(this, new MtrlFile(bytes))); _modelTab = new FileEditor(this, gameData, config, _fileDialog, "Models", ".mdl", - () => _editor.Files.Mdl, DrawModelPanel, () => _mod?.ModPath.FullName ?? string.Empty, null); + () => _editor.Files.Mdl, DrawModelPanel, () => _mod?.ModPath.FullName ?? string.Empty, bytes => new MdlFile(bytes)); _shaderPackageTab = new FileEditor(this, gameData, config, _fileDialog, "Shader Packages", ".shpk", - () => _editor.Files.Shpk, DrawShaderPackagePanel, () => _mod?.ModPath.FullName ?? string.Empty, null); + () => _editor.Files.Shpk, DrawShaderPackagePanel, () => _mod?.ModPath.FullName ?? string.Empty, bytes => new ShpkTab(_fileDialog, bytes)); _center = new CombinedTexture(_left, _right); _quickImportViewer = new ResourceTreeViewer(_config, resourceTreeFactory, 2, OnQuickImportRefresh, DrawQuickImportActions); }