diff --git a/pk3DS/Main.Designer.cs b/pk3DS/Main.Designer.cs index 0590ca1..e0df99f 100644 --- a/pk3DS/Main.Designer.cs +++ b/pk3DS/Main.Designer.cs @@ -55,6 +55,7 @@ private void InitializeComponent() this.B_MoveTutor = new System.Windows.Forms.Button(); this.B_TMHM = new System.Windows.Forms.Button(); this.RTB_Status = new System.Windows.Forms.RichTextBox(); + this.L_SubTools = new System.Windows.Forms.Label(); this.GB_RomFS.SuspendLayout(); this.GB_ExeFS.SuspendLayout(); this.SuspendLayout(); @@ -362,11 +363,22 @@ private void InitializeComponent() this.RTB_Status.TabIndex = 7; this.RTB_Status.Text = ""; // + // L_SubTools + // + this.L_SubTools.AutoSize = true; + this.L_SubTools.Location = new System.Drawing.Point(393, -1); + this.L_SubTools.Name = "L_SubTools"; + this.L_SubTools.Size = new System.Drawing.Size(64, 13); + this.L_SubTools.TabIndex = 8; + this.L_SubTools.Text = "[Misc Tools]"; + this.L_SubTools.Click += new System.EventHandler(this.L_SubTools_Click); + // // Main // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(454, 422); + this.Controls.Add(this.L_SubTools); this.Controls.Add(this.RTB_Status); this.Controls.Add(this.GB_ExeFS); this.Controls.Add(this.L_About); @@ -420,5 +432,6 @@ private void InitializeComponent() private System.Windows.Forms.Button B_TMHM; public System.Windows.Forms.RichTextBox RTB_Status; private System.Windows.Forms.Button B_OPower; + private System.Windows.Forms.Label L_SubTools; } } \ No newline at end of file diff --git a/pk3DS/Main.cs b/pk3DS/Main.cs index 6e76465..9e80783 100644 --- a/pk3DS/Main.cs +++ b/pk3DS/Main.cs @@ -510,6 +510,12 @@ private void B_OPower_Click(object sender, EventArgs e) if (ExeFS != null) new OPower().Show(); } + // Extra Tools + private void L_SubTools_Click(object sender, EventArgs e) + { + new Tools().ShowDialog(); + } + // GARC Requests public string getGARCFileName(string requestedGARC) { diff --git a/pk3DS/Main.resx b/pk3DS/Main.resx index 2709f75..ba2b31f 100644 --- a/pk3DS/Main.resx +++ b/pk3DS/Main.resx @@ -162,6 +162,42 @@ True + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + True @@ -192,9 +228,24 @@ True + + True + + + True + + + True + + + True + True + + True + True diff --git a/pk3DS/Tools/ToolsUI.Designer.cs b/pk3DS/Tools/ToolsUI.Designer.cs new file mode 100644 index 0000000..43b7517 --- /dev/null +++ b/pk3DS/Tools/ToolsUI.Designer.cs @@ -0,0 +1,114 @@ +namespace pk3DS +{ + partial class ToolsUI + { + /// + /// 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.PB_Unpack = new System.Windows.Forms.Panel(); + this.L_DARCMini = new System.Windows.Forms.Label(); + this.PB_BCLIM = new System.Windows.Forms.Panel(); + this.CHK_PNG = new System.Windows.Forms.CheckBox(); + this.label1 = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // PB_Unpack + // + this.PB_Unpack.Location = new System.Drawing.Point(12, 25); + this.PB_Unpack.Name = "PB_Unpack"; + this.PB_Unpack.Size = new System.Drawing.Size(150, 67); + this.PB_Unpack.TabIndex = 0; + // + // L_DARCMini + // + this.L_DARCMini.AutoSize = true; + this.L_DARCMini.Location = new System.Drawing.Point(12, 9); + this.L_DARCMini.Name = "L_DARCMini"; + this.L_DARCMini.Size = new System.Drawing.Size(109, 13); + this.L_DARCMini.TabIndex = 1; + this.L_DARCMini.Text = "DARC && Mini Unpack"; + // + // PB_BCLIM + // + this.PB_BCLIM.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.PB_BCLIM.Location = new System.Drawing.Point(15, 283); + this.PB_BCLIM.Name = "PB_BCLIM"; + this.PB_BCLIM.Size = new System.Drawing.Size(300, 67); + this.PB_BCLIM.TabIndex = 1; + this.PB_BCLIM.Paint += new System.Windows.Forms.PaintEventHandler(this.PB_BCLIM_Paint); + // + // CHK_PNG + // + this.CHK_PNG.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.CHK_PNG.AutoSize = true; + this.CHK_PNG.Location = new System.Drawing.Point(218, 266); + this.CHK_PNG.Name = "CHK_PNG"; + this.CHK_PNG.Size = new System.Drawing.Size(97, 17); + this.CHK_PNG.TabIndex = 2; + this.CHK_PNG.Text = "Autosave PNG"; + this.CHK_PNG.UseVisualStyleBackColor = true; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(12, 267); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(88, 13); + this.label1.TabIndex = 3; + this.label1.Text = "BCLIM Converter"; + // + // ToolsUI + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(324, 362); + this.Controls.Add(this.label1); + this.Controls.Add(this.CHK_PNG); + this.Controls.Add(this.PB_BCLIM); + this.Controls.Add(this.L_DARCMini); + this.Controls.Add(this.PB_Unpack); + this.MaximizeBox = false; + this.MinimumSize = new System.Drawing.Size(340, 400); + this.Name = "ToolsUI"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Tools"; + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Panel PB_Unpack; + private System.Windows.Forms.Label L_DARCMini; + private System.Windows.Forms.Panel PB_BCLIM; + private System.Windows.Forms.CheckBox CHK_PNG; + private System.Windows.Forms.Label label1; + + } +} \ No newline at end of file diff --git a/pk3DS/Tools/ToolsUI.cs b/pk3DS/Tools/ToolsUI.cs new file mode 100644 index 0000000..1b0dbd1 --- /dev/null +++ b/pk3DS/Tools/ToolsUI.cs @@ -0,0 +1,84 @@ +using System; +using System.Drawing; +using System.IO; +using System.Windows.Forms; + +namespace pk3DS +{ + public partial class ToolsUI : Form + { + public ToolsUI() + { + InitializeComponent(); + + PB_Unpack.DragEnter += tabMain_DragEnter; + PB_Unpack.DragDrop += tabMain_DragDrop; + } + private void tabMain_DragEnter(object sender, DragEventArgs e) + { + if (e.Data.GetDataPresent(DataFormats.FileDrop)) e.Effect = DragDropEffects.Copy; + } + private void tabMain_DragDrop(object sender, DragEventArgs e) + { + string[] files = (string[])e.Data.GetData(DataFormats.FileDrop); + string path = files[0]; // open first D&D + openQuick(path); + } + private void openQuick(string path, bool recursing = false) + { + try + { + // Pre-check file length to see if it is at least valid. + FileInfo fi = new FileInfo(path); + if (fi.Length > 900000) { Util.Error("File is too big!"); return; } + + string newFolder = Path.Combine(Path.GetDirectoryName(path), Path.GetFileNameWithoutExtension(path)); + // Determine if it is a DARC or a Mini + using (var s = new FileStream(path, FileMode.Open)) + using (var br = new BinaryReader(s)) + { + // Check if Mini first + // ushort magic = br.ReadUInt16(); + string fx = new string(br.ReadChars(2)); + newFolder += "." + fx + "-"; + ushort count = br.ReadUInt16(); + uint[] offsets = new uint[count + 1]; + for (int i = 0; i < count; i++) + { + offsets[i] = br.ReadUInt32(); + } + uint length = br.ReadUInt32(); + offsets[offsets.Length - 1] = length; + if (fi.Length == length) + { + // Fetch Mini File Contents + Util.unpackMini(path, fx, newFolder); + // Recurse throught the extracted contents if they extract successfully + if (Directory.Exists(newFolder)) + foreach (string file in Directory.GetFiles(newFolder)) + openQuick(file, true); + } + else if (false) + { + + } + else if (!recursing) + Util.Alert("File is not a darc or a mini packed file:" + Environment.NewLine + path); + } + } + catch (Exception e) + { + Util.Error("File error:" + Environment.NewLine + path, e.ToString()); + } + } + + private void PB_BCLIM_Paint(object sender, PaintEventArgs e) + { + if (ModifierKeys == Keys.Control && Util.Prompt(MessageBoxButtons.YesNo, "Copy image to clipboard?") == DialogResult.Yes) + Clipboard.SetImage(PB_BCLIM.BackgroundImage); + else if (PB_BCLIM.BackColor == Color.Transparent) + PB_BCLIM.BackColor = Color.GreenYellow; + else PB_BCLIM.BackColor = Color.Transparent; + } + } +} \ No newline at end of file diff --git a/pk3DS/Tools/ToolsUI.resx b/pk3DS/Tools/ToolsUI.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/pk3DS/Tools/ToolsUI.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