From 5430c395d0b91da65943f1281374d41cd70ac757 Mon Sep 17 00:00:00 2001 From: adelikat Date: Sun, 11 May 2014 18:13:32 +0000 Subject: [PATCH] Dual GB XML Creator - add a "Current Rom" button that is enabled when possible --- .../config/GB/DualGBFileSelector.Designer.cs | 23 +++++-- .../config/GB/DualGBFileSelector.cs | 31 ++++++++- .../tools/GB/DualGBXMLCreator.Designer.cs | 67 ++++++++++--------- .../tools/GB/DualGBXMLCreator.cs | 5 ++ 4 files changed, 87 insertions(+), 39 deletions(-) diff --git a/BizHawk.Client.EmuHawk/config/GB/DualGBFileSelector.Designer.cs b/BizHawk.Client.EmuHawk/config/GB/DualGBFileSelector.Designer.cs index 319895cb31..d8cdb542f1 100644 --- a/BizHawk.Client.EmuHawk/config/GB/DualGBFileSelector.Designer.cs +++ b/BizHawk.Client.EmuHawk/config/GB/DualGBFileSelector.Designer.cs @@ -30,14 +30,15 @@ { this.button1 = new System.Windows.Forms.Button(); this.textBox1 = new System.Windows.Forms.TextBox(); + this.UseCurrentRomButton = new System.Windows.Forms.Button(); this.SuspendLayout(); // // button1 // this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.button1.Location = new System.Drawing.Point(279, 3); + this.button1.Location = new System.Drawing.Point(362, 3); this.button1.Name = "button1"; - this.button1.Size = new System.Drawing.Size(75, 23); + this.button1.Size = new System.Drawing.Size(60, 23); this.button1.TabIndex = 2; this.button1.Text = "Browse..."; this.button1.UseVisualStyleBackColor = true; @@ -46,8 +47,6 @@ // textBox1 // this.textBox1.AllowDrop = true; - this.textBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); this.textBox1.Location = new System.Drawing.Point(3, 5); this.textBox1.Name = "textBox1"; this.textBox1.Size = new System.Drawing.Size(270, 20); @@ -55,14 +54,27 @@ this.textBox1.DragDrop += new System.Windows.Forms.DragEventHandler(this.textBox1_DragDrop); this.textBox1.DragEnter += new System.Windows.Forms.DragEventHandler(this.textBox1_DragEnter); // + // UseCurrentRomButton + // + this.UseCurrentRomButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.UseCurrentRomButton.Location = new System.Drawing.Point(279, 3); + this.UseCurrentRomButton.Name = "UseCurrentRomButton"; + this.UseCurrentRomButton.Size = new System.Drawing.Size(83, 23); + this.UseCurrentRomButton.TabIndex = 3; + this.UseCurrentRomButton.Text = "Current Rom"; + this.UseCurrentRomButton.UseVisualStyleBackColor = true; + this.UseCurrentRomButton.Click += new System.EventHandler(this.UseCurrentRomButton_Click); + // // DualGBFileSelector // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.UseCurrentRomButton); this.Controls.Add(this.button1); this.Controls.Add(this.textBox1); this.Name = "DualGBFileSelector"; - this.Size = new System.Drawing.Size(357, 29); + this.Size = new System.Drawing.Size(425, 29); + this.Load += new System.EventHandler(this.DualGBFileSelector_Load); this.ResumeLayout(false); this.PerformLayout(); @@ -72,6 +84,7 @@ private System.Windows.Forms.Button button1; private System.Windows.Forms.TextBox textBox1; + private System.Windows.Forms.Button UseCurrentRomButton; } } diff --git a/BizHawk.Client.EmuHawk/config/GB/DualGBFileSelector.cs b/BizHawk.Client.EmuHawk/config/GB/DualGBFileSelector.cs index 00c33028ae..3c5e88bbb1 100644 --- a/BizHawk.Client.EmuHawk/config/GB/DualGBFileSelector.cs +++ b/BizHawk.Client.EmuHawk/config/GB/DualGBFileSelector.cs @@ -8,6 +8,7 @@ using System.Text; using System.Windows.Forms; using BizHawk.Client.Common; +using BizHawk.Emulation.Common; namespace BizHawk.Client.EmuHawk { @@ -42,10 +43,15 @@ namespace BizHawk.Client.EmuHawk private void textBox1_DragEnter(object sender, DragEventArgs e) { - if (e.Data.GetDataPresent(DataFormats.FileDrop) && ((string[])e.Data.GetData(DataFormats.FileDrop)).Length == 1) + if (e.Data.GetDataPresent(DataFormats.FileDrop) && + ((string[])e.Data.GetData(DataFormats.FileDrop)).Length == 1) + { e.Effect = DragDropEffects.Copy; + } else + { e.Effect = DragDropEffects.None; + } } private void textBox1_DragDrop(object sender, DragEventArgs e) @@ -54,7 +60,9 @@ namespace BizHawk.Client.EmuHawk { var ff = (string[])e.Data.GetData(DataFormats.FileDrop); if (ff.Length == 1) + { textBox1.Text = ff[0]; + } } } @@ -67,8 +75,29 @@ namespace BizHawk.Client.EmuHawk ofd.RestoreDirectory = true; var result = ofd.ShowDialog(this); if (result == DialogResult.OK) + { textBox1.Text = ofd.FileName; + } } } + + private void UseCurrentRomButton_Click(object sender, EventArgs e) + { + textBox1.Text = GlobalWin.MainForm.CurrentlyOpenRom; + } + + private void DualGBFileSelector_Load(object sender, EventArgs e) + { + Update(); + } + + public void Update() + { + UseCurrentRomButton.Enabled = Global.Emulator != null && // For the designer + !(Global.Emulator is NullEmulator) && + !string.IsNullOrEmpty(GlobalWin.MainForm.CurrentlyOpenRom) && + !GlobalWin.MainForm.CurrentlyOpenRom.Contains('|') && // Can't be archive + !GlobalWin.MainForm.CurrentlyOpenRom.Contains(".xml"); // Can't already be an xml + } } } diff --git a/BizHawk.Client.EmuHawk/tools/GB/DualGBXMLCreator.Designer.cs b/BizHawk.Client.EmuHawk/tools/GB/DualGBXMLCreator.Designer.cs index b4cfc762a7..03962aacd3 100644 --- a/BizHawk.Client.EmuHawk/tools/GB/DualGBXMLCreator.Designer.cs +++ b/BizHawk.Client.EmuHawk/tools/GB/DualGBXMLCreator.Designer.cs @@ -30,9 +30,7 @@ { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(DualGBXMLCreator)); this.groupBox1 = new System.Windows.Forms.GroupBox(); - this.dualGBFileSelector1 = new BizHawk.Client.EmuHawk.DualGBFileSelector(); this.groupBox2 = new System.Windows.Forms.GroupBox(); - this.dualGBFileSelector2 = new BizHawk.Client.EmuHawk.DualGBFileSelector(); this.groupBox3 = new System.Windows.Forms.GroupBox(); this.textBoxName = new System.Windows.Forms.TextBox(); this.buttonOK = new System.Windows.Forms.Button(); @@ -41,6 +39,8 @@ this.textBoxOutputDir = new System.Windows.Forms.TextBox(); this.groupBox5 = new System.Windows.Forms.GroupBox(); this.textBoxXML = new System.Windows.Forms.TextBox(); + this.dualGBFileSelector2 = new BizHawk.Client.EmuHawk.DualGBFileSelector(); + this.dualGBFileSelector1 = new BizHawk.Client.EmuHawk.DualGBFileSelector(); this.groupBox1.SuspendLayout(); this.groupBox2.SuspendLayout(); this.groupBox3.SuspendLayout(); @@ -55,21 +55,11 @@ this.groupBox1.Controls.Add(this.dualGBFileSelector1); this.groupBox1.Location = new System.Drawing.Point(12, 12); this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(335, 54); + this.groupBox1.Size = new System.Drawing.Size(432, 54); this.groupBox1.TabIndex = 0; this.groupBox1.TabStop = false; this.groupBox1.Text = "Left Rom"; // - // dualGBFileSelector1 - // - this.dualGBFileSelector1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.dualGBFileSelector1.Location = new System.Drawing.Point(6, 19); - this.dualGBFileSelector1.Name = "dualGBFileSelector1"; - this.dualGBFileSelector1.Size = new System.Drawing.Size(323, 29); - this.dualGBFileSelector1.TabIndex = 0; - this.dualGBFileSelector1.NameChanged += new System.EventHandler(this.dualGBFileSelector1_NameChanged); - // // groupBox2 // this.groupBox2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) @@ -77,21 +67,11 @@ this.groupBox2.Controls.Add(this.dualGBFileSelector2); this.groupBox2.Location = new System.Drawing.Point(12, 72); this.groupBox2.Name = "groupBox2"; - this.groupBox2.Size = new System.Drawing.Size(335, 54); + this.groupBox2.Size = new System.Drawing.Size(432, 54); this.groupBox2.TabIndex = 1; this.groupBox2.TabStop = false; this.groupBox2.Text = "Right Rom"; // - // dualGBFileSelector2 - // - this.dualGBFileSelector2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.dualGBFileSelector2.Location = new System.Drawing.Point(6, 19); - this.dualGBFileSelector2.Name = "dualGBFileSelector2"; - this.dualGBFileSelector2.Size = new System.Drawing.Size(323, 29); - this.dualGBFileSelector2.TabIndex = 1; - this.dualGBFileSelector2.NameChanged += new System.EventHandler(this.dualGBFileSelector2_NameChanged); - // // groupBox3 // this.groupBox3.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) @@ -99,7 +79,7 @@ this.groupBox3.Controls.Add(this.textBoxName); this.groupBox3.Location = new System.Drawing.Point(12, 132); this.groupBox3.Name = "groupBox3"; - this.groupBox3.Size = new System.Drawing.Size(335, 45); + this.groupBox3.Size = new System.Drawing.Size(432, 45); this.groupBox3.TabIndex = 3; this.groupBox3.TabStop = false; this.groupBox3.Text = "Name"; @@ -110,7 +90,7 @@ | System.Windows.Forms.AnchorStyles.Right))); this.textBoxName.Location = new System.Drawing.Point(6, 19); this.textBoxName.Name = "textBoxName"; - this.textBoxName.Size = new System.Drawing.Size(323, 20); + this.textBoxName.Size = new System.Drawing.Size(420, 20); this.textBoxName.TabIndex = 0; this.textBoxName.TextChanged += new System.EventHandler(this.textBoxName_TextChanged); // @@ -118,7 +98,7 @@ // this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.buttonOK.Enabled = false; - this.buttonOK.Location = new System.Drawing.Point(191, 477); + this.buttonOK.Location = new System.Drawing.Point(288, 477); this.buttonOK.Name = "buttonOK"; this.buttonOK.Size = new System.Drawing.Size(75, 23); this.buttonOK.TabIndex = 6; @@ -130,7 +110,7 @@ // this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.buttonCancel.Location = new System.Drawing.Point(272, 477); + this.buttonCancel.Location = new System.Drawing.Point(369, 477); this.buttonCancel.Name = "buttonCancel"; this.buttonCancel.Size = new System.Drawing.Size(75, 23); this.buttonCancel.TabIndex = 7; @@ -144,7 +124,7 @@ this.groupBox4.Controls.Add(this.textBoxOutputDir); this.groupBox4.Location = new System.Drawing.Point(12, 183); this.groupBox4.Name = "groupBox4"; - this.groupBox4.Size = new System.Drawing.Size(335, 45); + this.groupBox4.Size = new System.Drawing.Size(432, 45); this.groupBox4.TabIndex = 5; this.groupBox4.TabStop = false; this.groupBox4.Text = "Output Directory"; @@ -156,7 +136,7 @@ this.textBoxOutputDir.Location = new System.Drawing.Point(6, 19); this.textBoxOutputDir.Name = "textBoxOutputDir"; this.textBoxOutputDir.ReadOnly = true; - this.textBoxOutputDir.Size = new System.Drawing.Size(323, 20); + this.textBoxOutputDir.Size = new System.Drawing.Size(420, 20); this.textBoxOutputDir.TabIndex = 4; // // groupBox5 @@ -167,7 +147,7 @@ this.groupBox5.Controls.Add(this.textBoxXML); this.groupBox5.Location = new System.Drawing.Point(12, 234); this.groupBox5.Name = "groupBox5"; - this.groupBox5.Size = new System.Drawing.Size(335, 237); + this.groupBox5.Size = new System.Drawing.Size(432, 237); this.groupBox5.TabIndex = 6; this.groupBox5.TabStop = false; this.groupBox5.Text = "XML Preview"; @@ -183,17 +163,37 @@ this.textBoxXML.Name = "textBoxXML"; this.textBoxXML.ReadOnly = true; this.textBoxXML.ScrollBars = System.Windows.Forms.ScrollBars.Both; - this.textBoxXML.Size = new System.Drawing.Size(323, 212); + this.textBoxXML.Size = new System.Drawing.Size(420, 212); this.textBoxXML.TabIndex = 5; this.textBoxXML.WordWrap = false; // + // dualGBFileSelector2 + // + this.dualGBFileSelector2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.dualGBFileSelector2.Location = new System.Drawing.Point(6, 19); + this.dualGBFileSelector2.Name = "dualGBFileSelector2"; + this.dualGBFileSelector2.Size = new System.Drawing.Size(420, 29); + this.dualGBFileSelector2.TabIndex = 1; + this.dualGBFileSelector2.NameChanged += new System.EventHandler(this.dualGBFileSelector2_NameChanged); + // + // dualGBFileSelector1 + // + this.dualGBFileSelector1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.dualGBFileSelector1.Location = new System.Drawing.Point(6, 19); + this.dualGBFileSelector1.Name = "dualGBFileSelector1"; + this.dualGBFileSelector1.Size = new System.Drawing.Size(420, 29); + this.dualGBFileSelector1.TabIndex = 0; + this.dualGBFileSelector1.NameChanged += new System.EventHandler(this.dualGBFileSelector1_NameChanged); + // // DualGBXMLCreator // this.AcceptButton = this.buttonOK; this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.CancelButton = this.buttonCancel; - this.ClientSize = new System.Drawing.Size(359, 512); + this.ClientSize = new System.Drawing.Size(456, 512); this.Controls.Add(this.groupBox5); this.Controls.Add(this.groupBox4); this.Controls.Add(this.buttonCancel); @@ -205,6 +205,7 @@ this.Name = "DualGBXMLCreator"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.Text = "Create Dual Gameboy XML"; + this.Load += new System.EventHandler(this.DualGBXMLCreator_Load); this.groupBox1.ResumeLayout(false); this.groupBox2.ResumeLayout(false); this.groupBox3.ResumeLayout(false); diff --git a/BizHawk.Client.EmuHawk/tools/GB/DualGBXMLCreator.cs b/BizHawk.Client.EmuHawk/tools/GB/DualGBXMLCreator.cs index e681dac5d4..8f34176c9d 100644 --- a/BizHawk.Client.EmuHawk/tools/GB/DualGBXMLCreator.cs +++ b/BizHawk.Client.EmuHawk/tools/GB/DualGBXMLCreator.cs @@ -143,5 +143,10 @@ namespace BizHawk.Client.EmuHawk Close(); } } + + private void DualGBXMLCreator_Load(object sender, EventArgs e) + { + + } } }