1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2024-11-08 00:37:15 +01:00

Implemented functions to create keybind entities and added constructor to create an entity reference from a base reference.

This commit is contained in:
Sandu Liviu Catalin 2015-11-01 01:31:46 +02:00
parent 986fc5769e
commit 78c72399db
2 changed files with 106 additions and 1 deletions

View File

@ -1,9 +1,17 @@
#include "Entity/Keybind.hpp"
#include "Core.hpp"
#include "Register.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// ------------------------------------------------------------------------------------------------
CKeybind::CKeybind(const Reference< CKeybind > & o) noexcept
: Reference(o)
{
/* ... */
}
// ------------------------------------------------------------------------------------------------
SQInt32 CKeybind::GetPrimary() const noexcept
{
@ -64,6 +72,70 @@ bool CKeybind::IsRelease() const noexcept
return false;
}
// ------------------------------------------------------------------------------------------------
Reference< CKeybind > CreateBaseKeybind_ES(bool release,
SQInt32 primary, SQInt32 secondary, SQInt32 alternative) noexcept
{
return _Core->NewKeybind(SQMOD_UNKNOWN, release, primary, secondary, alternative,
SQMOD_CREATE_DEFAULT, NullData());
}
Reference< CKeybind > CreateBaseKeybind_ES(bool release,
SQInt32 primary, SQInt32 secondary, SQInt32 alternative,
SQInt32 header, SqObj & payload) noexcept
{
return _Core->NewKeybind(SQMOD_UNKNOWN, release, primary, secondary, alternative,
header, payload);
}
// ------------------------------------------------------------------------------------------------
Reference< CKeybind > CreateBaseKeybind_EF(SQInt32 slot, bool release,
SQInt32 primary, SQInt32 secondary, SQInt32 alternative) noexcept
{
return _Core->NewKeybind(slot, release, primary, secondary, alternative,
SQMOD_CREATE_DEFAULT, NullData());
}
Reference< CKeybind > CreateBaseKeybind_EF(SQInt32 slot, bool release,
SQInt32 primary, SQInt32 secondary, SQInt32 alternative,
SQInt32 header, SqObj & payload) noexcept
{
return _Core->NewKeybind(slot, release, primary, secondary, alternative,
header, payload);
}
// ------------------------------------------------------------------------------------------------
CKeybind CreateKeybind_ES(bool release,
SQInt32 primary, SQInt32 secondary, SQInt32 alternative) noexcept
{
return _Core->NewKeybind(SQMOD_UNKNOWN, release, primary, secondary, alternative,
SQMOD_CREATE_DEFAULT, NullData());
}
CKeybind CreateKeybind_ES(bool release,
SQInt32 primary, SQInt32 secondary, SQInt32 alternative,
SQInt32 header, SqObj & payload) noexcept
{
return _Core->NewKeybind(SQMOD_UNKNOWN, release, primary, secondary, alternative,
header, payload);
}
// ------------------------------------------------------------------------------------------------
CKeybind CreateKeybind_EF(SQInt32 slot, bool release,
SQInt32 primary, SQInt32 secondary, SQInt32 alternative) noexcept
{
return _Core->NewKeybind(slot, release, primary, secondary, alternative,
SQMOD_CREATE_DEFAULT, NullData());
}
CKeybind CreateKeybind_EF(SQInt32 slot, bool release,
SQInt32 primary, SQInt32 secondary, SQInt32 alternative,
SQInt32 header, SqObj & payload) noexcept
{
return _Core->NewKeybind(slot, release, primary, secondary, alternative,
header, payload);
}
// ================================================================================================
bool Register_CKeybind(HSQUIRRELVM vm)
{
@ -74,10 +146,12 @@ bool Register_CKeybind(HSQUIRRELVM vm)
// Registration failed
return false;
}
// Typedef the base reference type for simplicity
typedef Reference< CKeybind > RefType;
// Output debugging information
LogDbg("Beginning registration of <CKeybind> type");
// Attempt to register the actual reference that implements all of the entity functionality
Sqrat::RootTable(vm).Bind(_SC("CKeybind"), Sqrat::DerivedClass< CKeybind, Reference< CKeybind > >(vm, _SC("CKeybind"))
Sqrat::RootTable(vm).Bind(_SC("CKeybind"), Sqrat::DerivedClass< CKeybind, RefType >(vm, _SC("CKeybind"))
/* Constructors */
.Ctor()
.Ctor< SQInt32 >()
@ -89,6 +163,32 @@ bool Register_CKeybind(HSQUIRRELVM vm)
);
// Output debugging information
LogDbg("Registration of <CKeybind> type was successful");
// Output debugging information
LogDbg("Beginning registration of <Keybind functions> type");
// Register global functions related to this entity type
Sqrat::RootTable(vm)
/* Create BaseKeybind [E]xtended [S]ubstitute */
.Overload< RefType (*)(bool, SQInt32, SQInt32, SQInt32) >
(_SC("CreateBaseKeybind_ES"), &CreateBaseKeybind_ES)
.Overload< RefType (*)(bool, SQInt32, SQInt32, SQInt32, SQInt32, SqObj &) >
(_SC("CreateBaseKeybind_ES"), &CreateBaseKeybind_ES)
/* Create BaseKeybind [E]xtended [F]Full */
.Overload< RefType (*)(SQInt32, bool, SQInt32, SQInt32, SQInt32) >
(_SC("CreateBaseKeybind_EF"), &CreateBaseKeybind_EF)
.Overload< RefType (*)(SQInt32, bool, SQInt32, SQInt32, SQInt32, SQInt32, SqObj &) >
(_SC("CreateBaseKeybind_EF"), &CreateBaseKeybind_EF)
/* Create CKeybind [E]xtended [S]ubstitute */
.Overload< CKeybind (*)(bool, SQInt32, SQInt32, SQInt32) >
(_SC("CreateKeybind_ES"), &CreateKeybind_ES)
.Overload< CKeybind (*)(bool, SQInt32, SQInt32, SQInt32, SQInt32, SqObj &) >
(_SC("CreateKeybind_ES"), &CreateKeybind_ES)
/* Create CKeybind [E]xtended [F]Full */
.Overload< CKeybind (*)(SQInt32, bool, SQInt32, SQInt32, SQInt32) >
(_SC("CreateKeybind_EF"), &CreateKeybind_EF)
.Overload< CKeybind (*)(SQInt32, bool, SQInt32, SQInt32, SQInt32, SQInt32, SqObj &) >
(_SC("CreateKeybind_EF"), &CreateKeybind_EF);
// Output debugging information
LogDbg("Registration of <Keybind functions> type was successful");
// Registration succeeded
return true;
}

View File

@ -19,6 +19,11 @@ public:
*/
using RefType::Reference;
/* --------------------------------------------------------------------------------------------
* Construct a reference from a base reference.
*/
CKeybind(const Reference< CKeybind > & o) noexcept;
/* --------------------------------------------------------------------------------------------
* Retrieve the primary key code of the referenced keybind instance.
*/