Lots of work on the Macro Tool.
This commit is contained in:
parent
eccbe1ce2a
commit
6fd8aad86b
|
@ -810,12 +810,16 @@
|
||||||
<Compile Include="tools\Lua\SyncTextBox.cs">
|
<Compile Include="tools\Lua\SyncTextBox.cs">
|
||||||
<SubType>Component</SubType>
|
<SubType>Component</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="tools\Macros\MacroInput.ButtonSelect.cs">
|
||||||
|
<SubType>Form</SubType>
|
||||||
|
</Compile>
|
||||||
<Compile Include="tools\Macros\MacroInput.cs">
|
<Compile Include="tools\Macros\MacroInput.cs">
|
||||||
<SubType>Form</SubType>
|
<SubType>Form</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="tools\Macros\MacroInput.Designer.cs">
|
<Compile Include="tools\Macros\MacroInput.Designer.cs">
|
||||||
<DependentUpon>MacroInput.cs</DependentUpon>
|
<DependentUpon>MacroInput.cs</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="tools\Macros\MovieZone.cs" />
|
||||||
<Compile Include="tools\NES\BarcodeEntry.cs">
|
<Compile Include="tools\NES\BarcodeEntry.cs">
|
||||||
<SubType>Form</SubType>
|
<SubType>Form</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
|
|
@ -0,0 +1,89 @@
|
||||||
|
using System;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
using BizHawk.Emulation.Common;
|
||||||
|
using BizHawk.Client.Common;
|
||||||
|
|
||||||
|
namespace BizHawk.Client.EmuHawk
|
||||||
|
{
|
||||||
|
public partial class MacroInputTool
|
||||||
|
{
|
||||||
|
private CheckBox[] _buttonBoxes;
|
||||||
|
private void SetUpButtonBoxes()
|
||||||
|
{
|
||||||
|
ControllerDefinition def = Global.Emulator.ControllerDefinition;
|
||||||
|
int count = def.BoolButtons.Count + def.FloatControls.Count;
|
||||||
|
_buttonBoxes = new CheckBox[count];
|
||||||
|
|
||||||
|
for (int i = 0; i < def.FloatControls.Count; i++)
|
||||||
|
{
|
||||||
|
CheckBox box = new CheckBox();
|
||||||
|
box.Text = def.FloatControls[i];
|
||||||
|
_buttonBoxes[i] = box;
|
||||||
|
}
|
||||||
|
for (int i = 0; i < def.BoolButtons.Count; i++)
|
||||||
|
{
|
||||||
|
CheckBox box = new CheckBox();
|
||||||
|
box.Text = def.BoolButtons[i];
|
||||||
|
_buttonBoxes[i + def.FloatControls.Count] = box;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < _buttonBoxes.Length; i++)
|
||||||
|
{
|
||||||
|
_buttonBoxes[i].Parent = this;
|
||||||
|
_buttonBoxes[i].AutoSize = true;
|
||||||
|
_buttonBoxes[i].CheckedChanged += ButtonBox_CheckedChanged;
|
||||||
|
}
|
||||||
|
|
||||||
|
PositionBoxes();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonBox_CheckedChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (selectedZone == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
CheckBox s = sender as CheckBox;
|
||||||
|
s.ForeColor = s.Checked ? SystemColors.ControlText : SystemColors.ControlLight;
|
||||||
|
|
||||||
|
// Update the selected zone's key
|
||||||
|
var lg = Global.MovieSession.LogGeneratorInstance() as Bk2LogEntryGenerator;
|
||||||
|
lg.SetSource(Global.MovieSession.MovieControllerAdapter);
|
||||||
|
string key = lg.GenerateLogKey();
|
||||||
|
key = key.Replace("LogKey:", "").Replace("#", "");
|
||||||
|
key = key.Substring(0, key.Length - 1);
|
||||||
|
|
||||||
|
for (int i = 0; i < _buttonBoxes.Length; i++)
|
||||||
|
key = key.Replace(_buttonBoxes[i].Text + "|", "");
|
||||||
|
|
||||||
|
selectedZone.InputKey = key;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void PositionBoxes()
|
||||||
|
{
|
||||||
|
int X = this.ClientSize.Width - 3;
|
||||||
|
int Y = this.ClientSize.Height - _buttonBoxes[0].Height - 3;
|
||||||
|
|
||||||
|
for (int i = _buttonBoxes.Length - 1; i >= 0; i--)
|
||||||
|
{
|
||||||
|
X -= _buttonBoxes[i].Width;
|
||||||
|
if (X <= 3)
|
||||||
|
{
|
||||||
|
X = this.ClientSize.Width - 3 - _buttonBoxes[i].Width;
|
||||||
|
Y -= (_buttonBoxes[0].Height + 6);
|
||||||
|
}
|
||||||
|
|
||||||
|
_buttonBoxes[i].Location = new Point(X, Y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void MacroInputTool_Resize(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (_initializing)
|
||||||
|
return;
|
||||||
|
|
||||||
|
PositionBoxes();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -30,8 +30,29 @@
|
||||||
{
|
{
|
||||||
this.MacroMenu = new System.Windows.Forms.MenuStrip();
|
this.MacroMenu = new System.Windows.Forms.MenuStrip();
|
||||||
this.FileSubMenu = new System.Windows.Forms.ToolStripMenuItem();
|
this.FileSubMenu = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.saveAsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.loadMacroToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.RecentToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
|
||||||
|
this.sepToolStripMenuItem = new System.Windows.Forms.ToolStripSeparator();
|
||||||
this.ExitMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
this.ExitMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.NameTextbox = new System.Windows.Forms.TextBox();
|
||||||
|
this.ReplaceBox = new System.Windows.Forms.CheckBox();
|
||||||
|
this.label2 = new System.Windows.Forms.Label();
|
||||||
|
this.PlaceNum = new System.Windows.Forms.NumericUpDown();
|
||||||
|
this.EndNum = new System.Windows.Forms.NumericUpDown();
|
||||||
|
this.PlaceZoneButton = new System.Windows.Forms.Button();
|
||||||
|
this.StartNum = new System.Windows.Forms.NumericUpDown();
|
||||||
|
this.SetZoneButton = new System.Windows.Forms.Button();
|
||||||
|
this.ZonesList = new System.Windows.Forms.ListBox();
|
||||||
|
this.label3 = new System.Windows.Forms.Label();
|
||||||
|
this.label1 = new System.Windows.Forms.Label();
|
||||||
|
this.CurrentButton = new System.Windows.Forms.Button();
|
||||||
|
this.OverlayBox = new System.Windows.Forms.CheckBox();
|
||||||
this.MacroMenu.SuspendLayout();
|
this.MacroMenu.SuspendLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.PlaceNum)).BeginInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.EndNum)).BeginInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.StartNum)).BeginInit();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// MacroMenu
|
// MacroMenu
|
||||||
|
@ -40,39 +61,237 @@
|
||||||
this.FileSubMenu});
|
this.FileSubMenu});
|
||||||
this.MacroMenu.Location = new System.Drawing.Point(0, 0);
|
this.MacroMenu.Location = new System.Drawing.Point(0, 0);
|
||||||
this.MacroMenu.Name = "MacroMenu";
|
this.MacroMenu.Name = "MacroMenu";
|
||||||
this.MacroMenu.Size = new System.Drawing.Size(352, 24);
|
this.MacroMenu.Size = new System.Drawing.Size(289, 24);
|
||||||
this.MacroMenu.TabIndex = 0;
|
this.MacroMenu.TabIndex = 0;
|
||||||
this.MacroMenu.Text = "menuStrip1";
|
this.MacroMenu.Text = "menuStrip1";
|
||||||
//
|
//
|
||||||
// FileSubMenu
|
// FileSubMenu
|
||||||
//
|
//
|
||||||
this.FileSubMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
this.FileSubMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||||
|
this.saveAsToolStripMenuItem,
|
||||||
|
this.loadMacroToolStripMenuItem,
|
||||||
|
this.RecentToolStripMenuItem,
|
||||||
|
this.sepToolStripMenuItem,
|
||||||
this.ExitMenuItem});
|
this.ExitMenuItem});
|
||||||
this.FileSubMenu.Name = "FileSubMenu";
|
this.FileSubMenu.Name = "FileSubMenu";
|
||||||
this.FileSubMenu.Size = new System.Drawing.Size(37, 20);
|
this.FileSubMenu.Size = new System.Drawing.Size(37, 20);
|
||||||
this.FileSubMenu.Text = "&File";
|
this.FileSubMenu.Text = "&File";
|
||||||
//
|
//
|
||||||
|
// saveAsToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.saveAsToolStripMenuItem.Name = "saveAsToolStripMenuItem";
|
||||||
|
this.saveAsToolStripMenuItem.Size = new System.Drawing.Size(170, 22);
|
||||||
|
this.saveAsToolStripMenuItem.Text = "Save Selected As...";
|
||||||
|
this.saveAsToolStripMenuItem.Click += new System.EventHandler(this.saveAsToolStripMenuItem_Click);
|
||||||
|
//
|
||||||
|
// loadMacroToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.loadMacroToolStripMenuItem.Name = "loadMacroToolStripMenuItem";
|
||||||
|
this.loadMacroToolStripMenuItem.Size = new System.Drawing.Size(170, 22);
|
||||||
|
this.loadMacroToolStripMenuItem.Text = "Load Macro...";
|
||||||
|
this.loadMacroToolStripMenuItem.Click += new System.EventHandler(this.loadMacroToolStripMenuItem_Click);
|
||||||
|
//
|
||||||
|
// RecentToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.RecentToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||||
|
this.toolStripSeparator1});
|
||||||
|
this.RecentToolStripMenuItem.Name = "RecentToolStripMenuItem";
|
||||||
|
this.RecentToolStripMenuItem.Size = new System.Drawing.Size(170, 22);
|
||||||
|
this.RecentToolStripMenuItem.Text = "Recent";
|
||||||
|
this.RecentToolStripMenuItem.DropDownOpened += new System.EventHandler(this.RecentToolStripMenuItem_DropDownOpened);
|
||||||
|
//
|
||||||
|
// toolStripSeparator1
|
||||||
|
//
|
||||||
|
this.toolStripSeparator1.Name = "toolStripSeparator1";
|
||||||
|
this.toolStripSeparator1.Size = new System.Drawing.Size(57, 6);
|
||||||
|
//
|
||||||
|
// sepToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.sepToolStripMenuItem.Name = "sepToolStripMenuItem";
|
||||||
|
this.sepToolStripMenuItem.Size = new System.Drawing.Size(167, 6);
|
||||||
|
//
|
||||||
// ExitMenuItem
|
// ExitMenuItem
|
||||||
//
|
//
|
||||||
this.ExitMenuItem.Name = "ExitMenuItem";
|
this.ExitMenuItem.Name = "ExitMenuItem";
|
||||||
this.ExitMenuItem.ShortcutKeyDisplayString = "Alt+F4";
|
this.ExitMenuItem.ShortcutKeyDisplayString = "Alt+F4";
|
||||||
this.ExitMenuItem.Size = new System.Drawing.Size(152, 22);
|
this.ExitMenuItem.Size = new System.Drawing.Size(170, 22);
|
||||||
this.ExitMenuItem.Text = "E&xit";
|
this.ExitMenuItem.Text = "E&xit";
|
||||||
this.ExitMenuItem.Click += new System.EventHandler(this.ExitMenuItem_Click);
|
this.ExitMenuItem.Click += new System.EventHandler(this.ExitMenuItem_Click);
|
||||||
//
|
//
|
||||||
|
// NameTextbox
|
||||||
|
//
|
||||||
|
this.NameTextbox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||||
|
| System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.NameTextbox.Location = new System.Drawing.Point(77, 181);
|
||||||
|
this.NameTextbox.Name = "NameTextbox";
|
||||||
|
this.NameTextbox.Size = new System.Drawing.Size(99, 20);
|
||||||
|
this.NameTextbox.TabIndex = 4;
|
||||||
|
this.NameTextbox.Text = "Zone 0";
|
||||||
|
this.NameTextbox.TextChanged += new System.EventHandler(this.NameTextbox_TextChanged);
|
||||||
|
//
|
||||||
|
// ReplaceBox
|
||||||
|
//
|
||||||
|
this.ReplaceBox.AutoSize = true;
|
||||||
|
this.ReplaceBox.Checked = true;
|
||||||
|
this.ReplaceBox.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||||
|
this.ReplaceBox.Location = new System.Drawing.Point(88, 207);
|
||||||
|
this.ReplaceBox.Name = "ReplaceBox";
|
||||||
|
this.ReplaceBox.Size = new System.Drawing.Size(66, 17);
|
||||||
|
this.ReplaceBox.TabIndex = 5;
|
||||||
|
this.ReplaceBox.Text = "Replace";
|
||||||
|
this.ReplaceBox.UseVisualStyleBackColor = true;
|
||||||
|
this.ReplaceBox.CheckedChanged += new System.EventHandler(this.ReplaceBox_CheckedChanged);
|
||||||
|
//
|
||||||
|
// label2
|
||||||
|
//
|
||||||
|
this.label2.AutoSize = true;
|
||||||
|
this.label2.Location = new System.Drawing.Point(12, 24);
|
||||||
|
this.label2.Name = "label2";
|
||||||
|
this.label2.Size = new System.Drawing.Size(127, 13);
|
||||||
|
this.label2.TabIndex = 16;
|
||||||
|
this.label2.Text = "macro start macro end";
|
||||||
|
//
|
||||||
|
// PlaceNum
|
||||||
|
//
|
||||||
|
this.PlaceNum.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.PlaceNum.Location = new System.Drawing.Point(220, 182);
|
||||||
|
this.PlaceNum.Maximum = new decimal(new int[] {
|
||||||
|
10000000,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0});
|
||||||
|
this.PlaceNum.Name = "PlaceNum";
|
||||||
|
this.PlaceNum.Size = new System.Drawing.Size(63, 20);
|
||||||
|
this.PlaceNum.TabIndex = 6;
|
||||||
|
this.PlaceNum.ValueChanged += new System.EventHandler(this.PlaceNum_ValueChanged);
|
||||||
|
//
|
||||||
|
// EndNum
|
||||||
|
//
|
||||||
|
this.EndNum.Location = new System.Drawing.Point(77, 40);
|
||||||
|
this.EndNum.Maximum = new decimal(new int[] {
|
||||||
|
10000000,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0});
|
||||||
|
this.EndNum.Name = "EndNum";
|
||||||
|
this.EndNum.Size = new System.Drawing.Size(65, 20);
|
||||||
|
this.EndNum.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// PlaceZoneButton
|
||||||
|
//
|
||||||
|
this.PlaceZoneButton.Location = new System.Drawing.Point(7, 203);
|
||||||
|
this.PlaceZoneButton.Name = "PlaceZoneButton";
|
||||||
|
this.PlaceZoneButton.Size = new System.Drawing.Size(75, 23);
|
||||||
|
this.PlaceZoneButton.TabIndex = 8;
|
||||||
|
this.PlaceZoneButton.Text = "Place Zone";
|
||||||
|
this.PlaceZoneButton.UseVisualStyleBackColor = true;
|
||||||
|
this.PlaceZoneButton.Click += new System.EventHandler(this.PlaceZoneButton_Click);
|
||||||
|
//
|
||||||
|
// StartNum
|
||||||
|
//
|
||||||
|
this.StartNum.Location = new System.Drawing.Point(7, 40);
|
||||||
|
this.StartNum.Maximum = new decimal(new int[] {
|
||||||
|
10000000,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0});
|
||||||
|
this.StartNum.Name = "StartNum";
|
||||||
|
this.StartNum.Size = new System.Drawing.Size(65, 20);
|
||||||
|
this.StartNum.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// SetZoneButton
|
||||||
|
//
|
||||||
|
this.SetZoneButton.Location = new System.Drawing.Point(148, 37);
|
||||||
|
this.SetZoneButton.Name = "SetZoneButton";
|
||||||
|
this.SetZoneButton.Size = new System.Drawing.Size(75, 23);
|
||||||
|
this.SetZoneButton.TabIndex = 2;
|
||||||
|
this.SetZoneButton.Text = "Set Macro";
|
||||||
|
this.SetZoneButton.UseVisualStyleBackColor = true;
|
||||||
|
this.SetZoneButton.Click += new System.EventHandler(this.SetZoneButton_Click);
|
||||||
|
//
|
||||||
|
// ZonesList
|
||||||
|
//
|
||||||
|
this.ZonesList.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||||
|
| System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.ZonesList.FormattingEnabled = true;
|
||||||
|
this.ZonesList.Location = new System.Drawing.Point(7, 66);
|
||||||
|
this.ZonesList.Name = "ZonesList";
|
||||||
|
this.ZonesList.Size = new System.Drawing.Size(276, 108);
|
||||||
|
this.ZonesList.TabIndex = 3;
|
||||||
|
this.ZonesList.SelectedIndexChanged += new System.EventHandler(this.ZonesList_SelectedIndexChanged);
|
||||||
|
//
|
||||||
|
// label3
|
||||||
|
//
|
||||||
|
this.label3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.label3.AutoSize = true;
|
||||||
|
this.label3.Location = new System.Drawing.Point(178, 184);
|
||||||
|
this.label3.Name = "label3";
|
||||||
|
this.label3.Size = new System.Drawing.Size(39, 13);
|
||||||
|
this.label3.TabIndex = 17;
|
||||||
|
this.label3.Text = "Frame:";
|
||||||
|
//
|
||||||
|
// label1
|
||||||
|
//
|
||||||
|
this.label1.AutoSize = true;
|
||||||
|
this.label1.Location = new System.Drawing.Point(4, 184);
|
||||||
|
this.label1.Name = "label1";
|
||||||
|
this.label1.Size = new System.Drawing.Size(71, 13);
|
||||||
|
this.label1.TabIndex = 22;
|
||||||
|
this.label1.Text = "Macro Name:";
|
||||||
|
//
|
||||||
|
// CurrentButton
|
||||||
|
//
|
||||||
|
this.CurrentButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.CurrentButton.Location = new System.Drawing.Point(227, 203);
|
||||||
|
this.CurrentButton.Name = "CurrentButton";
|
||||||
|
this.CurrentButton.Size = new System.Drawing.Size(56, 23);
|
||||||
|
this.CurrentButton.TabIndex = 7;
|
||||||
|
this.CurrentButton.Text = "Current";
|
||||||
|
this.CurrentButton.UseVisualStyleBackColor = true;
|
||||||
|
this.CurrentButton.Click += new System.EventHandler(this.CurrentButton_Click);
|
||||||
|
//
|
||||||
|
// OverlayBox
|
||||||
|
//
|
||||||
|
this.OverlayBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.OverlayBox.AutoSize = true;
|
||||||
|
this.OverlayBox.Location = new System.Drawing.Point(160, 207);
|
||||||
|
this.OverlayBox.Name = "OverlayBox";
|
||||||
|
this.OverlayBox.Size = new System.Drawing.Size(62, 17);
|
||||||
|
this.OverlayBox.TabIndex = 24;
|
||||||
|
this.OverlayBox.Text = "Overlay";
|
||||||
|
this.OverlayBox.UseVisualStyleBackColor = true;
|
||||||
|
this.OverlayBox.CheckedChanged += new System.EventHandler(this.OverlayBox_CheckedChanged);
|
||||||
|
//
|
||||||
// MacroInputTool
|
// MacroInputTool
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.ClientSize = new System.Drawing.Size(352, 332);
|
this.ClientSize = new System.Drawing.Size(289, 333);
|
||||||
|
this.Controls.Add(this.OverlayBox);
|
||||||
|
this.Controls.Add(this.CurrentButton);
|
||||||
|
this.Controls.Add(this.label1);
|
||||||
|
this.Controls.Add(this.NameTextbox);
|
||||||
|
this.Controls.Add(this.ReplaceBox);
|
||||||
|
this.Controls.Add(this.label2);
|
||||||
|
this.Controls.Add(this.PlaceNum);
|
||||||
|
this.Controls.Add(this.EndNum);
|
||||||
|
this.Controls.Add(this.PlaceZoneButton);
|
||||||
|
this.Controls.Add(this.StartNum);
|
||||||
|
this.Controls.Add(this.SetZoneButton);
|
||||||
|
this.Controls.Add(this.ZonesList);
|
||||||
|
this.Controls.Add(this.label3);
|
||||||
this.Controls.Add(this.MacroMenu);
|
this.Controls.Add(this.MacroMenu);
|
||||||
this.MainMenuStrip = this.MacroMenu;
|
this.MainMenuStrip = this.MacroMenu;
|
||||||
this.Name = "MacroInputTool";
|
this.Name = "MacroInputTool";
|
||||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||||
this.Text = "Macro Input";
|
this.Text = "Macro Input";
|
||||||
this.Load += new System.EventHandler(this.MacroInputTool_Load);
|
this.Load += new System.EventHandler(this.MacroInputTool_Load);
|
||||||
|
this.Resize += new System.EventHandler(this.MacroInputTool_Resize);
|
||||||
this.MacroMenu.ResumeLayout(false);
|
this.MacroMenu.ResumeLayout(false);
|
||||||
this.MacroMenu.PerformLayout();
|
this.MacroMenu.PerformLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.PlaceNum)).EndInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.EndNum)).EndInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.StartNum)).EndInit();
|
||||||
this.ResumeLayout(false);
|
this.ResumeLayout(false);
|
||||||
this.PerformLayout();
|
this.PerformLayout();
|
||||||
|
|
||||||
|
@ -83,6 +302,24 @@
|
||||||
private System.Windows.Forms.MenuStrip MacroMenu;
|
private System.Windows.Forms.MenuStrip MacroMenu;
|
||||||
private System.Windows.Forms.ToolStripMenuItem FileSubMenu;
|
private System.Windows.Forms.ToolStripMenuItem FileSubMenu;
|
||||||
private System.Windows.Forms.ToolStripMenuItem ExitMenuItem;
|
private System.Windows.Forms.ToolStripMenuItem ExitMenuItem;
|
||||||
|
private System.Windows.Forms.TextBox NameTextbox;
|
||||||
|
private System.Windows.Forms.CheckBox ReplaceBox;
|
||||||
|
private System.Windows.Forms.Label label2;
|
||||||
|
private System.Windows.Forms.NumericUpDown PlaceNum;
|
||||||
|
private System.Windows.Forms.NumericUpDown EndNum;
|
||||||
|
private System.Windows.Forms.Button PlaceZoneButton;
|
||||||
|
private System.Windows.Forms.NumericUpDown StartNum;
|
||||||
|
private System.Windows.Forms.Button SetZoneButton;
|
||||||
|
private System.Windows.Forms.ListBox ZonesList;
|
||||||
|
private System.Windows.Forms.Label label3;
|
||||||
|
private System.Windows.Forms.Label label1;
|
||||||
|
private System.Windows.Forms.ToolStripMenuItem saveAsToolStripMenuItem;
|
||||||
|
private System.Windows.Forms.ToolStripMenuItem loadMacroToolStripMenuItem;
|
||||||
|
private System.Windows.Forms.ToolStripMenuItem RecentToolStripMenuItem;
|
||||||
|
private System.Windows.Forms.ToolStripSeparator sepToolStripMenuItem;
|
||||||
|
private System.Windows.Forms.Button CurrentButton;
|
||||||
|
private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
|
||||||
|
private System.Windows.Forms.CheckBox OverlayBox;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,5 +1,4 @@
|
||||||
using BizHawk.Emulation.Common;
|
using System;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
|
@ -7,6 +6,12 @@ using System.Drawing;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
using BizHawk.Emulation.Common;
|
||||||
|
using BizHawk.Client.Common;
|
||||||
|
using BizHawk.Client.EmuHawk.WinFormExtensions;
|
||||||
|
using BizHawk.Client.EmuHawk.ToolExtensions;
|
||||||
|
|
||||||
namespace BizHawk.Client.EmuHawk
|
namespace BizHawk.Client.EmuHawk
|
||||||
{
|
{
|
||||||
|
@ -14,46 +19,241 @@ namespace BizHawk.Client.EmuHawk
|
||||||
{
|
{
|
||||||
[RequiredService]
|
[RequiredService]
|
||||||
private IEmulator Emulator { get; set; }
|
private IEmulator Emulator { get; set; }
|
||||||
|
// Zones
|
||||||
|
List<MovieZone> zones = new List<MovieZone>();
|
||||||
|
private TasMovie CurrentTasMovie
|
||||||
|
{
|
||||||
|
get { return Global.MovieSession.Movie as TasMovie; }
|
||||||
|
}
|
||||||
|
|
||||||
|
[ConfigPersist]
|
||||||
|
private MacroSettings Settings { get; set; }
|
||||||
|
|
||||||
|
class MacroSettings
|
||||||
|
{
|
||||||
|
public MacroSettings()
|
||||||
|
{
|
||||||
|
RecentMacro = new RecentFiles(8);
|
||||||
|
}
|
||||||
|
|
||||||
|
public RecentFiles RecentMacro { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool _initializing = false;
|
||||||
public MacroInputTool()
|
public MacroInputTool()
|
||||||
{
|
{
|
||||||
|
_initializing = true;
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void MacroInputTool_Load(object sender, EventArgs e)
|
private void MacroInputTool_Load(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
// Movie recording must be active
|
||||||
|
if (!Global.MovieSession.Movie.IsActive)
|
||||||
|
{
|
||||||
|
MessageBox.Show("In order to use this tool you must be recording a movie.");
|
||||||
|
this.Close();
|
||||||
|
this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ReplaceBox.Enabled = CurrentTasMovie is TasMovie;
|
||||||
|
PlaceNum.Enabled = CurrentTasMovie is TasMovie;
|
||||||
|
|
||||||
|
Settings = new MacroSettings();
|
||||||
|
|
||||||
|
MovieZone main = new MovieZone(CurrentTasMovie, 0, CurrentTasMovie.InputLogLength);
|
||||||
|
main.Name = "Entire Movie";
|
||||||
|
|
||||||
|
zones.Add(main);
|
||||||
|
ZonesList.Items.Add(main.Name + " - length: " + main.Length);
|
||||||
|
ZonesList.Items[0] += " [Zones don't change!]";
|
||||||
|
|
||||||
|
SetUpButtonBoxes();
|
||||||
|
|
||||||
|
_initializing = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Restart()
|
public void Restart()
|
||||||
{
|
{
|
||||||
|
if (_initializing)
|
||||||
|
return;
|
||||||
|
|
||||||
|
zones.Clear();
|
||||||
|
ZonesList.Items.Clear();
|
||||||
|
|
||||||
|
MovieZone main = new MovieZone(CurrentTasMovie, 0, CurrentTasMovie.InputLogLength);
|
||||||
|
main.Name = "Entire Movie";
|
||||||
|
|
||||||
|
zones.Add(main);
|
||||||
|
ZonesList.Items.Add(main.Name + " - length: " + main.Length);
|
||||||
|
ZonesList.Items[0] += " [Zones don't change!]";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// These do absolutely nothing.
|
||||||
public void UpdateValues()
|
public void UpdateValues()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
}
|
||||||
public void FastUpdate()
|
public void FastUpdate()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
public bool UpdateBefore
|
||||||
|
{
|
||||||
|
get { return true; }
|
||||||
|
}
|
||||||
|
|
||||||
public bool AskSaveChanges()
|
public bool AskSaveChanges()
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool UpdateBefore
|
|
||||||
{
|
|
||||||
get { return true; } // TODO: think about this
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ExitMenuItem_Click(object sender, EventArgs e)
|
private void ExitMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void SetZoneButton_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (StartNum.Value >= CurrentTasMovie.InputLogLength || EndNum.Value > CurrentTasMovie.InputLogLength)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Start and end frames must be inside the movie.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
MovieZone newZone = new MovieZone(CurrentTasMovie, (int)StartNum.Value, (int)(EndNum.Value - StartNum.Value));
|
||||||
|
newZone.Name = "Zone " + zones.Count;
|
||||||
|
zones.Add(newZone);
|
||||||
|
ZonesList.Items.Add(newZone.Name + " - length: " + newZone.Length);
|
||||||
|
}
|
||||||
|
|
||||||
|
private MovieZone selectedZone
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (ZonesList.SelectedIndex == -1)
|
||||||
|
return null;
|
||||||
|
return zones[ZonesList.SelectedIndex];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private bool _selecting = false;
|
||||||
|
private void ZonesList_SelectedIndexChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (selectedZone == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
_selecting = true;
|
||||||
|
PlaceNum.Value = selectedZone.Start;
|
||||||
|
ReplaceBox.Checked = selectedZone.Replace;
|
||||||
|
NameTextbox.Text = selectedZone.Name;
|
||||||
|
OverlayBox.Checked = selectedZone.Overlay;
|
||||||
|
_selecting = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void NameTextbox_TextChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (selectedZone == null || _selecting)
|
||||||
|
return;
|
||||||
|
|
||||||
|
selectedZone.Name = NameTextbox.Text;
|
||||||
|
ZonesList.Items[ZonesList.SelectedIndex] = selectedZone.Name + " - length: " + selectedZone.Length;
|
||||||
|
}
|
||||||
|
private void PlaceNum_ValueChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (selectedZone == null || _selecting)
|
||||||
|
return;
|
||||||
|
|
||||||
|
selectedZone.Start = (int)PlaceNum.Value;
|
||||||
|
}
|
||||||
|
private void ReplaceBox_CheckedChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (selectedZone == null || _selecting)
|
||||||
|
return;
|
||||||
|
|
||||||
|
selectedZone.Replace = ReplaceBox.Checked;
|
||||||
|
}
|
||||||
|
private void OverlayBox_CheckedChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (selectedZone == null || _selecting)
|
||||||
|
return;
|
||||||
|
|
||||||
|
selectedZone.Overlay = OverlayBox.Checked;
|
||||||
|
}
|
||||||
|
private void CurrentButton_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
PlaceNum.Value = Global.Emulator.Frame;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void PlaceZoneButton_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (selectedZone == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!(CurrentTasMovie is TasMovie))
|
||||||
|
{
|
||||||
|
selectedZone.Start = Global.Emulator.Frame;
|
||||||
|
}
|
||||||
|
selectedZone.PlaceZone(CurrentTasMovie);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region "Menu Items"
|
||||||
|
private void saveAsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (selectedZone == null)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Please select a zone first.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
SaveFileDialog dialog = new SaveFileDialog();
|
||||||
|
dialog.InitialDirectory = SuggestedFolder();
|
||||||
|
dialog.Filter = "Movie Macros (*.bk2m)|*.bk2m|All Files|*.*";
|
||||||
|
|
||||||
|
DialogResult result = dialog.ShowHawkDialog();
|
||||||
|
if (result != DialogResult.OK)
|
||||||
|
return;
|
||||||
|
|
||||||
|
selectedZone.Save(dialog.FileName);
|
||||||
|
Settings.RecentMacro.Add(dialog.FileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void loadMacroToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
OpenFileDialog dialog = new OpenFileDialog();
|
||||||
|
dialog.InitialDirectory = SuggestedFolder();
|
||||||
|
dialog.Filter = "Movie Macros (*.bk2m)|*.bk2m|All Files|*.*";
|
||||||
|
|
||||||
|
DialogResult result = dialog.ShowHawkDialog();
|
||||||
|
if (result != DialogResult.OK)
|
||||||
|
return;
|
||||||
|
|
||||||
|
MovieZone loadZone = new MovieZone(dialog.FileName);
|
||||||
|
zones.Add(loadZone);
|
||||||
|
ZonesList.Items.Add(loadZone.Name + " - length: " + loadZone.Length);
|
||||||
|
|
||||||
|
Settings.RecentMacro.Add(dialog.FileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void RecentToolStripMenuItem_DropDownOpened(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
RecentToolStripMenuItem.DropDownItems.Clear();
|
||||||
|
RecentToolStripMenuItem.DropDownItems.AddRange(
|
||||||
|
Settings.RecentMacro.RecentMenu(DummyLoadProject, true));
|
||||||
|
}
|
||||||
|
private void DummyLoadProject(string path)
|
||||||
|
{
|
||||||
|
MovieZone loadZone = new MovieZone(path);
|
||||||
|
zones.Add(loadZone);
|
||||||
|
ZonesList.Items.Add(loadZone.Name + " - length: " + loadZone.Length);
|
||||||
|
}
|
||||||
|
|
||||||
|
private string SuggestedFolder()
|
||||||
|
{
|
||||||
|
return PathManager.MakeAbsolutePath(Global.Config.PathEntries.MoviesPathFragment, null) +
|
||||||
|
"\\Macros";
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,135 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
using BizHawk.Client.Common;
|
||||||
|
using BizHawk.Emulation.Common;
|
||||||
|
|
||||||
|
namespace BizHawk.Client.EmuHawk
|
||||||
|
{
|
||||||
|
class MovieZone
|
||||||
|
{
|
||||||
|
public string Name;
|
||||||
|
|
||||||
|
public int Start;
|
||||||
|
public int Length;
|
||||||
|
public string InputKey;
|
||||||
|
private string[] _log;
|
||||||
|
|
||||||
|
public bool Replace = true;
|
||||||
|
public bool Overlay = false;
|
||||||
|
public float defaultFloat = 0f;
|
||||||
|
|
||||||
|
private Bk2ControllerAdapter controller;
|
||||||
|
private Bk2ControllerAdapter targetController;
|
||||||
|
|
||||||
|
public MovieZone()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
public MovieZone(TasMovie movie, int start, int length, string key = "")
|
||||||
|
{
|
||||||
|
var lg = Global.MovieSession.LogGeneratorInstance() as Bk2LogEntryGenerator;
|
||||||
|
lg.SetSource(Global.MovieSession.MovieControllerAdapter);
|
||||||
|
targetController = new Bk2ControllerAdapter();
|
||||||
|
targetController.Type = Global.Emulator.ControllerDefinition;
|
||||||
|
|
||||||
|
if (key == "")
|
||||||
|
key = lg.GenerateLogKey();
|
||||||
|
key = key.Replace("LogKey:", "").Replace("#", "");
|
||||||
|
key = key.Substring(0, key.Length - 1);
|
||||||
|
|
||||||
|
InputKey = key;
|
||||||
|
Length = length;
|
||||||
|
_log = new string[length];
|
||||||
|
|
||||||
|
// Get a IController that only contains buttons in key.
|
||||||
|
string[] keys = key.Split('|');
|
||||||
|
ControllerDefinition d = new ControllerDefinition();
|
||||||
|
for (int i = 0; i < keys.Length; i++)
|
||||||
|
{
|
||||||
|
if (Global.Emulator.ControllerDefinition.BoolButtons.Contains(keys[i]))
|
||||||
|
d.BoolButtons.Add(keys[i]);
|
||||||
|
else
|
||||||
|
d.FloatControls.Add(keys[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
controller = new Bk2ControllerAdapter() { Type = d };
|
||||||
|
var logGenerator = new Bk2LogEntryGenerator("");
|
||||||
|
logGenerator.SetSource(controller);
|
||||||
|
for (int i = 0; i < length; i++)
|
||||||
|
{
|
||||||
|
// Set controller with only the buttons in it's Type.
|
||||||
|
_log[i] = logGenerator.GenerateLogEntry();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void PlaceZone(TasMovie movie)
|
||||||
|
{
|
||||||
|
// TODO: This should probably do something with undo history batches/naming.
|
||||||
|
if (!Replace)
|
||||||
|
movie.InsertEmptyFrame(Start, Length);
|
||||||
|
|
||||||
|
if (Overlay)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < Length; i++)
|
||||||
|
{
|
||||||
|
// Overlay the frame. Float controls should use the defaultFloat value.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (int i = 0; i < Length; i++)
|
||||||
|
{
|
||||||
|
// Copy over the frame. (Only using the buttons in controller.Type)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (movie is TasMovie) // Assume TAStudio is open?
|
||||||
|
{
|
||||||
|
if (Global.Emulator.Frame < Start)
|
||||||
|
{
|
||||||
|
// TODO: Go to start of macro? Ask TAStudio to do that?
|
||||||
|
|
||||||
|
// TasMovie.InvalidateAfter(Start) [this is private]
|
||||||
|
// Load last state, Emulate to Start
|
||||||
|
|
||||||
|
// Or do this, if we can accept that TAStudio has to be open.
|
||||||
|
(GlobalWin.Tools.Get<TAStudio>() as TAStudio).GoToFrame(Start);
|
||||||
|
|
||||||
|
GlobalWin.Tools.UpdateBefore();
|
||||||
|
GlobalWin.Tools.UpdateAfter();
|
||||||
|
}
|
||||||
|
else if (GlobalWin.Tools.IsLoaded<TAStudio>())
|
||||||
|
{
|
||||||
|
GlobalWin.Tools.Get<TAStudio>().UpdateValues();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Save(string fileName)
|
||||||
|
{
|
||||||
|
// Save the controller definition/LogKey
|
||||||
|
// Save the controller name and player count. (Only for the user.)
|
||||||
|
// Save whether or not the macro should use overlay input, and/or replace
|
||||||
|
|
||||||
|
File.WriteAllText(fileName, Global.Emulator.ControllerDefinition.Name);
|
||||||
|
File.AppendAllText(fileName, "\n" + Global.Emulator.ControllerDefinition.PlayerCount);
|
||||||
|
File.AppendAllLines(fileName, _log);
|
||||||
|
}
|
||||||
|
public MovieZone(string fileName)
|
||||||
|
{
|
||||||
|
// If the LogKey contains buttons/controls not accepted by the emulator, tell the user and display the macro's controller name and player count.
|
||||||
|
|
||||||
|
if (!File.Exists(fileName))
|
||||||
|
return;
|
||||||
|
|
||||||
|
_log = File.ReadAllLines(fileName);
|
||||||
|
Length = _log.Length;
|
||||||
|
Start = 0;
|
||||||
|
|
||||||
|
Name = Path.GetFileNameWithoutExtension(fileName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue