From 0486328093a212c29455413bf459ae9c1990c9b4 Mon Sep 17 00:00:00 2001 From: Amr Shaheen Date: Thu, 2 Nov 2023 22:19:21 +0200 Subject: [PATCH] Update 1.2.3 --- Forms/FrmMain.Designer.cs | 58 ++++++++++++++++---------------- Forms/FrmMain.cs | 71 ++++++++++++++++++++------------------- Forms/FrmMain.resx | 6 ++-- Helper/DDSToBitmap.cs | 4 +-- 4 files changed, 70 insertions(+), 69 deletions(-) diff --git a/Forms/FrmMain.Designer.cs b/Forms/FrmMain.Designer.cs index cc86060..ad26a4a 100644 --- a/Forms/FrmMain.Designer.cs +++ b/Forms/FrmMain.Designer.cs @@ -35,7 +35,8 @@ private void InitializeComponent() this.imageList1 = new System.Windows.Forms.ImageList(this.components); this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components); this.eportSelectedToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.replaceSelectedFileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.importfiles = new System.Windows.Forms.ToolStripMenuItem(); + this.exportRowToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.imageList2 = new System.Windows.Forms.ImageList(this.components); this.statusStrip1 = new System.Windows.Forms.StatusStrip(); this.toolStripStatusLabel1 = new System.Windows.Forms.ToolStripStatusLabel(); @@ -48,14 +49,13 @@ private void InitializeComponent() this.expotAllToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.toolsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.stringTableEditorToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.imageViewerToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.splitContainer1 = new System.Windows.Forms.SplitContainer(); - this.exportRowToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.treeView1 = new Controls.NTreeView(); this.listView1 = new Controls.NListView(); this.FileName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.Offset = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.Size = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.imageViewerToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.contextMenuStrip1.SuspendLayout(); this.statusStrip1.SuspendLayout(); this.menuStrip1.SuspendLayout(); @@ -75,7 +75,7 @@ private void InitializeComponent() // this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.eportSelectedToolStripMenuItem, - this.replaceSelectedFileToolStripMenuItem, + this.importfiles, this.exportRowToolStripMenuItem}); this.contextMenuStrip1.Name = "contextMenuStrip1"; this.contextMenuStrip1.Size = new System.Drawing.Size(230, 70); @@ -88,13 +88,24 @@ private void InitializeComponent() this.eportSelectedToolStripMenuItem.Text = "Export Selected"; this.eportSelectedToolStripMenuItem.Click += new System.EventHandler(this.eportSelectedToolStripMenuItem_Click); // - // replaceSelectedFileToolStripMenuItem + // importfiles + // + this.importfiles.Enabled = false; + this.importfiles.Name = "importfiles"; + this.importfiles.Size = new System.Drawing.Size(229, 22); + this.importfiles.Text = "Import Files"; + this.importfiles.Click += new System.EventHandler(this.importfiles_Click); // - this.replaceSelectedFileToolStripMenuItem.Enabled = false; - this.replaceSelectedFileToolStripMenuItem.Name = "replaceSelectedFileToolStripMenuItem"; - this.replaceSelectedFileToolStripMenuItem.Size = new System.Drawing.Size(180, 22); - this.replaceSelectedFileToolStripMenuItem.Text = "Replace selected file"; - this.replaceSelectedFileToolStripMenuItem.Click += new System.EventHandler(this.replaceSelectedFileToolStripMenuItem_Click); + // exportRowToolStripMenuItem + // + this.exportRowToolStripMenuItem.Name = "exportRowToolStripMenuItem"; + this.exportRowToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Alt) + | System.Windows.Forms.Keys.Shift) + | System.Windows.Forms.Keys.T))); + this.exportRowToolStripMenuItem.Size = new System.Drawing.Size(229, 22); + this.exportRowToolStripMenuItem.Text = "Export Row"; + this.exportRowToolStripMenuItem.Visible = false; + this.exportRowToolStripMenuItem.Click += new System.EventHandler(this.exportRowToolStripMenuItem_Click); // // imageList2 // @@ -197,6 +208,13 @@ private void InitializeComponent() this.stringTableEditorToolStripMenuItem.Text = "StringTable Editor"; this.stringTableEditorToolStripMenuItem.Click += new System.EventHandler(this.stringTableEditorToolStripMenuItem_Click); // + // imageViewerToolStripMenuItem + // + this.imageViewerToolStripMenuItem.Name = "imageViewerToolStripMenuItem"; + this.imageViewerToolStripMenuItem.Size = new System.Drawing.Size(166, 22); + this.imageViewerToolStripMenuItem.Text = "Image Viewer"; + this.imageViewerToolStripMenuItem.Click += new System.EventHandler(this.imageViewerToolStripMenuItem_Click); + // // splitContainer1 // this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill; @@ -214,17 +232,6 @@ private void InitializeComponent() this.splitContainer1.SplitterDistance = 264; this.splitContainer1.TabIndex = 2; // - // exportRowToolStripMenuItem - // - this.exportRowToolStripMenuItem.Name = "exportRowToolStripMenuItem"; - this.exportRowToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Alt) - | System.Windows.Forms.Keys.Shift) - | System.Windows.Forms.Keys.T))); - this.exportRowToolStripMenuItem.Size = new System.Drawing.Size(229, 22); - this.exportRowToolStripMenuItem.Text = "Export Row"; - this.exportRowToolStripMenuItem.Visible = false; - this.exportRowToolStripMenuItem.Click += new System.EventHandler(this.exportRowToolStripMenuItem_Click); - // // treeView1 // this.treeView1.BackColor = System.Drawing.SystemColors.Window; @@ -283,13 +290,6 @@ private void InitializeComponent() this.Size.Text = "Size"; this.Size.Width = 193; // - // imageViewerToolStripMenuItem - // - this.imageViewerToolStripMenuItem.Name = "imageViewerToolStripMenuItem"; - this.imageViewerToolStripMenuItem.Size = new System.Drawing.Size(180, 22); - this.imageViewerToolStripMenuItem.Text = "Image Viewer"; - this.imageViewerToolStripMenuItem.Click += new System.EventHandler(this.imageViewerToolStripMenuItem_Click); - // // FrmMain // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -340,7 +340,7 @@ private void TreeView1_BeforeClear(object sender, System.EventArgs e) private System.Windows.Forms.ToolStripMenuItem expotAllToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem toolsToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem stringTableEditorToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem replaceSelectedFileToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem importfiles; private System.Windows.Forms.ToolStripMenuItem saveToolStripMenuItem; private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel1; private System.Windows.Forms.ToolStripMenuItem exportRowToolStripMenuItem; diff --git a/Forms/FrmMain.cs b/Forms/FrmMain.cs index b34198c..640e1b1 100644 --- a/Forms/FrmMain.cs +++ b/Forms/FrmMain.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using System.IO; +using System.Linq; using System.Windows.Forms; namespace alan_wake_2_rmdtoc_Tool @@ -32,6 +33,10 @@ private void treeView1_AfterSelect(object sender, TreeViewEventArgs e) foreach (var item in Tag.Files) { var LVitem = new ListViewItem(); + + if (item.IsEdited) + LVitem.Font = new System.Drawing.Font(LVitem.Font, System.Drawing.FontStyle.Bold); + LVitem.Text = item.Name; LVitem.Tag = item; LVitem.ImageIndex = 0; @@ -77,7 +82,7 @@ private void openToolStripMenuItem_Click(object sender, EventArgs e) saveToolStripMenuItem.Enabled = true; expotAllToolStripMenuItem.Enabled = true; - replaceSelectedFileToolStripMenuItem.Enabled = true; + importfiles.Enabled = true; eportSelectedToolStripMenuItem.Enabled = true; toolToolStripMenuItem.Enabled = true; } @@ -106,39 +111,7 @@ private void stringTableEditorToolStripMenuItem_Click(object sender, EventArgs e new FrmStringTable().Show(); } - private void replaceSelectedFileToolStripMenuItem_Click(object sender, EventArgs e) - { - if (listView1.SelectedItems.Count == 0) - { - MessageBox.Show("No file selected!"); - return; - } - - if (listView1.SelectedItems.Count > 1) - { - MessageBox.Show("Select only one file!"); - return; - } - - var ofd = new OpenFileDialog(); - ofd.Filter = "All Files|*.*"; - ofd.Title = "Select File"; - if (ofd.ShowDialog() != DialogResult.OK) - return; - - if (!File.Exists(ofd.FileName)) - { - MessageBox.Show("File not found!"); - return; - } - - var fileInfo = listView1.SelectedItems[0].Tag as FileInfo; - fileInfo.IsEdited = true; - fileInfo.NewFileBytes = File.ReadAllBytes(ofd.FileName); - Modifiedtrmdtoc.Add(fileInfo.Rmdtoc); - - MessageBox.Show("Done!, Don't forget to save!"); - } + private void saveToolStripMenuItem_Click(object sender, EventArgs e) { @@ -223,5 +196,35 @@ private void imageViewerToolStripMenuItem_Click(object sender, EventArgs e) { new frmImageViewer().Show(); } + + private void importfiles_Click(object sender, EventArgs e) + { + MessageBox.Show("Make sure that the files names in this list"); + var ofd = new OpenFileDialog(); + ofd.Filter = "All Files|*.*"; + ofd.Multiselect = true; + ofd.Title = "Select Files"; + if (ofd.ShowDialog() != DialogResult.OK) + return; + var ImportedFiles = 0; + foreach(var FilePath in ofd.FileNames) + { + var item= listView1.Items.Cast().FirstOrDefault(x => x.Text == Path.GetFileName(FilePath)); + if (item == null) + { + MessageBox.Show($"File {Path.GetFileName(FilePath)} not found in list, the file will be ignored"); + continue; + } + var fileInfo = item.Tag as FileInfo; + fileInfo.IsEdited = true; + fileInfo.NewFileBytes = File.ReadAllBytes(FilePath); + Modifiedtrmdtoc.Add(fileInfo.Rmdtoc); + ImportedFiles++; + + item.Font= new System.Drawing.Font(item.Font, System.Drawing.FontStyle.Bold); + } + + MessageBox.Show($"Done! {ImportedFiles} files imported"); + } } } diff --git a/Forms/FrmMain.resx b/Forms/FrmMain.resx index f0b684c..932e9b4 100644 --- a/Forms/FrmMain.resx +++ b/Forms/FrmMain.resx @@ -125,7 +125,7 @@ AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG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oCmrUAAUIBTQE+BwABPgMA ASgDAAFAAwABEAMAAQEBAAEBBQABgBcAA/8BAAHzAf8GAAHnAf8GAAHgAQcGAAHgAQ8GAAHgAQ8GAAHg AQ8GAAHgAQ8GAAHgAR8GAAHgAR8GAAHgAR8GAAHgAR8GAAHgAR8GAAHgAR8GAAHgAR8GAAL/BgAC/wYA @@ -172,7 +172,7 @@ AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0 ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAAC0 - BwAAAk1TRnQBSQFMAwEBAAE8AQIBPAECARABAAEQAQAE/wEJAQAI/wFCAU0BNgEEBgABNgEEAgABKAMA + BwAAAk1TRnQBSQFMAwEBAAFUAQIBVAECARABAAEQAQAE/wEJAQAI/wFCAU0BNgEEBgABNgEEAgABKAMA AUADAAEQAwABAQEAAQgGAAEEGAABgAIAAYADAAKAAQABgAMAAYABAAGAAQACgAIAA8ABAAHAAdwBwAEA AfABygGmAQABMwUAATMBAAEzAQABMwEAAjMCAAMWAQADHAEAAyIBAAMpAQADVQEAA00BAANCAQADOQEA AYABfAH/AQACUAH/AQABkwEAAdYBAAH/AewBzAEAAcYB1gHvAQAB1gLnAQABkAGpAa0CAAH/ATMDAAFm diff --git a/Helper/DDSToBitmap.cs b/Helper/DDSToBitmap.cs index 1adb009..58c11f9 100644 --- a/Helper/DDSToBitmap.cs +++ b/Helper/DDSToBitmap.cs @@ -225,13 +225,11 @@ private static Bitmap UncompressDXT3(IStream stream, int w, int h) { using (BinaryWriter bitmapBW = new BinaryWriter(bitmapStream)) { - int ptr = 0; for (int s = 0; s < h; s += 4) { for (int t = 0; t < w; t += 4) { - blockStorage = stream.GetBytes(bufferSize, false, ptr); - ptr += bufferSize; + blockStorage = stream.GetBytes(bufferSize); { int color0 = blockStorage[8] | blockStorage[9] << 8; int color1 = blockStorage[10] | blockStorage[11] << 8;