Skip to content

Commit a263e1b

Browse files
committed
Add some hotkeys for markers, and display them in tool tips.
1 parent ec6b3b6 commit a263e1b

File tree

11 files changed

+107
-40
lines changed

11 files changed

+107
-40
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,10 @@ void Bind(string tabGroup, string displayName, string defaultBinding = "", strin
137137
Bind("TAStudio", "Toggle Turbo Seek", "Shift+S");
138138
Bind("TAStudio", "Undo", "Ctrl+Z"); // TODO: these are getting not unique enough
139139
Bind("TAStudio", "Redo", "Ctrl+Y");
140+
Bind("TAStudio", "Seek To Prev Marker", "Shift+PageUp");
141+
Bind("TAStudio", "Seek To Next Marker", "Shift+PageDown");
142+
Bind("TAStudio", "Set Marker", "M");
143+
Bind("TAStudio", "Delete Marker", "Ctrl+M");
140144
Bind("TAStudio", "Sel. bet. Markers", "Ctrl+A");
141145
Bind("TAStudio", "Select All", "Ctrl+Shift+A");
142146
Bind("TAStudio", "Reselect Clip.", "Ctrl+B");

src/BizHawk.Client.Common/tools/Interfaces/IToolForm.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,5 +58,7 @@ public interface IToolForm
5858
bool ContainsFocus { get; }
5959
void Show();
6060
void Close();
61+
62+
void HandleHotkeyUpdate();
6163
}
6264
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -755,6 +755,8 @@ private void HotkeysMenuItem_Click(object sender, EventArgs e)
755755

756756
InitControls();
757757
InputManager.SyncControls(Emulator, MovieSession, Config);
758+
759+
Tools.HandleHotkeyUpdate();
758760
}
759761

760762
private void OpenFWConfigRomLoadFailed(RomLoader.RomErrorArgs args)

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,22 @@ void SelectAndLoadFromSlot(int slot)
395395
if (!Tools.IsLoaded<TAStudio>()) return false;
396396
Tools.TAStudio.RedoExternal();
397397
break;
398+
case "Seek To Prev Marker":
399+
if (!Tools.IsLoaded<TAStudio>()) return false;
400+
Tools.TAStudio.GoToPreviousMarker();
401+
break;
402+
case "Seek To Next Marker":
403+
if (!Tools.IsLoaded<TAStudio>()) return false;
404+
Tools.TAStudio.GoToNextMarker();
405+
break;
406+
case "Set Marker":
407+
if (!Tools.IsLoaded<TAStudio>()) return false;
408+
Tools.TAStudio.SetMarker();
409+
break;
410+
case "Delete Marker":
411+
if (!Tools.IsLoaded<TAStudio>()) return false;
412+
Tools.TAStudio.RemoveMarker();
413+
break;
398414
case "Sel. bet. Markers":
399415
if (!Tools.IsLoaded<TAStudio>()) return false;
400416
Tools.TAStudio.SelectBetweenMarkersExternal();

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ public MarkerControl()
3939
MarkerView.QueryItemText += MarkerView_QueryItemText;
4040
}
4141

42+
public void UpdateHotkeyTooltips(Config config)
43+
{
44+
toolTip1.SetToolTip(AddMarkerButton, $"Add Marker to Emulated Frame ({config.HotkeyBindings["Set Marker"]})");
45+
toolTip1.SetToolTip(AddMarkerWithTextButton, $"Add Marker with Text to Emulated Frame ({config.HotkeyBindings["Set Marker"]} {config.HotkeyBindings["Set Marker"]})");
46+
}
47+
4248
private void SetupColumns()
4349
{
4450
MarkerView.AllColumns.Clear();

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@ public PlaybackBox()
6262
InitializeComponent();
6363
}
6464

65+
public void UpdateHotkeyTooltips(Config config)
66+
{
67+
toolTip1.SetToolTip(NextMarkerButton, config.HotkeyBindings["Seek To Next Marker"]);
68+
toolTip1.SetToolTip(PreviousMarkerButton, config.HotkeyBindings["Seek To Prev Marker"]);
69+
}
70+
6571
protected override void OnLoad(EventArgs e)
6672
{
6773
base.OnLoad(e);

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

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -999,24 +999,42 @@ private void TasView_MouseWheel(object sender, MouseEventArgs e)
999999
}
10001000
}
10011001

