Skip to content

Commit

Permalink
Tastudio - Make mainform hotkeys out of a bunch of built in hotkeys
Browse files Browse the repository at this point in the history
  • Loading branch information
adelikat committed Dec 11, 2019
1 parent f309c83 commit 515f409
Show file tree
Hide file tree
Showing 4 changed files with 110 additions and 19 deletions.
14 changes: 7 additions & 7 deletions BizHawk.Client.Common/config/Binding.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,7 @@ IEnumerator IEnumerable.GetEnumerator()
return GetEnumerator();
}

public Binding this[string index]
{
get
{
return Bindings.FirstOrDefault(b => b.DisplayName == index) ?? new Binding();
}
}
public Binding this[string index] => Bindings.FirstOrDefault(b => b.DisplayName == index) ?? new Binding();

private static Binding Bind(string tabGroup, string displayName, string bindings = "", string defaultBinding = "", string toolTip = "")
{
Expand Down Expand Up @@ -223,8 +217,14 @@ public static List<Binding> DefaultValues
Bind("TAStudio", "Toggle Follow Cursor", "Shift+F"),
Bind("TAStudio", "Toggle Auto-Restore", "Shift+R"),
Bind("TAStudio", "Toggle Turbo Seek", "Shift+S"),
Bind("TAStudio", "Undo", "Ctrl+Z"), // TODO: these are getting not unique enough
Bind("TAStudio", "Redo", "Ctrl+Y"),
Bind("TAStudio", "Sel. bet. Markers", "Ctrl+A"),
Bind("TAStudio", "Select All", "Ctrl+Shift+A"),
Bind("TAStudio", "Reselect Clip.", "Ctrl+B"),
Bind("TAStudio", "Clear Frames", "Delete"),
Bind("TAStudio", "Insert Frame", "Insert"),
Bind("TAStudio", "Insert # Frames", "Ctrl+Shift+Insert"),
Bind("TAStudio", "Delete Frames", "Ctrl+Delete"),
Bind("TAStudio", "Clone Frames", "Ctrl+Insert"),
Bind("TAStudio", "Analog Increment", "UpArrow"),
Expand Down
65 changes: 65 additions & 0 deletions BizHawk.Client.EmuHawk/MainForm.Hotkey.cs
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,61 @@ private bool CheckHotkey(string trigger)
return false;
}

break;
case "Undo":
if (GlobalWin.Tools.IsLoaded<TAStudio>())
{
GlobalWin.Tools.TAStudio.UndoExternal();
}
else
{
return false;
}

break;
case "Redo":
if (GlobalWin.Tools.IsLoaded<TAStudio>())
{
GlobalWin.Tools.TAStudio.RedoExternal();
}
else
{
return false;
}

break;
case "Select between Markers":
if (GlobalWin.Tools.IsLoaded<TAStudio>())
{
GlobalWin.Tools.TAStudio.SelectBetweenMarkersExternal();
}
else
{
return false;
}

break;
case "Select All":
if (GlobalWin.Tools.IsLoaded<TAStudio>())
{
GlobalWin.Tools.TAStudio.SelectAllExternal();
}
else
{
return false;
}

break;
case "Reselect Clip.":
if (GlobalWin.Tools.IsLoaded<TAStudio>())
{
GlobalWin.Tools.TAStudio.SelectAllExternal();
}
else
{
return false;
}

break;
case "Clear Frames":
if (GlobalWin.Tools.IsLoaded<TAStudio>())
Expand All @@ -522,6 +577,16 @@ private bool CheckHotkey(string trigger)
return false;
}

break;
case "Insert # Frames":
if (GlobalWin.Tools.IsLoaded<TAStudio>())
{
GlobalWin.Tools.TAStudio.InsertNumFramesExternal();
}
else
{
return false;
}
break;
case "Delete Frames":
if (GlobalWin.Tools.IsLoaded<TAStudio>())
Expand Down
12 changes: 0 additions & 12 deletions BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 38 additions & 0 deletions BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.MenuItems.cs
Original file line number Diff line number Diff line change
Expand Up @@ -357,8 +357,14 @@ private void EditSubMenu_DropDownOpened(object sender, EventArgs e)
StateHistoryIntegrityCheckMenuItem.Visible =
VersionInfo.DeveloperBuild;

