2011-05-08 11:29:34 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
2011-05-22 18:38:44 +00:00
|
|
|
|
namespace BizHawk.MultiClient
|
2011-05-08 11:29:34 +00:00
|
|
|
|
{
|
2011-06-11 22:32:12 +00:00
|
|
|
|
public partial class TAStudio : Form
|
|
|
|
|
{
|
2011-06-12 18:31:42 +00:00
|
|
|
|
//TODO:
|
2011-07-24 17:29:09 +00:00
|
|
|
|
//If null emulator do a base virtualpad so getmnemonic doesn't fail
|
2011-06-12 18:31:42 +00:00
|
|
|
|
//Right-click - Go to current frame
|
|
|
|
|
//Clicking a frame should go there
|
2011-06-12 20:33:42 +00:00
|
|
|
|
//Multiple timeline system
|
|
|
|
|
//Macro listview
|
|
|
|
|
// Double click brings up a macro editing window
|
|
|
|
|
//NES Controls virtualpad (Power-on & Reset, eventually FDS options)
|
2011-06-12 21:36:03 +00:00
|
|
|
|
//SMS virtualpad
|
|
|
|
|
//PCE virtualpad
|
|
|
|
|
//Dynamic virtualpad system based on platform
|
|
|
|
|
//ensureVisible when recording
|
2011-06-12 18:31:42 +00:00
|
|
|
|
|
2011-06-11 22:32:12 +00:00
|
|
|
|
int defaultWidth; //For saving the default size of the dialog, so the user can restore if desired
|
|
|
|
|
int defaultHeight;
|
2011-06-12 14:42:50 +00:00
|
|
|
|
|
|
|
|
|
public bool Engaged; //When engaged the Client will listen to TAStudio for input
|
2011-07-24 17:29:09 +00:00
|
|
|
|
List<VirtualPad> Pads = new List<VirtualPad>();
|
2011-06-11 22:32:12 +00:00
|
|
|
|
|
2011-06-12 20:33:42 +00:00
|
|
|
|
//Movie header object - to have the main project header data
|
|
|
|
|
//List<string> MacroFiles - list of .macro files (simply log files)
|
|
|
|
|
//List<string> TimeLines - list of .tas files
|
|
|
|
|
//List<string> Bookmarks - list of savestate files
|
|
|
|
|
|
2011-06-11 22:32:12 +00:00
|
|
|
|
public TAStudio()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
Closing += (o, e) => SaveConfigSettings();
|
|
|
|
|
TASView.QueryItemText += new QueryItemTextHandler(TASView_QueryItemText);
|
|
|
|
|
TASView.QueryItemBkColor += new QueryItemBkColorHandler(TASView_QueryItemBkColor);
|
|
|
|
|
TASView.VirtualMode = true;
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-11 22:59:21 +00:00
|
|
|
|
public void UpdateValues()
|
2011-06-11 22:32:12 +00:00
|
|
|
|
{
|
2011-06-12 21:36:03 +00:00
|
|
|
|
if (!this.IsHandleCreated || this.IsDisposed) return;
|
2011-07-17 14:39:15 +00:00
|
|
|
|
if (Global.MainForm.UserMovie.Mode == MOVIEMODE.INACTIVE)
|
2011-06-12 21:36:03 +00:00
|
|
|
|
TASView.ItemCount = 0;
|
|
|
|
|
else
|
|
|
|
|
DisplayList();
|
2011-06-11 22:59:21 +00:00
|
|
|
|
}
|
2011-06-11 22:32:12 +00:00
|
|
|
|
|
2011-06-12 14:42:50 +00:00
|
|
|
|
public string GetMnemonic()
|
|
|
|
|
{
|
2011-07-24 19:31:58 +00:00
|
|
|
|
StringBuilder str = new StringBuilder("|"); //TODO: Control Command virtual pad
|
2011-07-24 17:29:09 +00:00
|
|
|
|
|
2011-07-24 19:31:58 +00:00
|
|
|
|
//TODO: remove this hack with a nes controls pad
|
|
|
|
|
if (Global.Emulator.SystemId == "NES")
|
|
|
|
|
str.Append("0|");
|
|
|
|
|
|
2011-07-24 17:29:09 +00:00
|
|
|
|
for (int x = 0; x < Pads.Count; x++)
|
|
|
|
|
str.Append(Pads[x].GetMnemonic());
|
2011-06-12 14:42:50 +00:00
|
|
|
|
return str.ToString();
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-11 22:59:21 +00:00
|
|
|
|
private void TASView_QueryItemBkColor(int index, int column, ref Color color)
|
|
|
|
|
{
|
|
|
|
|
if (index == Global.Emulator.Frame)
|
|
|
|
|
color = Color.LightGreen;
|
2011-06-11 22:32:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void TASView_QueryItemText(int index, int column, out string text)
|
|
|
|
|
{
|
|
|
|
|
text = "";
|
2011-06-11 22:59:21 +00:00
|
|
|
|
if (column == 0)
|
|
|
|
|
text = String.Format("{0:#,##0}", index);
|
|
|
|
|
if (column == 1)
|
|
|
|
|
text = Global.MainForm.UserMovie.GetInputFrame(index);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void DisplayList()
|
|
|
|
|
{
|
2011-07-17 14:39:15 +00:00
|
|
|
|
TASView.ItemCount = Global.MainForm.UserMovie.Length();
|
2011-06-11 23:54:35 +00:00
|
|
|
|
TASView.ensureVisible(Global.Emulator.Frame);
|
2011-06-11 22:32:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void TAStudio_Load(object sender, EventArgs e)
|
|
|
|
|
{
|
2011-06-12 14:42:50 +00:00
|
|
|
|
//TODO: don't engage until new/open project
|
|
|
|
|
//
|
|
|
|
|
Engaged = true;
|
|
|
|
|
Global.RenderPanel.AddMessage("TAStudio engaged");
|
|
|
|
|
|
2011-06-11 22:32:12 +00:00
|
|
|
|
LoadConfigSettings();
|
|
|
|
|
ReadOnlyCheckBox.Checked = Global.MainForm.ReadOnly;
|
2011-06-11 22:59:21 +00:00
|
|
|
|
DisplayList();
|
2011-07-24 17:29:09 +00:00
|
|
|
|
|
|
|
|
|
//Add virtual pads
|
|
|
|
|
switch (Global.Emulator.SystemId)
|
|
|
|
|
{
|
|
|
|
|
case "NULL":
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
case "NES":
|
2011-07-24 19:31:58 +00:00
|
|
|
|
VirtualPadNES nespad1 = new VirtualPadNES();
|
|
|
|
|
nespad1.Location = new Point(8, 19);
|
2011-07-24 20:17:21 +00:00
|
|
|
|
nespad1.Controller = "P1";
|
2011-07-24 19:31:58 +00:00
|
|
|
|
VirtualPadNES nespad2 = new VirtualPadNES();
|
|
|
|
|
nespad2.Location = new Point(188, 19);
|
2011-07-24 20:17:21 +00:00
|
|
|
|
nespad2.Controller = "P2";
|
2011-07-24 19:31:58 +00:00
|
|
|
|
Pads.Add(nespad1);
|
|
|
|
|
Pads.Add(nespad2);
|
|
|
|
|
ControllerBox.Controls.Add(Pads[0]);
|
|
|
|
|
ControllerBox.Controls.Add(Pads[1]);
|
|
|
|
|
break;
|
|
|
|
|
case "SMS":
|
|
|
|
|
case "SG": //TODO: correct sys ID???
|
|
|
|
|
case "GG":
|
|
|
|
|
VirtualPadSMS smspad1 = new VirtualPadSMS();
|
|
|
|
|
smspad1.Location = new Point(8, 19);
|
|
|
|
|
VirtualPadSMS smspad2 = new VirtualPadSMS();
|
|
|
|
|
smspad2.Location = new Point(188, 19);
|
|
|
|
|
Pads.Add(smspad1);
|
|
|
|
|
Pads.Add(smspad2);
|
2011-07-24 17:29:09 +00:00
|
|
|
|
ControllerBox.Controls.Add(Pads[0]);
|
|
|
|
|
ControllerBox.Controls.Add(Pads[1]);
|
|
|
|
|
break;
|
|
|
|
|
}
|
2011-06-11 22:32:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void LoadConfigSettings()
|
|
|
|
|
{
|
|
|
|
|
defaultWidth = Size.Width; //Save these first so that the user can restore to its original size
|
|
|
|
|
defaultHeight = Size.Height;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void SaveConfigSettings()
|
|
|
|
|
{
|
2011-06-12 18:31:42 +00:00
|
|
|
|
Engaged = false;
|
2011-06-11 22:32:12 +00:00
|
|
|
|
Global.Config.TASWndx = this.Location.X;
|
|
|
|
|
Global.Config.TASWndy = this.Location.Y;
|
|
|
|
|
Global.Config.TASWidth = this.Right - this.Left;
|
|
|
|
|
Global.Config.TASHeight = this.Bottom - this.Top;
|
2011-07-24 20:17:21 +00:00
|
|
|
|
|
|
|
|
|
for (int x = 0; x < Pads.Count; x++)
|
|
|
|
|
Pads[x].Clear();
|
2011-06-11 22:32:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Restart()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
this.Close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void settingsToolStripMenuItem_DropDownOpened(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
saveWindowPositionToolStripMenuItem.Checked = Global.Config.TAStudioSaveWindowPosition;
|
|
|
|
|
autoloadToolStripMenuItem.Checked = Global.Config.AutoloadTAStudio;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void saveWindowPositionToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Global.Config.TAStudioSaveWindowPosition ^= true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void restoreWindowToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
this.Size = new System.Drawing.Size(defaultWidth, defaultHeight);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void StopButton_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2011-07-22 01:34:21 +00:00
|
|
|
|
Global.MainForm.StopMovie();
|
2011-06-11 22:32:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void FrameAdvanceButton_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2011-06-11 19:39:34 +00:00
|
|
|
|
Global.MainForm.PressFrameAdvance = true;
|
2011-06-11 22:32:12 +00:00
|
|
|
|
}
|
2011-05-22 18:38:44 +00:00
|
|
|
|
|
2011-06-11 22:32:12 +00:00
|
|
|
|
private void RewindButton_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2011-06-11 19:39:34 +00:00
|
|
|
|
Global.MainForm.PressRewind = true;
|
2011-06-11 22:32:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void PauseButton_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
Global.MainForm.TogglePause();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void autoloadToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Global.Config.AutoloadTAStudio ^= true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void checkBox1_CheckedChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
2011-06-11 23:54:35 +00:00
|
|
|
|
Global.MainForm.SetReadOnly(ReadOnlyCheckBox.Checked);
|
2011-06-11 22:32:12 +00:00
|
|
|
|
if (ReadOnlyCheckBox.Checked)
|
|
|
|
|
{
|
|
|
|
|
ReadOnlyCheckBox.BackColor = System.Drawing.SystemColors.Control;
|
2011-06-12 00:14:19 +00:00
|
|
|
|
toolTip1.SetToolTip(this.ReadOnlyCheckBox, "Currently Read-Only Mode");
|
2011-06-11 22:32:12 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ReadOnlyCheckBox.BackColor = Color.LightCoral;
|
2011-06-12 00:14:19 +00:00
|
|
|
|
toolTip1.SetToolTip(this.ReadOnlyCheckBox, "Currently Read+Write Mode");
|
2011-06-11 22:32:12 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void toolStripButton1_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Global.MainForm.PlayMovieFromBeginning();
|
|
|
|
|
}
|
2011-06-11 23:54:35 +00:00
|
|
|
|
|
|
|
|
|
private void RewindToBeginning_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2011-06-12 00:14:19 +00:00
|
|
|
|
Global.MainForm.Rewind(Global.Emulator.Frame);
|
|
|
|
|
DisplayList();
|
2011-06-11 23:54:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void FastForwardToEnd_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void editToolStripMenuItem_DropDownOpened(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (Global.MainForm.ReadOnly)
|
|
|
|
|
{
|
|
|
|
|
insertFrameToolStripMenuItem.Enabled = false;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
insertFrameToolStripMenuItem.Enabled = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void insertFrameToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (Global.MainForm.ReadOnly)
|
|
|
|
|
return;
|
|
|
|
|
}
|
2011-06-11 22:32:12 +00:00
|
|
|
|
}
|
2011-05-08 11:29:34 +00:00
|
|
|
|
}
|