TAStudio - implement recent menu and Open file, but it is currently pointless since the input log parsing isn't implemented
This commit is contained in:
parent
fd149237ee
commit
4d770ab0f3
|
@ -482,6 +482,7 @@ namespace BizHawk.Client.Common
|
|||
public int TASWidth = -1;
|
||||
public int TASHeight = -1;
|
||||
public bool TAStudioDrawInput = true;
|
||||
public RecentFiles RecentTas = new RecentFiles(8);
|
||||
|
||||
// VirtualPad Dialog
|
||||
public bool VirtualPadsUpdatePads = true;
|
||||
|
|
|
@ -154,11 +154,11 @@ namespace BizHawk.Client.EmuHawk
|
|||
//
|
||||
// OpenTASMenuItem
|
||||
//
|
||||
this.OpenTASMenuItem.Enabled = false;
|
||||
this.OpenTASMenuItem.Name = "OpenTASMenuItem";
|
||||
this.OpenTASMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.O)));
|
||||
this.OpenTASMenuItem.Size = new System.Drawing.Size(186, 22);
|
||||
this.OpenTASMenuItem.Text = "&Open";
|
||||
this.OpenTASMenuItem.Click += new System.EventHandler(this.OpenTASMenuItem_Click);
|
||||
//
|
||||
// SaveTASMenuItem
|
||||
//
|
||||
|
@ -181,16 +181,16 @@ namespace BizHawk.Client.EmuHawk
|
|||
//
|
||||
this.RecentSubMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.toolStripSeparator3});
|
||||
this.RecentSubMenu.Enabled = false;
|
||||
this.RecentSubMenu.Image = global::BizHawk.Client.EmuHawk.Properties.Resources.Recent;
|
||||
this.RecentSubMenu.Name = "RecentSubMenu";
|
||||
this.RecentSubMenu.Size = new System.Drawing.Size(186, 22);
|
||||
this.RecentSubMenu.Text = "Recent";
|
||||
this.RecentSubMenu.DropDownOpened += new System.EventHandler(this.RecentSubMenu_DropDownOpened);
|
||||
//
|
||||
// toolStripSeparator3
|
||||
//
|
||||
this.toolStripSeparator3.Name = "toolStripSeparator3";
|
||||
this.toolStripSeparator3.Size = new System.Drawing.Size(57, 6);
|
||||
this.toolStripSeparator3.Size = new System.Drawing.Size(149, 6);
|
||||
//
|
||||
// toolStripSeparator1
|
||||
//
|
||||
|
|
|
@ -206,6 +206,30 @@ namespace BizHawk.Client.EmuHawk
|
|||
Global.Config.TASHeight = Bottom - Top;
|
||||
}
|
||||
|
||||
public void LoadFileFromRecent(string path)
|
||||
{
|
||||
var askResult = true;
|
||||
if (_tas.Changes)
|
||||
{
|
||||
askResult = AskSave();
|
||||
}
|
||||
|
||||
if (askResult)
|
||||
{
|
||||
_tas.Filename = path;
|
||||
var loadResult = _tas.Load();
|
||||
if (!loadResult)
|
||||
{
|
||||
ToolHelpers.HandleLoadError(Global.Config.RecentTas, path);
|
||||
}
|
||||
else
|
||||
{
|
||||
Global.Config.RecentTas.Add(path);
|
||||
TASView.ItemCount = _tas.InputLogLength;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#region Events
|
||||
|
||||
#region File Menu
|
||||
|
@ -215,6 +239,26 @@ namespace BizHawk.Client.EmuHawk
|
|||
SaveTASMenuItem.Enabled = !String.IsNullOrWhiteSpace(_tas.Filename);
|
||||
}
|
||||
|
||||
private void RecentSubMenu_DropDownOpened(object sender, EventArgs e)
|
||||
{
|
||||
RecentSubMenu.DropDownItems.Clear();
|
||||
RecentSubMenu.DropDownItems.AddRange(
|
||||
ToolHelpers.GenerateRecentMenu(Global.Config.RecentTas, LoadFileFromRecent)
|
||||
);
|
||||
}
|
||||
|
||||
private void OpenTASMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var file = ToolHelpers.GetTasProjFileFromUser(_tas.Filename);
|
||||
if (file != null)
|
||||
{
|
||||
_tas.Filename = file.FullName;
|
||||
_tas.Load();
|
||||
Global.Config.RecentTas.Add(_tas.Filename);
|
||||
// TOOD: message to the user
|
||||
}
|
||||
}
|
||||
|
||||
private void SaveTASMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
_tas.Save();
|
||||
|
@ -228,6 +272,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
_tas.Filename = file.FullName;
|
||||
_tas.Save();
|
||||
Global.Config.RecentTas.Add(_tas.Filename);
|
||||
// TODO: inform the user it happened somehow
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,27 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
public static class ToolHelpers
|
||||
{
|
||||
public static FileInfo GetTasProjFileFromUser(string currentFile)
|
||||
{
|
||||
var ofd = new OpenFileDialog();
|
||||
if (!String.IsNullOrWhiteSpace(currentFile))
|
||||
{
|
||||
ofd.FileName = Path.GetFileNameWithoutExtension(currentFile);
|
||||
}
|
||||
|
||||
ofd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.PathEntries.MoviesPath, null);
|
||||
ofd.Filter = "Tas Project Files (*.tasproj)|*.tasproj|All Files|*.*";
|
||||
ofd.RestoreDirectory = true;
|
||||
|
||||
var result = ofd.ShowHawkDialog();
|
||||
if (result != DialogResult.OK)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new FileInfo(ofd.FileName);
|
||||
}
|
||||
|
||||
public static FileInfo GetTasProjSaveFileFromUser(string currentFile)
|
||||
{
|
||||
var sfd = new SaveFileDialog();
|
||||
|
|
Loading…
Reference in New Issue