MultiHawk - Rom Session loading/saving/etc
This commit is contained in:
parent
1e0c65150b
commit
a40ce37d50
|
@ -61,6 +61,7 @@ namespace BizHawk.Client.Common
|
|||
public int DispFinalFilter = 0;
|
||||
public string DispUserFilterPath = "";
|
||||
public RecentFiles RecentRoms = new RecentFiles(10);
|
||||
public RecentFiles RecentRomSessions = new RecentFiles(8); // Only used for MultiHawk
|
||||
public bool PauseWhenMenuActivated = true;
|
||||
public bool SaveWindowPosition = true;
|
||||
public bool StartPaused = false;
|
||||
|
|
|
@ -175,6 +175,7 @@
|
|||
<Compile Include="PresentationPanel.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="EmulatorWindowList.cs" />
|
||||
<Compile Include="ScreenSaver.cs" />
|
||||
<Compile Include="Extensions\ToolExtensions.cs" />
|
||||
<Compile Include="Throttle.cs" />
|
||||
|
|
|
@ -30,9 +30,18 @@
|
|||
{
|
||||
this.MainformMenu = new MenuStripEx();
|
||||
this.FileSubMenu = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.NewSessionMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.OpenSessionMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.SaveSessionMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.SaveSessionAsMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.RecentSessionSubMenu = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripSeparator6 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.toolStripSeparator7 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.OpenRomMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.RecentRomSubMenu = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.toolStripSeparator5 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.RebootCoresMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.ExitMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.MovieSubMenu = new System.Windows.Forms.ToolStripMenuItem();
|
||||
|
@ -52,8 +61,6 @@
|
|||
this.FameStatusBarLabel = new System.Windows.Forms.ToolStripStatusLabel();
|
||||
this.StatusBarMessageLabel = new System.Windows.Forms.ToolStripStatusLabel();
|
||||
this.PlayRecordStatusButton = new System.Windows.Forms.ToolStripDropDownButton();
|
||||
this.RebootCoresMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripSeparator5 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.MainformMenu.SuspendLayout();
|
||||
this.WorkspacePanel.SuspendLayout();
|
||||
this.MainStatusBar.SuspendLayout();
|
||||
|
@ -75,6 +82,12 @@
|
|||
// FileSubMenu
|
||||
//
|
||||
this.FileSubMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.NewSessionMenuItem,
|
||||
this.OpenSessionMenuItem,
|
||||
this.SaveSessionMenuItem,
|
||||
this.SaveSessionAsMenuItem,
|
||||
this.RecentSessionSubMenu,
|
||||
this.toolStripSeparator7,
|
||||
this.OpenRomMenuItem,
|
||||
this.RecentRomSubMenu,
|
||||
this.toolStripSeparator5,
|
||||
|
@ -86,11 +99,58 @@
|
|||
this.FileSubMenu.Text = "&File";
|
||||
this.FileSubMenu.DropDownOpened += new System.EventHandler(this.FileSubMenu_DropDownOpened);
|
||||
//
|
||||
// NewSessionMenuItem
|
||||
//
|
||||
this.NewSessionMenuItem.Name = "NewSessionMenuItem";
|
||||
this.NewSessionMenuItem.Size = new System.Drawing.Size(165, 22);
|
||||
this.NewSessionMenuItem.Text = "&New Session";
|
||||
this.NewSessionMenuItem.Click += new System.EventHandler(this.NewSessionMenuItem_Click);
|
||||
//
|
||||
// OpenSessionMenuItem
|
||||
//
|
||||
this.OpenSessionMenuItem.Name = "OpenSessionMenuItem";
|
||||
this.OpenSessionMenuItem.Size = new System.Drawing.Size(165, 22);
|
||||
this.OpenSessionMenuItem.Text = "&Open Session";
|
||||
this.OpenSessionMenuItem.Click += new System.EventHandler(this.OpenSessionMenuItem_Click);
|
||||
//
|
||||
// SaveSessionMenuItem
|
||||
//
|
||||
this.SaveSessionMenuItem.Name = "SaveSessionMenuItem";
|
||||
this.SaveSessionMenuItem.Size = new System.Drawing.Size(165, 22);
|
||||
this.SaveSessionMenuItem.Text = "&Save Session";
|
||||
this.SaveSessionMenuItem.Click += new System.EventHandler(this.SaveSessionMenuItem_Click);
|
||||
//
|
||||
// SaveSessionAsMenuItem
|
||||
//
|
||||
this.SaveSessionAsMenuItem.Name = "SaveSessionAsMenuItem";
|
||||
this.SaveSessionAsMenuItem.Size = new System.Drawing.Size(165, 22);
|
||||
this.SaveSessionAsMenuItem.Text = "Save Session &As...";
|
||||
this.SaveSessionAsMenuItem.Click += new System.EventHandler(this.SaveSessionAsMenuItem_Click);
|
||||
//
|
||||
// RecentSessionSubMenu
|
||||
//
|
||||
this.RecentSessionSubMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.toolStripSeparator6});
|
||||
this.RecentSessionSubMenu.Name = "RecentSessionSubMenu";
|
||||
this.RecentSessionSubMenu.Size = new System.Drawing.Size(165, 22);
|
||||
this.RecentSessionSubMenu.Text = "Recent Session";
|
||||
this.RecentSessionSubMenu.DropDownOpened += new System.EventHandler(this.RecentSessionSubMenu_DropDownOpened);
|
||||
//
|
||||
// toolStripSeparator6
|
||||
//
|
||||
this.toolStripSeparator6.Name = "toolStripSeparator6";
|
||||
this.toolStripSeparator6.Size = new System.Drawing.Size(57, 6);
|
||||
//
|
||||
// toolStripSeparator7
|
||||
//
|
||||
this.toolStripSeparator7.Name = "toolStripSeparator7";
|
||||
this.toolStripSeparator7.Size = new System.Drawing.Size(162, 6);
|
||||
//
|
||||
// OpenRomMenuItem
|
||||
//
|
||||
this.OpenRomMenuItem.Image = global::BizHawk.Client.MultiHawk.Properties.Resources.OpenFile;
|
||||
this.OpenRomMenuItem.Name = "OpenRomMenuItem";
|
||||
this.OpenRomMenuItem.Size = new System.Drawing.Size(152, 22);
|
||||
this.OpenRomMenuItem.Size = new System.Drawing.Size(165, 22);
|
||||
this.OpenRomMenuItem.Text = "Open ROM";
|
||||
this.OpenRomMenuItem.Click += new System.EventHandler(this.OpenRomMenuItem_Click);
|
||||
//
|
||||
|
@ -100,24 +160,37 @@
|
|||
this.toolStripSeparator1});
|
||||
this.RecentRomSubMenu.Image = global::BizHawk.Client.MultiHawk.Properties.Resources.Recent;
|
||||
this.RecentRomSubMenu.Name = "RecentRomSubMenu";
|
||||
this.RecentRomSubMenu.Size = new System.Drawing.Size(152, 22);
|
||||
this.RecentRomSubMenu.Size = new System.Drawing.Size(165, 22);
|
||||
this.RecentRomSubMenu.Text = "Recent";
|
||||
this.RecentRomSubMenu.DropDownOpened += new System.EventHandler(this.RecentRomSubMenu_DropDownOpened);
|
||||
//
|
||||
// toolStripSeparator1
|
||||
//
|
||||
this.toolStripSeparator1.Name = "toolStripSeparator1";
|
||||
this.toolStripSeparator1.Size = new System.Drawing.Size(57, 6);
|
||||
//
|
||||
// toolStripSeparator5
|
||||
//
|
||||
this.toolStripSeparator5.Name = "toolStripSeparator5";
|
||||
this.toolStripSeparator5.Size = new System.Drawing.Size(162, 6);
|
||||
//
|
||||
// RebootCoresMenuItem
|
||||
//
|
||||
this.RebootCoresMenuItem.Name = "RebootCoresMenuItem";
|
||||
this.RebootCoresMenuItem.Size = new System.Drawing.Size(165, 22);
|
||||
this.RebootCoresMenuItem.Text = "Reboot Cores";
|
||||
this.RebootCoresMenuItem.Click += new System.EventHandler(this.RebootCoresMenuItem_Click);
|
||||
//
|
||||
// toolStripSeparator3
|
||||
//
|
||||
this.toolStripSeparator3.Name = "toolStripSeparator3";
|
||||
this.toolStripSeparator3.Size = new System.Drawing.Size(149, 6);
|
||||
this.toolStripSeparator3.Size = new System.Drawing.Size(162, 6);
|
||||
//
|
||||
// ExitMenuItem
|
||||
//
|
||||
this.ExitMenuItem.Name = "ExitMenuItem";
|
||||
this.ExitMenuItem.ShortcutKeyDisplayString = "Alt+F4";
|
||||
this.ExitMenuItem.Size = new System.Drawing.Size(152, 22);
|
||||
this.ExitMenuItem.Size = new System.Drawing.Size(165, 22);
|
||||
this.ExitMenuItem.Text = "E&xit";
|
||||
this.ExitMenuItem.Click += new System.EventHandler(this.ExitMenuItem_Click);
|
||||
//
|
||||
|
@ -263,18 +336,6 @@
|
|||
this.PlayRecordStatusButton.Size = new System.Drawing.Size(29, 20);
|
||||
this.PlayRecordStatusButton.Text = "No movie is active";
|
||||
//
|
||||
// RebootCoresMenuItem
|
||||
//
|
||||
this.RebootCoresMenuItem.Name = "RebootCoresMenuItem";
|
||||
this.RebootCoresMenuItem.Size = new System.Drawing.Size(152, 22);
|
||||
this.RebootCoresMenuItem.Text = "Reboot Cores";
|
||||
this.RebootCoresMenuItem.Click += new System.EventHandler(this.RebootCoresMenuItem_Click);
|
||||
//
|
||||
// toolStripSeparator5
|
||||
//
|
||||
this.toolStripSeparator5.Name = "toolStripSeparator5";
|
||||
this.toolStripSeparator5.Size = new System.Drawing.Size(149, 6);
|
||||
//
|
||||
// Mainform
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
|
@ -325,6 +386,13 @@
|
|||
private System.Windows.Forms.ToolStripMenuItem saveConfigToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripSeparator5;
|
||||
private System.Windows.Forms.ToolStripMenuItem RebootCoresMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem OpenSessionMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem SaveSessionMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem RecentSessionSubMenu;
|
||||
private System.Windows.Forms.ToolStripMenuItem NewSessionMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem SaveSessionAsMenuItem;
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripSeparator6;
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripSeparator7;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -100,13 +100,13 @@ namespace BizHawk.Client.MultiHawk
|
|||
{
|
||||
SetMainformMovieInfo();
|
||||
|
||||
if (Global.Config.RecentRoms.AutoLoad)
|
||||
if (Global.Config.RecentRomSessions.AutoLoad)
|
||||
{
|
||||
LoadRomFromRecent(Global.Config.RecentRoms.MostRecent);
|
||||
LoadRomSessionFromRecent(Global.Config.RecentRomSessions.MostRecent);
|
||||
}
|
||||
}
|
||||
|
||||
public List<EmulatorWindow> EmulatorWindows = new List<EmulatorWindow>();
|
||||
public EmulatorWindowList EmulatorWindows = new EmulatorWindowList();
|
||||
|
||||
private bool _exit;
|
||||
|
||||
|
@ -1005,15 +1005,14 @@ namespace BizHawk.Client.MultiHawk
|
|||
{
|
||||
if (EmulatorWindows.Any())
|
||||
{
|
||||
FameStatusBarLabel.Text = EmulatorWindows.First().Emulator.Frame.ToString();
|
||||
FameStatusBarLabel.Text = EmulatorWindows.Master.Emulator.Frame.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
private void FileSubMenu_DropDownOpened(object sender, EventArgs e)
|
||||
{
|
||||
RecentRomSubMenu.DropDownItems.Clear();
|
||||
RecentRomSubMenu.DropDownItems.AddRange(
|
||||
Global.Config.RecentRoms.RecentMenu(LoadRomFromRecent, true));
|
||||
SaveSessionMenuItem.Enabled = !string.IsNullOrWhiteSpace(EmulatorWindows.SessionName);
|
||||
SaveSessionAsMenuItem.Enabled = EmulatorWindows.Any();
|
||||
}
|
||||
|
||||
private void LoadRomFromRecent(string rom)
|
||||
|
@ -1207,5 +1206,149 @@ namespace BizHawk.Client.MultiHawk
|
|||
|
||||
AddMessage("Rebooted all cores");
|
||||
}
|
||||
|
||||
private void SaveSessionMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(EmulatorWindows.SessionName))
|
||||
{
|
||||
File.WriteAllText(EmulatorWindows.SessionName, EmulatorWindows.SessionJson);
|
||||
AddMessage("Session saved.");
|
||||
}
|
||||
}
|
||||
|
||||
private void SaveSessionAsMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (EmulatorWindows.Any())
|
||||
{
|
||||
var file = GetSaveFileFromUser();
|
||||
if (file != null)
|
||||
{
|
||||
EmulatorWindows.SessionName = file.FullName;
|
||||
Global.Config.RecentRomSessions.Add(file.FullName);
|
||||
SaveSessionMenuItem_Click(sender, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private FileInfo GetSaveFileFromUser()
|
||||
{
|
||||
var sfd = new SaveFileDialog();
|
||||
if (!string.IsNullOrWhiteSpace(EmulatorWindows.SessionName))
|
||||
{
|
||||
sfd.FileName = Path.GetFileNameWithoutExtension(EmulatorWindows.SessionName);
|
||||
sfd.InitialDirectory = Path.GetDirectoryName(EmulatorWindows.SessionName);
|
||||
}
|
||||
else if (EmulatorWindows.Master != null)
|
||||
{
|
||||
sfd.FileName = PathManager.FilesystemSafeName(EmulatorWindows.Master.Game);
|
||||
sfd.InitialDirectory = PathManager.GetRomsPath("Global");
|
||||
}
|
||||
else
|
||||
{
|
||||
sfd.FileName = "NULL";
|
||||
sfd.InitialDirectory = PathManager.GetRomsPath("Global");
|
||||
}
|
||||
|
||||
sfd.Filter = "Rom Session Files (*.romses)|*.romses|All Files|*.*";
|
||||
sfd.RestoreDirectory = true;
|
||||
var result = sfd.ShowDialog();
|
||||
if (result != DialogResult.OK)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new FileInfo(sfd.FileName);
|
||||
}
|
||||
|
||||
private void OpenSessionMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var file = GetFileFromUser("Rom Session Files (*.romses)|*.romses|All Files|*.*");
|
||||
if (file != null)
|
||||
{
|
||||
NewSessionMenuItem_Click(null, null);
|
||||
var json = File.ReadAllText(file.FullName);
|
||||
EmulatorWindows.SessionName = file.FullName;
|
||||
LoadRomSession(EmulatorWindowList.FromJson(json));
|
||||
Global.Config.RecentRomSessions.Add(file.FullName);
|
||||
}
|
||||
}
|
||||
|
||||
private static FileInfo GetFileFromUser(string filter)
|
||||
{
|
||||
var ofd = new OpenFileDialog
|
||||
{
|
||||
InitialDirectory = PathManager.GetRomsPath("Global"),
|
||||
Filter = filter,
|
||||
RestoreDirectory = true
|
||||
};
|
||||
|
||||
if (!Directory.Exists(ofd.InitialDirectory))
|
||||
{
|
||||
Directory.CreateDirectory(ofd.InitialDirectory);
|
||||
}
|
||||
|
||||
var result = ofd.ShowDialog();
|
||||
return result == DialogResult.OK ? new FileInfo(ofd.FileName) : null;
|
||||
}
|
||||
|
||||
private void CloseAllWindows()
|
||||
{
|
||||
foreach (var ew in EmulatorWindows.ToList())
|
||||
{
|
||||
ew.Close();
|
||||
}
|
||||
|
||||
EmulatorWindows.Clear();
|
||||
}
|
||||
|
||||
private void NewSessionMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
foreach (var ew in EmulatorWindows.ToList())
|
||||
{
|
||||
ew.Close();
|
||||
}
|
||||
|
||||
EmulatorWindows.Clear();
|
||||
}
|
||||
|
||||
private void LoadRomSession(IEnumerable<EmulatorWindowList.RomSessionEntry> entries)
|
||||
{
|
||||
foreach (var entry in entries)
|
||||
{
|
||||
LoadRom(entry.RomName);
|
||||
EmulatorWindows.Last().Location = new Point(entry.Wndx, entry.Wndy);
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadRomSessionFromRecent(string path)
|
||||
{
|
||||
var file = new FileInfo(path);
|
||||
if (file.Exists)
|
||||
{
|
||||
NewSessionMenuItem_Click(null, null);
|
||||
var json = File.ReadAllText(file.FullName);
|
||||
EmulatorWindows.SessionName = file.FullName;
|
||||
LoadRomSession(EmulatorWindowList.FromJson(json));
|
||||
Global.Config.RecentRomSessions.Add(file.FullName);
|
||||
}
|
||||
else
|
||||
{
|
||||
Global.Config.RecentRomSessions.HandleLoadError(path);
|
||||
}
|
||||
}
|
||||
|
||||
private void RecentSessionSubMenu_DropDownOpened(object sender, EventArgs e)
|
||||
{
|
||||
RecentSessionSubMenu.DropDownItems.Clear();
|
||||
RecentSessionSubMenu.DropDownItems.AddRange(
|
||||
Global.Config.RecentRomSessions.RecentMenu(LoadRomSessionFromRecent, autoload: true));
|
||||
}
|
||||
|
||||
private void RecentRomSubMenu_DropDownOpened(object sender, EventArgs e)
|
||||
{
|
||||
RecentRomSubMenu.DropDownItems.Clear();
|
||||
RecentRomSubMenu.DropDownItems.AddRange(
|
||||
Global.Config.RecentRoms.RecentMenu(LoadRomFromRecent, autoload: false));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -123,4 +123,7 @@
|
|||
<metadata name="MainStatusBar.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>153, 17</value>
|
||||
</metadata>
|
||||
<metadata name="MainStatusBar.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>153, 17</value>
|
||||
</metadata>
|
||||
</root>
|
Loading…
Reference in New Issue