2015-09-30 02:56:11 +02:00
|
|
|
#include "Entity/Keybind.hpp"
|
|
|
|
#include "Register.hpp"
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
namespace SqMod {
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-10-29 21:09:53 +01:00
|
|
|
SQInt32 CKeybind::GetPrimary() const noexcept
|
|
|
|
{
|
|
|
|
if (VALID_ENTITY(m_ID))
|
|
|
|
{
|
|
|
|
RefType::Get(m_ID).Primary;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
LogWrn(_SC("[SOURCE: CKeybind::GetPrimary()] [INFO: Invalid reference] [DATA: (this::m_ID {0:d})]"), m_ID);
|
|
|
|
}
|
|
|
|
|
|
|
|
return SQMOD_UNKNOWN;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
SQInt32 CKeybind::GetSecondary() const noexcept
|
|
|
|
{
|
|
|
|
if (VALID_ENTITY(m_ID))
|
|
|
|
{
|
|
|
|
RefType::Get(m_ID).Secondary;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
LogWrn(_SC("[SOURCE: CKeybind::GetSecondary()] [INFO: Invalid reference] [DATA: (this::m_ID {0:d})]"), m_ID);
|
|
|
|
}
|
|
|
|
|
|
|
|
return SQMOD_UNKNOWN;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
SQInt32 CKeybind::GetAlternative() const noexcept
|
|
|
|
{
|
|
|
|
if (VALID_ENTITY(m_ID))
|
|
|
|
{
|
|
|
|
RefType::Get(m_ID).Alternative;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
LogWrn(_SC("[SOURCE: CKeybind::GetAlternative()] [INFO: Invalid reference] [DATA: (this::m_ID {0:d})]"), m_ID);
|
|
|
|
}
|
|
|
|
|
|
|
|
return SQMOD_UNKNOWN;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
bool CKeybind::IsRelease() const noexcept
|
|
|
|
{
|
|
|
|
if (VALID_ENTITY(m_ID))
|
|
|
|
{
|
|
|
|
RefType::Get(m_ID).Release;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
LogWrn(_SC("[SOURCE: CKeybind::IsRelease()] [INFO: Invalid reference] [DATA: (this::m_ID {0:d})]"), m_ID);
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ================================================================================================
|
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-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-09-30 02:56:11 +02:00
|
|
|
Sqrat::RootTable(vm).Bind(_SC("CKeybind"), Sqrat::DerivedClass< CKeybind, Reference< CKeybind > >(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-10-29 21:09:53 +01:00
|
|
|
// Registration succeeded
|
2015-09-30 02:56:11 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // Namespace:: SqMod
|