Skip to content

Commit 220e820

Browse files
committed
add hotkey and make hotkeys configurable in TAStudio
1 parent b107445 commit 220e820

5 files changed

Lines changed: 47 additions & 20 deletions

File tree

src/BizHawk.Client.Common/config/Binding.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@ void Bind(string tabGroup, string displayName, string defaultBinding = "", strin
137137
Bind("TAStudio", "Delete Branch", "Alt+Delete");
138138
Bind("TAStudio", "Show Cursor");
139139
Bind("TAStudio", "Select Current Frame");
140+
Bind("TAStudio", "Seek To Selected Frame");
141+
Bind("TAStudio", "Seek To...", "Ctrl+G");
140142
Bind("TAStudio", "Toggle Follow Cursor", "Shift+F");
141143
Bind("TAStudio", "Toggle Auto-Restore", "Alt+R");
142144
Bind("TAStudio", "Seek To Green Arrow", "R");
@@ -157,6 +159,7 @@ void Bind(string tabGroup, string displayName, string defaultBinding = "", strin
157159
Bind("TAStudio", "Insert # Frames", "Shift+Insert");
158160
Bind("TAStudio", "Clone Frames", "Ctrl+Insert");
159161
Bind("TAStudio", "Clone # Times", "Ctrl+Shift+Insert");
162+
Bind("TAStudio", "Paste Insert", "Ctrl+Shift+V");
160163
Bind("TAStudio", "Analog Increment", "Up");
161164
Bind("TAStudio", "Analog Decrement", "Down");
162165
Bind("TAStudio", "Analog Incr. by 10", "Shift+Up");

src/BizHawk.Client.EmuHawk/MainForm.Hotkey.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,14 @@ void SelectAndLoadFromSlot(int slot)
422422
if (!Tools.IsLoaded<TAStudio>()) return false;
423423
Tools.TAStudio.SelectCurrentFrame();
424424
break;
425+
case "Seek To Selected Frame":
426+
if (!Tools.IsLoaded<TAStudio>()) return false;
427+
Tools.TAStudio.SeekToSelectedFrame();
428+
break;
429+
case "Seek To...":
430+
if (!Tools.IsLoaded<TAStudio>()) return false;
431+
Tools.TAStudio.SeekToUserSpecifiedFrame();
432+
break;
425433
case "Toggle Follow Cursor":
426434
if (!Tools.IsLoaded<TAStudio>()) return false;
427435
var playbackBox = Tools.TAStudio.TasPlaybackBox;
@@ -505,6 +513,10 @@ void SelectAndLoadFromSlot(int slot)
505513
if (!Tools.IsLoaded<TAStudio>()) return false;
506514
Tools.TAStudio.CloneFramesXTimesExternal();
507515
break;
516+
case "Paste Insert":
517+
if (!Tools.IsLoaded<TAStudio>()) return false;
518+
Tools.TAStudio.PasteInsertExternal();
519+
break;
508520

509521
// SNES
510522
case "Toggle BG 1":

src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.Designer.cs

Lines changed: 8 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.MenuItems.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,18 @@ private void ReselectClipboardMenuItem_Click(object sender, EventArgs e)
382382
SetSplicer();
383383
}
384384

385+
private void GoToFrameMenuItem_Click(object sender, EventArgs e)
386+
{
387+
MainForm.PauseEmulator();
388+
using InputPrompt dialog = new()
389+
{
390+
Text = "Go to Frame",
391+
Message = "Jump/Seek to frame index:",
392+
TextInputType = InputPrompt.InputType.Unsigned,
393+
};
394+
if (this.ShowDialogWithTempMute(dialog).IsOk()) GoToFrame(int.Parse(dialog.PromptText));
395+
}
396+
385397
private void CopyMenuItem_Click(object sender, EventArgs e)
386398
{
387399
if (AnyRowsSelected)

src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -190,24 +190,6 @@ public TAStudio()
190190
_tasViewPanel.Controls.Add(_tasViewHBar);
191191
_tasViewPanel.Controls.Add(_tasViewVBar);
192192

193-
ToolStripMenuItemEx goToFrameMenuItem = new()
194-
{
195-
ShortcutKeys = Keys.Control | Keys.G,
196-
Text = "Go to Frame...",
197-
};
198-
goToFrameMenuItem.Click += (_, _) =>
199-
{
200-
MainForm.PauseEmulator();
201-
using InputPrompt dialog = new()
202-
{
203-
Text = "Go to Frame",
204-
Message = "Jump/Seek to frame index:",
205-
TextInputType = InputPrompt.InputType.Unsigned,
206-
};
207-
if (this.ShowDialogWithTempMute(dialog).IsOk()) GoToFrame(int.Parse(dialog.PromptText));
208-
};
209-
_ = EditSubMenu.DropDownItems.InsertAfter(ReselectClipboardMenuItem, insert: goToFrameMenuItem);
210-
211193
RecentSubMenu.Image = Resources.Recent;
212194
recentMacrosToolStripMenuItem.Image = Resources.Recent;
213195
TASEditorManualOnlineMenuItem.Image = Resources.Help;
@@ -261,6 +243,7 @@ public override void HandleHotkeyUpdate()
261243
SelectBetweenMarkersMenuItem.ShortcutKeyDisplayString = Config.HotkeyBindings["Sel. bet. Markers"];
262244
SelectAllMenuItem.ShortcutKeyDisplayString = Config.HotkeyBindings["Select All"];
263245
ReselectClipboardMenuItem.ShortcutKeyDisplayString = Config.HotkeyBindings["Reselect Clip."];
246+
GoToFrameMenuItem.ShortcutKeyDisplayString = Config.HotkeyBindings["Seek To..."];
264247
ClearFramesMenuItem.ShortcutKeyDisplayString = Config.HotkeyBindings["Clear Frames"];
265248
DeleteFramesMenuItem.ShortcutKeyDisplayString = Config.HotkeyBindings["Delete Frames"];
266249
InsertFrameMenuItem.ShortcutKeyDisplayString = Config.HotkeyBindings["Insert Frame"];
@@ -275,6 +258,7 @@ public override void HandleHotkeyUpdate()
275258
InsertNumFramesContextMenuItem.ShortcutKeyDisplayString = Config.HotkeyBindings["Insert # Frames"];
276259
CloneContextMenuItem.ShortcutKeyDisplayString = Config.HotkeyBindings["Clone Frames"];
277260
CloneXTimesContextMenuItem.ShortcutKeyDisplayString = Config.HotkeyBindings["Clone # Times"];
261+
PasteInsertMenuItem.ShortcutKeyDisplayString = Config.HotkeyBindings["Paste Insert"];
278262

279263
TasPlaybackBox.UpdateHotkeyTooltips(Config);
280264
BookMarkControl.UpdateHotkeyTooltips(Config);
@@ -602,6 +586,8 @@ public void CloneFramesExternal()
602586
public void CloneFramesXTimesExternal()
603587
=> CloneFramesXTimesMenuItem_Click(null, EventArgs.Empty);
604588

589+
public void PasteInsertExternal() => MaybePasteFromClipboard(overwriteSelection: false);
590+
605591
public void UndoExternal()
606592
=> UndoMenuItem_Click(null, EventArgs.Empty);
607593

@@ -625,6 +611,14 @@ public void SelectCurrentFrame()
625611
RefreshDialog();
626612
}
627613

614+
public void SeekToSelectedFrame()
615+
{
616+
if (!AnyRowsSelected) return;
617+
GoToFrame(FirstSelectedRowIndex);
618+
}
619+
620+
public void SeekToUserSpecifiedFrame() => GoToFrameMenuItem_Click(null, EventArgs.Empty);
621+
628622
public IMovieController GetBranchInput(string branchId, int frame)
629623
{
630624
var branch = Guid.TryParseExact(branchId, format: "D", out var parsed)

0 commit comments

Comments
 (0)