Tastudio - support drag n drop of tasproj files onto the Tastudio dialog
This commit is contained in:
parent
5a2e8071d6
commit
c71aaf4e4a
|
@ -972,6 +972,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
//
|
||||
// TAStudio
|
||||
//
|
||||
this.AllowDrop = true;
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(506, 519);
|
||||
|
@ -988,6 +989,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
this.Text = "TAStudio";
|
||||
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Tastudio_Closing);
|
||||
this.Load += new System.EventHandler(this.Tastudio_Load);
|
||||
this.DragDrop += new System.Windows.Forms.DragEventHandler(this.TAStudio_DragDrop);
|
||||
this.DragEnter += new System.Windows.Forms.DragEventHandler(this.TAStudio_DragEnter);
|
||||
this.TASMenu.ResumeLayout(false);
|
||||
this.TASMenu.PerformLayout();
|
||||
this.TasStatusStrip.ResumeLayout(false);
|
||||
|
|
|
@ -59,21 +59,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
var file = ToolHelpers.GetTasProjFileFromUser(filename);
|
||||
if (file != null)
|
||||
{
|
||||
CurrentTasMovie.Filename = file.FullName;
|
||||
CurrentTasMovie.Load();
|
||||
Global.Config.RecentTas.Add(CurrentTasMovie.Filename);
|
||||
|
||||
if (CurrentTasMovie.InputLogLength > 0) // TODO: this is probably reoccuring logic, break off into a function
|
||||
{
|
||||
CurrentTasMovie.SwitchToPlay();
|
||||
}
|
||||
else
|
||||
{
|
||||
CurrentTasMovie.SwitchToRecord();
|
||||
}
|
||||
|
||||
RefreshDialog();
|
||||
MessageStatusLabel.Text = Path.GetFileName(CurrentTasMovie.Filename) + " loaded.";
|
||||
LoadFile(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -473,6 +473,25 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
}
|
||||
|
||||
private void LoadFile(FileInfo file)
|
||||
{
|
||||
CurrentTasMovie.Filename = file.FullName;
|
||||
CurrentTasMovie.Load();
|
||||
Global.Config.RecentTas.Add(CurrentTasMovie.Filename);
|
||||
|
||||
if (CurrentTasMovie.InputLogLength > 0) // TODO: this is probably reoccuring logic, break off into a function
|
||||
{
|
||||
CurrentTasMovie.SwitchToPlay();
|
||||
}
|
||||
else
|
||||
{
|
||||
CurrentTasMovie.SwitchToRecord();
|
||||
}
|
||||
|
||||
RefreshDialog();
|
||||
MessageStatusLabel.Text = Path.GetFileName(CurrentTasMovie.Filename) + " loaded.";
|
||||
}
|
||||
|
||||
#region Dialog Events
|
||||
|
||||
private void Tastudio_Load(object sender, EventArgs e)
|
||||
|
@ -587,6 +606,27 @@ namespace BizHawk.Client.EmuHawk
|
|||
RemoveMarkersContextMenuItem.Enabled = CurrentTasMovie.Markers.Any(m => TasView.SelectedRows.Contains(m.Frame)); // Disable the option to remove markers if no markers are selected (FCEUX does this).
|
||||
}
|
||||
|
||||
private void TAStudio_DragEnter(object sender, DragEventArgs e)
|
||||
{
|
||||
e.Effect = e.Data.GetDataPresent(DataFormats.FileDrop) ? DragDropEffects.Copy : DragDropEffects.None;
|
||||
}
|
||||
|
||||
private void TAStudio_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
var filePaths = (string[])e.Data.GetData(DataFormats.FileDrop);
|
||||
if (Path.GetExtension(filePaths[0]) == "." + TasMovie.Extension)
|
||||
{
|
||||
var file = new FileInfo(filePaths[0]);
|
||||
if (file != null)
|
||||
{
|
||||
if (AskSaveChanges())
|
||||
{
|
||||
LoadFile(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue