InputpPompt: allow multiline info

bk2 export for tastudio: stop endlessly appending extensions
tasstudio autosave:
- fix interval init on load
- 0 interval disables autosave
- canceling SaveAs doesn't kill the timer
- ability to append "backup" to filename allows saving to a separate file
-- don't let tasproject switch to the backup file (bit hacky)
This commit is contained in:
feos 2016-06-10 16:05:12 +03:00
parent c7c706d085
commit 559eacf95a
7 changed files with 168 additions and 89 deletions

View File

@ -77,8 +77,7 @@ namespace BizHawk.Client.Common.MovieConversionExtensions
public static Bk2Movie ToBk2(this IMovie old, bool copy = false)
{
var newFilename = old.Filename + "." + Bk2Movie.Extension;
var bk2 = new Bk2Movie(newFilename);
var bk2 = new Bk2Movie(old.Filename.Replace(old.PreferredExtension, Bk2Movie.Extension));
for (var i = 0; i < old.InputLogLength; i++)
{

View File

@ -177,7 +177,7 @@ namespace BizHawk.Client.Common
}
}
// This event is Raised ony when Changes is TOGGLED.
// This event is Raised only when Changes is TOGGLED.
private void OnPropertyChanged(string propertyName)
{
if (PropertyChanged != null)

View File

@ -28,72 +28,76 @@
/// </summary>
private void InitializeComponent()
{
this.PromptLabel = new System.Windows.Forms.Label();
this.PromptBox = new System.Windows.Forms.TextBox();
this.OK = new System.Windows.Forms.Button();
this.Cancel = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// PromptLabel
//
this.PromptLabel.AutoSize = true;
this.PromptLabel.Location = new System.Drawing.Point(33, 9);
this.PromptLabel.Name = "PromptLabel";
this.PromptLabel.Size = new System.Drawing.Size(73, 13);
this.PromptLabel.TabIndex = 0;
this.PromptLabel.Text = "Enter a value:";
//
// PromptBox
//
this.PromptBox.Location = new System.Drawing.Point(36, 25);
this.PromptBox.Name = "PromptBox";
this.PromptBox.Size = new System.Drawing.Size(164, 20);
this.PromptBox.TabIndex = 1;
this.PromptBox.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.PromptBox_KeyPress);
//
// OK
//
this.OK.Location = new System.Drawing.Point(36, 67);
this.OK.Name = "OK";
this.OK.Size = new System.Drawing.Size(75, 23);
this.OK.TabIndex = 2;
this.OK.Text = "&OK";
this.OK.UseVisualStyleBackColor = true;
this.OK.Click += new System.EventHandler(this.Ok_Click);
//
// Cancel
//
this.Cancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.Cancel.Location = new System.Drawing.Point(125, 67);
this.Cancel.Name = "Cancel";
this.Cancel.Size = new System.Drawing.Size(75, 23);
this.Cancel.TabIndex = 3;
this.Cancel.Text = "&Cancel";
this.Cancel.UseVisualStyleBackColor = true;
this.Cancel.Click += new System.EventHandler(this.Cancel_Click);
//
// InputPrompt
//
this.AcceptButton = this.OK;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.Cancel;
this.ClientSize = new System.Drawing.Size(235, 106);
this.Controls.Add(this.Cancel);
this.Controls.Add(this.OK);
this.Controls.Add(this.PromptBox);
this.Controls.Add(this.PromptLabel);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.MinimumSize = new System.Drawing.Size(241, 133);
this.Name = "InputPrompt";
this.ShowIcon = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Input Prompt";
this.Load += new System.EventHandler(this.InputPrompt_Load);
this.ResumeLayout(false);
this.PerformLayout();
this.PromptLabel = new System.Windows.Forms.Label();
this.PromptBox = new System.Windows.Forms.TextBox();
this.OK = new System.Windows.Forms.Button();
this.Cancel = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// PromptLabel
//
this.PromptLabel.AutoSize = true;
this.PromptLabel.Location = new System.Drawing.Point(33, 9);
this.PromptLabel.Name = "PromptLabel";
this.PromptLabel.Size = new System.Drawing.Size(73, 13);
this.PromptLabel.TabIndex = 0;
this.PromptLabel.Text = "Enter a value:";
//
// PromptBox
//
this.PromptBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.PromptBox.Location = new System.Drawing.Point(36, 25);
this.PromptBox.Name = "PromptBox";
this.PromptBox.Size = new System.Drawing.Size(164, 20);
this.PromptBox.TabIndex = 1;
this.PromptBox.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.PromptBox_KeyPress);
//
// OK
//
this.OK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.OK.Location = new System.Drawing.Point(36, 67);
this.OK.Name = "OK";
this.OK.Size = new System.Drawing.Size(75, 23);
this.OK.TabIndex = 2;
this.OK.Text = "&OK";
this.OK.UseVisualStyleBackColor = true;
this.OK.Click += new System.EventHandler(this.Ok_Click);
//
// Cancel
//
this.Cancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.Cancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.Cancel.Location = new System.Drawing.Point(125, 67);
this.Cancel.Name = "Cancel";
this.Cancel.Size = new System.Drawing.Size(75, 23);
this.Cancel.TabIndex = 3;
this.Cancel.Text = "&Cancel";
this.Cancel.UseVisualStyleBackColor = true;
this.Cancel.Click += new System.EventHandler(this.Cancel_Click);
//
// InputPrompt
//
this.AcceptButton = this.OK;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.CancelButton = this.Cancel;
this.ClientSize = new System.Drawing.Size(235, 106);
this.Controls.Add(this.Cancel);
this.Controls.Add(this.OK);
this.Controls.Add(this.PromptBox);
this.Controls.Add(this.PromptLabel);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.MinimumSize = new System.Drawing.Size(241, 138);
this.Name = "InputPrompt";
this.ShowIcon = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Input Prompt";
this.Load += new System.EventHandler(this.InputPrompt_Load);
this.ResumeLayout(false);
this.PerformLayout();
}

