Skip to content

Commit

Permalink
- fix optional param for hotkeys
Browse files Browse the repository at this point in the history
  • Loading branch information
cesare-montresor committed Feb 11, 2024
1 parent 946762c commit 878c77a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
4 changes: 3 additions & 1 deletion Razor/Network/EventManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ public class EventManager
{
static readonly public EventManager Instance = new EventManager();


public delegate void OnPacketCallback(string path, byte[] data);
public delegate void OnJournalCallback(Journal.JournalEntry entry);
public delegate void OnHotkeyCallback(string hotkey);
Expand All @@ -95,6 +96,7 @@ public class EventManager
private readonly ConcurrentDictionary<Thread, ConcurrentDictionary<string, HashSet<OnJournalCallback>>> m_JournalCallbacks = new ConcurrentDictionary<Thread, ConcurrentDictionary<string, HashSet<OnJournalCallback>>>();
private readonly ConcurrentDictionary<Thread, ConcurrentDictionary<string, HashSet<OnHotkeyCallback>>> m_HotkeyCallbacks = new ConcurrentDictionary<Thread, ConcurrentDictionary<string, HashSet<OnHotkeyCallback>>>();


// Auto-cleanup based on thead state/activity, can and should be improved.
public void Cleanup()
{
Expand Down Expand Up @@ -200,7 +202,7 @@ public void didRecieveHotkey(Keys hotkey)
{
var notify = new Task(() =>
{
var textHotkey = hotkey.ToString();
var textHotkey = hotkey.ToString() ;
Cleanup();
foreach (var pairs in m_HotkeyCallbacks)
{
Expand Down
2 changes: 1 addition & 1 deletion Razor/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:

[assembly: AssemblyVersion("0.8.2.117")]
[assembly: AssemblyVersion("0.8.2.118")]

//
// In order to sign your assembly you must specify a key to use. Refer to the
Expand Down
8 changes: 5 additions & 3 deletions Razor/RazorEnhanced/Events.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ namespace RazorEnhanced
{
public class Events
{


/*
- DONE:
Events.OnPacket(packetid, callback)
Expand Down Expand Up @@ -82,10 +84,10 @@ public static void OnJournal(IronPython.Runtime.PythonFunction callback, string
/// Register a Python function to be called when a hotkey get pressed
/// </summary>
/// <param name="callback">Python function to be called.</param>
/// <param name="hotkey">Name of the Hotkey</param>

public static void OnHotkey(IronPython.Runtime.PythonFunction callback, string hotkey)
/// <param name="hotkey">(Optional) Name of the Hotkey (null or "": Match all)</param>
public static void OnHotkey(IronPython.Runtime.PythonFunction callback, string hotkey=null)
{
if (hotkey == null) { hotkey = ""; }
var script = EnhancedScriptService.Instance.CurrentScript();
EventManager.Instance.OnHotkey(hotkey, (hotkeyMatch) =>
{
Expand Down

0 comments on commit 878c77a

Please sign in to comment.