Tastudio - implement playback controls
This commit is contained in:
parent
816fac55fa
commit
2ebba5ab07
|
@ -120,6 +120,14 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
|
||||
public TasMovieMarker Previous(int currentFrame)
|
||||
{
|
||||
return this
|
||||
.Where(m => m.Frame < currentFrame)
|
||||
.OrderBy(m => m.Frame)
|
||||
.LastOrDefault();
|
||||
}
|
||||
|
||||
public TasMovieMarker PreviousOrCurrent(int currentFrame)
|
||||
{
|
||||
return this
|
||||
.Where(m => m.Frame <= currentFrame)
|
||||
|
|
|
@ -36,7 +36,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void MarkerView_QueryItemBkColor(int index, int column, ref Color color)
|
||||
{
|
||||
var prev = Markers.Previous(Global.Emulator.Frame);
|
||||
var prev = Markers.PreviousOrCurrent(Global.Emulator.Frame);
|
||||
|
||||
if (prev != null)
|
||||
{
|
||||
|
|
|
@ -61,7 +61,6 @@
|
|||
this.PlaybackGroupBox.TabIndex = 0;
|
||||
this.PlaybackGroupBox.TabStop = false;
|
||||
this.PlaybackGroupBox.Text = "Playback";
|
||||
this.PlaybackGroupBox.Enter += new System.EventHandler(this.PlaybackGroupBox_Enter);
|
||||
//
|
||||
// AutoRestoreCheckbox
|
||||
//
|
||||
|
@ -107,53 +106,53 @@
|
|||
//
|
||||
// NextMarkerButton
|
||||
//
|
||||
this.NextMarkerButton.Enabled = false;
|
||||
this.NextMarkerButton.Location = new System.Drawing.Point(154, 19);
|
||||
this.NextMarkerButton.Name = "NextMarkerButton";
|
||||
this.NextMarkerButton.Size = new System.Drawing.Size(38, 23);
|
||||
this.NextMarkerButton.TabIndex = 4;
|
||||
this.NextMarkerButton.Text = ">>";
|
||||
this.NextMarkerButton.UseVisualStyleBackColor = true;
|
||||
this.NextMarkerButton.Click += new System.EventHandler(this.NextMarkerButton_Click);
|
||||
//
|
||||
// FrameAdvanceButton
|
||||
//
|
||||
this.FrameAdvanceButton.Enabled = false;
|
||||
this.FrameAdvanceButton.Location = new System.Drawing.Point(117, 19);
|
||||
this.FrameAdvanceButton.Name = "FrameAdvanceButton";
|
||||
this.FrameAdvanceButton.Size = new System.Drawing.Size(38, 23);
|
||||
this.FrameAdvanceButton.TabIndex = 3;
|
||||
this.FrameAdvanceButton.Text = ">";
|
||||
this.FrameAdvanceButton.UseVisualStyleBackColor = true;
|
||||
this.FrameAdvanceButton.Click += new System.EventHandler(this.FrameAdvanceButton_Click);
|
||||
//
|
||||
// PauseButton
|
||||
//
|
||||
this.PauseButton.Enabled = false;
|
||||
this.PauseButton.Location = new System.Drawing.Point(80, 19);
|
||||
this.PauseButton.Name = "PauseButton";
|
||||
this.PauseButton.Size = new System.Drawing.Size(38, 23);
|
||||
this.PauseButton.TabIndex = 2;
|
||||
this.PauseButton.Text = "| |";
|
||||
this.PauseButton.UseVisualStyleBackColor = true;
|
||||
this.PauseButton.Click += new System.EventHandler(this.PauseButton_Click);
|
||||
//
|
||||
// RewindButton
|
||||
//
|
||||
this.RewindButton.Enabled = false;
|
||||
this.RewindButton.Location = new System.Drawing.Point(43, 19);
|
||||
this.RewindButton.Name = "RewindButton";
|
||||
this.RewindButton.Size = new System.Drawing.Size(38, 23);
|
||||
this.RewindButton.TabIndex = 1;
|
||||
this.RewindButton.Text = "<";
|
||||
this.RewindButton.UseVisualStyleBackColor = true;
|
||||
this.RewindButton.Click += new System.EventHandler(this.RewindButton_Click);
|
||||
//
|
||||
// PreviousMarkerButton
|
||||
//
|
||||
this.PreviousMarkerButton.Enabled = false;
|
||||
this.PreviousMarkerButton.Location = new System.Drawing.Point(6, 19);
|
||||
this.PreviousMarkerButton.Name = "PreviousMarkerButton";
|
||||
this.PreviousMarkerButton.Size = new System.Drawing.Size(38, 23);
|
||||
this.PreviousMarkerButton.TabIndex = 0;
|
||||
this.PreviousMarkerButton.Text = "<<";
|
||||
this.PreviousMarkerButton.UseVisualStyleBackColor = true;
|
||||
this.PreviousMarkerButton.Click += new System.EventHandler(this.PreviousMarkerButton_Click);
|
||||
//
|
||||
// PlaybackBox
|
||||
//
|
||||
|
|
|
@ -7,18 +7,42 @@ using System.Linq;
|
|||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using BizHawk.Client.Common;
|
||||
|
||||
namespace BizHawk.Client.EmuHawk
|
||||
{
|
||||
public partial class PlaybackBox : UserControl
|
||||
{
|
||||
public TAStudio Tastudio { get; set; }
|
||||
|
||||
public PlaybackBox()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void PlaybackGroupBox_Enter(object sender, EventArgs e)
|
||||
private void PreviousMarkerButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
Tastudio.GoToPreviousMarker();
|
||||
}
|
||||
|
||||
private void RewindButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
Tastudio.GoToPreviousFrame();
|
||||
}
|
||||
|
||||
private void PauseButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
Tastudio.TogglePause();
|
||||
}
|
||||
|
||||
private void FrameAdvanceButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
Tastudio.GoToNextFrame();
|
||||
}
|
||||
|
||||
private void NextMarkerButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
Tastudio.GoToNextMarker();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,6 +68,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
public TAStudio()
|
||||
{
|
||||
InitializeComponent();
|
||||
TasPlaybackBox.Tastudio = this;
|
||||
MarkerControl.Tastudio = this;
|
||||
TasView.QueryItemText += TasView_QueryItemText;
|
||||
TasView.QueryItemBkColor += TasView_QueryItemBkColor;
|
||||
|
@ -313,6 +314,42 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
}
|
||||
|
||||
#region Playback Controls
|
||||
|
||||
public void GoToPreviousMarker()
|
||||
{
|
||||
var prevMarker = _tas.Markers.Previous(Global.Emulator.Frame);
|
||||
var prev = prevMarker != null ? prevMarker.Frame : 0;
|
||||
GoToFrame(prev);
|
||||
}
|
||||
|
||||
public void GoToPreviousFrame()
|
||||
{
|
||||
if (Global.Emulator.Frame > 0)
|
||||
{
|
||||
GoToFrame(Global.Emulator.Frame - 1);
|
||||
}
|
||||
}
|
||||
|
||||
public void TogglePause()
|
||||
{
|
||||
GlobalWin.MainForm.PauseEmulator();
|
||||
}
|
||||
|
||||
public void GoToNextFrame()
|
||||
{
|
||||
GoToFrame(Global.Emulator.Frame + 1);
|
||||
}
|
||||
|
||||
public void GoToNextMarker()
|
||||
{
|
||||
var nextMarker = _tas.Markers.Next(Global.Emulator.Frame);
|
||||
var next = nextMarker != null ? nextMarker.Frame : _tas.InputLogLength - 1;
|
||||
GoToFrame(next);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private void SetSplicer()
|
||||
{
|
||||
// TODO: columns selected
|
||||
|
@ -481,7 +518,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
if (SelectedIndices.Any())
|
||||
{
|
||||
var prevMarker = _tas.Markers.Previous(LastSelectedIndex);
|
||||
var prevMarker = _tas.Markers.PreviousOrCurrent(LastSelectedIndex);
|
||||
var nextMarker = _tas.Markers.Next(LastSelectedIndex);
|
||||
|
||||
int prev = prevMarker != null ? prevMarker.Frame : 0;
|
||||
|
|
Loading…
Reference in New Issue