View File

@ -1,13 +1,15 @@
using System;
using System.Drawing;
using System.Windows.Forms;
using System.Linq;
using BizHawk.Common.StringExtensions;
namespace BizHawk.Client.EmuHawk
{
/// <summary>
/// A simple form that prompts the user for a single line of input
/// A simple form that prompts the user for a single line of input.
/// Supports multiline messages
/// </summary>
public partial class InputPrompt : Form
{
@ -24,8 +26,15 @@ namespace BizHawk.Client.EmuHawk
public string Message
{
get { return PromptLabel.Text; }
set { PromptLabel.Text = value ?? string.Empty; }
get
{
return PromptLabel.Text;
}
set
{
PromptLabel.Text = value ?? string.Empty;
Height += PromptLabel.Font.Height * Message.Count(x => x == '\n');
}
}
public string InitialValue

View File

@ -83,8 +83,10 @@ namespace BizHawk.Client.EmuHawk
this.SetMaxUndoLevelsMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.SetBranchCellHoverIntervalMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.SetSeekingCutoffIntervalMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator26 = new System.Windows.Forms.ToolStripSeparator();
this.setAutosaveIntervalToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.AutosaveAsBk2MenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.AppendBackupToFilenameMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator9 = new System.Windows.Forms.ToolStripSeparator();
this.AutoadjustInputMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator11 = new System.Windows.Forms.ToolStripSeparator();
@ -608,8 +610,10 @@ namespace BizHawk.Client.EmuHawk
this.SetMaxUndoLevelsMenuItem,
this.SetBranchCellHoverIntervalMenuItem,
this.SetSeekingCutoffIntervalMenuItem,
this.toolStripSeparator26,
this.setAutosaveIntervalToolStripMenuItem,
this.AutosaveAsBk2MenuItem,
this.AppendBackupToFilenameMenuItem,
this.toolStripSeparator9,
this.AutoadjustInputMenuItem,
this.toolStripSeparator11,
@ -654,6 +658,11 @@ namespace BizHawk.Client.EmuHawk
this.SetSeekingCutoffIntervalMenuItem.Visible = false;
this.SetSeekingCutoffIntervalMenuItem.Click += new System.EventHandler(this.SetSeekingCutoffIntervalMenuItem_Click);
//
// toolStripSeparator26
//
this.toolStripSeparator26.Name = "toolStripSeparator26";
this.toolStripSeparator26.Size = new System.Drawing.Size(250, 6);
//
// setAutosaveIntervalToolStripMenuItem
//
this.setAutosaveIntervalToolStripMenuItem.Name = "setAutosaveIntervalToolStripMenuItem";
@ -668,6 +677,13 @@ namespace BizHawk.Client.EmuHawk
this.AutosaveAsBk2MenuItem.Text = "Autosave As Bk2";
this.AutosaveAsBk2MenuItem.Click += new System.EventHandler(this.AutosaveAsBk2MenuItem_Click);
//
// AppendBackupToFilenameMenuItem
//
this.AppendBackupToFilenameMenuItem.Name = "AppendBackupToFilenameMenuItem";
this.AppendBackupToFilenameMenuItem.Size = new System.Drawing.Size(253, 22);
this.AppendBackupToFilenameMenuItem.Text = "Append \"backup\" to Filename";
this.AppendBackupToFilenameMenuItem.Click += new System.EventHandler(this.AppendBackupToFilenameMenuItem_Click);
//
// toolStripSeparator9
//
this.toolStripSeparator9.Name = "toolStripSeparator9";
@ -1170,6 +1186,7 @@ namespace BizHawk.Client.EmuHawk
this.TasView.ScrollSpeed = 1;
this.TasView.SeekingCutoffInterval = 0;
this.TasView.Size = new System.Drawing.Size(289, 528);
this.TasView.suspendHotkeys = false;
this.TasView.TabIndex = 1;
this.TasView.ColumnClick += new BizHawk.Client.EmuHawk.InputRoll.ColumnClickEventHandler(this.TasView_ColumnClick);
this.TasView.ColumnRightClick += new BizHawk.Client.EmuHawk.InputRoll.ColumnClickEventHandler(this.TasView_ColumnRightClick);
@ -1722,5 +1739,7 @@ namespace BizHawk.Client.EmuHawk
private System.Windows.Forms.ToolStripMenuItem SetSeekingCutoffIntervalMenuItem;
private System.Windows.Forms.ToolStripMenuItem setAutosaveIntervalToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem AutosaveAsBk2MenuItem;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator26;
private System.Windows.Forms.ToolStripMenuItem AppendBackupToFilenameMenuItem;
}
}