1002+
public void SetMarker(int frame = -1)
1003+
{
1004+
if (frame == -1) frame = Emulator.Frame;
1005+
1006+
TasMovieMarker existingMarker = CurrentTasMovie.Markers.FirstOrDefault(m => m.Frame == frame);
1007+
1008+
if (existingMarker != null)
1009+
{
1010+
MarkerControl.EditMarkerPopUp(existingMarker);
1011+
}
1012+
else
1013+
{
1014+
MarkerControl.AddMarker(frame);
1015+
}
1016+
}
1017+
1018+
public void RemoveMarker(int frame = -1)
1019+
{
1020+
if (frame == -1) frame = Emulator.Frame;
1021+
1022+
TasMovieMarker existingMarker = CurrentTasMovie.Markers.FirstOrDefault(m => m.Frame == frame);
1023+
if (existingMarker == null) return;
1024+
1025+
CurrentTasMovie.Markers.Remove(existingMarker);
1026+
MarkerControl.UpdateMarkerCount();
1027+
}
1028+
10021029
private void TasView_MouseDoubleClick(object sender, MouseEventArgs e)
10031030
{
10041031
if (TasView.CurrentCell?.Column is not { Name: var columnName }) return;
10051032

10061033
if (e.Button == MouseButtons.Left)
10071034
{
1008-
if (!AxisEditingMode && TasView.CurrentCell.RowIndex is not null && columnName is FrameColumnName)
1035+
if (!AxisEditingMode && columnName is FrameColumnName)
10091036
{
1010-
var existingMarker = CurrentTasMovie.Markers.FirstOrDefault(m => m.Frame == TasView.CurrentCell.RowIndex.Value);
1011-
1012-
if (existingMarker != null)
1013-
{
1014-
MarkerControl.EditMarkerPopUp(existingMarker);
1015-
}
1016-
else
1017-
{
1018-
MarkerControl.AddMarker(TasView.CurrentCell.RowIndex.Value);
1019-
}
1037+
SetMarker(TasView.CurrentCell.RowIndex.Value);
10201038
}
10211039
}
10221040
}
@@ -1469,15 +1487,7 @@ public void EditAnalogProgrammatically(KeyEventArgs e)
14691487
private void TasView_KeyDown(object sender, KeyEventArgs e)
14701488
{
14711489
// taseditor uses Ctrl for selection and Shift for frame cursor
1472-
if (e.IsShift(Keys.PageUp))
1473-
{
1474-
GoToPreviousMarker();
1475-
}
1476-
else if (e.IsShift(Keys.PageDown))
1477-
{
1478-
GoToNextMarker();
1479-
}
1480-
else if (e.IsShift(Keys.Home))
1490+
if (e.IsShift(Keys.Home))
14811491
{
14821492
GoToFrame(0);
14831493
}

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

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -265,18 +265,6 @@ private void EditSubMenu_DropDownOpened(object sender, EventArgs e)
265265
GreenzoneICheckSeparator.Visible =
266266
StateHistoryIntegrityCheckMenuItem.Visible =
267267
VersionInfo.DeveloperBuild;
268-
269-
UndoMenuItem.ShortcutKeyDisplayString = Config.HotkeyBindings["Undo"];
270-
RedoMenuItem.ShortcutKeyDisplayString = Config.HotkeyBindings["Redo"];
271-
SelectBetweenMarkersMenuItem.ShortcutKeyDisplayString = Config.HotkeyBindings["Sel. bet. Markers"];
272-
SelectAllMenuItem.ShortcutKeyDisplayString = Config.HotkeyBindings["Select All"];
273-
ReselectClipboardMenuItem.ShortcutKeyDisplayString = Config.HotkeyBindings["Reselect Clip."];
274-
ClearFramesMenuItem.ShortcutKeyDisplayString = Config.HotkeyBindings["Clear Frames"];
275-
DeleteFramesMenuItem.ShortcutKeyDisplayString = Config.HotkeyBindings["Delete Frames"];
276-
InsertFrameMenuItem.ShortcutKeyDisplayString = Config.HotkeyBindings["Insert Frame"];
277-
InsertNumFramesMenuItem.ShortcutKeyDisplayString = Config.HotkeyBindings["Insert # Frames"];
278-
CloneFramesMenuItem.ShortcutKeyDisplayString = Config.HotkeyBindings["Clone Frames"];
279-
CloneFramesXTimesMenuItem.ShortcutKeyDisplayString = Config.HotkeyBindings["Clone # Times"];
280268
}
281269

