private void BeforeQuickSave(object sender, BeforeQuickSaveEventArgs e) { if (treeView.SelectedNode == null) { treeView.SelectedNode = treeView.Nodes[0]; } if (treeView.SelectedNode.Tag is FileInfo) { treeView.SelectedNode = treeView.SelectedNode.Parent; } string path = Path.Combine(PathManager.GetSaveStatePath(Global.Game), treeView.SelectedNode.FullPath); ClientApi.SaveState(Path.Combine(path, e.Name)); e.Handled = true; foreach (TreeNode node in treeView.SelectedNode.Nodes) { if (node.Text == e.Name) { return; } } TreeNode newNode = new TreeNode(e.Name); newNode.Tag = new FileInfo(Path.Combine(path, string.Format("{0}.State", e.Name))); treeView.SelectedNode.Nodes.Add(newNode); if (treeView.SelectedNode != null) { treeView.SelectedNode.ExpandAll(); } }
/// <summary> /// Raised before a quicksave is done (just after pressing shortcut button) /// </summary> /// <param name="sender">Object who raised the event</param> /// <param name="quickSaveSlotName">Slot used for quicksave</param> /// <param name="eventHandled">A boolean that can be set if users want to handle save themselves; if so, BizHawk won't do anything</param> public static void OnBeforeQuickSave(object sender, string quickSaveSlotName, out bool eventHandled) { eventHandled = false; if (BeforeQuickSave != null) { var e = new BeforeQuickSaveEventArgs(quickSaveSlotName); BeforeQuickSave(sender, e); eventHandled = e.Handled; } }
//We will override F10 quicksave behavior private void ClientApi_BeforeQuickSave(object sender, BeforeQuickSaveEventArgs e) { if (e.Slot == 0) { string basePath = Path.Combine(PathManager.GetSaveStatePath(Global.Game), "Test"); if (!Directory.Exists(basePath)) { Directory.CreateDirectory(basePath); } ClientApi.SaveState(Path.Combine(basePath, e.Name)); e.Handled = true; } }