View File

@ -89,10 +89,29 @@ namespace BizHawk.Client.EmuHawk
MessageStatusLabel.Text = "Saving...";
this.Cursor = Cursors.WaitCursor;
Update();
if (_autosaveAppendFilenamePending)
{
// temp filename
var ext = CurrentTasMovie.PreferredExtension;
CurrentTasMovie.Filename = CurrentTasMovie.Filename.Replace(ext, "backup." + ext);
}
CurrentTasMovie.Save();
Settings.RecentTas.Add(CurrentTasMovie.Filename);
_autosaveTimer.Start();
MessageStatusLabel.Text = Path.GetFileName(CurrentTasMovie.Filename) + " saved.";
if (Settings.AutosaveInterval > 0)
_autosaveTimer.Start();
MessageStatusLabel.Text = CurrentTasMovie.Name + " saved.";
if (_autosaveAppendFilenamePending)
{
// switch back to original
CurrentTasMovie.Filename = CurrentTasMovie.Filename.Replace("backup.", "");
// we should only arrive here if changes were true
// and saving to a different file clears changes
// so assuming the original file remains unsaved, keep changes flagged
CurrentTasMovie.FlagChanges();
}
else
{
Settings.RecentTas.Add(CurrentTasMovie.Filename);
}
this.Cursor = Cursors.Default;
}
}
@ -121,10 +140,12 @@ namespace BizHawk.Client.EmuHawk
CurrentTasMovie.Save();
Settings.RecentTas.Add(CurrentTasMovie.Filename);
SetTextProperty();
_autosaveTimer.Start();
MessageStatusLabel.Text = Path.GetFileName(CurrentTasMovie.Filename) + " saved.";
this.Cursor = Cursors.Default;
}
// keep insisting
if (Settings.AutosaveInterval > 0)
_autosaveTimer.Start();
}
private void saveSelectionToMacroToolStripMenuItem_Click(object sender, EventArgs e)
@ -165,9 +186,15 @@ namespace BizHawk.Client.EmuHawk
MessageStatusLabel.Text = "Exporting to .bk2...";
this.Cursor = Cursors.WaitCursor;
Update();
if (_autosaveAppendFilenamePending)
{
var ext = bk2.PreferredExtension;
bk2.Filename = bk2.Filename.Replace(ext, "backup." + ext);
}
bk2.Save();
_autosaveTimer.Start();
MessageStatusLabel.Text = Path.GetFileName(bk2.Filename) + " exported.";
if (Settings.AutosaveInterval > 0)
_autosaveTimer.Start();
MessageStatusLabel.Text = bk2.Name + " exported.";
this.Cursor = Cursors.Default;
}
@ -730,18 +757,19 @@ namespace BizHawk.Client.EmuHawk
using (var prompt = new InputPrompt
{
TextInputType = InputPrompt.InputType.Unsigned,
Message = "Autosave Interval in seconds",
Message = "Autosave Interval in seconds\nSet to 0 to disable",
InitialValue = (Settings.AutosaveInterval / 1000).ToString()
})
{
DialogResult result = prompt.ShowDialog();
if (result == DialogResult.OK)
{
int val = int.Parse(prompt.PromptText) * 1000;
uint val = uint.Parse(prompt.PromptText) * 1000;
Settings.AutosaveInterval = val;
if (val > 0)
{
Settings.AutosaveInterval = val;
_autosaveTimer.Interval = val;
_autosaveTimer.Interval = (int)val;
_autosaveTimer.Start();
}
}
}
@ -752,12 +780,18 @@ namespace BizHawk.Client.EmuHawk
Settings.AutosaveAsBk2 ^= true;
}
private void AppendBackupToFilenameMenuItem_Click(object sender, EventArgs e)
{
Settings.AppendBackupToFilename ^= true;
}
private void ConfigSubMenu_DropDownOpened(object sender, EventArgs e)
{
DrawInputByDraggingMenuItem.Checked = Settings.DrawInput;
AutopauseAtEndOfMovieMenuItem.Checked = Settings.AutoPause;
EmptyNewMarkerNotesMenuItem.Checked = Settings.EmptyMarkers;
AutosaveAsBk2MenuItem.Checked = Settings.AutosaveAsBk2;
AppendBackupToFilenameMenuItem.Checked = Settings.AppendBackupToFilename;
}
private void DrawInputByDraggingMenuItem_Click(object sender, EventArgs e)

