2015-11-11 07:57:18 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-09-30 02:56:11 +02:00
|
|
|
#include "Entity/Keybind.hpp"
|
2015-11-01 00:31:46 +01:00
|
|
|
#include "Core.hpp"
|
2015-09-30 02:56:11 +02:00
|
|
|
#include "Register.hpp"
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
namespace SqMod {
|
|
|
|
|
2015-11-01 00:31:46 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
CKeybind::CKeybind(const Reference< CKeybind > & o)
|
2015-11-01 00:31:46 +01:00
|
|
|
: Reference(o)
|
|
|
|
{
|
|
|
|
/* ... */
|
|
|
|
}
|
|
|
|
|
2015-09-30 02:56:11 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
SQInt32 CKeybind::GetPrimary() const
|
2015-10-29 21:09:53 +01:00
|
|
|
{
|
|
|
|
if (VALID_ENTITY(m_ID))
|
|
|
|
{
|
|
|
|
RefType::Get(m_ID).Primary;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-11-11 07:57:18 +01:00
|
|
|
BadRef("@primary", "get primary keycode");
|
2015-10-29 21:09:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return SQMOD_UNKNOWN;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
SQInt32 CKeybind::GetSecondary() const
|
2015-10-29 21:09:53 +01:00
|
|
|
{
|
|
|
|
if (VALID_ENTITY(m_ID))
|
|
|
|
{
|
|
|
|
RefType::Get(m_ID).Secondary;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-11-11 07:57:18 +01:00
|
|
|
BadRef("@secondary", "get secondary keycode");
|
2015-10-29 21:09:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return SQMOD_UNKNOWN;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
SQInt32 CKeybind::GetAlternative() const
|
2015-10-29 21:09:53 +01:00
|
|
|
{
|
|
|
|
if (VALID_ENTITY(m_ID))
|
|
|
|
{
|
|
|
|
RefType::Get(m_ID).Alternative;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-11-11 07:57:18 +01:00
|
|
|
BadRef("@alternative", "get alternative keycode");
|
2015-10-29 21:09:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return SQMOD_UNKNOWN;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
bool CKeybind::IsRelease() const
|
2015-10-29 21:09:53 +01:00
|
|
|
{
|
|
|
|
if (VALID_ENTITY(m_ID))
|
|
|
|
{
|
|
|
|
RefType::Get(m_ID).Release;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-11-11 07:57:18 +01:00
|
|
|
BadRef("@is_release", "see whether it reacts on release");
|
2015-10-29 21:09:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-11-01 00:31:46 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
Reference< CKeybind > CreateBaseKeybind_ES(bool release,
|
2015-11-01 04:48:01 +01:00
|
|
|
SQInt32 primary, SQInt32 secondary, SQInt32 alternative)
|
2015-11-01 00:31:46 +01:00
|
|
|
{
|
|
|
|
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,
|
2015-11-01 04:48:01 +01:00
|
|
|
SQInt32 header, SqObj & payload)
|
2015-11-01 00:31:46 +01:00
|
|
|
{
|
|
|
|
return _Core->NewKeybind(SQMOD_UNKNOWN, release, primary, secondary, alternative,
|
|
|
|
header, payload);
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
Reference< CKeybind > CreateBaseKeybind_EF(SQInt32 slot, bool release,
|
2015-11-01 04:48:01 +01:00
|
|
|
SQInt32 primary, SQInt32 secondary, SQInt32 alternative)
|
2015-11-01 00:31:46 +01:00
|
|
|
{
|
|
|
|
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,
|
2015-11-01 04:48:01 +01:00
|
|
|
SQInt32 header, SqObj & payload)
|
2015-11-01 00:31:46 +01:00
|
|
|
{
|
|
|
|
return _Core->NewKeybind(slot, release, primary, secondary, alternative,
|
|
|
|
header, payload);
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
CKeybind CreateKeybind_ES(bool release,
|
2015-11-01 04:48:01 +01:00
|
|
|
SQInt32 primary, SQInt32 secondary, SQInt32 alternative)
|
2015-11-01 00:31:46 +01:00
|
|
|
{
|
|
|
|
return _Core->NewKeybind(SQMOD_UNKNOWN, release, primary, secondary, alternative,
|
|
|
|
SQMOD_CREATE_DEFAULT, NullData());
|
|
|
|
}
|
|
|
|
|
|
|
|
CKeybind CreateKeybind_ES(bool release,
|
|
|
|
SQInt32 primary, SQInt32 secondary, SQInt32 alternative,
|
2015-11-01 04:48:01 +01:00
|
|
|
SQInt32 header, SqObj & payload)
|
2015-11-01 00:31:46 +01:00
|
|
|
{
|
|
|
|
return _Core->NewKeybind(SQMOD_UNKNOWN, release, primary, secondary, alternative,
|
|
|
|
header, payload);
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
CKeybind CreateKeybind_EF(SQInt32 slot, bool release,
|
2015-11-01 04:48:01 +01:00
|
|
|
SQInt32 primary, SQInt32 secondary, SQInt32 alternative)
|
2015-11-01 00:31:46 +01:00
|
|
|
{
|
|
|
|
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,
|
2015-11-01 04:48:01 +01:00
|
|
|
SQInt32 header, SqObj & payload)
|
2015-11-01 00:31:46 +01:00
|
|
|
{
|
|
|
|
return _Core->NewKeybind(slot, release, primary, secondary, alternative,
|
|
|
|
header, payload);
|
|
|
|
}
|
|
|
|
|
2015-10-29 21:09:53 +01:00
|
|
|
// ================================================================================================
|
2015-09-30 02:56:11 +02:00
|
|
|
bool Register_CKeybind(HSQUIRRELVM vm)
|
|
|
|
{
|
2015-10-29 21:09:53 +01:00
|
|
|
// Attempt to register the base reference type before the actual implementation
|
2015-09-30 02:56:11 +02:00
|
|
|
if (!Register_Reference< CKeybind >(vm, _SC("BaseKeybind")))
|
|
|
|
{
|
2015-10-29 21:09:53 +01:00
|
|
|
LogFtl("Unable to register the base class <BaseKeybind> for <CKeybind> type");
|
|
|
|
// Registration failed
|
2015-09-30 02:56:11 +02:00
|
|
|
return false;
|
|
|
|
}
|
2015-11-01 00:31:46 +01:00
|
|
|
// Typedef the base reference type for simplicity
|
|
|
|
typedef Reference< CKeybind > RefType;
|
2015-10-29 21:09:53 +01:00
|
|
|
// Output debugging information
|
2015-09-30 02:56:11 +02:00
|
|
|
LogDbg("Beginning registration of <CKeybind> type");
|
2015-10-29 21:09:53 +01:00
|
|
|
// Attempt to register the actual reference that implements all of the entity functionality
|
2015-11-01 00:31:46 +01:00
|
|
|
Sqrat::RootTable(vm).Bind(_SC("CKeybind"), Sqrat::DerivedClass< CKeybind, RefType >(vm, _SC("CKeybind"))
|
2015-10-29 21:09:53 +01:00
|
|
|
/* Constructors */
|
2015-09-30 02:56:11 +02:00
|
|
|
.Ctor()
|
|
|
|
.Ctor< SQInt32 >()
|
2015-10-29 21:09:53 +01:00
|
|
|
/* Properties */
|
|
|
|
.Prop(_SC("primary"), &CKeybind::GetPrimary)
|
|
|
|
.Prop(_SC("secondary"), &CKeybind::GetSecondary)
|
|
|
|
.Prop(_SC("alternative"), &CKeybind::GetAlternative)
|
|
|
|
.Prop(_SC("is_release"), &CKeybind::IsRelease)
|
2015-09-30 02:56:11 +02:00
|
|
|
);
|
2015-10-29 21:09:53 +01:00
|
|
|
// Output debugging information
|
2015-09-30 02:56:11 +02:00
|
|
|
LogDbg("Registration of <CKeybind> type was successful");
|
2015-11-01 00:31:46 +01:00
|
|
|
// Output debugging information
|
2015-11-11 07:57:18 +01:00
|
|
|
LogDbg("Beginning registration of <Keybind> functions");
|
2015-11-01 00:31:46 +01:00
|
|
|
// 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
|
2015-11-11 07:57:18 +01:00
|
|
|
LogDbg("Registration of <Keybind> functions was successful");
|
2015-10-29 21:09:53 +01:00
|
|
|
// Registration succeeded
|
2015-09-30 02:56:11 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // Namespace:: SqMod
|