UndoMenuItem.ShortcutKeyDisplayString = Global.Config.HotkeyBindings["Undo"].Bindings;
RedoMenuItem.ShortcutKeyDisplayString = Global.Config.HotkeyBindings["Redo"].Bindings;
SelectBetweenMarkersMenuItem.ShortcutKeyDisplayString = Global.Config.HotkeyBindings["Select between Markers"].Bindings;
SelectAllMenuItem.ShortcutKeyDisplayString = Global.Config.HotkeyBindings["Select All"].Bindings;
ReselectClipboardMenuItem.ShortcutKeyDisplayString = Global.Config.HotkeyBindings["Reselect Clip."].Bindings;
ClearFramesMenuItem.ShortcutKeyDisplayString = Global.Config.HotkeyBindings["Clear Frames"].Bindings;
InsertFrameMenuItem.ShortcutKeyDisplayString = Global.Config.HotkeyBindings["Insert Frame"].Bindings;
InsertNumFramesMenuItem.ShortcutKeyDisplayString = Global.Config.HotkeyBindings["Insert # Frames"].Bindings;
DeleteFramesMenuItem.ShortcutKeyDisplayString = Global.Config.HotkeyBindings["Delete Frames"].Bindings;
CloneFramesMenuItem.ShortcutKeyDisplayString = Global.Config.HotkeyBindings["Clone Frames"].Bindings;
}
Expand All @@ -373,6 +379,11 @@ public void InsertFrameExternal()
InsertFrameMenuItem_Click(null, null);
}

public void InsertNumFramesExternal()
{
InsertNumFramesMenuItem_Click(null, null);
}

public void DeleteFramesExternal()
{
DeleteFramesMenuItem_Click(null, null);
Expand All @@ -383,6 +394,31 @@ public void CloneFramesExternal()
CloneFramesMenuItem_Click(null, null);
}

public void UndoExternal()
{
UndoMenuItem_Click(null, null);
}

public void RedoExternal()
{
RedoMenuItem_Click(null, null);
}

public void SelectBetweenMarkersExternal()
{
SelectBetweenMarkersMenuItem_Click(null, null);
}

public void SelectAllExternal()
{
SelectAllMenuItem_Click(null, null);
}

public void ReselectClipboardExternal()
{
ReselectClipboardMenuItem_Click(null, null);
}

private void UndoMenuItem_Click(object sender, EventArgs e)
{
if (CurrentTasMovie.ChangeLog.Undo() < Emulator.Frame)
Expand Down Expand Up @@ -1455,6 +1491,8 @@ private void RightClickMenu_Opened(object sender, EventArgs e)
CancelSeekContextMenuItem.Enabled = Mainform.PauseOnFrame.HasValue;
BranchContextMenuItem.Visible = TasView.CurrentCell.RowIndex == Emulator.Frame;

SelectBetweenMarkersContextMenuItem.ShortcutKeyDisplayString = Global.Config.HotkeyBindings["Sel. bet. Markers"].Bindings;
InsertNumFramesContextMenuItem.ShortcutKeyDisplayString = Global.Config.HotkeyBindings["Insert # Frames"].Bindings;
ClearContextMenuItem.ShortcutKeyDisplayString = Global.Config.HotkeyBindings["Clear Frames"].Bindings;
InsertFrameContextMenuItem.ShortcutKeyDisplayString = Global.Config.HotkeyBindings["Insert Frame"].Bindings;
DeleteFramesContextMenuItem.ShortcutKeyDisplayString = Global.Config.HotkeyBindings["Delete Frames"].Bindings;
Expand Down

0 comments on commit 515f409

Please sign in to comment.