-Bugfix: TAStudio couldn't re-save a project.

-Bugfix: tasproj files without StateHistory couldn't load.
-Gave a bunch of StateHistory stuff proper names.
This commit is contained in:
SuuperW 2015-03-02 23:43:52 +00:00
parent f44f32997d
commit 2c876858f2
11 changed files with 75 additions and 62 deletions

View File

@ -23,7 +23,7 @@ namespace BizHawk.Client.Common
// TasMovie // TasMovie
LagLog, LagLog,
Greenzone, Greenzone, // Greenzone actually means StateHistory. Changing these two names would break previous save files, though.
GreenzoneSettings, GreenzoneSettings,
Markers, Markers,
ClientSettings, ClientSettings,

View File

@ -21,7 +21,8 @@ namespace BizHawk.Client.Common
EnableZip64 = Zip64Option.Never, EnableZip64 = Zip64Option.Never,
CompressionLevel = (Ionic.Zlib.CompressionLevel)level CompressionLevel = (Ionic.Zlib.CompressionLevel)level
}; };
} z.CompressionMethod = CompressionMethod.Deflate;
}
public void WriteItem(string name, Action<Stream> callback) public void WriteItem(string name, Action<Stream> callback)
{ {

View File

@ -54,9 +54,10 @@ namespace BizHawk.Client.Common
ReportProgress(PROGRESS_STEP); ReportProgress(PROGRESS_STEP);
// TasProj extras // TasProj extras
// Greenzone actually means StateHistory. Changing these two names would break previous save files, though.
bs.PutLump(BinaryStateLump.GreenzoneSettings, tw => tw.WriteLine(StateManager.Settings.ToString())); bs.PutLump(BinaryStateLump.GreenzoneSettings, tw => tw.WriteLine(StateManager.Settings.ToString()));
ReportProgress(PROGRESS_STEP); ReportProgress(PROGRESS_STEP);
if (StateManager.Settings.SaveGreenzone) if (StateManager.Settings.SaveStateHistory)
{ {
bs.PutLump(BinaryStateLump.Greenzone, (BinaryWriter bw) => StateManager.Save(bw)); bs.PutLump(BinaryStateLump.Greenzone, (BinaryWriter bw) => StateManager.Save(bw));
} }
@ -197,12 +198,13 @@ namespace BizHawk.Client.Common
}); });
} }
// Greenzone actually means StateHistory. Changing these two names would break previous save files, though.
bl.GetLump(BinaryStateLump.GreenzoneSettings, false, delegate(TextReader tr) bl.GetLump(BinaryStateLump.GreenzoneSettings, false, delegate(TextReader tr)
{ {
StateManager.Settings.PopulateFromString(tr.ReadToEnd()); StateManager.Settings.PopulateFromString(tr.ReadToEnd());
}); });
if (StateManager.Settings.SaveGreenzone) if (StateManager.Settings.SaveStateHistory)
{ {
bl.GetLump(BinaryStateLump.Greenzone, false, delegate(BinaryReader br, long length) bl.GetLump(BinaryStateLump.Greenzone, false, delegate(BinaryReader br, long length)
{ {

View File

@ -23,6 +23,10 @@ namespace BizHawk.Client.Common
private readonly List<string> VerificationLog = new List<string>(); // For movies that do not begin with power-on, this is the input required to get into the initial state private readonly List<string> VerificationLog = new List<string>(); // For movies that do not begin with power-on, this is the input required to get into the initial state
private BackgroundWorker _progressReportWorker = null; private BackgroundWorker _progressReportWorker = null;
public void NewBGWorker(BackgroundWorker newWorker)
{
_progressReportWorker = newWorker;
}
public TasMovie(string path, bool startsFromSavestate = false, BackgroundWorker progressReportWorker = null) public TasMovie(string path, bool startsFromSavestate = false, BackgroundWorker progressReportWorker = null)
: base(path) : base(path)
@ -248,7 +252,7 @@ namespace BizHawk.Client.Common
{ {
if (StateManager.Any()) if (StateManager.Any())
{ {
StateManager.ClearGreenzone(); StateManager.ClearStateHistory();
Changes = true; Changes = true;
} }
} }

View File

@ -207,7 +207,7 @@ namespace BizHawk.Client.Common
Used = 0; Used = 0;
} }
public void ClearGreenzone() public void ClearStateHistory()
{ {
if (States.Any()) if (States.Any())
{ {

View File

@ -10,13 +10,13 @@ namespace BizHawk.Client.Common
{ {
public TasStateManagerSettings() public TasStateManagerSettings()
{ {
SaveGreenzone = true; SaveStateHistory = true;
Capacitymb = 512; Capacitymb = 512;
} }
public TasStateManagerSettings(TasStateManagerSettings settings) public TasStateManagerSettings(TasStateManagerSettings settings)
{ {
SaveGreenzone = settings.SaveGreenzone; SaveStateHistory = settings.SaveStateHistory;
Capacitymb = settings.Capacitymb; Capacitymb = settings.Capacitymb;
} }
@ -25,7 +25,7 @@ namespace BizHawk.Client.Common
/// </summary> /// </summary>
[DisplayName("Save History")] [DisplayName("Save History")]
[Description("Whether or not to use savestate history")] [Description("Whether or not to use savestate history")]
public bool SaveGreenzone { get; set; } public bool SaveStateHistory { get; set; }
/// <summary> /// <summary>
/// The total amount of memory to devote to greenzone in megabytes /// The total amount of memory to devote to greenzone in megabytes
@ -45,7 +45,7 @@ namespace BizHawk.Client.Common
{ {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.AppendLine(SaveGreenzone.ToString()); sb.AppendLine(SaveStateHistory.ToString());
sb.AppendLine(Capacitymb.ToString()); sb.AppendLine(Capacitymb.ToString());
return sb.ToString(); return sb.ToString();
@ -56,7 +56,7 @@ namespace BizHawk.Client.Common
if (!string.IsNullOrWhiteSpace(settings)) if (!string.IsNullOrWhiteSpace(settings))
{ {
var lines = settings.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); var lines = settings.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
SaveGreenzone = bool.Parse(lines[0]); SaveStateHistory = bool.Parse(lines[0]);
Capacitymb = int.Parse(lines[1]); Capacitymb = int.Parse(lines[1]);
} }
} }

View File

@ -9,7 +9,7 @@ using System.Windows.Forms;
namespace BizHawk.Client.EmuHawk namespace BizHawk.Client.EmuHawk
{ {
public partial class GreenzoneSettingsForm public partial class StateHistorySettingsForm
{ {
/// <summary> /// <summary>
/// Required designer variable. /// Required designer variable.
@ -35,10 +35,10 @@ namespace BizHawk.Client.EmuHawk
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(GreenzoneSettingsForm)); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(StateHistorySettingsForm));
this.CancelBtn = new System.Windows.Forms.Button(); this.CancelBtn = new System.Windows.Forms.Button();
this.OkBtn = new System.Windows.Forms.Button(); this.OkBtn = new System.Windows.Forms.Button();
this.SaveGreenzoneCheckbox = new System.Windows.Forms.CheckBox(); this.SaveStateHistoryCheckbox = new System.Windows.Forms.CheckBox();
this.CapacityNumeric = new System.Windows.Forms.NumericUpDown(); this.CapacityNumeric = new System.Windows.Forms.NumericUpDown();
this.label1 = new System.Windows.Forms.Label(); this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label();
@ -74,13 +74,13 @@ namespace BizHawk.Client.EmuHawk
// //
// SaveGreenzoneCheckbox // SaveGreenzoneCheckbox
// //
this.SaveGreenzoneCheckbox.AutoSize = true; this.SaveStateHistoryCheckbox.AutoSize = true;
this.SaveGreenzoneCheckbox.Location = new System.Drawing.Point(13, 20); this.SaveStateHistoryCheckbox.Location = new System.Drawing.Point(13, 20);
this.SaveGreenzoneCheckbox.Name = "SaveGreenzoneCheckbox"; this.SaveStateHistoryCheckbox.Name = "SaveGreenzoneCheckbox";
this.SaveGreenzoneCheckbox.Size = new System.Drawing.Size(234, 17); this.SaveStateHistoryCheckbox.Size = new System.Drawing.Size(234, 17);
this.SaveGreenzoneCheckbox.TabIndex = 2; this.SaveStateHistoryCheckbox.TabIndex = 2;
this.SaveGreenzoneCheckbox.Text = "Save savestate history information in proj file"; this.SaveStateHistoryCheckbox.Text = "Save savestate history information in proj file";
this.SaveGreenzoneCheckbox.UseVisualStyleBackColor = true; this.SaveStateHistoryCheckbox.UseVisualStyleBackColor = true;
// //
// CapacityNumeric // CapacityNumeric
// //
@ -173,7 +173,7 @@ namespace BizHawk.Client.EmuHawk
this.Controls.Add(this.label2); this.Controls.Add(this.label2);
this.Controls.Add(this.label1); this.Controls.Add(this.label1);
this.Controls.Add(this.CapacityNumeric); this.Controls.Add(this.CapacityNumeric);
this.Controls.Add(this.SaveGreenzoneCheckbox); this.Controls.Add(this.SaveStateHistoryCheckbox);
this.Controls.Add(this.OkBtn); this.Controls.Add(this.OkBtn);
this.Controls.Add(this.CancelBtn); this.Controls.Add(this.CancelBtn);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
@ -181,7 +181,7 @@ namespace BizHawk.Client.EmuHawk
this.Name = "GreenzoneSettingsForm"; this.Name = "GreenzoneSettingsForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.Manual; this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
this.Text = "Savestate History Settings"; this.Text = "Savestate History Settings";
this.Load += new System.EventHandler(this.GreenzoneSettings_Load); this.Load += new System.EventHandler(this.StateHistorySettings_Load);
((System.ComponentModel.ISupportInitialize)(this.CapacityNumeric)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.CapacityNumeric)).EndInit();
this.ResumeLayout(false); this.ResumeLayout(false);
this.PerformLayout(); this.PerformLayout();
@ -190,7 +190,7 @@ namespace BizHawk.Client.EmuHawk
private Button CancelBtn; private Button CancelBtn;
private Button OkBtn; private Button OkBtn;
private CheckBox SaveGreenzoneCheckbox; private CheckBox SaveStateHistoryCheckbox;
private NumericUpDown CapacityNumeric; private NumericUpDown CapacityNumeric;
private Label label1; private Label label1;
private Label label2; private Label label2;

View File

@ -13,23 +13,23 @@ using BizHawk.Client.Common;
namespace BizHawk.Client.EmuHawk namespace BizHawk.Client.EmuHawk
{ {
public partial class GreenzoneSettingsForm : Form public partial class StateHistorySettingsForm : Form
{ {
public IStatable Statable { get; set; } public IStatable Statable { get; set; }
private readonly TasStateManagerSettings Settings; private readonly TasStateManagerSettings Settings;
private decimal _stateSizeMb; private decimal _stateSizeMb;
public GreenzoneSettingsForm(TasStateManagerSettings settings) public StateHistorySettingsForm(TasStateManagerSettings settings)
{ {
Settings = settings; Settings = settings;
InitializeComponent(); InitializeComponent();
} }
private void GreenzoneSettings_Load(object sender, EventArgs e) private void StateHistorySettings_Load(object sender, EventArgs e)
{ {
_stateSizeMb = Statable.SaveStateBinary().Length / (decimal)1024 / (decimal)1024; _stateSizeMb = Statable.SaveStateBinary().Length / (decimal)1024 / (decimal)1024;
SaveGreenzoneCheckbox.Checked = Settings.SaveGreenzone; SaveStateHistoryCheckbox.Checked = Settings.SaveStateHistory;
CapacityNumeric.Value = Settings.Capacitymb == 0 ? 1 : Settings.Capacitymb < CapacityNumeric.Maximum ? CapacityNumeric.Value = Settings.Capacitymb == 0 ? 1 : Settings.Capacitymb < CapacityNumeric.Maximum ?
Settings.Capacitymb : Settings.Capacitymb :
CapacityNumeric.Maximum; CapacityNumeric.Maximum;
@ -45,7 +45,7 @@ namespace BizHawk.Client.EmuHawk
private void OkBtn_Click(object sender, EventArgs e) private void OkBtn_Click(object sender, EventArgs e)
{ {
Settings.SaveGreenzone = SaveGreenzoneCheckbox.Checked; Settings.SaveStateHistory = SaveStateHistoryCheckbox.Checked;
Settings.Capacitymb = (int)CapacityNumeric.Value; Settings.Capacitymb = (int)CapacityNumeric.Value;
DialogResult = DialogResult.OK; DialogResult = DialogResult.OK;
Close(); Close();

View File

@ -88,7 +88,7 @@ namespace BizHawk.Client.EmuHawk
this.AutopauseAtEndOfMovieMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.AutopauseAtEndOfMovieMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.MetaSubMenu = new System.Windows.Forms.ToolStripMenuItem(); this.MetaSubMenu = new System.Windows.Forms.ToolStripMenuItem();
this.HeaderMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.HeaderMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.GreenzoneSettingsMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.StateHistorySettingsMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.CommentsMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.CommentsMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.SubtitlesMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.SubtitlesMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator21 = new System.Windows.Forms.ToolStripSeparator(); this.toolStripSeparator21 = new System.Windows.Forms.ToolStripSeparator();
@ -602,7 +602,7 @@ namespace BizHawk.Client.EmuHawk
// //
this.MetaSubMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.MetaSubMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.HeaderMenuItem, this.HeaderMenuItem,
this.GreenzoneSettingsMenuItem, this.StateHistorySettingsMenuItem,
this.CommentsMenuItem, this.CommentsMenuItem,
this.SubtitlesMenuItem, this.SubtitlesMenuItem,
this.toolStripSeparator21, this.toolStripSeparator21,
@ -618,12 +618,12 @@ namespace BizHawk.Client.EmuHawk
this.HeaderMenuItem.Text = "&Header..."; this.HeaderMenuItem.Text = "&Header...";
this.HeaderMenuItem.Click += new System.EventHandler(this.HeaderMenuItem_Click); this.HeaderMenuItem.Click += new System.EventHandler(this.HeaderMenuItem_Click);
// //
// GreenzoneSettingsMenuItem // StateHistorySettingsMenuItem
// //
this.GreenzoneSettingsMenuItem.Name = "GreenzoneSettingsMenuItem"; this.StateHistorySettingsMenuItem.Name = "StateHistorySettingsMenuItem";
this.GreenzoneSettingsMenuItem.Size = new System.Drawing.Size(236, 22); this.StateHistorySettingsMenuItem.Size = new System.Drawing.Size(236, 22);
this.GreenzoneSettingsMenuItem.Text = "&Savestate History Settings..."; this.StateHistorySettingsMenuItem.Text = "&Savestate History Settings...";
this.GreenzoneSettingsMenuItem.Click += new System.EventHandler(this.GreenzoneSettingsMenuItem_Click); this.StateHistorySettingsMenuItem.Click += new System.EventHandler(this.StateHistorySettingsMenuItem_Click);
// //
// CommentsMenuItem // CommentsMenuItem
// //
@ -1187,7 +1187,7 @@ namespace BizHawk.Client.EmuHawk
private System.Windows.Forms.ToolStripMenuItem HeaderMenuItem; private System.Windows.Forms.ToolStripMenuItem HeaderMenuItem;
private System.Windows.Forms.ToolStripMenuItem CommentsMenuItem; private System.Windows.Forms.ToolStripMenuItem CommentsMenuItem;
private System.Windows.Forms.ToolStripMenuItem SubtitlesMenuItem; private System.Windows.Forms.ToolStripMenuItem SubtitlesMenuItem;
private System.Windows.Forms.ToolStripMenuItem GreenzoneSettingsMenuItem; private System.Windows.Forms.ToolStripMenuItem StateHistorySettingsMenuItem;
private MarkerControl MarkerControl; private MarkerControl MarkerControl;
private System.Windows.Forms.ContextMenuStrip RightClickMenu; private System.Windows.Forms.ContextMenuStrip RightClickMenu;
private System.Windows.Forms.ToolStripMenuItem SetMarkersContextMenuItem; private System.Windows.Forms.ToolStripMenuItem SetMarkersContextMenuItem;

View File

@ -611,9 +611,9 @@ namespace BizHawk.Client.EmuHawk
UpdateChangesIndicator(); UpdateChangesIndicator();
} }
private void GreenzoneSettingsMenuItem_Click(object sender, EventArgs e) private void StateHistorySettingsMenuItem_Click(object sender, EventArgs e)
{ {
new GreenzoneSettingsForm(CurrentTasMovie.TasStateManager.Settings) new StateHistorySettingsForm(CurrentTasMovie.TasStateManager.Settings)
{ {
Owner = GlobalWin.MainForm, Owner = GlobalWin.MainForm,
Location = this.ChildPointToScreen(TasView), Location = this.ChildPointToScreen(TasView),

View File

@ -70,6 +70,32 @@ namespace BizHawk.Client.EmuHawk
// TODO: show this at all times or hide it when saving is done? // TODO: show this at all times or hide it when saving is done?
this.SavingProgressBar.Visible = false; this.SavingProgressBar.Visible = false;
InitializeSaveWorker();
WantsToControlStopMovie = true;
TasPlaybackBox.Tastudio = this;
MarkerControl.Tastudio = this;
MarkerControl.Emulator = this.Emulator;
TasView.QueryItemText += TasView_QueryItemText;
TasView.QueryItemBkColor += TasView_QueryItemBkColor;
TasView.QueryItemIcon += TasView_QueryItemIcon;
TasView.QueryFrameLag += TasView_QueryFrameLag;
TasView.InputPaintingMode = Settings.DrawInput;
TasView.PointedCellChanged += TasView_PointedCellChanged;
TasView.MultiSelect = true;
TasView.MaxCharactersInHorizontal = 1;
WantsToControlRestartMovie = true;
}
private void InitializeSaveWorker()
{
if (_saveBackgroundWorker != null)
{
_saveBackgroundWorker.Dispose();
_saveBackgroundWorker = null; // Idk if this line is even useful.
}
_saveBackgroundWorker = new BackgroundWorker(); _saveBackgroundWorker = new BackgroundWorker();
_saveBackgroundWorker.WorkerReportsProgress = true; _saveBackgroundWorker.WorkerReportsProgress = true;
_saveBackgroundWorker.DoWork += (s, e) => _saveBackgroundWorker.DoWork += (s, e) =>
@ -89,31 +115,11 @@ namespace BizHawk.Client.EmuHawk
this.Invoke(() => this.MessageStatusLabel.Text = Path.GetFileName(CurrentTasMovie.Filename) + " saved."); this.Invoke(() => this.MessageStatusLabel.Text = Path.GetFileName(CurrentTasMovie.Filename) + " saved.");
this.Invoke(() => this.SavingProgressBar.Visible = false); this.Invoke(() => this.SavingProgressBar.Visible = false);
// SUPER HACKY, and i'm not even sure it's necessary InitializeSaveWorker(); // Required, or it will error when trying to report progress again.
Timer t = new Timer();
t.Tick += (a, b) =>
{
this.Invoke(() => this.MessageStatusLabel.Text = "TAStudio engaged.");
t.Stop();
};
t.Interval = 5000;
t.Start();
}; };
WantsToControlStopMovie = true; if (CurrentTasMovie != null) // Again required. TasMovie has a separate reference.
TasPlaybackBox.Tastudio = this; CurrentTasMovie.NewBGWorker(_saveBackgroundWorker);
MarkerControl.Tastudio = this;
MarkerControl.Emulator = this.Emulator;
TasView.QueryItemText += TasView_QueryItemText;
TasView.QueryItemBkColor += TasView_QueryItemBkColor;
TasView.QueryItemIcon += TasView_QueryItemIcon;
TasView.QueryFrameLag += TasView_QueryFrameLag;
TasView.InputPaintingMode = Settings.DrawInput;
TasView.PointedCellChanged += TasView_PointedCellChanged;
TasView.MultiSelect = true;
TasView.MaxCharactersInHorizontal = 1;
WantsToControlRestartMovie = true;
} }
private void TastudioToStopMovie() private void TastudioToStopMovie()