282270
private void UndoMenuItem_Click(object sender, EventArgs e)
@@ -1315,14 +1303,6 @@ private void RightClickMenu_Opened(object sender, EventArgs e)
13151303
RemoveMarkersContextMenuItem.Enabled = CurrentTasMovie.Markers.Any(m => TasView.IsRowSelected(m.Frame)); // Disable the option to remove markers if no markers are selected (FCEUX does this).
13161304
CancelSeekContextMenuItem.Enabled = _seekingTo != -1;
13171305
BranchContextMenuItem.Visible = TasView.CurrentCell?.RowIndex == Emulator.Frame;
1318-
1319-
SelectBetweenMarkersContextMenuItem.ShortcutKeyDisplayString = Config.HotkeyBindings["Sel. bet. Markers"];
1320-
ClearContextMenuItem.ShortcutKeyDisplayString = Config.HotkeyBindings["Clear Frames"];
1321-
DeleteFramesContextMenuItem.ShortcutKeyDisplayString = Config.HotkeyBindings["Delete Frames"];
1322-
InsertFrameContextMenuItem.ShortcutKeyDisplayString = Config.HotkeyBindings["Insert Frame"];
1323-
InsertNumFramesContextMenuItem.ShortcutKeyDisplayString = Config.HotkeyBindings["Insert # Frames"];
1324-
CloneContextMenuItem.ShortcutKeyDisplayString = Config.HotkeyBindings["Clone Frames"];
1325-
CloneXTimesContextMenuItem.ShortcutKeyDisplayString = Config.HotkeyBindings["Clone # Times"];
13261306
}
13271307

13281308
private void CancelSeekContextMenuItem_Click(object sender, EventArgs e)

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

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,11 +208,39 @@ private void Tastudio_Load(object sender, EventArgs e)
208208
Settings.BranchMarkerSplitDistance,
209209
_defaultBranchMarkerSplitDistance);
210210

211+
HandleHotkeyUpdate();
212+
211213
TasView.Font = TasViewFont;
212214
RefreshDialog();
213215
_initialized = true;
214216
}
215217

218+
public override void HandleHotkeyUpdate()
219+
{
220+
UndoMenuItem.ShortcutKeyDisplayString = Config.HotkeyBindings["Undo"];
221+
RedoMenuItem.ShortcutKeyDisplayString = Config.HotkeyBindings["Redo"];
222+
SelectBetweenMarkersMenuItem.ShortcutKeyDisplayString = Config.HotkeyBindings["Sel. bet. Markers"];
223+
SelectAllMenuItem.ShortcutKeyDisplayString = Config.HotkeyBindings["Select All"];
224+
ReselectClipboardMenuItem.ShortcutKeyDisplayString = Config.HotkeyBindings["Reselect Clip."];
225+
ClearFramesMenuItem.ShortcutKeyDisplayString = Config.HotkeyBindings["Clear Frames"];
226+
DeleteFramesMenuItem.ShortcutKeyDisplayString = Config.HotkeyBindings["Delete Frames"];
227+
InsertFrameMenuItem.ShortcutKeyDisplayString = Config.HotkeyBindings["Insert Frame"];
228+
InsertNumFramesMenuItem.ShortcutKeyDisplayString = Config.HotkeyBindings["Insert # Frames"];
229+
CloneFramesMenuItem.ShortcutKeyDisplayString = Config.HotkeyBindings["Clone Frames"];
230+
CloneFramesXTimesMenuItem.ShortcutKeyDisplayString = Config.HotkeyBindings["Clone # Times"];
231+
232+
SelectBetweenMarkersContextMenuItem.ShortcutKeyDisplayString = Config.HotkeyBindings["Sel. bet. Markers"];
233+
ClearContextMenuItem.ShortcutKeyDisplayString = Config.HotkeyBindings["Clear Frames"];
234+
DeleteFramesContextMenuItem.ShortcutKeyDisplayString = Config.HotkeyBindings["Delete Frames"];
235+
InsertFrameContextMenuItem.ShortcutKeyDisplayString = Config.HotkeyBindings["Insert Frame"];
236+
InsertNumFramesContextMenuItem.ShortcutKeyDisplayString = Config.HotkeyBindings["Insert # Frames"];
237+
CloneContextMenuItem.ShortcutKeyDisplayString = Config.HotkeyBindings["Clone Frames"];
238+
CloneXTimesContextMenuItem.ShortcutKeyDisplayString = Config.HotkeyBindings["Clone # Times"];
239+
240+
TasPlaybackBox.UpdateHotkeyTooltips(Config);
241+
MarkerControl.UpdateHotkeyTooltips(Config);
242+
}
243+
216244
private bool LoadMostRecentOrStartNew()
217245
{
218246
return LoadFileWithFallback(Settings.RecentTas.MostRecent);

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,5 +134,7 @@ protected override void OnLoad(EventArgs e)
134134
}
135135
base.OnLoad(e);
136136
}
137+
138+
public virtual void HandleHotkeyUpdate() { }
137139
}
138140
}

0 commit comments

Comments
 (0)