Port events to transitional syntax.
This commit is contained in:
+109
-40
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* vim: set ts=4 sw=4 tw=99 noet :
|
||||
* =============================================================================
|
||||
* SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved.
|
||||
* SourceMod (C)2004-2014 AlliedModders LLC. All rights reserved.
|
||||
* =============================================================================
|
||||
*
|
||||
* This file is part of the SourceMod/SourcePawn SDK.
|
||||
@@ -40,9 +40,9 @@
|
||||
*/
|
||||
enum EventHookMode
|
||||
{
|
||||
EventHookMode_Pre, /**< Hook callback fired before event is fired */
|
||||
EventHookMode_Post, /**< Hook callback fired after event is fired */
|
||||
EventHookMode_PostNoCopy /**< Hook callback fired after event is fired, but event data won't be copied */
|
||||
EventHookMode_Pre, //< Hook callback fired before event is fired */
|
||||
EventHookMode_Post, //< Hook callback fired after event is fired */
|
||||
EventHookMode_PostNoCopy //< Hook callback fired after event is fired, but event data won't be copied */
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -50,28 +50,113 @@ enum EventHookMode
|
||||
*/
|
||||
typeset EventHook
|
||||
{
|
||||
/**
|
||||
* Called when a game event is fired.
|
||||
*
|
||||
* @param event Handle to event. This could be INVALID_HANDLE if every plugin hooking
|
||||
* this event has set the hook mode EventHookMode_PostNoCopy.
|
||||
* @param name String containing the name of the event.
|
||||
* @param dontBroadcast True if event was not broadcast to clients, false otherwise.
|
||||
* @return Ignored for post hooks. Plugin_Handled will block event if hooked as pre.
|
||||
*/
|
||||
// Called when a game event is fired.
|
||||
//
|
||||
// @param event Handle to event. This could be INVALID_HANDLE if every plugin hooking
|
||||
// this event has set the hook mode EventHookMode_PostNoCopy.
|
||||
// @param name String containing the name of the event.
|
||||
// @param dontBroadcast True if event was not broadcast to clients, false otherwise.
|
||||
// @return Ignored for post hooks. Plugin_Handled will block event if hooked as pre.
|
||||
///
|
||||
function Action (Event event, const char[] name, bool dontBroadcast);
|
||||
/**
|
||||
* Called when a game event is fired.
|
||||
*
|
||||
* @param event Handle to event. This could be INVALID_HANDLE if every plugin hooking
|
||||
* this event has set the hook mode EventHookMode_PostNoCopy.
|
||||
* @param name String containing the name of the event.
|
||||
* @param dontBroadcast True if event was not broadcast to clients, false otherwise.
|
||||
* @noreturn
|
||||
*/
|
||||
//
|
||||
// Called when a game event is fired.
|
||||
//
|
||||
// @param event Handle to event. This could be INVALID_HANDLE if every plugin hooking
|
||||
// this event has set the hook mode EventHookMode_PostNoCopy.
|
||||
// @param name String containing the name of the event.
|
||||
// @param dontBroadcast True if event was not broadcast to clients, false otherwise.
|
||||
// @noreturn
|
||||
///
|
||||
function void (Event event, const char[] name, bool dontBroadcast);
|
||||
};
|
||||
|
||||
methodmap Event < Handle
|
||||
{
|
||||
// Fires a game event.
|
||||
//
|
||||
// This function closes the event Handle after completing.
|
||||
//
|
||||
// @param dontBroadcast Optional boolean that determines if event should be broadcast to clients.
|
||||
public native void Fire(bool dontBroadcast=false);
|
||||
|
||||
// Cancels a previously created game event that has not been fired. This
|
||||
// is necessary to avoid leaking memory when an event isn't fired.
|
||||
public native void Cancel();
|
||||
|
||||
// Returns the boolean value of a game event's key.
|
||||
//
|
||||
// @param key Name of event key.
|
||||
// @param defValue Optional default value to use if the key is not found.
|
||||
// @return The boolean value of the specfied event key.
|
||||
public native bool GetBool(const char[] key, bool defValue=false);
|
||||
|
||||
// Sets the boolean value of a game event's key.
|
||||
//
|
||||
// @param key Name of event key.
|
||||
// @param value New boolean value.
|
||||
public native void SetBool(const char[] key, bool value);
|
||||
|
||||
// Returns the integer value of a game event's key.
|
||||
//
|
||||
// @param key Name of event key.
|
||||
// @param defValue Optional default value to use if the key is not found.
|
||||
// @return The integer value of the specfied event key.
|
||||
public native int GetInt(const char[] key, int defValue=0);
|
||||
|
||||
// Sets the integer value of a game event's key.
|
||||
//
|
||||
// Integer value refers to anything that can be reduced to an integer.
|
||||
// The various size specifiers, such as "byte" and "short" are still
|
||||
// integers, and only refer to how much data will actually be sent
|
||||
// over the network (if applicable).
|
||||
//
|
||||
// @param key Name of event key.
|
||||
// @param value New integer value.
|
||||
public native void SetInt(const char[] key, int value);
|
||||
|
||||
// Returns the floating point value of a game event's key.
|
||||
//
|
||||
// @param key Name of event key.
|
||||
// @param defValue Optional default value to use if the key is not found.
|
||||
// @return The floating point value of the specfied event key.
|
||||
public native float GetFloat(const char[] key, float defValue=0.0);
|
||||
|
||||
// Sets the floating point value of a game event's key.
|
||||
//
|
||||
// @param key Name of event key.
|
||||
// @param value New floating point value.
|
||||
public native void SetFloat(const char[] key, float value);
|
||||
|
||||
// Retrieves the string value of a game event's key.
|
||||
//
|
||||
// @param key Name of event key.
|
||||
// @param value Buffer to store the value of the specified event key.
|
||||
// @param maxlength Maximum length of string buffer.
|
||||
// @param defValue Optional default value to use if the key is not found.
|
||||
public native void GetString(const char[] key, char[] value, int maxlength, const char[] defvalue="");
|
||||
|
||||
// Sets the string value of a game event's key.
|
||||
//
|
||||
// @param key Name of event key.
|
||||
// @param value New string value.
|
||||
public native void SetString(const char[] key, const char[] value);
|
||||
|
||||
// Retrieves the name of a game event.
|
||||
//
|
||||
// @param name Buffer to store the name of the event.
|
||||
// @param maxlength Maximum length of string buffer.
|
||||
public native void GetName(char[] name, int maxlength);
|
||||
|
||||
// Sets whether an event's broadcasting will be disabled or not.
|
||||
//
|
||||
// This has no effect on events Handles that are not from HookEvent
|
||||
// or HookEventEx callbacks.
|
||||
property bool BroadcastDisabled {
|
||||
public native set(bool dontBroadcast);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a hook for when a game event is fired.
|
||||
*
|
||||
@@ -109,7 +194,7 @@ native void UnhookEvent(const char[] name, EventHook callback, EventHookMode mod
|
||||
* Creates a game event to be fired later.
|
||||
*
|
||||
* The Handle should not be closed via CloseHandle(). It must be closed via
|
||||
* FireEvent() or CancelCreatedEvent().
|
||||
* event.Fire() or event.Cancel().
|
||||
*
|
||||
* @param name Name of event.
|
||||
* @param force If set to true, this forces the event to be created even if it's not being hooked.
|
||||
@@ -258,19 +343,3 @@ native void GetEventName(Handle event, char[] name, int maxlength);
|
||||
* @error Invalid Handle.
|
||||
*/
|
||||
native void SetEventBroadcast(Handle event, bool dontBroadcast);
|
||||
|
||||
methodmap Event < Handle {
|
||||
public Event() = CreateEvent;
|
||||
public Fire() = FireEvent;
|
||||
public Cancel() = CancelCreatedEvent;
|
||||
public GetBool() = GetEventBool;
|
||||
public SetBool() = SetEventBool;
|
||||
public GetInt() = GetEventInt;
|
||||
public SetInt() = SetEventInt;
|
||||
public GetFloat() = GetEventFloat;
|
||||
public SetFloat() = SetEventFloat;
|
||||
public GetString() = GetEventString;
|
||||
public SetString() = SetEventString;
|
||||
public GetName() = GetEventName;
|
||||
public SetBroadcast() = SetEventBroadcast;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user