Dialog Title now has a asterisk at the end if the movie has pending changes to be saved. Added UI functionality for Auto-pause At End of Movie; does work yet.

This commit is contained in:
kylelyk 2014-08-23 18:02:02 +00:00
parent 3e80e59f2d
commit b66db36046
6 changed files with 82 additions and 14 deletions

View File

@ -523,6 +523,7 @@ namespace BizHawk.Client.Common
public bool AutoloadTAStudio = false;
public bool AutoloadTAStudioProject = false;
public bool TAStudioDrawInput = true;
public bool TAStudioAutoPause = true;
public bool TAStudioAutoRestoreLastPosition = false;
public bool AutoloadExperimentalTAStudio = false;

View File

@ -4,8 +4,8 @@ namespace BizHawk.Client.Common
{
public partial class Bk2Movie
{
private enum Moviemode { Inactive, Play, Record, Finished }
private Moviemode _mode = Moviemode.Inactive;
protected enum Moviemode { Inactive, Play, Record, Finished }
protected Moviemode _mode = Moviemode.Inactive;
public bool IsActive
{
@ -39,17 +39,17 @@ namespace BizHawk.Client.Common
_log.Clear();
}
public void StartNewPlayback()
public virtual void StartNewPlayback()
{
_mode = Moviemode.Play;
}
public void SwitchToRecord()
public virtual void SwitchToRecord()
{
_mode = Moviemode.Record;
}
public void SwitchToPlay()
public virtual void SwitchToPlay()
{
_mode = Moviemode.Play;
Save();

View File

@ -47,7 +47,7 @@ namespace BizHawk.Client.Common
public virtual string PreferredExtension { get { return Extension; } }
public const string Extension = "bk2";
public bool Changes { get; protected set; }
public virtual bool Changes { get; protected set; }
public bool IsCountingRerecords { get; set; }
public ILogEntryGenerator LogGeneratorInstance()

View File

@ -6,10 +6,11 @@ using System.Text;
using BizHawk.Common;
using BizHawk.Emulation.Common;
using System.ComponentModel;
namespace BizHawk.Client.Common
{
public sealed partial class TasMovie : Bk2Movie
public sealed partial class TasMovie : Bk2Movie, INotifyPropertyChanged
{
private List<bool> LagLog = new List<bool>();
private readonly TasStateManager StateManager;
@ -30,6 +31,36 @@ namespace BizHawk.Client.Common
get { return Extension; }
}
#region OnPropertyChanged Event
public event PropertyChangedEventHandler PropertyChanged;
private bool _changes;
public override bool Changes
{
get { return _changes; }
protected set
{
if (_changes != value)
{
_changes = value;
OnPropertyChanged("Changes");
}
}
}
#endregion
//This event is Raised ony when Changes is TOGGLED.
private void OnPropertyChanged(string propertyName)
{
if (PropertyChanged != null)
{
//Raising the event when FirstName or LastName property value changed
PropertyChanged.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
public new const string Extension = "tasproj";
public TasMovieMarkerList Markers { get; set; }
@ -62,6 +93,11 @@ namespace BizHawk.Client.Common
Markers.Add(0, StartsFromSavestate ? "Savestate" : "Power on");
}
public override void SwitchToPlay()
{
_mode = Moviemode.Play;
}
/// <summary>
/// Removes lag log and greenzone after this frame
/// </summary>

View File

@ -555,10 +555,10 @@ namespace BizHawk.Client.EmuHawk
//
// AutopauseAtEndOfMovieMenuItem
//
this.AutopauseAtEndOfMovieMenuItem.Enabled = false;
this.AutopauseAtEndOfMovieMenuItem.Name = "AutopauseAtEndOfMovieMenuItem";
this.AutopauseAtEndOfMovieMenuItem.Size = new System.Drawing.Size(288, 22);
this.AutopauseAtEndOfMovieMenuItem.Text = "Autopause at end of Movie";
this.AutopauseAtEndOfMovieMenuItem.Click += new System.EventHandler(this.AutopauseAtEndMenuItem_Click);
//
// MetaSubMenu
//

View File

@ -5,6 +5,7 @@ using System.IO;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.ComponentModel;
using BizHawk.Client.Common;
using BizHawk.Client.Common.MovieConversionExtensions;
@ -96,6 +97,7 @@ namespace BizHawk.Client.EmuHawk
private void NewTasMovie()
{
Global.MovieSession.Movie = new TasMovie();
_currentTasMovie.PropertyChanged += TasMovie_OnPropertyChanged;
_currentTasMovie = Global.MovieSession.Movie as TasMovie;
_currentTasMovie.Filename = DefaultTasProjName(); // TODO don't do this, take over any mainform actions that can crash without a filename
_currentTasMovie.PopulateWithDefaultHeaderValues();
@ -126,10 +128,11 @@ namespace BizHawk.Client.EmuHawk
{
if (AskSaveChanges())
{
var movie = new TasMovie
var movie = new TasMovie()
{
Filename = path
};
movie.PropertyChanged += TasMovie_OnPropertyChanged;
var file = new FileInfo(path);
if (!file.Exists)
@ -287,7 +290,15 @@ namespace BizHawk.Client.EmuHawk
_currentTasMovie.SwitchToPlay(); // TODO: stop copy/pasting this logic
Global.Emulator.LoadStateBinary(new BinaryReader(new MemoryStream(_currentTasMovie[_currentTasMovie.LastEmulatedFrame].State.ToArray())));
GlobalWin.MainForm.UnpauseEmulator();
GlobalWin.MainForm.PauseOnFrame = frame;
if(Global.Config.TAStudioAutoPause)
{
GlobalWin.MainForm.PauseOnFrame = _currentTasMovie.LastEmulatedFrame;
}
else
{
GlobalWin.MainForm.PauseOnFrame = frame;
}
}
RefreshDialog();
@ -337,18 +348,18 @@ namespace BizHawk.Client.EmuHawk
// TODO: columns selected
// TODO: clipboard
var list = TasView.SelectedIndices;
string message;
string message = "Selected: ";
if (list.Count > 0)
{
message = list.Count + " rows, 0 col, clipboard: ";
message += list.Count + " rows 0 col, Clipboard: ";
}
else
{
message = list.Count + " selected: none, clipboard: ";
message += list.Count + " none, Clipboard: ";
}
message += _tasClipboard.Any() ? _tasClipboard.Count.ToString() : "empty";
message += _tasClipboard.Any() ? _tasClipboard.Count.ToString() + " rows 0 col": "empty";
SplicerStatusLabel.Text = message;
}
@ -798,6 +809,7 @@ namespace BizHawk.Client.EmuHawk
private void ConfigSubMenu_DropDownOpened(object sender, EventArgs e)
{
DrawInputByDraggingMenuItem.Checked = Global.Config.TAStudioDrawInput;
AutopauseAtEndOfMovieMenuItem.Checked = Global.Config.TAStudioAutoPause;
}
private void DrawInputByDraggingMenuItem_Click(object sender, EventArgs e)
@ -806,6 +818,11 @@ namespace BizHawk.Client.EmuHawk
TasView.InputPaintingMode = Global.Config.TAStudioDrawInput ^= true;
}
private void AutopauseAtEndMenuItem_Click(object sender, EventArgs e)
{
Global.Config.TAStudioAutoPause ^= true;
}
#endregion
#region Metadata
@ -954,6 +971,20 @@ namespace BizHawk.Client.EmuHawk
}
}
//This method is called everytime the Changes property is toggled on a TasMovie instance.
private void TasMovie_OnPropertyChanged(object sender, PropertyChangedEventArgs e)
{
if (_currentTasMovie.Changes)
{
Text += "*";
}
else
{
Text = Text.Replace("*", "");
}
}
#endregion
#endregion