View File

@ -38,6 +38,7 @@ namespace BizHawk.Client.EmuHawk
private UndoHistoryForm _undoForm;
private Timer _autosaveTimer = new Timer();
private bool _autosaveAppendFilenamePending = false;
public ScreenshotPopupControl ScreenshotControl = new ScreenshotPopupControl
{
@ -69,6 +70,7 @@ namespace BizHawk.Client.EmuHawk
SeekingCutoffInterval = 2; // unused, relying on VisibleRows is smarter
AutosaveInterval = 120000;
AutosaveAsBk2 = false;
AppendBackupToFilename = false;
// default to taseditor fashion
denoteStatesWithIcons = false;
denoteStatesWithBGColor = true;
@ -87,8 +89,9 @@ namespace BizHawk.Client.EmuHawk
public string FollowCursorScrollMethod { get; set; }
public int BranchCellHoverInterval { get; set; }
public int SeekingCutoffInterval { get; set; }
public int AutosaveInterval { get; set; }
public uint AutosaveInterval { get; set; }
public bool AutosaveAsBk2 { get; set; }
public bool AppendBackupToFilename { get; set; }
public bool denoteStatesWithIcons { get; set; }
public bool denoteStatesWithBGColor { get; set; }
@ -151,17 +154,19 @@ namespace BizHawk.Client.EmuHawk
TasView.MultiSelect = true;
TasView.MaxCharactersInHorizontal = 1;
WantsToControlRestartMovie = true;
_autosaveTimer.Interval = Settings.AutosaveInterval;
_autosaveTimer.Tick += AutosaveTimerEventProcessor;
_autosaveTimer.Start();
}
private void AutosaveTimerEventProcessor(object sender, EventArgs e)
{
if (!CurrentTasMovie.Changes)
if (CurrentTasMovie == null)
return;
if (!CurrentTasMovie.Changes || Settings.AutosaveInterval == 0)
return;
if (Settings.AppendBackupToFilename)
_autosaveAppendFilenamePending = true;
if (Settings.AutosaveAsBk2)
{
ToBk2MenuItem_Click(sender, e);
@ -170,6 +175,8 @@ namespace BizHawk.Client.EmuHawk
{
SaveTasMenuItem_Click(sender, e);
}
_autosaveAppendFilenamePending = false;
}
private void InitializeSaveWorker()
@ -292,7 +299,14 @@ namespace BizHawk.Client.EmuHawk
TasView.denoteStatesWithIcons = Settings.denoteStatesWithIcons;
TasView.denoteStatesWithBGColor = Settings.denoteStatesWithBGColor;
TasView.denoteMarkersWithIcons = Settings.denoteMarkersWithIcons;
TasView.denoteMarkersWithBGColor = Settings.denoteMarkersWithBGColor;
TasView.denoteMarkersWithBGColor = Settings.denoteMarkersWithBGColor;
_autosaveTimer.Tick += AutosaveTimerEventProcessor;
if (Settings.AutosaveInterval > 0)
{
_autosaveTimer.Interval = (int)Settings.AutosaveInterval;
_autosaveTimer.Start();
}
// Remembering Split container logic
int defaultMainSplitDistance = MainVertialSplit.SplitterDistance;