Dual GB XML Creator - a "Use Current Rom for all" button for the uberlazy
This commit is contained in:
parent
5abd6f8387
commit
edb90839d0
|
@ -20,6 +20,11 @@ namespace BizHawk.Client.EmuHawk
|
|||
return textBox1.Text;
|
||||
}
|
||||
|
||||
public void SetName(string val)
|
||||
{
|
||||
textBox1.Text = val;
|
||||
}
|
||||
|
||||
public event EventHandler NameChanged;
|
||||
|
||||
private void HandleLabelTextChanged(object sender, EventArgs e)
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
this.groupBox5 = new System.Windows.Forms.GroupBox();
|
||||
this.textBoxXML = new System.Windows.Forms.TextBox();
|
||||
this.SaveRunButton = new System.Windows.Forms.Button();
|
||||
this.CurrentForAllButton = new System.Windows.Forms.Button();
|
||||
this.dualGBFileSelector2 = new BizHawk.Client.EmuHawk.DualGBFileSelector();
|
||||
this.dualGBFileSelector1 = new BizHawk.Client.EmuHawk.DualGBFileSelector();
|
||||
this.groupBox1.SuspendLayout();
|
||||
|
@ -104,6 +105,7 @@
|
|||
this.buttonCancel.TabIndex = 7;
|
||||
this.buttonCancel.Text = "&Cancel";
|
||||
this.buttonCancel.UseVisualStyleBackColor = true;
|
||||
this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
|
||||
//
|
||||
// groupBox4
|
||||
//
|
||||
|
@ -167,6 +169,17 @@
|
|||
this.SaveRunButton.UseVisualStyleBackColor = true;
|
||||
this.SaveRunButton.Click += new System.EventHandler(this.SaveRunButton_Click);
|
||||
//
|
||||
// CurrentForAllButton
|
||||
//
|
||||
this.CurrentForAllButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||
this.CurrentForAllButton.Location = new System.Drawing.Point(12, 477);
|
||||
this.CurrentForAllButton.Name = "CurrentForAllButton";
|
||||
this.CurrentForAllButton.Size = new System.Drawing.Size(128, 23);
|
||||
this.CurrentForAllButton.TabIndex = 9;
|
||||
this.CurrentForAllButton.Text = "Use Current Rom for All";
|
||||
this.CurrentForAllButton.UseVisualStyleBackColor = true;
|
||||
this.CurrentForAllButton.Click += new System.EventHandler(this.CurrentForAllButton_Click);
|
||||
//
|
||||
// dualGBFileSelector2
|
||||
//
|
||||
this.dualGBFileSelector2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
|
@ -194,6 +207,7 @@
|
|||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.CancelButton = this.buttonCancel;
|
||||
this.ClientSize = new System.Drawing.Size(456, 512);
|
||||
this.Controls.Add(this.CurrentForAllButton);
|
||||
this.Controls.Add(this.SaveRunButton);
|
||||
this.Controls.Add(this.groupBox5);
|
||||
this.Controls.Add(this.groupBox4);
|
||||
|
@ -232,5 +246,6 @@
|
|||
private System.Windows.Forms.GroupBox groupBox5;
|
||||
private System.Windows.Forms.TextBox textBoxXML;
|
||||
private System.Windows.Forms.Button SaveRunButton;
|
||||
private System.Windows.Forms.Button CurrentForAllButton;
|
||||
}
|
||||
}
|
|
@ -4,11 +4,15 @@ using System.Linq;
|
|||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using System.IO;
|
||||
using BizHawk.Client.Common;
|
||||
using BizHawk.Emulation.Cores.Nintendo.Gameboy;
|
||||
|
||||
namespace BizHawk.Client.EmuHawk
|
||||
{
|
||||
public partial class DualGBXMLCreator : Form
|
||||
{
|
||||
private bool _suspendRecalculate = false;
|
||||
|
||||
public DualGBXMLCreator()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
@ -51,8 +55,13 @@ namespace BizHawk.Client.EmuHawk
|
|||
throw new FileNotFoundException();
|
||||
}
|
||||
|
||||
bool Recalculate()
|
||||
private bool Recalculate()
|
||||
{
|
||||
if (_suspendRecalculate)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var PathLeft = dualGBFileSelector1.GetName();
|
||||
|
@ -130,23 +139,13 @@ namespace BizHawk.Client.EmuHawk
|
|||
Recalculate();
|
||||
}
|
||||
|
||||
private void buttonOK_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (Recalculate())
|
||||
{
|
||||
using (var sw = new StreamWriter(textBoxOutputDir.Text))
|
||||
{
|
||||
sw.Write(textBoxXML.Text);
|
||||
}
|
||||
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
|
||||
private void DualGBXMLCreator_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
CurrentForAllButton.Enabled = Global.Emulator != null && // For the designer
|
||||
(Global.Emulator is Gameboy) &&
|
||||
!string.IsNullOrEmpty(GlobalWin.MainForm.CurrentlyOpenRom) &&
|
||||
!GlobalWin.MainForm.CurrentlyOpenRom.Contains('|') && // Can't be archive
|
||||
!GlobalWin.MainForm.CurrentlyOpenRom.Contains(".xml"); // Can't already be an xml
|
||||
}
|
||||
|
||||
private void SaveRunButton_Click(object sender, EventArgs e)
|
||||
|
@ -163,5 +162,23 @@ namespace BizHawk.Client.EmuHawk
|
|||
GlobalWin.MainForm.LoadRom(textBoxOutputDir.Text);
|
||||
}
|
||||
}
|
||||
|
||||
private void CurrentForAllButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
_suspendRecalculate = true;
|
||||
dualGBFileSelector1.SetName(GlobalWin.MainForm.CurrentlyOpenRom);
|
||||
dualGBFileSelector2.SetName(GlobalWin.MainForm.CurrentlyOpenRom);
|
||||
|
||||
textBoxName.Text = Path.GetFileNameWithoutExtension(GlobalWin.MainForm.CurrentlyOpenRom);
|
||||
_suspendRecalculate = false;
|
||||
|
||||
Recalculate();
|
||||
}
|
||||
|
||||
private void buttonCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue