1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2024-11-12 18:57:16 +01:00
SqMod/module/Entity/Keybind.hpp

186 lines
6.4 KiB
C++
Raw Normal View History

#pragma once
2015-09-30 02:56:11 +02:00
// ------------------------------------------------------------------------------------------------
#include "Base/Shared.hpp"
2015-09-30 02:56:11 +02:00
// ------------------------------------------------------------------------------------------------
namespace SqMod {
/* ------------------------------------------------------------------------------------------------
* Manages a single keybind entity.
2015-09-30 02:56:11 +02:00
*/
class CKeybind
2015-09-30 02:56:11 +02:00
{
// --------------------------------------------------------------------------------------------
friend class Core;
private:
/* --------------------------------------------------------------------------------------------
* Identifier of the managed entity.
*/
Int32 m_ID;
/* --------------------------------------------------------------------------------------------
* User tag associated with this instance.
*/
String m_Tag;
/* --------------------------------------------------------------------------------------------
* User data associated with this instance.
*/
LightObj m_Data;
/* --------------------------------------------------------------------------------------------
* Base constructor.
*/
2020-03-22 09:00:31 +01:00
explicit CKeybind(Int32 id);
public:
/* --------------------------------------------------------------------------------------------
* Maximum possible number that could represent an identifier for this entity type.
*/
static const Int32 Max;
/* --------------------------------------------------------------------------------------------
* Copy constructor. (disabled)
*/
CKeybind(const CKeybind &) = delete;
/* --------------------------------------------------------------------------------------------
* Move constructor. (disabled)
*/
CKeybind(CKeybind &&) = delete;
/* --------------------------------------------------------------------------------------------
* Copy assignment operator. (disabled)
*/
CKeybind & operator = (const CKeybind &) = delete;
/* --------------------------------------------------------------------------------------------
* Move assignment operator. (disabled)
*/
CKeybind & operator = (CKeybind &&) = delete;
/* --------------------------------------------------------------------------------------------
* See whether this instance manages a valid entity instance otherwise throw an exception.
*/
void Validate() const
{
if (INVALID_ENTITY(m_ID))
{
STHROWF("Invalid keybind reference [%s]", m_Tag.c_str());
}
}
2015-10-29 22:06:20 +01:00
/* --------------------------------------------------------------------------------------------
* Used by the script engine to convert an instance of this type to a string.
2015-10-29 22:06:20 +01:00
*/
const String & ToString() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the associated null entity instance.
*/
static SQInteger SqGetNull(HSQUIRRELVM vm);
/* --------------------------------------------------------------------------------------------
* Retrieve the associated null entity instance.
*/
static LightObj & GetNull();
/* --------------------------------------------------------------------------------------------
* Retrieve the identifier of the entity managed by this instance.
*/
Int32 GetID() const
{
return m_ID;
}
/* --------------------------------------------------------------------------------------------
* Check whether this instance manages a valid entity.
*/
bool IsActive() const
{
return VALID_ENTITY(m_ID);
}
/* --------------------------------------------------------------------------------------------
* Retrieve the associated user tag.
*/
const String & GetTag() const;
/* --------------------------------------------------------------------------------------------
* Modify the associated user tag.
*/
void SetTag(StackStrF & tag);
/* --------------------------------------------------------------------------------------------
* Modify the associated user tag.
*/
CKeybind & ApplyTag(StackStrF & tag);
/* --------------------------------------------------------------------------------------------
* Retrieve the associated user data.
*/
LightObj & GetData();
/* --------------------------------------------------------------------------------------------
* Modify the associated user data.
*/
void SetData(LightObj & data);
/* --------------------------------------------------------------------------------------------
* Destroy the managed destroy entity.
*/
bool Destroy()
{
return Destroy(0, NullLightObj());
}
/* --------------------------------------------------------------------------------------------
* Destroy the managed destroy entity.
*/
bool Destroy(Int32 header)
{
return Destroy(header, NullLightObj());
}
/* --------------------------------------------------------------------------------------------
* Destroy the managed destroy entity.
*/
bool Destroy(Int32 header, LightObj & payload);
/* --------------------------------------------------------------------------------------------
* Retrieve the events table of this entity.
*/
LightObj & GetEvents() const;
/* --------------------------------------------------------------------------------------------
* Emit a custom event for the managed entity
*/
void CustomEvent(Int32 header, LightObj & payload) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the first key code of the managed keybind entity.
*/
Int32 GetFirst() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the second key code of the managed keybind entity.
*/
Int32 GetSecond() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the third key code of the managed keybind entity.
*/
Int32 GetThird() const;
/* --------------------------------------------------------------------------------------------
* See whether the managed keybind entity reacts to key release events.
*/
bool IsRelease() const;
2015-09-30 02:56:11 +02:00
};
} // Namespace:: SqMod