Fix bug with shpk editing.

This commit is contained in:
Ottermandias 2023-04-20 09:35:23 +02:00
parent 1364b39f65
commit 25cb46525a
2 changed files with 4 additions and 7 deletions

View file

@ -26,7 +26,7 @@ public class FileEditor<T> where T : class, IWritable
public FileEditor(ModEditWindow owner, DataManager gameData, Configuration config, FileDialogService fileDialog, string tabName,
string fileType, Func<IReadOnlyList<FileRegistry>> getFiles, Func<T, bool, bool> drawEdit, Func<string> getInitialPath,
Func<byte[], T?>? parseFile)
Func<byte[], T?> parseFile)
{
_owner = owner;
_gameData = gameData;
@ -35,7 +35,7 @@ public class FileEditor<T> 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<T> 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))

View file

@ -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<MdlFile>(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<ShpkTab>(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);
}