diff --git a/.gitmodules b/.gitmodules index 8c90bc1..e69de29 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +0,0 @@ -[submodule "VictorBush.Ego.NefsCommon"] - path = VictorBush.Ego.NefsCommon - url = https://github.com/victorbush/ego.nefscommon.git diff --git a/NeFSedit.sln b/NeFSedit.sln index e3fe8fa..176cc15 100644 --- a/NeFSedit.sln +++ b/NeFSedit.sln @@ -22,10 +22,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VictorBush.Ego.NefsLib.Test EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VictorBush.Ego.NefsEdit.Tests", "VictorBush.Ego.NefsEdit.Tests\VictorBush.Ego.NefsEdit.Tests.csproj", "{40723AAF-DC4B-4DFE-BE01-90C562C7E298}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VictorBush.Ego.NefsCommon.InjectionDatabase.Tests", "VictorBush.Ego.NefsCommon\VictorBush.Ego.NefsCommon.InjectionDatabase.Tests\VictorBush.Ego.NefsCommon.InjectionDatabase.Tests.csproj", "{181257C0-BBE9-408C-B3EF-3BD12E0F7AF3}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VictorBush.Ego.NefsCommon.InjectionDatabase", "VictorBush.Ego.NefsCommon\VictorBush.Ego.NefsCommon.InjectionDatabase\VictorBush.Ego.NefsCommon.InjectionDatabase.csproj", "{D9336E22-6F6C-43F3-A5A5-71C0C81B85EE}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -48,14 +44,6 @@ Global {40723AAF-DC4B-4DFE-BE01-90C562C7E298}.Debug|Any CPU.Build.0 = Debug|Any CPU {40723AAF-DC4B-4DFE-BE01-90C562C7E298}.Release|Any CPU.ActiveCfg = Release|Any CPU {40723AAF-DC4B-4DFE-BE01-90C562C7E298}.Release|Any CPU.Build.0 = Release|Any CPU - {181257C0-BBE9-408C-B3EF-3BD12E0F7AF3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {181257C0-BBE9-408C-B3EF-3BD12E0F7AF3}.Debug|Any CPU.Build.0 = Debug|Any CPU - {181257C0-BBE9-408C-B3EF-3BD12E0F7AF3}.Release|Any CPU.ActiveCfg = Release|Any CPU - {181257C0-BBE9-408C-B3EF-3BD12E0F7AF3}.Release|Any CPU.Build.0 = Release|Any CPU - {D9336E22-6F6C-43F3-A5A5-71C0C81B85EE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {D9336E22-6F6C-43F3-A5A5-71C0C81B85EE}.Debug|Any CPU.Build.0 = Debug|Any CPU - {D9336E22-6F6C-43F3-A5A5-71C0C81B85EE}.Release|Any CPU.ActiveCfg = Release|Any CPU - {D9336E22-6F6C-43F3-A5A5-71C0C81B85EE}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/TODO.md b/TODO.md index 22b81a6..928e9e9 100644 --- a/TODO.md +++ b/TODO.md @@ -12,3 +12,4 @@ - Support reading and writing split archives across multiple files - Add support for versions 0.1.0, 0.2.0, 1.3.0, 1.4.0 - Bring back auto-search of nefs headers in game exe +- Determine behavior for extracting duplicate and removed files diff --git a/VictorBush.Ego.NefsCommon b/VictorBush.Ego.NefsCommon deleted file mode 160000 index 469e1d6..0000000 --- a/VictorBush.Ego.NefsCommon +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 469e1d62b4612223aba9a5c65e9cb51357885b43 diff --git a/VictorBush.Ego.NefsEdit/Source/Program.cs b/VictorBush.Ego.NefsEdit/Source/Program.cs index 8612d88..84b13f9 100644 --- a/VictorBush.Ego.NefsEdit/Source/Program.cs +++ b/VictorBush.Ego.NefsEdit/Source/Program.cs @@ -6,7 +6,6 @@ using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; using Serilog; -using VictorBush.Ego.NefsCommon.InjectionDatabase; using VictorBush.Ego.NefsEdit.Services; using VictorBush.Ego.NefsEdit.UI; using VictorBush.Ego.NefsEdit.Utility; @@ -66,8 +65,6 @@ internal static void Main() x.AddSingleton(); x.AddSingleton(x => new NefsWriter(TempDirectory, x.GetRequiredService(), x.GetRequiredService())); x.AddSingleton(); - x.AddSingleton(); - x.AddSingleton(); }).Build(); // Run application diff --git a/VictorBush.Ego.NefsEdit/Source/Services/UiService.cs b/VictorBush.Ego.NefsEdit/Source/Services/UiService.cs index a907982..3ce705b 100644 --- a/VictorBush.Ego.NefsEdit/Source/Services/UiService.cs +++ b/VictorBush.Ego.NefsEdit/Source/Services/UiService.cs @@ -2,7 +2,6 @@ using System.IO.Abstractions; using System.Windows.Threading; -using VictorBush.Ego.NefsCommon.InjectionDatabase; using VictorBush.Ego.NefsEdit.UI; using VictorBush.Ego.NefsLib.ArchiveSource; using VictorBush.Ego.NefsLib.IO; @@ -14,16 +13,13 @@ namespace VictorBush.Ego.NefsEdit.Services; /// internal class UiService : IUiService { - private readonly IInjectionDatabaseService injectionDatabaseService; - /// /// Initializes a new instance of the class. /// - public UiService(Dispatcher dispatcher, IFileSystem fileSystem, IInjectionDatabaseService injectionDatabaseService) + public UiService(Dispatcher dispatcher, IFileSystem fileSystem) { Dispatcher = dispatcher ?? throw new ArgumentNullException(nameof(dispatcher)); FileSystem = fileSystem ?? throw new ArgumentNullException(nameof(fileSystem)); - this.injectionDatabaseService = injectionDatabaseService ?? throw new ArgumentNullException(nameof(injectionDatabaseService)); } /// @@ -55,7 +51,7 @@ public DialogResult ShowMessageBox(string message, string? title = null, Message IProgressService progressService, INefsReader reader) { - using var dialog = new OpenFileForm(settingsService, this, progressService, reader, FileSystem, this.injectionDatabaseService); + using var dialog = new OpenFileForm(settingsService, this, progressService, reader, FileSystem); var result = dialog.ShowDialog(); var source = dialog.ArchiveSource; return (result, source); diff --git a/VictorBush.Ego.NefsEdit/Source/Settings/OpenFileDialogState.cs b/VictorBush.Ego.NefsEdit/Source/Settings/OpenFileDialogState.cs index eba0c05..09a52ce 100644 --- a/VictorBush.Ego.NefsEdit/Source/Settings/OpenFileDialogState.cs +++ b/VictorBush.Ego.NefsEdit/Source/Settings/OpenFileDialogState.cs @@ -48,9 +48,5 @@ public class OpenFileDialogState /// public string NefsFilePath { get; set; } = ""; - public string NefsInjectDataFilePath { get; set; } = ""; - - public string NefsInjectFilePath { get; set; } = ""; - public string HeadlessExePath { get; set; } = ""; } diff --git a/VictorBush.Ego.NefsEdit/Source/Settings/RecentFile.cs b/VictorBush.Ego.NefsEdit/Source/Settings/RecentFile.cs index a00abaf..bafcd5b 100644 --- a/VictorBush.Ego.NefsEdit/Source/Settings/RecentFile.cs +++ b/VictorBush.Ego.NefsEdit/Source/Settings/RecentFile.cs @@ -43,13 +43,6 @@ public RecentFile(NefsArchiveSource source) GameDatSecondaryOffset = gameDatSource.SecondaryOffset; GameDatSecondarySize = gameDatSource.SecondarySize; Type = "GameDatSource"; - - break; - - case NefsInjectSource nefsInjectSource: - NefsInjectDataFilePath = nefsInjectSource.DataFilePath; - NefsInjectFilePath = nefsInjectSource.NefsInjectFilePath; - Type = nameof(NefsInjectSource); break; default: @@ -63,8 +56,6 @@ public RecentFile(NefsArchiveSource source) public int? GameDatPrimarySize { get; set; } public long? GameDatSecondaryOffset { get; set; } public int? GameDatSecondarySize { get; set; } - public string NefsInjectDataFilePath { get; set; } = ""; - public string NefsInjectFilePath { get; set; } = ""; public string StandardFilePath { get; set; } = ""; public string Type { get; set; } = ""; @@ -78,9 +69,6 @@ public NefsArchiveSource ToArchiveSource() case "GameDatSource": return NefsArchiveSource.Headless(GameDatDataFilePath, GameDatHeaderFilePath, GameDatPrimaryOffset!.Value, GameDatPrimarySize, GameDatSecondaryOffset!.Value, GameDatSecondarySize); - case nameof(NefsInjectSource): - return NefsArchiveSource.NefsInject(NefsInjectDataFilePath, NefsInjectFilePath); - default: throw new InvalidOperationException("Unknown source."); } @@ -97,9 +85,6 @@ public override string ToString() case "GameDatSource": return $"[Headless] {Path.GetFileName(GameDatDataFilePath)} [{GameDatPrimaryOffset}|{GameDatSecondaryOffset}]"; - case nameof(NefsInjectSource): - return $"[NefsInject] {Path.GetFileName(NefsInjectDataFilePath)}"; - default: return "Unknown source."; } diff --git a/VictorBush.Ego.NefsEdit/Source/UI/ArchiveDebugForm.cs b/VictorBush.Ego.NefsEdit/Source/UI/ArchiveDebugForm.cs index acaee77..8594608 100644 --- a/VictorBush.Ego.NefsEdit/Source/UI/ArchiveDebugForm.cs +++ b/VictorBush.Ego.NefsEdit/Source/UI/ArchiveDebugForm.cs @@ -4,7 +4,6 @@ using VictorBush.Ego.NefsEdit.Workspace; using VictorBush.Ego.NefsLib; using VictorBush.Ego.NefsLib.ArchiveSource; -using VictorBush.Ego.NefsLib.Header; using VictorBush.Ego.NefsLib.Header.Version160; using VictorBush.Ego.NefsLib.Header.Version200; using WeifenLuo.WinFormsUI.Docking; @@ -48,11 +47,6 @@ private string GetArchiveSourceInfo(NefsArchiveSource source) Archive file: {standardSource.FilePath} Header offset: 0"; - case NefsInjectSource nefsInjectSource: - return $@"NefsInject archive. -Data file: {nefsInjectSource.DataFilePath} -NefsInject file: {nefsInjectSource.NefsInjectFilePath}"; - case HeadlessSource gameDatSource: return $@"GameDat archive. Data file: {gameDatSource.DataFilePath} diff --git a/VictorBush.Ego.NefsEdit/Source/UI/EditorForm.cs b/VictorBush.Ego.NefsEdit/Source/UI/EditorForm.cs index b23f62b..f6ed75d 100644 --- a/VictorBush.Ego.NefsEdit/Source/UI/EditorForm.cs +++ b/VictorBush.Ego.NefsEdit/Source/UI/EditorForm.cs @@ -1,7 +1,6 @@ // See LICENSE.txt for license information. using Microsoft.Extensions.Logging; -using VictorBush.Ego.NefsCommon.InjectionDatabase; using VictorBush.Ego.NefsEdit.Commands; using VictorBush.Ego.NefsEdit.Services; using VictorBush.Ego.NefsEdit.Workspace; @@ -15,7 +14,6 @@ namespace VictorBush.Ego.NefsEdit.UI; internal partial class EditorForm : Form { private readonly ILogger logger; - private readonly IInjectionDatabaseService injectionDatabaseService; private readonly IProgressService progressService; private ArchiveDebugForm archiveDebugForm; private BrowseAllForm browseAllForm; @@ -32,13 +30,11 @@ public EditorForm( INefsEditWorkspace workspace, IUiService uiService, ISettingsService settingsService, - IInjectionDatabaseService injectionDatabaseService, IProgressService progressService) { InitializeComponent(); UiService = uiService ?? throw new ArgumentNullException(nameof(uiService)); SettingsService = settingsService ?? throw new ArgumentNullException(nameof(settingsService)); - this.injectionDatabaseService = injectionDatabaseService ?? throw new ArgumentNullException(nameof(injectionDatabaseService)); this.progressService = progressService ?? throw new ArgumentNullException(nameof(progressService)); this.logger = logger ?? throw new ArgumentNullException(nameof(logger)); Workspace = workspace ?? throw new ArgumentNullException(nameof(workspace)); @@ -131,38 +127,6 @@ private void EditorForm_Load(object sender, EventArgs e) // Load settings SettingsService.Load(); - - // Check for database update - if (SettingsService.CheckForDatabaseUpdatesOnStartup) - { - this.logger.LogInformation("Checking for injection database update."); - - UiService.Dispatcher.InvokeAsync(async () => - { - try - { - var update = await this.injectionDatabaseService.CheckForDatabaseUpdateAsync(); - if (update is null) - { - this.logger.LogInformation("No injection database update found."); - return; - } - - var result = UiService.ShowMessageBox("A new injection database is available. Download now?", "Database Update Available", MessageBoxButtons.YesNo); - if (result != DialogResult.Yes) - { - return; - } - - await this.progressService.RunModalTaskAsync(progress => this.injectionDatabaseService.UpdateDatabaseAsync(update)); - this.logger.LogInformation($"Injection database updates to version {update.DbVersion}."); - } - catch (Exception ex) - { - this.logger.LogError(ex, "Failed to check for injection database update."); - } - }); - } } private void ExitToolStripMenuItem_Click(object sender, EventArgs e) diff --git a/VictorBush.Ego.NefsEdit/Source/UI/OpenFileForm.Designer.cs b/VictorBush.Ego.NefsEdit/Source/UI/OpenFileForm.Designer.cs index 4c9ee71..eb71ee4 100644 --- a/VictorBush.Ego.NefsEdit/Source/UI/OpenFileForm.Designer.cs +++ b/VictorBush.Ego.NefsEdit/Source/UI/OpenFileForm.Designer.cs @@ -35,13 +35,7 @@ private void InitializeComponent() this.fileLabel = new System.Windows.Forms.Label(); this.nefsFileButton = new System.Windows.Forms.Button(); this.nefsFileTextBox = new System.Windows.Forms.TextBox(); - this.nefsInjectTabPage = new System.Windows.Forms.TabPage(); - this.label1 = new System.Windows.Forms.Label(); - this.nefsInjectHeaderFileButton = new System.Windows.Forms.Button(); - this.nefsInjectFileTextBox = new System.Windows.Forms.TextBox(); this.label2 = new System.Windows.Forms.Label(); - this.nefsInjectDataFileButton = new System.Windows.Forms.Button(); - this.nefsInjectDataFileTextBox = new System.Windows.Forms.TextBox(); this.headlessTabPage = new System.Windows.Forms.TabPage(); this.gameDatRefreshButton = new System.Windows.Forms.Button(); this.gameDatFilesLabel = new System.Windows.Forms.Label(); @@ -69,14 +63,13 @@ private void InitializeComponent() this.modeListBox = new System.Windows.Forms.ListBox(); this.tablessControl1.SuspendLayout(); this.nefsTabPage.SuspendLayout(); - this.nefsInjectTabPage.SuspendLayout(); this.headlessTabPage.SuspendLayout(); this.headlessCustomTabPage.SuspendLayout(); this.recentTabPage.SuspendLayout(); this.SuspendLayout(); - // + // // cancelButton - // + // this.cancelButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel; this.cancelButton.Location = new System.Drawing.Point(509, 412); @@ -86,9 +79,9 @@ private void InitializeComponent() this.cancelButton.TabIndex = 24; this.cancelButton.Text = "Cancel"; this.cancelButton.UseVisualStyleBackColor = true; - // + // // openButton - // + // this.openButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.openButton.Location = new System.Drawing.Point(401, 412); this.openButton.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); @@ -98,15 +91,14 @@ private void InitializeComponent() this.openButton.Text = "Open"; this.openButton.UseVisualStyleBackColor = true; this.openButton.Click += new System.EventHandler(this.OpenButton_Click); - // + // // tablessControl1 - // - this.tablessControl1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) + // + this.tablessControl1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.tablessControl1.Appearance = System.Windows.Forms.TabAppearance.FlatButtons; this.tablessControl1.Controls.Add(this.nefsTabPage); - this.tablessControl1.Controls.Add(this.nefsInjectTabPage); this.tablessControl1.Controls.Add(this.headlessTabPage); this.tablessControl1.Controls.Add(this.headlessCustomTabPage); this.tablessControl1.Controls.Add(this.recentTabPage); @@ -116,9 +108,9 @@ private void InitializeComponent() this.tablessControl1.SelectedIndex = 0; this.tablessControl1.Size = new System.Drawing.Size(428, 388); this.tablessControl1.TabIndex = 18; - // + // // nefsTabPage - // + // this.nefsTabPage.Controls.Add(this.fileLabel); this.nefsTabPage.Controls.Add(this.nefsFileButton); this.nefsTabPage.Controls.Add(this.nefsFileTextBox); @@ -130,9 +122,9 @@ private void InitializeComponent() this.nefsTabPage.TabIndex = 0; this.nefsTabPage.Text = "NeFS"; this.nefsTabPage.UseVisualStyleBackColor = true; - // + // // fileLabel - // + // this.fileLabel.AutoSize = true; this.fileLabel.Location = new System.Drawing.Point(8, 12); this.fileLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); @@ -140,9 +132,9 @@ private void InitializeComponent() this.fileLabel.Size = new System.Drawing.Size(32, 20); this.fileLabel.TabIndex = 0; this.fileLabel.Text = "File"; - // + // // nefsFileButton - // + // this.nefsFileButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.nefsFileButton.Location = new System.Drawing.Point(371, 34); this.nefsFileButton.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); @@ -152,66 +144,19 @@ private void InitializeComponent() this.nefsFileButton.Text = "..."; this.nefsFileButton.UseVisualStyleBackColor = true; this.nefsFileButton.Click += new System.EventHandler(this.NefsFileButton_Click); - // + // // nefsFileTextBox - // - this.nefsFileTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + // + this.nefsFileTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.nefsFileTextBox.Location = new System.Drawing.Point(12, 38); this.nefsFileTextBox.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); this.nefsFileTextBox.Name = "nefsFileTextBox"; this.nefsFileTextBox.Size = new System.Drawing.Size(349, 27); this.nefsFileTextBox.TabIndex = 0; - // - // nefsInjectTabPage - // - this.nefsInjectTabPage.Controls.Add(this.label1); - this.nefsInjectTabPage.Controls.Add(this.nefsInjectHeaderFileButton); - this.nefsInjectTabPage.Controls.Add(this.nefsInjectFileTextBox); - this.nefsInjectTabPage.Controls.Add(this.label2); - this.nefsInjectTabPage.Controls.Add(this.nefsInjectDataFileButton); - this.nefsInjectTabPage.Controls.Add(this.nefsInjectDataFileTextBox); - this.nefsInjectTabPage.Location = new System.Drawing.Point(4, 32); - this.nefsInjectTabPage.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); - this.nefsInjectTabPage.Name = "nefsInjectTabPage"; - this.nefsInjectTabPage.Size = new System.Drawing.Size(420, 352); - this.nefsInjectTabPage.TabIndex = 5; - this.nefsInjectTabPage.Text = "NefsInject"; - this.nefsInjectTabPage.UseVisualStyleBackColor = true; - // - // label1 - // - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(9, 82); - this.label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(100, 20); - this.label1.TabIndex = 11; - this.label1.Text = "NefsInject file"; - // - // nefsInjectHeaderFileButton - // - this.nefsInjectHeaderFileButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.nefsInjectHeaderFileButton.Location = new System.Drawing.Point(372, 104); - this.nefsInjectHeaderFileButton.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - this.nefsInjectHeaderFileButton.Name = "nefsInjectHeaderFileButton"; - this.nefsInjectHeaderFileButton.Size = new System.Drawing.Size(35, 35); - this.nefsInjectHeaderFileButton.TabIndex = 13; - this.nefsInjectHeaderFileButton.Text = "..."; - this.nefsInjectHeaderFileButton.UseVisualStyleBackColor = true; - // - // nefsInjectFileTextBox - // - this.nefsInjectFileTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.nefsInjectFileTextBox.Location = new System.Drawing.Point(13, 108); - this.nefsInjectFileTextBox.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - this.nefsInjectFileTextBox.Name = "nefsInjectFileTextBox"; - this.nefsInjectFileTextBox.Size = new System.Drawing.Size(349, 27); - this.nefsInjectFileTextBox.TabIndex = 12; - // + // // label2 - // + // this.label2.AutoSize = true; this.label2.Location = new System.Drawing.Point(8, 12); this.label2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); @@ -219,30 +164,9 @@ private void InitializeComponent() this.label2.Size = new System.Drawing.Size(269, 20); this.label2.TabIndex = 8; this.label2.Text = "Data File (i.e., game.dat, game.bin, etc.)"; - // - // nefsInjectDataFileButton - // - this.nefsInjectDataFileButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.nefsInjectDataFileButton.Location = new System.Drawing.Point(371, 34); - this.nefsInjectDataFileButton.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - this.nefsInjectDataFileButton.Name = "nefsInjectDataFileButton"; - this.nefsInjectDataFileButton.Size = new System.Drawing.Size(35, 35); - this.nefsInjectDataFileButton.TabIndex = 10; - this.nefsInjectDataFileButton.Text = "..."; - this.nefsInjectDataFileButton.UseVisualStyleBackColor = true; - // - // nefsInjectDataFileTextBox - // - this.nefsInjectDataFileTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.nefsInjectDataFileTextBox.Location = new System.Drawing.Point(12, 38); - this.nefsInjectDataFileTextBox.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - this.nefsInjectDataFileTextBox.Name = "nefsInjectDataFileTextBox"; - this.nefsInjectDataFileTextBox.Size = new System.Drawing.Size(349, 27); - this.nefsInjectDataFileTextBox.TabIndex = 9; - // + // // headlessTabPage - // + // this.headlessTabPage.Controls.Add(this.gameDatRefreshButton); this.headlessTabPage.Controls.Add(this.gameDatFilesLabel); this.headlessTabPage.Controls.Add(this.gameDatFilesListBox); @@ -257,9 +181,9 @@ private void InitializeComponent() this.headlessTabPage.TabIndex = 1; this.headlessTabPage.Text = "Headless"; this.headlessTabPage.UseVisualStyleBackColor = true; - // + // // gameDatRefreshButton - // + // this.gameDatRefreshButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.gameDatRefreshButton.Location = new System.Drawing.Point(13, 305); this.gameDatRefreshButton.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); @@ -269,21 +193,21 @@ private void InitializeComponent() this.gameDatRefreshButton.Text = "Search"; this.gameDatRefreshButton.UseVisualStyleBackColor = true; this.gameDatRefreshButton.Click += new System.EventHandler(this.GameDatRefreshButton_Click); - // + // // gameDatFilesLabel - // + // this.gameDatFilesLabel.AutoSize = true; this.gameDatFilesLabel.Location = new System.Drawing.Point(13, 80); this.gameDatFilesLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.gameDatFilesLabel.Name = "gameDatFilesLabel"; this.gameDatFilesLabel.Size = new System.Drawing.Size(119, 20); this.gameDatFilesLabel.TabIndex = 15; - this.gameDatFilesLabel.Text = "Injection Profiles"; - // + this.gameDatFilesLabel.Text = "Data Files"; + // // gameDatFilesListBox - // - this.gameDatFilesListBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) + // + this.gameDatFilesListBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.gameDatFilesListBox.FormattingEnabled = true; this.gameDatFilesListBox.ItemHeight = 20; @@ -292,9 +216,9 @@ private void InitializeComponent() this.gameDatFilesListBox.Name = "gameDatFilesListBox"; this.gameDatFilesListBox.Size = new System.Drawing.Size(391, 184); this.gameDatFilesListBox.TabIndex = 14; - // + // // gameExeFileButton - // + // this.gameExeFileButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.gameExeFileButton.Location = new System.Drawing.Point(372, 34); this.gameExeFileButton.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); @@ -304,19 +228,19 @@ private void InitializeComponent() this.gameExeFileButton.Text = "..."; this.gameExeFileButton.UseVisualStyleBackColor = true; this.gameExeFileButton.Click += new System.EventHandler(this.GameExeFileButton_Click); - // + // // headlessGameExeFileTextBox - // - this.headlessGameExeFileTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + // + this.headlessGameExeFileTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.headlessGameExeFileTextBox.Location = new System.Drawing.Point(13, 38); this.headlessGameExeFileTextBox.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); this.headlessGameExeFileTextBox.Name = "headlessGameExeFileTextBox"; this.headlessGameExeFileTextBox.Size = new System.Drawing.Size(349, 27); this.headlessGameExeFileTextBox.TabIndex = 12; - // + // // gameExeFileLabel - // + // this.gameExeFileLabel.AutoSize = true; this.gameExeFileLabel.Location = new System.Drawing.Point(9, 12); this.gameExeFileLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); @@ -324,9 +248,9 @@ private void InitializeComponent() this.gameExeFileLabel.Size = new System.Drawing.Size(124, 20); this.gameExeFileLabel.TabIndex = 12; this.gameExeFileLabel.Text = "Game Executable"; - // + // // headlessCustomTabPage - // + // this.headlessCustomTabPage.Controls.Add(this.label6); this.headlessCustomTabPage.Controls.Add(this.splitSecondarySizeTextBox); this.headlessCustomTabPage.Controls.Add(this.label7); @@ -349,9 +273,9 @@ private void InitializeComponent() this.headlessCustomTabPage.TabIndex = 4; this.headlessCustomTabPage.Text = "Headless (Custom)"; this.headlessCustomTabPage.UseVisualStyleBackColor = true; - // + // // label6 - // + // this.label6.AutoSize = true; this.label6.Location = new System.Drawing.Point(187, 224); this.label6.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); @@ -359,17 +283,17 @@ private void InitializeComponent() this.label6.Size = new System.Drawing.Size(109, 20); this.label6.TabIndex = 32; this.label6.Text = "Secondary Size"; - // + // // splitSecondarySizeTextBox - // + // this.splitSecondarySizeTextBox.Location = new System.Drawing.Point(191, 250); this.splitSecondarySizeTextBox.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); this.splitSecondarySizeTextBox.Name = "splitSecondarySizeTextBox"; this.splitSecondarySizeTextBox.Size = new System.Drawing.Size(113, 27); this.splitSecondarySizeTextBox.TabIndex = 33; - // + // // label7 - // + // this.label7.AutoSize = true; this.label7.Location = new System.Drawing.Point(11, 224); this.label7.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); @@ -377,17 +301,17 @@ private void InitializeComponent() this.label7.Size = new System.Drawing.Size(162, 20); this.label7.TabIndex = 30; this.label7.Text = "Secondary Offset (Hex)"; - // + // // splitSecondaryOffsetTextBox - // + // this.splitSecondaryOffsetTextBox.Location = new System.Drawing.Point(15, 250); this.splitSecondaryOffsetTextBox.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); this.splitSecondaryOffsetTextBox.Name = "splitSecondaryOffsetTextBox"; this.splitSecondaryOffsetTextBox.Size = new System.Drawing.Size(113, 27); this.splitSecondaryOffsetTextBox.TabIndex = 31; - // + // // label5 - // + // this.label5.AutoSize = true; this.label5.Location = new System.Drawing.Point(186, 152); this.label5.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); @@ -395,17 +319,17 @@ private void InitializeComponent() this.label5.Size = new System.Drawing.Size(90, 20); this.label5.TabIndex = 28; this.label5.Text = "Primary Size"; - // + // // splitPrimarySizeTextBox - // + // this.splitPrimarySizeTextBox.Location = new System.Drawing.Point(190, 179); this.splitPrimarySizeTextBox.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); this.splitPrimarySizeTextBox.Name = "splitPrimarySizeTextBox"; this.splitPrimarySizeTextBox.Size = new System.Drawing.Size(113, 27); this.splitPrimarySizeTextBox.TabIndex = 29; - // + // // primaryOffsetLabel - // + // this.primaryOffsetLabel.AutoSize = true; this.primaryOffsetLabel.Location = new System.Drawing.Point(10, 152); this.primaryOffsetLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); @@ -413,17 +337,17 @@ private void InitializeComponent() this.primaryOffsetLabel.Size = new System.Drawing.Size(143, 20); this.primaryOffsetLabel.TabIndex = 26; this.primaryOffsetLabel.Text = "Primary Offset (Hex)"; - // + // // splitPrimaryOffsetTextBox - // + // this.splitPrimaryOffsetTextBox.Location = new System.Drawing.Point(14, 179); this.splitPrimaryOffsetTextBox.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); this.splitPrimaryOffsetTextBox.Name = "splitPrimaryOffsetTextBox"; this.splitPrimaryOffsetTextBox.Size = new System.Drawing.Size(113, 27); this.splitPrimaryOffsetTextBox.TabIndex = 27; - // + // // label4 - // + // this.label4.AutoSize = true; this.label4.Location = new System.Drawing.Point(9, 82); this.label4.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); @@ -431,9 +355,9 @@ private void InitializeComponent() this.label4.Size = new System.Drawing.Size(238, 20); this.label4.TabIndex = 5; this.label4.Text = "Header File (i.e., game executable)"; - // + // // splitHeaderFileBrowseButton - // + // this.splitHeaderFileBrowseButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.splitHeaderFileBrowseButton.Location = new System.Drawing.Point(372, 104); this.splitHeaderFileBrowseButton.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); @@ -443,19 +367,19 @@ private void InitializeComponent() this.splitHeaderFileBrowseButton.Text = "..."; this.splitHeaderFileBrowseButton.UseVisualStyleBackColor = true; this.splitHeaderFileBrowseButton.Click += new System.EventHandler(this.splitHeaderFileBrowseButton_Click); - // + // // splitHeaderFileTextBox - // - this.splitHeaderFileTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + // + this.splitHeaderFileTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.splitHeaderFileTextBox.Location = new System.Drawing.Point(13, 108); this.splitHeaderFileTextBox.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); this.splitHeaderFileTextBox.Name = "splitHeaderFileTextBox"; this.splitHeaderFileTextBox.Size = new System.Drawing.Size(349, 27); this.splitHeaderFileTextBox.TabIndex = 6; - // + // // label3 - // + // this.label3.AutoSize = true; this.label3.Location = new System.Drawing.Point(8, 12); this.label3.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); @@ -463,9 +387,9 @@ private void InitializeComponent() this.label3.Size = new System.Drawing.Size(269, 20); this.label3.TabIndex = 2; this.label3.Text = "Data File (i.e., game.dat, game.bin, etc.)"; - // + // // splitDataFileBrowseButton - // + // this.splitDataFileBrowseButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.splitDataFileBrowseButton.Location = new System.Drawing.Point(371, 34); this.splitDataFileBrowseButton.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); @@ -475,19 +399,19 @@ private void InitializeComponent() this.splitDataFileBrowseButton.Text = "..."; this.splitDataFileBrowseButton.UseVisualStyleBackColor = true; this.splitDataFileBrowseButton.Click += new System.EventHandler(this.splitDataFileBrowseButton_Click); - // + // // splitDataFileTextBox - // - this.splitDataFileTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + // + this.splitDataFileTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.splitDataFileTextBox.Location = new System.Drawing.Point(12, 38); this.splitDataFileTextBox.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); this.splitDataFileTextBox.Name = "splitDataFileTextBox"; this.splitDataFileTextBox.Size = new System.Drawing.Size(349, 27); this.splitDataFileTextBox.TabIndex = 3; - // + // // recentTabPage - // + // this.recentTabPage.Controls.Add(this.recentListBox); this.recentTabPage.Location = new System.Drawing.Point(4, 32); this.recentTabPage.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); @@ -497,11 +421,11 @@ private void InitializeComponent() this.recentTabPage.TabIndex = 3; this.recentTabPage.Text = "Recent"; this.recentTabPage.UseVisualStyleBackColor = true; - // + // // recentListBox - // - this.recentListBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) + // + this.recentListBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.recentListBox.FormattingEnabled = true; this.recentListBox.ItemHeight = 20; @@ -510,10 +434,10 @@ private void InitializeComponent() this.recentListBox.Name = "recentListBox"; this.recentListBox.Size = new System.Drawing.Size(411, 324); this.recentListBox.TabIndex = 26; - // + // // modeListBox - // - this.modeListBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + // + this.modeListBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left))); this.modeListBox.FormattingEnabled = true; this.modeListBox.ItemHeight = 20; @@ -523,9 +447,9 @@ private void InitializeComponent() this.modeListBox.Size = new System.Drawing.Size(171, 384); this.modeListBox.TabIndex = 25; this.modeListBox.SelectedIndexChanged += new System.EventHandler(this.ModeListBox_SelectedIndexChanged); - // + // // OpenFileForm - // + // this.AcceptButton = this.openButton; this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; @@ -548,8 +472,6 @@ private void InitializeComponent() this.tablessControl1.ResumeLayout(false); this.nefsTabPage.ResumeLayout(false); this.nefsTabPage.PerformLayout(); - this.nefsInjectTabPage.ResumeLayout(false); - this.nefsInjectTabPage.PerformLayout(); this.headlessTabPage.ResumeLayout(false); this.headlessTabPage.PerformLayout(); this.headlessCustomTabPage.ResumeLayout(false); @@ -593,12 +515,6 @@ private void InitializeComponent() private System.Windows.Forms.Label label3; private System.Windows.Forms.Button splitDataFileBrowseButton; private System.Windows.Forms.TextBox splitDataFileTextBox; - private System.Windows.Forms.TabPage nefsInjectTabPage; - private System.Windows.Forms.Label label1; - private System.Windows.Forms.Button nefsInjectHeaderFileButton; - private System.Windows.Forms.TextBox nefsInjectFileTextBox; private System.Windows.Forms.Label label2; - private System.Windows.Forms.Button nefsInjectDataFileButton; - private System.Windows.Forms.TextBox nefsInjectDataFileTextBox; } } diff --git a/VictorBush.Ego.NefsEdit/Source/UI/OpenFileForm.cs b/VictorBush.Ego.NefsEdit/Source/UI/OpenFileForm.cs index bae6e2a..3074f68 100644 --- a/VictorBush.Ego.NefsEdit/Source/UI/OpenFileForm.cs +++ b/VictorBush.Ego.NefsEdit/Source/UI/OpenFileForm.cs @@ -2,15 +2,12 @@ using Microsoft.Extensions.Logging; using System.Globalization; -using System.IO; using System.IO.Abstractions; -using VictorBush.Ego.NefsCommon.InjectionDatabase; using VictorBush.Ego.NefsEdit.Services; using VictorBush.Ego.NefsEdit.Settings; using VictorBush.Ego.NefsEdit.Utility; using VictorBush.Ego.NefsLib.ArchiveSource; using VictorBush.Ego.NefsLib.IO; -using VictorBush.Ego.NefsLib.Progress; namespace VictorBush.Ego.NefsEdit.UI; @@ -24,9 +21,7 @@ internal partial class OpenFileForm : Form private readonly OpenMode openModeHeadless = new OpenMode("Headless"); private readonly OpenMode openModeHeadlessCustom = new OpenMode("Headless (Custom)"); private readonly OpenMode openModeNefs = new OpenMode("NeFS"); - private readonly OpenMode openModeNefsInject = new OpenMode("NefsInject"); private readonly OpenMode openModeRecent = new OpenMode("Recent"); - private readonly IInjectionDatabaseService injectionDatabaseService; /// /// Initializes a new instance of the class. @@ -36,14 +31,12 @@ internal partial class OpenFileForm : Form /// Progress service. /// Nefs reader. /// The file system. - /// public OpenFileForm( ISettingsService settingsService, IUiService uiService, IProgressService progressService, INefsReader reader, - IFileSystem fileSystem, - IInjectionDatabaseService injectionDatabaseService) + IFileSystem fileSystem) { InitializeComponent(); SettingsService = settingsService ?? throw new ArgumentNullException(nameof(settingsService)); @@ -51,7 +44,6 @@ public OpenFileForm( ProgressService = progressService ?? throw new ArgumentNullException(nameof(progressService)); Reader = reader ?? throw new ArgumentNullException(nameof(reader)); FileSystem = fileSystem ?? throw new ArgumentNullException(nameof(fileSystem)); - this.injectionDatabaseService = injectionDatabaseService; } /// @@ -83,37 +75,8 @@ private static bool ParseHexNumberStringToLong(string input, out long result) private async Task> FindInjectionProfiles(string gameExePath) { - if (!FileSystem.File.Exists(gameExePath)) - { - UiService.ShowMessageBox($"Cannot find executable file: {gameExePath}."); - return new List(); - } - - var md5 = Md5Utility.Compute(gameExePath); - var gameExeFileName = Path.GetFileName(gameExePath); - var profile = await this.injectionDatabaseService.FindExeProfileAsync(gameExeFileName, md5); - if (profile == null) - { - Log.LogError($"No executable profile found for {gameExePath} with MD5 {md5}."); - UiService.ShowMessageBox($"No executable profile found for {gameExeFileName}."); - return new List(); - } - - if (profile.InjectionProfiles is null || profile.InjectionProfiles.Count == 0) - { - Log.LogError($"Executable profile for {gameExePath} with MD5 {md5} has no injection profiles."); - UiService.ShowMessageBox($"Executable profile for {gameExeFileName} has no injection profiles."); - return new List(); - } - - return profile.InjectionProfiles.Select(x => NefsArchiveSource.Headless( - Path.Combine(Path.GetDirectoryName(gameExePath)!, x.DataFile!), - gameExePath, - (long)x.PrimaryOffset!.Value, - (int)x.PrimarySize!.Value, - (long)x.SecondaryOffset!.Value, - (int)x.SecondarySize!.Value)) - .ToList(); + // Will be used to bring back auto-search at some point + throw new NotImplementedException(); } private async void GameDatRefreshButton_Click(Object sender, EventArgs e) @@ -166,8 +129,6 @@ private void LoadSettings() this.splitPrimarySizeTextBox.Text = SettingsService.OpenFileDialogState.GameDatPrimarySize; this.splitSecondaryOffsetTextBox.Text = SettingsService.OpenFileDialogState.GameDatSecondaryOffset; this.splitSecondarySizeTextBox.Text = SettingsService.OpenFileDialogState.GameDatSecondarySize; - this.nefsInjectDataFileTextBox.Text = SettingsService.OpenFileDialogState.NefsInjectDataFilePath; - this.nefsInjectFileTextBox.Text = SettingsService.OpenFileDialogState.NefsInjectFilePath; this.headlessGameExeFileTextBox.Text = SettingsService.OpenFileDialogState.HeadlessExePath; } @@ -178,10 +139,6 @@ private void ModeListBox_SelectedIndexChanged(Object sender, EventArgs e) // Open NeFS archive this.tablessControl1.SelectedTab = this.nefsTabPage; } - else if (this.modeListBox.SelectedItem == this.openModeNefsInject) - { - this.tablessControl1.SelectedTab = this.nefsInjectTabPage; - } else if (this.modeListBox.SelectedItem == this.openModeRecent) { // Open recent @@ -217,10 +174,6 @@ private void OpenButton_Click(Object sender, EventArgs e) { source = ValidateStandardSource(); } - else if (this.modeListBox.SelectedItem == this.openModeNefsInject) - { - source = ValidateNefsInjectSource(); - } else if (this.modeListBox.SelectedItem == this.openModeHeadless) { source = ValidateHeadlessSource(); @@ -258,7 +211,6 @@ private void OpenFileForm_Load(Object sender, EventArgs e) { // Setup combo box this.modeListBox.Items.Add(this.openModeNefs); - this.modeListBox.Items.Add(this.openModeNefsInject); this.modeListBox.Items.Add(this.openModeHeadless); this.modeListBox.Items.Add(this.openModeHeadlessCustom); this.modeListBox.Items.Add(this.openModeRecent); @@ -289,8 +241,6 @@ private void SaveSettings() SettingsService.OpenFileDialogState.GameDatPrimarySize = this.splitPrimarySizeTextBox.Text; SettingsService.OpenFileDialogState.GameDatSecondaryOffset = this.splitSecondaryOffsetTextBox.Text; SettingsService.OpenFileDialogState.GameDatSecondarySize = this.splitSecondarySizeTextBox.Text; - SettingsService.OpenFileDialogState.NefsInjectDataFilePath = this.nefsInjectDataFileTextBox.Text; - SettingsService.OpenFileDialogState.NefsInjectFilePath = this.nefsInjectFileTextBox.Text; SettingsService.OpenFileDialogState.HeadlessExePath = this.headlessGameExeFileTextBox.Text; SettingsService.Save(); @@ -420,21 +370,6 @@ private bool ValidateFileExists(string file) return source; } - private NefsArchiveSource? ValidateNefsInjectSource() - { - var dataFilePath = this.nefsInjectDataFileTextBox.Text; - var headerFilePath = this.nefsInjectFileTextBox.Text; - var source = NefsArchiveSource.NefsInject(dataFilePath, headerFilePath); - - if (!ValidateFileExists(source.DataFilePath)) - return null; - - if (!ValidateFileExists(source.NefsInjectFilePath)) - return null; - - return source; - } - private NefsArchiveSource? ValidateRecent() { var recent = this.recentListBox.SelectedItem as RecentFile; @@ -458,13 +393,6 @@ private bool ValidateFileExists(string file) return null; return gameDatSource; - case NefsInjectSource nefsInjectSource: - if (!ValidateFileExists(nefsInjectSource.NefsInjectFilePath)) - return null; - if (!ValidateFileExists(nefsInjectSource.DataFilePath)) - return null; - return nefsInjectSource; - default: UiService.ShowMessageBox($"Unknown archive source type."); return null; diff --git a/VictorBush.Ego.NefsEdit/Source/Workspace/NefsEditWorkspace.cs b/VictorBush.Ego.NefsEdit/Source/Workspace/NefsEditWorkspace.cs index a660cdc..4960c77 100644 --- a/VictorBush.Ego.NefsEdit/Source/Workspace/NefsEditWorkspace.cs +++ b/VictorBush.Ego.NefsEdit/Source/Workspace/NefsEditWorkspace.cs @@ -282,9 +282,6 @@ public async Task OpenArchiveAsync(NefsArchiveSource source) case HeadlessSource gameDatSource: return await OpenGameDatArchiveAsync(gameDatSource); - case NefsInjectSource nefsInjectSource: - return await OpenNefsInjectArchiveAsync(nefsInjectSource); - default: throw new ArgumentException("Unknown archive source type."); } @@ -410,10 +407,9 @@ public async Task SaveArchiveByDialogAsync() case StandardSource _: return await DoSaveStandardArchiveAsync(path); - case NefsInjectSource _: case HeadlessSource _: - var nefsInjectFilePath = path + ".nefsinject"; - return await DoSaveNefsInjectArchiveAsync(path, nefsInjectFilePath); + UiService.ShowMessageBox("Saving executable header archives is not supported.", icon: MessageBoxIcon.Error); + return false; default: throw new ArgumentException("Unknown archive source type."); @@ -474,55 +470,6 @@ await ProgressService.RunModalTaskAsync(p => Task.Run(async () => return result; } - private async Task DoSaveNefsInjectArchiveAsync(string dataFilePath, string nefsInjectFilePath) - { - if (Archive == null) - { - Log.LogError("Failed to save archive: no archive open."); - return false; - } - - // Currently don't support saving encrypted archives - if (Archive.Header.IsEncrypted) - { - UiService.ShowMessageBox("Saving encrypted archives is not supported.", icon: MessageBoxIcon.Error); - return false; - } - - Log.LogInformation("----------------------------"); - Log.LogInformation($"Writing NefsInject archive."); - Log.LogInformation($"Data file: {dataFilePath}."); - Log.LogInformation($"NefsInject file: {nefsInjectFilePath}."); - var result = false; - - // Save archive - await ProgressService.RunModalTaskAsync(p => Task.Run(async () => - { - using (var tt = p.BeginTask(1.0f)) - { - // Save archive - try - { - var (archive, source) = await NefsWriter.WriteNefsInjectArchiveAsync(dataFilePath, nefsInjectFilePath, Archive, p); - Archive = archive; - ArchiveSource = source; - UndoBuffer.MarkAsSaved(); - - ArchiveSaved?.Invoke(this, EventArgs.Empty); - result = true; - - Log.LogInformation($"Archive saved."); - } - catch (Exception ex) - { - Log.LogError($"Failed to saved archive {dataFilePath}.\r\n{ex.Message}"); - } - } - })); - - return result; - } - private async Task DoSaveStandardArchiveAsync(string filePath) { if (Archive == null) @@ -693,27 +640,6 @@ private async Task OpenGameDatArchiveAsync(HeadlessSource source) return await DoOpenArchiveAsync(source); } - private async Task OpenNefsInjectArchiveAsync(NefsInjectSource source) - { - Log.LogInformation("----------------------------"); - Log.LogInformation($"Opening archive: {source.DataFilePath}"); - Log.LogInformation($"NefsInject file: {source.NefsInjectFilePath}"); - - if (!FileSystem.File.Exists(source.DataFilePath)) - { - Log.LogError($"File not found: {source.DataFilePath}."); - return false; - } - - if (!FileSystem.File.Exists(source.NefsInjectFilePath)) - { - Log.LogError($"File not found: {source.NefsInjectFilePath}."); - return false; - } - - return await DoOpenArchiveAsync(source); - } - private async Task OpenStandardArchiveAsync(StandardSource source) { Log.LogInformation("----------------------------"); diff --git a/VictorBush.Ego.NefsEdit/VictorBush.Ego.NefsEdit.csproj b/VictorBush.Ego.NefsEdit/VictorBush.Ego.NefsEdit.csproj index e6be5cd..2501778 100644 --- a/VictorBush.Ego.NefsEdit/VictorBush.Ego.NefsEdit.csproj +++ b/VictorBush.Ego.NefsEdit/VictorBush.Ego.NefsEdit.csproj @@ -19,7 +19,6 @@ - diff --git a/VictorBush.Ego.NefsLib/Header/NefsInjectHeader.cs b/VictorBush.Ego.NefsLib/Header/NefsInjectHeader.cs deleted file mode 100644 index 4b87607..0000000 --- a/VictorBush.Ego.NefsLib/Header/NefsInjectHeader.cs +++ /dev/null @@ -1,73 +0,0 @@ -// See LICENSE.txt for license information. - -using VictorBush.Ego.NefsLib.DataTypes; - -namespace VictorBush.Ego.NefsLib.Header; - -public sealed class NefsInjectHeader -{ - public const int ExpectedMagicNumber = 4484; - public const int Size = 0x20; - - public NefsInjectHeader() - { - } - - public NefsInjectHeader(long primaryOffset, int primarySize, long secondaryOffset, int secondarySize) - { - Data0x00_MagicNum.Value = ExpectedMagicNumber; - Data0x04_Version.Value = 1; - Data0x08_PrimaryOffset.Value = (ulong)primaryOffset; - Data0x10_PrimarySize.Value = (uint)primarySize; - Data0x14_SecondaryOffset.Value = (ulong)secondaryOffset; - Data0x1C_SecondarySize.Value = (uint)secondarySize; - } - - /// - /// The NefsInject header magic number. - /// - public int MagicNumber => (int)Data0x00_MagicNum.Value; - - /// - /// Offset to the primary header section. This section contains header intro/toc, parts 1-5 and 8. - /// - public long PrimaryOffset => (long)Data0x08_PrimaryOffset.Value; - - /// - /// Size of the primary header section. - /// - public int PrimarySize => (int)Data0x10_PrimarySize.Value; - - /// - /// Offset to the secondary header section. This section contains header parts 6 and 7. - /// - public long SecondaryOffset => (long)Data0x14_SecondaryOffset.Value; - - /// - /// Size of the secondary header section. - /// - public int SecondarySize => (int)Data0x1C_SecondarySize.Value; - - /// - /// NefsInject header version. - /// - public int Version => (int)Data0x04_Version.Value; - - [FileData] - private UInt32Type Data0x00_MagicNum { get; } = new UInt32Type(0x00); - - [FileData] - private UInt32Type Data0x04_Version { get; } = new UInt32Type(0x04); - - [FileData] - private UInt64Type Data0x08_PrimaryOffset { get; } = new UInt64Type(0x08); - - [FileData] - private UInt32Type Data0x10_PrimarySize { get; } = new UInt32Type(0x10); - - [FileData] - private UInt64Type Data0x14_SecondaryOffset { get; } = new UInt64Type(0x14); - - [FileData] - private UInt32Type Data0x1C_SecondarySize { get; } = new UInt32Type(0x1C); -} diff --git a/VictorBush.Ego.NefsLib/IO/INefsWriter.cs b/VictorBush.Ego.NefsLib/IO/INefsWriter.cs index 50f05f8..be25c18 100644 --- a/VictorBush.Ego.NefsLib/IO/INefsWriter.cs +++ b/VictorBush.Ego.NefsLib/IO/INefsWriter.cs @@ -18,15 +18,4 @@ public interface INefsWriter /// Progress info. /// An updated archive object containing updated metadata. Task<(NefsArchive Archive, NefsArchiveSource Source)> WriteArchiveAsync(string destFilePath, NefsArchive nefs, NefsProgress p); - - /// - /// Writes the archive in NefsInject format. Archive header metadata is stored in a separate file (a NefsInject - /// file) from the archive item data. - /// - /// The path to write the item data file to. - /// The path to write the NefsInject file to. - /// The archive to write. - /// Progress info. - /// An updated archive object containing updated metadata. - Task<(NefsArchive Archive, NefsArchiveSource Source)> WriteNefsInjectArchiveAsync(string dataFilePath, string nefsInjectFilePath, NefsArchive nefs, NefsProgress p); } diff --git a/VictorBush.Ego.NefsLib/IO/NefsReader.cs b/VictorBush.Ego.NefsLib/IO/NefsReader.cs index 4fbbafe..314caa9 100644 --- a/VictorBush.Ego.NefsLib/IO/NefsReader.cs +++ b/VictorBush.Ego.NefsLib/IO/NefsReader.cs @@ -8,7 +8,6 @@ using System.Security.Cryptography; using System.Text; using VictorBush.Ego.NefsLib.ArchiveSource; -using VictorBush.Ego.NefsLib.DataTypes; using VictorBush.Ego.NefsLib.Header; using VictorBush.Ego.NefsLib.Header.Builder; using VictorBush.Ego.NefsLib.Progress; @@ -86,9 +85,6 @@ public Task ReadArchiveAsync(NefsArchiveSource source, NefsProgress case HeadlessSource gameDat: return ReadGameDatArchiveAsync(gameDat.FilePath, gameDat.HeaderFilePath, gameDat.PrimaryOffset, gameDat.PrimarySize, gameDat.SecondaryOffset, gameDat.SecondarySize, p); - case NefsInjectSource nefsInject: - return ReadNefsInjectArchiveAsync(nefsInject.FilePath, nefsInject.NefsInjectFilePath, p); - default: throw new ArgumentException("Unknown source type."); } @@ -124,36 +120,6 @@ public async Task ReadGameDatArchiveAsync(string dataFilePath, stri return new NefsArchive(header, items); } - public async Task ReadNefsInjectArchiveAsync(string dataFilePath, string nefsInjectFilePath, NefsProgress p) - { - if (!FileSystem.File.Exists(nefsInjectFilePath)) - { - throw new FileNotFoundException($"File not found: {nefsInjectFilePath}."); - } - - INefsHeader header; - using (var stream = FileSystem.File.OpenRead(nefsInjectFilePath)) - { - NefsInjectHeader nefsInject; - using (p.BeginTask(0.1f, "Reading NefsInject header")) - { - nefsInject = await ReadNefsInjectHeaderAsync(stream, 0, p); - } - - using (p.BeginTask(0.9f, "Reading Nefs header")) - { - header = await ReadSplitHeaderAsync(stream, nefsInject.PrimaryOffset, nefsInject.PrimarySize, nefsInject.SecondaryOffset, nefsInject.SecondarySize, p); - } - } - - // Create items from header - var itemsBuilder = NefsItemListBuilder.Create(header); - var items = itemsBuilder.Build(dataFilePath, p); - - // Create the archive - return new NefsArchive(header, items); - } - /// /// Decodes the intro header for file versions 1.5.1. /// @@ -404,13 +370,6 @@ internal async Task ReadHeaderAsync(Stream stream, long offset, Nef } } - internal async Task ReadNefsInjectHeaderAsync(Stream stream, long offset, NefsProgress p) - { - var nefsInject = new NefsInjectHeader(); - await FileData.ReadDataAsync(stream, offset, nefsInject, p); - return nefsInject; - } - internal async Task ReadSplitHeaderAsync( Stream stream, long primaryOffset, diff --git a/VictorBush.Ego.NefsLib/IO/NefsWriter.cs b/VictorBush.Ego.NefsLib/IO/NefsWriter.cs index 115e322..27dcecb 100644 --- a/VictorBush.Ego.NefsLib/IO/NefsWriter.cs +++ b/VictorBush.Ego.NefsLib/IO/NefsWriter.cs @@ -7,8 +7,6 @@ using VictorBush.Ego.NefsLib.DataSource; using VictorBush.Ego.NefsLib.Header; using VictorBush.Ego.NefsLib.Header.Builder; -using VictorBush.Ego.NefsLib.Header.Version160; -using VictorBush.Ego.NefsLib.Header.Version200; using VictorBush.Ego.NefsLib.Item; using VictorBush.Ego.NefsLib.Progress; using VictorBush.Ego.NefsLib.Utility; @@ -74,44 +72,6 @@ public NefsWriter( return (newArchive, NefsArchiveSource.Standard(destFilePath)); } - /// - public async Task<(NefsArchive Archive, NefsArchiveSource Source)> WriteNefsInjectArchiveAsync(string dataFilePath, string nefsInjectFilePath, NefsArchive nefs, NefsProgress p) - { - NefsArchive newArchive; - - // Setup temp working directory - var workDir = PrepareWorkingDirectory(dataFilePath); - - // Write to temp file - var tempDataFilePath = Path.Combine(workDir, "temp.dat"); - var tempNefsInjectFilePath = Path.Combine(workDir, "temp.dat.nefsinject"); - using (var dataFile = FileSystem.File.Open(tempDataFilePath, FileMode.Create)) - using (var nefsInjectFile = FileSystem.File.Open(tempNefsInjectFilePath, FileMode.Create)) - { - switch (nefs.Header) - { - case NefsHeader200 v20Header: - // newArchive = await WriteNefsInjectArchiveVersion20Async(dataFile, nefsInjectFile, v20Header, nefs.Items, workDir, p); - break; - - case NefsHeader160 v16Header: - // newArchive = await WriteNefsInjectArchiveVersion16Async(dataFile, nefsInjectFile, v16Header, nefs.Items, workDir, p); - break; - - default: - throw new NotSupportedException("Unsupported archive version."); - } - } - - // Copy to final destination - FileSystem.File.Copy(tempDataFilePath, dataFilePath, true); - FileSystem.File.Copy(tempNefsInjectFilePath, nefsInjectFilePath, true); - - var source = NefsArchiveSource.NefsInject(dataFilePath, nefsInjectFilePath); - return (null, source); - // return (newArchive, source); - } - /// /// Prepares an item's data to be written to the archive. /// diff --git a/VictorBush.Ego.NefsLib/Source/ArchiveSource/NefsArchiveSource.cs b/VictorBush.Ego.NefsLib/Source/ArchiveSource/NefsArchiveSource.cs index 7b944e5..516fe49 100644 --- a/VictorBush.Ego.NefsLib/Source/ArchiveSource/NefsArchiveSource.cs +++ b/VictorBush.Ego.NefsLib/Source/ArchiveSource/NefsArchiveSource.cs @@ -39,16 +39,6 @@ public static HeadlessSource Headless(string dataFilePath, string headerFilePath return new HeadlessSource(dataFilePath, headerFilePath, primaryOffset, primarySize, secondaryOffset, secondarySize); } - /// - /// Similar to a headless archive, but the header sections are stored in the NefsInject format. - /// - /// Path of the data file. - /// Path of the NefsInject file. - public static NefsInjectSource NefsInject(string dataFilePath, string nefsInjectFilePath) - { - return new NefsInjectSource(dataFilePath, nefsInjectFilePath); - } - /// /// Header and file data are both stored in the same file. /// diff --git a/VictorBush.Ego.NefsLib/Source/ArchiveSource/NefsInjectSource.cs b/VictorBush.Ego.NefsLib/Source/ArchiveSource/NefsInjectSource.cs deleted file mode 100644 index 4ef3bfd..0000000 --- a/VictorBush.Ego.NefsLib/Source/ArchiveSource/NefsInjectSource.cs +++ /dev/null @@ -1,25 +0,0 @@ -// See LICENSE.txt for license information. - -namespace VictorBush.Ego.NefsLib.ArchiveSource; - -/// -/// Similar to a headless archive, but the header sections are stored in the NefsInject format. -/// -public sealed class NefsInjectSource : NefsArchiveSource -{ - internal NefsInjectSource(string dataFilePath, string nefsInjectFilePath) - : base(dataFilePath) - { - NefsInjectFilePath = nefsInjectFilePath ?? throw new ArgumentNullException(nameof(nefsInjectFilePath)); - } - - /// - /// Path to the file containing the file data (i.e., game.dat, game.bin, etc.). - /// - public string DataFilePath => FilePath; - - /// - /// Path to the NefsInject file that contains the archive header and related offsets. - /// - public string NefsInjectFilePath { get; } -}