Add OnKeyDown and OnKeyUp event for API
This commit is contained in:
parent
cda3d37f37
commit
b1d67bd1c4
@ -82,6 +82,8 @@ namespace RageCoop.Client
|
||||
Tick += OnTick;
|
||||
Tick += (s,e) => { Scripting.API.Events.InvokeTick(); };
|
||||
KeyDown += OnKeyDown;
|
||||
KeyDown+=(s, e) => { Scripting.API.Events.InvokeKeyDown(s, e); };
|
||||
KeyUp+=(s, e) => { Scripting.API.Events.InvokeKeyUp(s, e); };
|
||||
Aborted += (object sender, EventArgs e) => CleanUp();
|
||||
|
||||
Util.NativeMemory();
|
||||
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using RageCoop.Core;
|
||||
using System.Windows.Forms;
|
||||
using GTA;
|
||||
|
||||
namespace RageCoop.Client.Scripting
|
||||
@ -117,6 +118,15 @@ namespace RageCoop.Client.Scripting
|
||||
/// </summary>
|
||||
public static event EmptyEvent OnTick;
|
||||
|
||||
/// <summary>
|
||||
/// This is equivalent of <see cref="Script.KeyDown"/>
|
||||
/// </summary>
|
||||
public static KeyEventHandler OnKeyDown;
|
||||
|
||||
/// <summary>
|
||||
/// This is equivalent of <see cref="Script.KeyUp"/>
|
||||
/// </summary>
|
||||
public static KeyEventHandler OnKeyUp;
|
||||
|
||||
#region INVOKE
|
||||
internal static void InvokeVehicleSpawned(SyncedVehicle v) { OnVehicleSpawned?.Invoke(null, v); }
|
||||
@ -126,6 +136,10 @@ namespace RageCoop.Client.Scripting
|
||||
internal static void InvokePlayerDied() { OnPlayerDied?.Invoke(); }
|
||||
internal static void InvokeTick() { OnTick?.Invoke(); }
|
||||
|
||||
internal static void InvokeKeyDown(object s,KeyEventArgs e) { OnKeyDown?.Invoke(s,e); }
|
||||
|
||||
internal static void InvokeKeyUp(object s, KeyEventArgs e) { OnKeyUp?.Invoke(s, e); }
|
||||
|
||||
internal static void InvokeCustomEventReceived(Packets.CustomEvent p)
|
||||
{
|
||||
var args = new CustomEventReceivedArgs() { Hash=p.Hash, Args=p.Args};
|
||||
@ -139,15 +153,6 @@ namespace RageCoop.Client.Scripting
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
internal static void ClearHandlers()
|
||||
{
|
||||
OnPlayerDied=null;
|
||||
OnTick=null;
|
||||
OnPedDeleted=null;
|
||||
OnPedSpawned=null;
|
||||
OnVehicleDeleted=null;
|
||||
OnVehicleSpawned=null;
|
||||
}
|
||||
}
|
||||
|
||||
#region FUNCTIONS
|
||||
|
Loading…
x
Reference in New Issue
Block a user