Start proof of concept of an IControlManinform interface. Mainform now has RelinguishControl and TakeControl methods. Tools that implement IControlMainform can override mainform actions. TAstudio implements this, currently the only ability is to override Read only toggle. The intend of this is to allow TAStudio and debuggers to take control of relevant mainform actions

This commit is contained in:
adelikat 2014-07-08 16:08:52 +00:00
parent bccf0e8c3b
commit 5843a8f396
4 changed files with 47 additions and 7 deletions

View File

@ -497,6 +497,7 @@
<Compile Include="Input\GamePad.cs" Condition=" '$(OS)' == 'Windows_NT' " />
<Compile Include="Input\GamePad360.cs" />
<Compile Include="Input\Input.cs" />
<Compile Include="IControlMainform.cs" />
<Compile Include="JumpLists.cs" />
<Compile Include="LogConsole.cs" />
<Compile Include="LogWindow.cs">

View File

@ -0,0 +1,7 @@
namespace BizHawk.Client.EmuHawk
{
public interface IControlMainform
{
void ToggleReadOnly();
}
}

View File

@ -1894,16 +1894,23 @@ namespace BizHawk.Client.EmuHawk
Global.Config.DisplayInput ^= true;
}
private static void ToggleReadOnly()
private void ToggleReadOnly()
{
if (Global.MovieSession.Movie.IsActive)
if (IsSlave)
{
Global.MovieSession.ReadOnly ^= true;
GlobalWin.OSD.AddMessage(Global.MovieSession.ReadOnly ? "Movie read-only mode" : "Movie read+write mode");
_master.ToggleReadOnly();
}
else
{
GlobalWin.OSD.AddMessage("No movie active");
if (Global.MovieSession.Movie.IsActive)
{
Global.MovieSession.ReadOnly ^= true;
GlobalWin.OSD.AddMessage(Global.MovieSession.ReadOnly ? "Movie read-only mode" : "Movie read+write mode");
}
else
{
GlobalWin.OSD.AddMessage("No movie active");
}
}
}
@ -3304,7 +3311,21 @@ namespace BizHawk.Client.EmuHawk
ProfileFirstBootLabel.Visible = false;
}
// TODO: move me
private IControlMainform _master;
public void RelinquishControl(IControlMainform master)
{
_master = master;
}
private bool IsSlave
{
get { return _master != null; }
}
public void TakeControl()
{
_master = null;
}
}
}

View File

@ -10,7 +10,7 @@ using BizHawk.Client.Common.MovieConversionExtensions;
namespace BizHawk.Client.EmuHawk
{
public partial class TAStudio : Form, IToolForm
public partial class TAStudio : Form, IToolForm, IControlMainform
{
// TODO: UI flow that conveniently allows to start from savestate
private const string MarkerColumnName = "MarkerColumn";
@ -129,6 +129,15 @@ namespace BizHawk.Client.EmuHawk
#endregion
#region IControlMainform implementation
public void ToggleReadOnly()
{
GlobalWin.OSD.AddMessage("TAStudio does not allow manual readonly toggle");
}
#endregion
private void TasView_QueryItemBkColor(int index, int column, ref Color color)
{
var record = _tas[index];
@ -227,12 +236,14 @@ namespace BizHawk.Client.EmuHawk
{
GlobalWin.OSD.AddMessage("TAStudio engaged");
_tas = Global.MovieSession.Movie as TasMovie;
GlobalWin.MainForm.RelinquishControl(this);
}
private void DisengageTastudio()
{
GlobalWin.OSD.AddMessage("TAStudio disengaged");
Global.MovieSession.Movie = MovieService.DefaultInstance;
GlobalWin.MainForm.TakeControl();
}
private void NewTasMovie()