diff --git a/Project/About.Designer.cs b/Project/About.Designer.cs index b2501fe..0498fe4 100644 --- a/Project/About.Designer.cs +++ b/Project/About.Designer.cs @@ -30,13 +30,15 @@ private void InitializeComponent() { this.labelAbout = new System.Windows.Forms.Label(); this.aboutLabel = new System.Windows.Forms.Label(); + this.vmuBox = new System.Windows.Forms.PictureBox(); + ((System.ComponentModel.ISupportInitialize)(this.vmuBox)).BeginInit(); this.SuspendLayout(); // // labelAbout // this.labelAbout.AutoSize = true; this.labelAbout.Font = new System.Drawing.Font("Microsoft Sans Serif", 21.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.labelAbout.Location = new System.Drawing.Point(9, 9); + this.labelAbout.Location = new System.Drawing.Point(10, 12); this.labelAbout.Name = "labelAbout"; this.labelAbout.Size = new System.Drawing.Size(292, 33); this.labelAbout.TabIndex = 0; @@ -46,23 +48,36 @@ private void InitializeComponent() // this.aboutLabel.AutoSize = true; this.aboutLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.aboutLabel.Location = new System.Drawing.Point(12, 42); + this.aboutLabel.Location = new System.Drawing.Point(13, 47); this.aboutLabel.Name = "aboutLabel"; this.aboutLabel.Size = new System.Drawing.Size(155, 20); this.aboutLabel.TabIndex = 1; this.aboutLabel.Text = "Created by derplayer"; // + // vmuBox + // + this.vmuBox.Cursor = System.Windows.Forms.Cursors.Hand; + this.vmuBox.Location = new System.Drawing.Point(355, 12); + this.vmuBox.Name = "vmuBox"; + this.vmuBox.Size = new System.Drawing.Size(48, 32); + this.vmuBox.TabIndex = 2; + this.vmuBox.TabStop = false; + this.vmuBox.Click += new System.EventHandler(this.vmuBox_Click); + // // About // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(459, 76); + this.BackColor = System.Drawing.SystemColors.HighlightText; + this.ClientSize = new System.Drawing.Size(415, 76); + this.Controls.Add(this.vmuBox); this.Controls.Add(this.aboutLabel); this.Controls.Add(this.labelAbout); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; this.Name = "About"; this.Text = "About"; this.Load += new System.EventHandler(this.About_Load); + ((System.ComponentModel.ISupportInitialize)(this.vmuBox)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); @@ -71,5 +86,6 @@ private void InitializeComponent() #endregion private System.Windows.Forms.Label aboutLabel; public System.Windows.Forms.Label labelAbout; + private System.Windows.Forms.PictureBox vmuBox; } } \ No newline at end of file diff --git a/Project/About.cs b/Project/About.cs index d31da13..0ca0258 100644 --- a/Project/About.cs +++ b/Project/About.cs @@ -1,11 +1,16 @@ -using System; +using ShenmueHDTools; +using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; +using System.Diagnostics; using System.Drawing; using System.Globalization; +using System.IO; using System.Linq; +using System.Runtime.InteropServices; using System.Text; +using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; @@ -13,6 +18,8 @@ namespace Shenmue_HD_Tools { public partial class About : Form { + Random random = new Random(); + public About() { InitializeComponent(); @@ -20,7 +27,94 @@ public About() private void About_Load(object sender, EventArgs e) { + this.labelAbout.Text += ShenmueHDTools.Version.actualVerison.ToString(CultureInfo.InvariantCulture); + this.vmuBox.Image = null; + this.vmuBox.Image = Resources.gfx[random.Next(0, Resources.gfx.Count)]; + + try + { + string filePath = Path.Combine(Path.GetTempPath(), random.Next(0, 8) + ".bin"); + Play(filePath, "playThread"); + } + catch (Exception) + { + + } + + } + + [DllImport("winmm.dll")] + static extern Int32 mciSendString(String command, StringBuilder buffer, + Int32 bufferSize, IntPtr hwndCallback); + + public static Dictionary playing = new Dictionary(); + + public static void Play(String fileName, String alias) + { + if (playing.ContainsKey(alias)) + throw new Exception("alias '" + alias + "' is already playing"); + + playing.Add(alias, false); + + Thread stoppingThread = new Thread(() => { StartAndStopWithDelay(fileName, alias); }); + stoppingThread.Start(); + } + + public static void StopFromOtherThread(String alias) + { + if (!playing.ContainsKey(alias)) + return; + + playing[alias] = true; + } + + public static bool isPlaying(String alias) + { + return playing.ContainsKey(alias); + } + + public static void StartAndStopWithDelay(String fileName, String alias) + { + mciSendString("open " + fileName + " type sequencer alias " + alias, null, 0, new IntPtr()); + mciSendString("play " + alias, null, 0, new IntPtr()); + + StringBuilder result = new StringBuilder(100); + mciSendString("set " + alias + " time format milliseconds", null, 0, new IntPtr()); + mciSendString("status " + alias + " length", result, 100, new IntPtr()); + + int LengthInMilliseconds; + Int32.TryParse(result.ToString(), out LengthInMilliseconds); + + Stopwatch timer = new Stopwatch(); + timer.Start(); + + while (timer.ElapsedMilliseconds < LengthInMilliseconds && !playing[alias]) + { + + } + + timer.Stop(); + + Stop(alias); + } + + public static void Stop(String alias) + { + if (!playing.ContainsKey(alias)) + throw new Exception("alias '" + alias + "' is already stopped"); + + // Execute calls to close and stop the player, on the same thread as the play and open calls + mciSendString("stop " + alias, null, 0, new IntPtr()); + mciSendString("close " + alias, null, 0, new IntPtr()); + + playing.Remove(alias); + } + + private void vmuBox_Click(object sender, EventArgs e) + { + this.vmuBox.Image = null; + this.vmuBox.Image = Resources.gfx[random.Next(0, Resources.gfx.Count)]; } } } diff --git a/Project/Form1.Designer.cs b/Project/Form1.Designer.cs index ac582ae..21b965d 100644 --- a/Project/Form1.Designer.cs +++ b/Project/Form1.Designer.cs @@ -46,6 +46,11 @@ private void InitializeComponent() this.helpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.howToModifyAFileInVFSToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.aboutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.statusStrip1 = new System.Windows.Forms.StatusStrip(); + this.toolStripStatusLabel1 = new System.Windows.Forms.ToolStripStatusLabel(); + this.button1 = new System.Windows.Forms.Button(); + this.labelMessage = new System.Windows.Forms.Label(); + this.refreshButton = new System.Windows.Forms.Button(); this.listViewMain = new System.Windows.Forms.ListView(); this.indexHeader = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.beginHeader = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); @@ -54,13 +59,9 @@ private void InitializeComponent() this.hashHeaderOne = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.hashHeaderTwo = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.modifiedFlag = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.fileExt = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.hashedPath = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.statusStrip1 = new System.Windows.Forms.StatusStrip(); - this.toolStripStatusLabel1 = new System.Windows.Forms.ToolStripStatusLabel(); - this.button1 = new System.Windows.Forms.Button(); - this.labelMessage = new System.Windows.Forms.Label(); this.dataCollectorBindingSource = new System.Windows.Forms.BindingSource(this.components); - this.refreshButton = new System.Windows.Forms.Button(); this.mainMenuStrip.SuspendLayout(); this.statusStrip1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.dataCollectorBindingSource)).BeginInit(); @@ -175,8 +176,8 @@ private void InitializeComponent() // cRC32FromLookupToolStripMenuItem // this.cRC32FromLookupToolStripMenuItem.Name = "cRC32FromLookupToolStripMenuItem"; - this.cRC32FromLookupToolStripMenuItem.Size = new System.Drawing.Size(130, 22); - this.cRC32FromLookupToolStripMenuItem.Text = "HASH Test"; + this.cRC32FromLookupToolStripMenuItem.Size = new System.Drawing.Size(103, 22); + this.cRC32FromLookupToolStripMenuItem.Text = "Show"; this.cRC32FromLookupToolStripMenuItem.Click += new System.EventHandler(this.cRC32FromLookupToolStripMenuItem_Click); // // helpToolStripMenuItem @@ -203,6 +204,58 @@ private void InitializeComponent() this.aboutToolStripMenuItem.Text = "About"; this.aboutToolStripMenuItem.Click += new System.EventHandler(this.aboutToolStripMenuItem_Click); // + // statusStrip1 + // + this.statusStrip1.BackColor = System.Drawing.SystemColors.ButtonFace; + this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.toolStripStatusLabel1}); + this.statusStrip1.Location = new System.Drawing.Point(0, 324); + this.statusStrip1.Name = "statusStrip1"; + this.statusStrip1.Size = new System.Drawing.Size(879, 22); + this.statusStrip1.TabIndex = 7; + this.statusStrip1.Text = "statusStrip1"; + this.statusStrip1.ItemClicked += new System.Windows.Forms.ToolStripItemClickedEventHandler(this.statusStrip1_ItemClicked); + // + // toolStripStatusLabel1 + // + this.toolStripStatusLabel1.Name = "toolStripStatusLabel1"; + this.toolStripStatusLabel1.Size = new System.Drawing.Size(42, 17); + this.toolStripStatusLabel1.Text = "Ready!"; + this.toolStripStatusLabel1.Click += new System.EventHandler(this.toolStripStatusLabel1_Click); + // + // button1 + // + this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.button1.Location = new System.Drawing.Point(829, 324); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(27, 22); + this.button1.TabIndex = 11; + this.button1.Text = "?"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click); + // + // labelMessage + // + this.labelMessage.Anchor = System.Windows.Forms.AnchorStyles.None; + this.labelMessage.AutoSize = true; + this.labelMessage.Font = new System.Drawing.Font("Microsoft Sans Serif", 26.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.labelMessage.Location = new System.Drawing.Point(211, 155); + this.labelMessage.Name = "labelMessage"; + this.labelMessage.Size = new System.Drawing.Size(446, 39); + this.labelMessage.TabIndex = 13; + this.labelMessage.Text = "Please load a TAD/TAC file!"; + // + // refreshButton + // + this.refreshButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.refreshButton.Location = new System.Drawing.Point(769, 324); + this.refreshButton.Name = "refreshButton"; + this.refreshButton.Size = new System.Drawing.Size(54, 22); + this.refreshButton.TabIndex = 14; + this.refreshButton.Text = "Refresh"; + this.refreshButton.UseVisualStyleBackColor = true; + this.refreshButton.Click += new System.EventHandler(this.refreshButton_Click); + // // listViewMain // this.listViewMain.Activation = System.Windows.Forms.ItemActivation.OneClick; @@ -215,12 +268,13 @@ private void InitializeComponent() this.hashHeaderOne, this.hashHeaderTwo, this.modifiedFlag, + this.fileExt, this.hashedPath}); this.listViewMain.Dock = System.Windows.Forms.DockStyle.Fill; this.listViewMain.FullRowSelect = true; - this.listViewMain.MultiSelect = false; this.listViewMain.HideSelection = false; this.listViewMain.Location = new System.Drawing.Point(0, 24); + this.listViewMain.MultiSelect = false; this.listViewMain.Name = "listViewMain"; this.listViewMain.ShowItemToolTips = true; this.listViewMain.Size = new System.Drawing.Size(879, 322); @@ -230,7 +284,6 @@ private void InitializeComponent() this.listViewMain.View = System.Windows.Forms.View.Details; this.listViewMain.Visible = false; this.listViewMain.SelectedIndexChanged += new System.EventHandler(this.listViewMain_SelectedIndexChanged); - this.listViewMain.DoubleClick += new System.EventHandler(this.listViewMain_Click); this.listViewMain.MouseDown += new System.Windows.Forms.MouseEventHandler(this.listView1_MouseDown); // // indexHeader @@ -265,63 +318,16 @@ private void InitializeComponent() // this.modifiedFlag.Text = "Modified"; // + // fileExt + // + this.fileExt.Text = "Extenstion"; + this.fileExt.Width = 80; + // // hashedPath // this.hashedPath.Text = "Path"; this.hashedPath.Width = 78; // - // statusStrip1 - // - this.statusStrip1.BackColor = System.Drawing.SystemColors.ButtonFace; - this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.toolStripStatusLabel1}); - this.statusStrip1.Location = new System.Drawing.Point(0, 324); - this.statusStrip1.Name = "statusStrip1"; - this.statusStrip1.Size = new System.Drawing.Size(879, 22); - this.statusStrip1.TabIndex = 7; - this.statusStrip1.Text = "statusStrip1"; - this.statusStrip1.ItemClicked += new System.Windows.Forms.ToolStripItemClickedEventHandler(this.statusStrip1_ItemClicked); - // - // toolStripStatusLabel1 - // - this.toolStripStatusLabel1.Name = "toolStripStatusLabel1"; - this.toolStripStatusLabel1.Size = new System.Drawing.Size(42, 17); - this.toolStripStatusLabel1.Text = "Ready!"; - this.toolStripStatusLabel1.Click += new System.EventHandler(this.toolStripStatusLabel1_Click); - // - // button1 - // - this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.button1.Location = new System.Drawing.Point(829, 324); - this.button1.Name = "button1"; - this.button1.Size = new System.Drawing.Size(27, 22); - this.button1.TabIndex = 11; - this.button1.Text = "?"; - this.button1.UseVisualStyleBackColor = true; - this.button1.Click += new System.EventHandler(this.button1_Click); - // - // labelMessage - // - this.labelMessage.Anchor = System.Windows.Forms.AnchorStyles.None; - this.labelMessage.AutoSize = true; - this.labelMessage.Font = new System.Drawing.Font("Microsoft Sans Serif", 26.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.labelMessage.Location = new System.Drawing.Point(211, 155); - this.labelMessage.Name = "labelMessage"; - this.labelMessage.Size = new System.Drawing.Size(446, 39); - this.labelMessage.TabIndex = 13; - this.labelMessage.Text = "Please load a TAD/TAC file!"; - // - // refreshButton - // - this.refreshButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.refreshButton.Location = new System.Drawing.Point(769, 324); - this.refreshButton.Name = "refreshButton"; - this.refreshButton.Size = new System.Drawing.Size(54, 22); - this.refreshButton.TabIndex = 14; - this.refreshButton.Text = "Refresh"; - this.refreshButton.UseVisualStyleBackColor = true; - this.refreshButton.Click += new System.EventHandler(this.refreshButton_Click); - // // MainWindow // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -350,6 +356,7 @@ private void InitializeComponent() this.ResumeLayout(false); this.PerformLayout(); + listViewColumnSorter = new ListViewColumnSorterExt(listViewMain); } #endregion @@ -384,6 +391,8 @@ private void InitializeComponent() public System.Windows.Forms.ColumnHeader hashedPath; private System.Windows.Forms.Button refreshButton; public System.Windows.Forms.ColumnHeader modifiedFlag; + public System.Windows.Forms.ColumnHeader fileExt; + private ListViewColumnSorterExt listViewColumnSorter; } } diff --git a/Project/Form1.cs b/Project/Form1.cs index 6efe395..faeb4c8 100644 --- a/Project/Form1.cs +++ b/Project/Form1.cs @@ -14,6 +14,7 @@ using System.Runtime.Serialization.Json; using System.Globalization; using static System.Windows.Forms.ListViewItem; +using System.Collections; namespace Shenmue_HD_Tools { @@ -104,6 +105,8 @@ private void test1ToolStripMenuItem_Click(object sender, EventArgs e) private void cRC32FromLookupToolStripMenuItem_Click(object sender, EventArgs e) { + Loading test = new Loading(); + test.ShowDialog(); } private void replaceFileToolStripMenuItem_Click(object sender, EventArgs e) @@ -128,50 +131,57 @@ private void listViewMain_SelectedIndexChanged(object sender, EventArgs e) private void listView1_MouseDown(object sender, MouseEventArgs e) { - bool match = false; - - if (e.Button == System.Windows.Forms.MouseButtons.Right) + try { - foreach (ListViewItem item in listViewMain.Items) - { + bool match = false; - if (item.Bounds.Contains(new Point(e.X, e.Y))) + if (e.Button == System.Windows.Forms.MouseButtons.Right) + { + foreach (ListViewItem item in listViewMain.Items) { - string allCollected = ""; - foreach (ListViewSubItem subItem in item.SubItems) + + if (item.Bounds.Contains(new Point(e.X, e.Y))) { - allCollected += subItem.Text + ", "; - } + string allCollected = ""; + foreach (ListViewSubItem subItem in item.SubItems) + { + allCollected += subItem.Text + ", "; + } - var m = new ContextMenu(); + var m = new ContextMenu(); - var fileHash = new MenuItem("Copy FileHash", new System.EventHandler(this.listViewMain_Click)); - fileHash.Tag = item.SubItems[4].Text; + var fileHash = new MenuItem("Copy FileHash", new System.EventHandler(this.listViewMain_Click)); + fileHash.Tag = item.SubItems[4].Text; - var fileHashHalf = new MenuItem("Copy FileHash (half)", new System.EventHandler(this.listViewMain_Click)); - fileHashHalf.Tag = item.SubItems[4].Text.Substring(2, 8); + var fileHashHalf = new MenuItem("Copy FileHash (half)", new System.EventHandler(this.listViewMain_Click)); + fileHashHalf.Tag = item.SubItems[4].Text.Substring(2, 8); - var fileAll = new MenuItem("Copy All", new System.EventHandler(this.listViewMain_Click)); - fileAll.Tag = allCollected; + var fileAll = new MenuItem("Copy All", new System.EventHandler(this.listViewMain_Click)); + fileAll.Tag = allCollected; - m.MenuItems.Add(fileHash); - m.MenuItems.Add(fileHashHalf); - m.MenuItems.Add(fileAll); + m.MenuItems.Add(fileHash); + m.MenuItems.Add(fileHashHalf); + m.MenuItems.Add(fileAll); - listViewMain.ContextMenu = m; - match = true; - break; + listViewMain.ContextMenu = m; + match = true; + break; + } + } + if (match) + { + listViewMain.ContextMenu.Show(listViewMain, new Point(e.X, e.Y)); + } + else + { + //Show listViews context menu } - } - if (match) - { - listViewMain.ContextMenu.Show(listViewMain, new Point(e.X, e.Y)); - } - else - { - //Show listViews context menu - } + } + } + catch (Exception) + { + return; } } @@ -308,4 +318,138 @@ public static TType DeSerialize(string json) } } } + + public class ListViewColumnSorterExt : IComparer + { + /// + /// Specifies the column to be sorted + /// + private int ColumnToSort; + /// + /// Specifies the order in which to sort (i.e. 'Ascending'). + /// + private SortOrder OrderOfSort; + /// + /// Case insensitive comparer object + /// + private CaseInsensitiveComparer ObjectCompare; + + private ListView listView; + /// + /// Class constructor. Initializes various elements + /// + public ListViewColumnSorterExt(ListView lv) + { + listView = lv; + listView.ListViewItemSorter = this; + listView.ColumnClick += new ColumnClickEventHandler(listView_ColumnClick); + + // Initialize the column to '0' + ColumnToSort = 0; + + // Initialize the sort order to 'none' + OrderOfSort = SortOrder.None; + + // Initialize the CaseInsensitiveComparer object + ObjectCompare = new CaseInsensitiveComparer(); + } + + private void listView_ColumnClick(object sender, ColumnClickEventArgs e) + { + ReverseSortOrderAndSort(e.Column, (ListView)sender); + } + + /// + /// This method is inherited from the IComparer interface. It compares the two objects passed using a case insensitive comparison. + /// + /// First object to be compared + /// Second object to be compared + /// The result of the comparison. "0" if equal, negative if 'x' is less than 'y' and positive if 'x' is greater than 'y' + public int Compare(object x, object y) + { + int compareResult; + ListViewItem listviewX, listviewY; + + // Cast the objects to be compared to ListViewItem objects + listviewX = (ListViewItem)x; + listviewY = (ListViewItem)y; + + // Compare the two items + compareResult = ObjectCompare.Compare(listviewX.SubItems[ColumnToSort].Text, listviewY.SubItems[ColumnToSort].Text); + + // Calculate correct return value based on object comparison + if (OrderOfSort == SortOrder.Ascending) + { + // Ascending sort is selected, return normal result of compare operation + return compareResult; + } + else if (OrderOfSort == SortOrder.Descending) + { + // Descending sort is selected, return negative result of compare operation + return (-compareResult); + } + else + { + // Return '0' to indicate they are equal + return 0; + } + } + + /// + /// Gets or sets the number of the column to which to apply the sorting operation (Defaults to '0'). + /// + private int SortColumn + { + set + { + ColumnToSort = value; + } + get + { + return ColumnToSort; + } + } + + /// + /// Gets or sets the order of sorting to apply (for example, 'Ascending' or 'Descending'). + /// + private SortOrder Order + { + set + { + OrderOfSort = value; + } + get + { + return OrderOfSort; + } + } + + private void ReverseSortOrderAndSort(int column, ListView lv) + { + // Determine if clicked column is already the column that is being sorted. + if (column == this.SortColumn) + { + // Reverse the current sort direction for this column. + if (this.Order == SortOrder.Ascending) + { + this.Order = SortOrder.Descending; + } + else + { + this.Order = SortOrder.Ascending; + } + } + else + { + // Set the column number that is to be sorted; default to ascending. + this.SortColumn = column; + this.Order = SortOrder.Ascending; + } + + // Perform the sort with these new sort options. + lv.Sort(); + } + } + } diff --git a/Project/Loading.Designer.cs b/Project/Loading.Designer.cs new file mode 100644 index 0000000..0257601 --- /dev/null +++ b/Project/Loading.Designer.cs @@ -0,0 +1,83 @@ +namespace ShenmueHDTools +{ + partial class Loading + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.loadLabel = new System.Windows.Forms.Label(); + this.vmuBox = new System.Windows.Forms.PictureBox(); + ((System.ComponentModel.ISupportInitialize)(this.vmuBox)).BeginInit(); + this.SuspendLayout(); + // + // loadLabel + // + this.loadLabel.AutoSize = true; + this.loadLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 26.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.loadLabel.Location = new System.Drawing.Point(12, 9); + this.loadLabel.Name = "loadLabel"; + this.loadLabel.Size = new System.Drawing.Size(175, 39); + this.loadLabel.TabIndex = 0; + this.loadLabel.Text = "Working..."; + // + // vmuBox + // + this.vmuBox.Location = new System.Drawing.Point(193, 12); + this.vmuBox.Name = "vmuBox"; + this.vmuBox.Size = new System.Drawing.Size(32, 32); + this.vmuBox.TabIndex = 1; + this.vmuBox.TabStop = false; + // + // Loading + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.BackColor = System.Drawing.SystemColors.ButtonFace; + this.ClientSize = new System.Drawing.Size(232, 57); + this.ControlBox = false; + this.Controls.Add(this.vmuBox); + this.Controls.Add(this.loadLabel); + this.Cursor = System.Windows.Forms.Cursors.WaitCursor; + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; + this.MaximizeBox = false; + this.Name = "Loading"; + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.Text = "Please wait!"; + this.UseWaitCursor = true; + this.Load += new System.EventHandler(this.Loading_Load); + ((System.ComponentModel.ISupportInitialize)(this.vmuBox)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Label loadLabel; + private System.Windows.Forms.PictureBox vmuBox; + } +} \ No newline at end of file diff --git a/Project/Loading.cs b/Project/Loading.cs new file mode 100644 index 0000000..93dc552 --- /dev/null +++ b/Project/Loading.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace ShenmueHDTools +{ + public partial class Loading : Form + { + Random random = new Random(); + + public Loading() + { + InitializeComponent(); + } + + private void Loading_Load(object sender, EventArgs e) + { + this.vmuBox.Image = null; + this.vmuBox.Image = Resources.load[random.Next(0, Resources.load.Count)]; + } + } +} diff --git a/Project/Loading.resx b/Project/Loading.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/Project/Loading.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Project/Main/Core.cs b/Project/Main/Core.cs index b62c884..9db6e44 100644 --- a/Project/Main/Core.cs +++ b/Project/Main/Core.cs @@ -9,6 +9,8 @@ using System.IO.Compression; using ShenmueHDTools.Main; using ShenmueHDTools.Main.DataStructure; +using System.Threading; +using ShenmueHDTools; namespace Shenmue_HD_Tools.ShenmueHD { @@ -16,6 +18,7 @@ class Core { public static string loadedVFS { get; set; } private static DataLogic data { get; set; } = new DataLogic(); + private Thread loadingThread; public void Main() { @@ -29,7 +32,7 @@ public void Main() if (newPathDlg.ShowDialog() == DialogResult.OK) { - + LockGUI(); file = newPathDlg.FileName; directory = Path.GetDirectoryName(file); loadedVFS = file; @@ -37,6 +40,7 @@ public void Main() List readedFiles = data.LoadVFS(file, directory); Program.MainWindowCore.toolStripStatusLabel1.Text = "Loading finished! (" + newPathDlg.FileName + ", " + readedFiles.Count + " files)"; + UnlockGUI(); Program.MainWindowCore.listViewMain.Visible = true; } } @@ -58,6 +62,7 @@ public void ImportProj() if (newPathDlg.ShowDialog() == DialogResult.OK) { + LockGUI(); file = newPathDlg.FileName; directory = Path.GetDirectoryName(file); loadedVFS = file; @@ -65,6 +70,7 @@ public void ImportProj() List readedFiles = data.LoadCache(file, directory); Program.MainWindowCore.toolStripStatusLabel1.Text = "Loading finished! (" + newPathDlg.FileName + ", " + readedFiles.Count + " files)"; + UnlockGUI(); Program.MainWindowCore.listViewMain.Visible = true; } } @@ -80,7 +86,9 @@ public void Save() { if (loadedVFS != null) { + LockGUI(); data.SaveVFS(loadedVFS); + UnlockGUI(); data.UpdateGUI(); Program.MainWindowCore.toolStripStatusLabel1.Text = "Tac/Tad saved!"; } @@ -106,7 +114,9 @@ public void SaveAs() if (newSavePathDlg.ShowDialog() == DialogResult.OK) { + LockGUI(); data.SaveVFS(newSavePathDlg.FileName); + UnlockGUI(); Program.MainWindowCore.toolStripStatusLabel1.Text = "Tac/Tad saved!"; } } @@ -132,8 +142,10 @@ public void Export() if (newSavePathDlg.ShowDialog() == DialogResult.OK) { + LockGUI(); data.Export(newSavePathDlg.FileName); Program.MainWindowCore.toolStripStatusLabel1.Text = "Export executed!"; + UnlockGUI(); } } else @@ -159,5 +171,17 @@ public void UpdateGUI() } } + public void LockGUI() + { + loadingThread = new Thread(() => new Loading().ShowDialog()); + Program.MainWindowCore.Hide(); + loadingThread.Start(); + } + + public void UnlockGUI() + { + loadingThread.Abort(); + Program.MainWindowCore.Show(); + } } } diff --git a/Project/Main/DataLogic.cs b/Project/Main/DataLogic.cs index 6f0517e..da5dc88 100644 --- a/Project/Main/DataLogic.cs +++ b/Project/Main/DataLogic.cs @@ -12,6 +12,7 @@ using Shenmue_HD_Tools; using ShenmueHDTools.Main.DataStructure; using System.Security.Cryptography; +using System.Threading; namespace ShenmueHDTools.Main { @@ -442,7 +443,6 @@ public void Export(string path) public void UpdateGUI() { - foreach (var item in Program.MainWindowCore.listViewMain.Items) { Program.MainWindowCore.listViewMain.Items.Remove((ListViewItem)item); @@ -460,16 +460,16 @@ public void UpdateGUI() lvi.SubItems.Add("0x" + (BitConverter.ToString((item.Meta.FileEnd)).Replace("-", ""))); lvi.SubItems.Add("0x" + (BitConverter.ToString((item.Hash1)).Replace("-", ""))); lvi.SubItems.Add("0x" + (BitConverter.ToString((item.Hash2)).Replace("-", ""))); - //lvi.SubItems.Add("0x" + (BitConverter.ToString((item.Meta.FileModified)).Replace("-", ""))); - lvi.SubItems.Add(item.Meta.FileModified.ToString()); - lvi.BeginEdit(); + lvi.SubItems.Add(item.Meta.FileExt); + lvi.SubItems.Add("?"); Program.MainWindowCore.listViewMain.Items.Add(lvi); Program.MainWindowCore.listViewMain.LabelEdit = true; } + Program.MainWindowCore.listViewMain.Items.Add(new ListViewItem()); Program.MainWindowCore.listViewMain.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize); } @@ -536,24 +536,67 @@ private string ExtFinder(byte[] dataArray) if (dataArray[i] == 0x00) nullCount++; } - if(nullCount == 0) return fileExt = ".csv"; + if(nullCount == 0) return fileExt = ".txt"; } catch (Exception) { return fileExt; } - // From now on it is just a "maybe" - - //FF8600 - if ( (dataArray[0] == 0xFF && dataArray[1] == 0x86 && dataArray[2] == 0x00) || (dataArray[0] == 0xFF && dataArray[1] == 0x00 && dataArray[2] == 0x40) || (dataArray[0] == 0xFF && dataArray[1] == 0xC5 && dataArray[2] == 0x40) || - (dataArray[0] == 0xFF && dataArray[1] == 0xEB && dataArray[2] == 0x40) + (dataArray[0] == 0xFF && dataArray[1] == 0xEB && dataArray[2] == 0x40) || + (dataArray[0] == 0x78 && dataArray[1] == 0x56 && dataArray[2] == 0x34) ) return ".fontdef"; + if ( + (dataArray[0] == 0x20 && dataArray[1] == 0x00 && dataArray[2] == 0x00) || + (dataArray[0] == 0x0A && dataArray[1] == 0x00 && dataArray[2] == 0x00) + ) return ".glyphs"; + + //Disk Container Detection + + if (semiIdentifier == "SCN") //MT5 + return ".scn"; + + if (semiIdentifier4 == "SCRL") //MT5 + return ".spr"; + + if ( + (dataArray[0] == 0x1F && dataArray[1] == 0x8B && dataArray[2] == 0x08 && dataArray[2] == 0x08) + ) return ".gz"; + + if (semiIdentifier4 == "ATTR") + return ".bin"; + + //PKS/PKF Detection + using (var ms = new MemoryStream(dataArray)) + { + ms.Seek(9, SeekOrigin.Begin); + int i = 0; //saftey check + while (true) + { + byte actualVar = (byte)ms.ReadByte(); + if (actualVar == 0x2E) //a dot + { + byte[] buffer = new byte[3]; + ms.Read(buffer, 0, 3); + + string semiArchiveIdentifier = Encoding.ASCII.GetString(buffer); + + if (semiArchiveIdentifier == "PKF") return ".pkf"; + if (semiArchiveIdentifier == "PKS") return ".pks"; + + break; + } + + i++; + if (i >= 24) break; + } + } + return fileExt; } diff --git a/Project/Program.cs b/Project/Program.cs index 34e1df6..442a3b1 100644 --- a/Project/Program.cs +++ b/Project/Program.cs @@ -1,4 +1,5 @@ -using System; +using ShenmueHDTools; +using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; @@ -24,7 +25,14 @@ static void Main() public static void Run() { + Resources.InitResources(); + Application.ApplicationExit += new EventHandler(OnApplicationExit); Application.Run(MainWindowCore); } + + private static void OnApplicationExit(object sender, EventArgs e) + { + About.StopFromOtherThread("playThread"); + } } } diff --git a/Project/Properties/DataSources/Initial_D_PSP_Tools.InitD.DataCollector.datasource b/Project/Properties/DataSources/Initial_D_PSP_Tools.InitD.DataCollector.datasource deleted file mode 100644 index c0a385c..0000000 --- a/Project/Properties/DataSources/Initial_D_PSP_Tools.InitD.DataCollector.datasource +++ /dev/null @@ -1,10 +0,0 @@ - - - - Shenmue_HD_Tools.ShenmueHD.DataCollector, Shenmue_HD_Tools, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null - \ No newline at end of file diff --git a/Project/Properties/Resources.Designer.cs b/Project/Properties/Resources.Designer.cs index 844e7b9..e6c6800 100644 --- a/Project/Properties/Resources.Designer.cs +++ b/Project/Properties/Resources.Designer.cs @@ -22,7 +22,7 @@ namespace ShenmueHDTools.Properties { [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Resources { + public class Resources { private static global::System.Resources.ResourceManager resourceMan; @@ -36,7 +36,7 @@ internal Resources() { /// Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird. /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { + public static global::System.Resources.ResourceManager ResourceManager { get { if (object.ReferenceEquals(resourceMan, null)) { global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ShenmueHDTools.Properties.Resources", typeof(Resources).Assembly); @@ -51,7 +51,7 @@ internal Resources() { /// Ressourcenzuordnungen, die diese stark typisierte Ressourcenklasse verwenden. /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { + public static global::System.Globalization.CultureInfo Culture { get { return resourceCulture; } @@ -59,5 +59,35 @@ internal Resources() { resourceCulture = value; } } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Byte[]. + /// + public static byte[] gfx { + get { + object obj = ResourceManager.GetObject("gfx", resourceCulture); + return ((byte[])(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Byte[]. + /// + public static byte[] load { + get { + object obj = ResourceManager.GetObject("load", resourceCulture); + return ((byte[])(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Byte[]. + /// + public static byte[] mid { + get { + object obj = ResourceManager.GetObject("mid", resourceCulture); + return ((byte[])(obj)); + } + } } } diff --git a/Project/Properties/Resources.resx b/Project/Properties/Resources.resx index af7dbeb..66095fc 100644 --- a/Project/Properties/Resources.resx +++ b/Project/Properties/Resources.resx @@ -46,7 +46,7 @@ mimetype: application/x-microsoft.net.object.binary.base64 value : The object must be serialized with - : System.Serialization.Formatters.Binary.BinaryFormatter + : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter : and then encoded with base64 encoding. mimetype: application/x-microsoft.net.object.soap.base64 @@ -60,6 +60,7 @@ : and then encoded with base64 encoding. --> + @@ -68,9 +69,10 @@ - + + @@ -85,9 +87,10 @@ - + + @@ -109,9 +112,19 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + ..\Resources\gfx;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + ..\Resources\load;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + ..\Resources\mid;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + \ No newline at end of file diff --git a/Project/Resources.cs b/Project/Resources.cs new file mode 100644 index 0000000..f15a7d3 --- /dev/null +++ b/Project/Resources.cs @@ -0,0 +1,91 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.IO; +using System.IO.Compression; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading.Tasks; + +namespace ShenmueHDTools +{ + public static class Resources + { + public static List gfx = new List(); + public static List load = new List(); + + public static List Unzip(byte[] zippedBuffer) + { + List tempList = new List(); + + using (var zippedStream = new MemoryStream(zippedBuffer)) + { + using (var archive = new ZipArchive(zippedStream)) + { + foreach (var entry in archive.Entries) + { + using (var unzippedEntryStream = entry.Open()) + { + using (var ms = new MemoryStream()) + { + unzippedEntryStream.CopyTo(ms); + var unzippedArray = ms.ToArray(); + tempList.Add(unzippedArray); + } + } + } + + return tempList; + } + } + } + + public static void InitResources() + { + using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("ShenmueHDTools.Resources.gfx")) + { + byte[] bytes = new byte[stream.Length]; stream.Position = 0; stream.Read(bytes, 0, (int)stream.Length); + var Res = Unzip(bytes); + + foreach (var Item in Res) + { + TypeConverter tc = TypeDescriptor.GetConverter(typeof(Image)); + Image newImage = (Image)tc.ConvertFrom(Item); + gfx.Add(newImage); + } + } + + using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("ShenmueHDTools.Resources.load")) + { + byte[] bytes = new byte[stream.Length]; stream.Position = 0; stream.Read(bytes, 0, (int)stream.Length); + var Res = Unzip(bytes); + + foreach (var Item in Res) + { + TypeConverter tc = TypeDescriptor.GetConverter(typeof(Image)); + Image newImage = (Image)tc.ConvertFrom(Item); + load.Add(newImage); + } + } + + using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("ShenmueHDTools.Resources.mid")) + { + byte[] bytes = new byte[stream.Length]; stream.Position = 0; stream.Read(bytes, 0, (int)stream.Length); + var Res = Unzip(bytes); + + int i = 0; + foreach (var Item in Res) + { + string filePath = Path.Combine(Path.GetTempPath(), i + ".bin"); + using (BinaryWriter writer = new BinaryWriter(new FileStream(filePath, FileMode.Create))) + { + writer.Write(Item, 0, Item.Length); + i++; + } + } + } + } + } +} diff --git a/Project/Resources/gfx b/Project/Resources/gfx new file mode 100644 index 0000000..cc65139 Binary files /dev/null and b/Project/Resources/gfx differ diff --git a/Project/Resources/load b/Project/Resources/load new file mode 100644 index 0000000..fc91805 Binary files /dev/null and b/Project/Resources/load differ diff --git a/Project/Resources/mid b/Project/Resources/mid new file mode 100644 index 0000000..6802a5f Binary files /dev/null and b/Project/Resources/mid differ diff --git a/Project/Shenmue_HD_Tools.csproj b/Project/Shenmue_HD_Tools.csproj index 1453f43..4ab3843 100644 --- a/Project/Shenmue_HD_Tools.csproj +++ b/Project/Shenmue_HD_Tools.csproj @@ -50,6 +50,7 @@ + @@ -74,6 +75,12 @@ Form1.cs + + Form + + + Loading.cs + @@ -83,6 +90,7 @@ + About.cs @@ -90,8 +98,11 @@ Form1.cs + + Loading.cs + - ResXFileCodeGenerator + PublicResXFileCodeGenerator Resources.Designer.cs Designer @@ -100,7 +111,6 @@ Resources.resx True - SettingsSingleFileGenerator Settings.Designer.cs @@ -110,6 +120,9 @@ Settings.settings True + + + @@ -128,6 +141,9 @@ false + + +